Skip to content

Commit

Permalink
added scidatapackage method. Automates calls to aspects, facets, and …
Browse files Browse the repository at this point in the history
…datapoints methods and links datapoints to associated aspects and facets. See example.py for usage.
  • Loading branch information
JohnsonDylan committed Nov 2, 2021
1 parent c4fed82 commit 8348cb1
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
65 changes: 65 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,70 @@
lic = 'https://creativecommons.org/licenses/by-nc-nd/4.0/'
example.rights(holder, lic)


package = [{
"aspects": [{
"@id": "assay",
"@type": "sdo:assay",
"description": "Inhibition of human ERG by MK499 binding assay",
"assay_organism": "Homo sapiens"
}],
"facets": [{
"@id": "compound",
"@type": "sdo:compound",
"mw_freebase": "491.52",
"full_molformula": "C26H26FN5O4",
"standard_inchi_key": "OINHUVBCKUJZAG-UHFFFAOYSA-N"
},{
"@id": "target",
"@type": "sdo:target",
"pref_name": "HERG",
"tax_id": 9606,
"organism": "Homo sapiens"
}],
"dataset": [{
"@id": "datapoint",
"@type": "sdo:datapoint",
"data": [{
"@id": "datum",
"@type": "sdo:exptdata",
"type": "IC50",
"value": "15.200000000000000000000000000000",
"units": "uM"
}]}]},
{
"aspects": [{
"@id": "assay",
"@type": "sdo:assay",
"description": "Inhibition of human ERG by MK499 binding assay",
"assay_organism": "Homo sapiens"
}],
"facets": [{
"@id": "compound",
"@type": "sdo:compound",
"mw_freebase": "491.52",
"full_molformula": "C26H26FN5O4",
"standard_inchi_key": "OINHUVBCKUJZAG-UHFFFAOYSA-N"
},{
"@id": "target",
"@type": "sdo:target",
"pref_name": "HERG",
"tax_id": 9606,
"organism": "Homo sapiens"
}],
"dataset": [{
"@id": "datapoint",
"@type": "sdo:datapoint",
"data": [{
"@id": "datum",
"@type": "sdo:exptdata",
"type": "IC50",
"value": "12.300000000000000000000000000000",
"units": "uM"
}]}]}]

example.scidatapackage(package)


# print(json.dumps(example.output, ensure_ascii=False))
print(json.dumps(example.output, indent=4, ensure_ascii=False))
13 changes: 13 additions & 0 deletions scidatalib/scidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,19 @@ def datagroup(self, group: list) -> list:
self.meta['@graph']['scidata'] = scidata
return new_group

def scidatapackage(self, package):
"""Add a package of data where the datapoints are linked with the associated aspects and facets
package = [{'aspects':{},'facets':{},'datapoint':{}},{'aspects':{},'facets':{},'datapoint':{}}]"""
for packet in package:
packet['facets'] = self.facets(packet['facets'])
packet['aspects'] = self.aspects(packet['aspects'])
atfacet = [a_dict["@id"] for a_dict in packet['facets']]
ataspect = [a_dict["@id"] for a_dict in packet['aspects']]
for dp in packet['dataset']:
dp.update({'facets#': atfacet})
dp.update({'aspects#': ataspect})
self.datapoint(packet['dataset'])

def sources(self, sources: list, replace=False) -> dict:
"""
Add to or replace the source reference list
Expand Down

0 comments on commit 8348cb1

Please sign in to comment.