In [1]:
from biothings_explorer.user_query_dispatcher import SingleEdgeQueryDispatcher
In [2]:
seqd = SingleEdgeQueryDispatcher(output_cls='ChemicalSubstance',
input_cls='Gene',
pred="physically_interacts_with",
input_id='NCBIGene',
values='1017')
In [3]:
seqd.query(verbose=True)
==== Step #1: Query path planning ====
Because NCBIGene:1017 is of type 'Gene', BTE will query our meta-KG for APIs that can take 'Gene' as input and 'ChemicalSubstance' as output
BTE found 3 apis:
API 1. mychem(2 API calls)
API 2. dgidb(1 API call)
API 3. semmed_gene(1 API call)
==== Step #2: Query path execution ====
NOTE: API requests are dispatched in parallel, so the list of APIs below is ordered by query time.
API 1.2: https://mychem.info/v1/query?fields=chembl.molecule_chembl_id&size=250 (POST -d q=CDK2&scopes=drugcentral.bioactivity.uniprot.gene_symbol)
API 1.1: https://mychem.info/v1/query?fields=drugbank.id&size=250 (POST -d q=CDK2&scopes=drugbank.targets.gene_name)
API 2.1: http://dgidb.genome.wustl.edu/api/v2/interactions.json?genes=CDK2
API 3.1: https://biothings.ncats.io/semmedgene/query?fields=physically_interacts_with (POST -d q=C1332733,C0108855&scopes=umls)
==== Step #3: Output normalization ====
API 3.1 semmed_gene: 112 hits
API 2.1 dgidb: 142 hits
API 1.1 mychem: 136 hits
API 1.2 mychem: 6 hits
After id-to-object translation, BTE retrieved 277 unique objects.
In [5]:
output = seqd.to_reasoner_std()
In [6]:
output.keys()
Out[6]:
dict_keys(['query_graph', 'knowledge_graph', 'results'])
In [7]:
output['query_graph']
Out[7]:
{'edges': [{'id': 'e0',
'source_id': 'n0',
'target_id': 'n1',
'directed': True}],
'nodes': [{'id': 'n0', 'type': 'Gene', 'curie': 'NCBIGene:1017'},
{'id': 'n1', 'type': 'ChemicalSubstance'}]}
In [8]:
output['knowledge_graph']['nodes'][:20]
Out[8]:
[{'id': 'NCBIGene:1017',
'name': 'CYCLIN DEPENDENT KINASE 2',
'type': 'Gene',
'equivalent_identifiers': defaultdict(set,
{'NCBIGene': ['1017'],
'name': ['CYCLIN DEPENDENT KINASE 2'],
'SYMBOL': ['CDK2'],
'UMLS': ['C1332733', 'C0108855'],
'HGNC': ['1771'],
'UNIPROTKB': ['P24941'],
'ENSEMBL': ['ENSG00000123374']})},
{'id': 'UMLS:C0034760',
'name': 'UMLS:C0034760',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0034760']}},
{'id': 'UMLS:C0220806',
'name': 'UMLS:C0220806',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0220806']}},
{'id': 'UMLS:C0304497',
'name': 'UMLS:C0304497',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0304497']}},
{'id': 'UMLS:C0444626',
'name': 'UMLS:C0444626',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0444626']}},
{'id': 'UMLS:C0567415',
'name': 'UMLS:C0567415',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0567415']}},
{'id': 'UMLS:C0599473',
'name': 'UMLS:C0599473',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0599473']}},
{'id': 'UMLS:C0678518',
'name': 'UMLS:C0678518',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0678518']}},
{'id': 'UMLS:C0001128',
'name': 'UMLS:C0001128',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0001128']}},
{'id': 'UMLS:C0086860',
'name': 'UMLS:C0086860',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0086860']}},
{'id': 'UMLS:C0280038',
'name': 'UMLS:C0280038',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0280038']}},
{'id': 'UMLS:C0597667',
'name': 'UMLS:C0597667',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0597667']}},
{'id': 'UMLS:C0699857',
'name': 'UMLS:C0699857',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0699857']}},
{'id': 'UMLS:C1171350',
'name': 'UMLS:C1171350',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C1171350']}},
{'id': 'UMLS:C1513403',
'name': 'UMLS:C1513403',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C1513403']}},
{'id': 'UMLS:C0243077',
'name': 'UMLS:C0243077',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0243077']}},
{'id': 'UMLS:C0450442',
'name': 'UMLS:C0450442',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0450442']}},
{'id': 'UMLS:C0243071',
'name': 'UMLS:C0243071',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0243071']}},
{'id': 'UMLS:C0303231',
'name': 'UMLS:C0303231',
'type': 'ChemicalSubstance',
'equivalent_identifiers': {'UMLS': ['C0303231']}},
{'id': 'CHEMBL.COMPOUND:CHEMBL1802728',
'name': 'CHEMBL.COMPOUND:CHEMBL1802728',
'type': 'ChemicalSubstance',
'equivalent_identifiers': defaultdict(set,
{'CHEMBL.COMPOUND': ['CHEMBL1802728'],
'PUBCHEM': ['10202471']})}]
In [9]:
output['knowledge_graph']['edges'][:20]
Out[9]:
[{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0034760',
'edge_source': 'SEMMED Gene API',
'id': 'd2f964b4c125a9e6d7900e82dc0f9949de63bb66a1a63575ddb685b1aa2c92ce',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0220806',
'edge_source': 'SEMMED Gene API',
'id': '0d3020e8b77f59b3698c2b8e18966743a5cb8198112d0e928024bd678ef3cbdb',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0304497',
'edge_source': 'SEMMED Gene API',
'id': 'c46637cc4d656411f53f7ab5b051a4f9c4da973562f94ac0d39a3121a4bfb8e7',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0444626',
'edge_source': 'SEMMED Gene API',
'id': '6607126c2d681d736f3e6b032758fbd3a9682390782239e7e0f7b5b494be8b98',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0444626',
'edge_source': 'SEMMED Gene API',
'id': '6607126c2d681d736f3e6b032758fbd3a9682390782239e7e0f7b5b494be8b98',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0567415',
'edge_source': 'SEMMED Gene API',
'id': '4772f4342cb641cdb176688040148a6cb43065301719773a0d68035a5494311a',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0599473',
'edge_source': 'SEMMED Gene API',
'id': 'dd18ca55bdc18f383864537cbcf663e8f95319cb70742ef90340a825700553ce',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0678518',
'edge_source': 'SEMMED Gene API',
'id': '26e940eca7c1430c634fda17e03b735f5a28179631034d07251d023f5ea97ec4',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0001128',
'edge_source': 'SEMMED Gene API',
'id': '903accd6f7401dd51329c30ad1b7d0c2ccd691406406014333f81441892e6797',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0086860',
'edge_source': 'SEMMED Gene API',
'id': '9552a7d9f0ebb931917e9955d7230ea75100d2cb9f36fe76c1453aeadc222901',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0280038',
'edge_source': 'SEMMED Gene API',
'id': 'fce70ee1b7a08c75dfefadfff5d667914bdab77765341cdbcc43ccc049fc16af',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0597667',
'edge_source': 'SEMMED Gene API',
'id': 'b1ef684cc863980476d09809f6cceb82b5c72d099fee58cd8550e11668bb5dfd',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0699857',
'edge_source': 'SEMMED Gene API',
'id': '6d3a6c6ab14d579258bb0efb8f03646b5b4a2de65c4295177b12794284fe01b0',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C1171350',
'edge_source': 'SEMMED Gene API',
'id': '863527c483a39daf22a98b52a00b53eb09717896290b59248384dfd9208662cf',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C1513403',
'edge_source': 'SEMMED Gene API',
'id': 'af016fe267e17e9e2dfb05cc28f8fb7de9ce5697224dda0a54a2cf09aadbd72a',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0243077',
'edge_source': 'SEMMED Gene API',
'id': 'd2c18288c3840658829512784b3838a09069e8eaae8937eeb2ddeda49e0417da',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0243077',
'edge_source': 'SEMMED Gene API',
'id': 'd2c18288c3840658829512784b3838a09069e8eaae8937eeb2ddeda49e0417da',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0450442',
'edge_source': 'SEMMED Gene API',
'id': '497324acce12210903e1d3f9f043e2fe1ad72ae4fc2a8ce2f0909f3303794a8d',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0243071',
'edge_source': 'SEMMED Gene API',
'id': '6c17d3a71884282c4d05c73cc203b45d764720fa7a1bdee5128673c8a863d961',
'type': 'physically_interacts_with'},
{'source_id': 'NCBIGene:1017',
'target_id': 'UMLS:C0303231',
'edge_source': 'SEMMED Gene API',
'id': '31af175d47d8a83b0d039735ae7e66f96c84489c9742df539cd3251f4d0fa0c8',
'type': 'physically_interacts_with'}]
In [12]:
output['results'][:20]
Out[12]:
[{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['CHEMBL:CHEMBL260273']},
'edge_bindings': {'e0': ['2720cfda869ff775b4c06f199d7e345331bd83b0']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['CHEMBL:CHEMBL429844']},
'edge_bindings': {'e0': ['c766ed7c37f23ead58a4e83777d61b0de4d0b19c']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['DRUGBANK:DB05203']},
'edge_bindings': {'e0': ['03ce86b5f42fc668191c4a9b494c7e60c5c34f14']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0003015']},
'edge_bindings': {'e0': ['a8bd272d050d9c12af163735b9b9edac2b07a719',
'a8bd272d050d9c12af163735b9b9edac2b07a719']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0012854']},
'edge_bindings': {'e0': ['57091960ded0f1bcf6af15357296ef50629e39aa']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0058206']},
'edge_bindings': {'e0': ['c4e994c106dd4dc9404ac1be7973d94f10f71366']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0065556']},
'edge_bindings': {'e0': ['b3a259f71b23307a859d8d64687e8a5e1ac179f4']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0682921']},
'edge_bindings': {'e0': ['5311d640414bfb77414343da2f539eca0cd04c4f']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0772162']},
'edge_bindings': {'e0': ['50c16358e9035afc3c468db1116ea0f0ae9a99d6']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C1098320']},
'edge_bindings': {'e0': ['e99c3887db5dda334dad4b36fbf81ee8fbbcc4bf']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C1314787']},
'edge_bindings': {'e0': ['9200a57504f3cc566228c0e869911be38d3e8fb8']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0014939']},
'edge_bindings': {'e0': ['74a87309f99a09831b3ca128b68765ebb50cc5f4']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0309049']},
'edge_bindings': {'e0': ['0abafcc58fdf8af5b773c72838808fd743cb82ed']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0608663']},
'edge_bindings': {'e0': ['7857fc4e384612d831bacf07544cb8d30aadc778']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C0684162']},
'edge_bindings': {'e0': ['8b3fe6386a542f5ebdb2ebec09392b0e74aa6d11']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['UMLS:C1257987']},
'edge_bindings': {'e0': ['717065d336b8d8feba7c1cbbf6ad8677c48bd0c5']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['NAME:LISINOPRIL']},
'edge_bindings': {'e0': ['5c205c2308628f99cd159100ba5403bade269c12']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['NAME:FLUTAMIDE']},
'edge_bindings': {'e0': ['4d9841ccde52d05c02c30e008a802415261db683']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['NAME:MOEXIPRIL']},
'edge_bindings': {'e0': ['0c238a195f643c7411ce77eeb91610bb64b42315']}},
{'node_bindings': {'n0': ['ENTREZ:ACE2'], 'n1': ['NAME:ENALAPRILAT']},
'edge_bindings': {'e0': ['0cfe25c7e88f1171da31971b80f977c3caa50291']}}]
In [ ]:
Content source: biothings/biothings_explorer
Similar notebooks: