from ontobio.ontol_factory import OntologyFactory # Create ontology object, for GO # Transparently uses remote SPARQL service. # (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do # not re-execute cell) ofactory = OntologyFactory() ont = ofactory.create('go') from ontobio.assoc_factory import AssociationSetFactory MOUSE = 'NCBITaxon:10090' # Create association set # Transparently uses remote Monarch service. # (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do # not re-execute cell) afactory = AssociationSetFactory() aset = afactory.create(ontology=ont, subject_category='gene', object_category='function', taxon=MOUSE) aset.subjects[0:5] aset.jaccard_similarity('MGI:1929214', 'MGI:1917826') HUMAN = 'NCBITaxon:9606' # Create association set # Transparently uses remote Monarch service. # (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do # not re-execute cell) afactory = AssociationSetFactory() aset_human = afactory.create(ontology=ont, subject_category='gene', object_category='function', taxon=HUMAN) ZFISH = 'NCBITaxon:7955' # Create association set # Transparently uses remote Monarch service. # (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do # not re-execute cell) afactory = AssociationSetFactory() aset_zfish = afactory.create(ontology=ont, subject_category='gene', object_category='function', taxon=ZFISH) # TODO - do not re-read aset = afa.create_from_gaf(url, ontology=ont) from collections import defaultdict rmap = defaultdict(set) for a in assocs: ev = a['evidence']['type'] gene = a['subject']['id'] p = a['object']['id'] up = process_regulates(p) for rp in up: rmap[(gene,rp)].add('R') rmap[(gene,p)].add('I') len(rmap) mixed = [(k,v) for (k,v) in rmap.items() if len(v)>1] len(mixed) mixed[0:20] ont.label('GO:0007049')