From a3a166072846bc26e312ba7b95f1f7fc11ce5e0b Mon Sep 17 00:00:00 2001 From: Yue Zhang Date: Tue, 28 Apr 2026 22:03:02 -0700 Subject: [PATCH 01/33] fix test error --- tests/test_nameres.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_nameres.py b/tests/test_nameres.py index 3e926b5..d9650a0 100644 --- a/tests/test_nameres.py +++ b/tests/test_nameres.py @@ -42,7 +42,7 @@ def test_nameres_status(): assert status['status'] == 'ok' assert status['babel_version'] != '' assert status['babel_version_url'] != '' - assert status['numDocs'] > 425_000_000 + assert status['solr']['numDocs'] > 425_000_000 def test_nameres_incorrect(): From afffeee5045c65d824f728e1adbf16bd4b5f258e Mon Sep 17 00:00:00 2001 From: Yue Zhang Date: Thu, 30 Apr 2026 03:52:32 -0700 Subject: [PATCH 02/33] adding scoring to pathfinder output --- TCT/TCT_pathfinder.py | 56 +++++- notebooks/Pathfinder_new.ipynb | 328 +++++++++++++++++++++++++-------- 2 files changed, 306 insertions(+), 78 deletions(-) diff --git a/TCT/TCT_pathfinder.py b/TCT/TCT_pathfinder.py index f7a5e28..eff8128 100644 --- a/TCT/TCT_pathfinder.py +++ b/TCT/TCT_pathfinder.py @@ -103,10 +103,50 @@ def build_query_graph(start_node_id, end_node_id, start_node_categories=None, en return q +def generate_score_results(results, method='infores'): + """ + Generates a score dict, and a list of "analyses". + method can be 'infores' or 'edges' + """ + graph_scores = {} + max_score = 0 + auxiliary_graphs = results['auxiliary_graphs'] + for k, graph in auxiliary_graphs.items(): + if method == 'infores': + sources = set() + for edge_index in graph: + edge = results['knowledge_graph']['edges'][edge_index] + for resource in edge['sources']: + sources.add(resource['resource_id']) + score = len(sources) + if score > max_score: + max_score = score + else: + score = len(graph) + if score > max_score: + max_score = score + graph_scores[k] = score + graph_scores_formatted = [] + for k in graph_scores.keys(): + graph_scores[k] = graph_scores[k]/max_score + graph_scores_formatted.append({ + 'attributes': None, + 'path_bindings': { + 'p0': [{'id': k}]}, + 'resource_id': 'infores:tct', + 'score': graph_scores[k], + 'scoring_method': None, + 'support_graphs': None + }) + return graph_scores, graph_scores_formatted + + def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dict, result2:dict, - start_node_categories=None, end_node_categories=None): + start_node_categories=None, end_node_categories=None, + scoring_method='infores'): """ Converts the results of two TRAPI queries into the same general json format as the other pathfinder APIs. + scoring_method is how the node scores are generated, and could be 'infores' or 'edges'. """ # TODO: parse results... # nodes @@ -155,6 +195,7 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic keys = [x[0] for x in e1s] + [x[0] for x in e2s] all_auxiliary_graphs[f'aux_{i}_{i1}'] = keys i += 1 + # generate output json output = { 'query_graph': build_query_graph(start_node_id, end_node_id, start_node_categories, end_node_categories), 'knowledge_graph': {'nodes': {x: {} for x in connection_counts.keys()}, @@ -163,11 +204,17 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic 'results': [{'analyses': []}], 'auxiliary_graphs': all_auxiliary_graphs } + graph_scores, graph_scores_formatted = generate_score_results(output, method=scoring_method) + output['results'][0]['analyses'] = graph_scores_formatted return output def pathfinder(input_node1_id:str, input_node2_id:str, - intermediate_categories:list, APInames, metaKG, API_predicates): + intermediate_categories:list, APInames, metaKG, API_predicates, + scoring_method='infores'): + """ + Returns a Pathfinder output for the given pair of nodes. scoring_method could be 'infores' or 'edges'. + """ # get categories for input nodes normalized_node_dict = node_normalizer.get_normalized_nodes([input_node1_id, input_node2_id]) input_node1_info = normalized_node_dict[input_node1_id] @@ -227,7 +274,8 @@ def pathfinder(input_node1_id:str, input_node2_id:str, output = parse_results_for_pathfinder(input_node1_id, input_node2_id, result1, result2, start_node_categories=input_node1_category, - end_node_categories=input_node2_category) + end_node_categories=input_node2_category, + scoring_method=scoring_method) return result1, result2, output, paths @@ -278,4 +326,4 @@ def query_arax_pathfinder(node1_id, node1_category, node2_id, node2_category): ARAX_endpoint = 'https://arax.ci.transltr.io/api/arax/v1.4/query' query_current = format_pathfinder_query(node1_id, node1_category, node2_id, node2_category) response = requests.post(ARAX_endpoint, json=query_current) - return response \ No newline at end of file + return response diff --git a/notebooks/Pathfinder_new.ipynb b/notebooks/Pathfinder_new.ipynb index 67512d1..6e33b5f 100644 --- a/notebooks/Pathfinder_new.ipynb +++ b/notebooks/Pathfinder_new.ipynb @@ -108,14 +108,15 @@ "output_type": "stream", "text": [ "MONDO:0100096\n", - "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0: Success!\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", "Automat-genome-alliance(Trapi v1.5.0): Success!\n", "RTX KG2 - TRAPI 1.5.0: Success!\n", "Automat-cam-kp(Trapi v1.5.0): Success!\n", "Automat-hetionet(Trapi v1.5.0): Success!\n", - "Automat-robokop(Trapi v1.5.0): Success!\n", + "Service Provider TRAPI: Success!\n", "BioThings Explorer (BTE) TRAPI: Success!\n", + "Automat-robokop(Trapi v1.5.0): Success!\n", "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", "Clinical Trials KP - TRAPI 1.5.0: Success!\n", "Microbiome KP - TRAPI 1.5.0: Success!\n", @@ -141,6 +142,14 @@ " API_predicates=API_predicates)" ] }, + { + "cell_type": "markdown", + "id": "bf0506c3-6615-421b-bc45-ab4e124e3477", + "metadata": {}, + "source": [ + "### Examining pathfinder outputs" + ] + }, { "cell_type": "code", "execution_count": 5, @@ -185,36 +194,36 @@ " PDCD1\n", " \n", " \n", - " TNF\n", - " 0.133333\n", - " NCBIGene:7124\n", - " biolink:genetically_interacts_with; biolink:in...\n", - " biolink:gene_associated_with_condition; biolin...\n", - " TNF\n", - " \n", - " \n", - " IL13\n", + " IL17A\n", " 0.133333\n", - " NCBIGene:3596\n", + " NCBIGene:3605\n", " biolink:interacts_with; biolink:affects\n", " biolink:related_to; biolink:gene_associated_wi...\n", - " IL13\n", + " IL17A\n", " \n", " \n", " NLRP3\n", " 0.133333\n", " NCBIGene:114548\n", - " biolink:affects; biolink:physically_interacts_...\n", + " biolink:physically_interacts_with; biolink:aff...\n", " biolink:related_to; biolink:gene_associated_wi...\n", " NLRP3\n", " \n", " \n", - " IL17A\n", + " IL13\n", " 0.133333\n", - " NCBIGene:3605\n", + " NCBIGene:3596\n", " biolink:interacts_with; biolink:affects\n", " biolink:related_to; biolink:gene_associated_wi...\n", - " IL17A\n", + " IL13\n", + " \n", + " \n", + " TNF\n", + " 0.133333\n", + " NCBIGene:7124\n", + " biolink:genetically_interacts_with; biolink:in...\n", + " biolink:gene_associated_with_condition; biolin...\n", + " TNF\n", " \n", " \n", " ...\n", @@ -225,44 +234,44 @@ " ...\n", " \n", " \n", - " LIF\n", + " IFIT2\n", " 0.033333\n", - " NCBIGene:3976\n", - " biolink:affects\n", + " NCBIGene:3433\n", + " biolink:physically_interacts_with\n", " biolink:gene_associated_with_condition\n", - " LIF\n", + " IFIT2\n", " \n", " \n", - " FAS\n", + " GPX3\n", " 0.033333\n", - " NCBIGene:355\n", - " biolink:regulates; biolink:affects\n", + " NCBIGene:2878\n", + " biolink:physically_interacts_with\n", " biolink:gene_associated_with_condition\n", - " FAS\n", + " GPX3\n", " \n", " \n", - " MEFV\n", + " RETNLB\n", " 0.033333\n", - " NCBIGene:4210\n", - " biolink:affects\n", + " NCBIGene:84666\n", + " biolink:interacts_with; biolink:physically_int...\n", " biolink:gene_associated_with_condition\n", - " MEFV\n", + " RETNLB\n", " \n", " \n", - " PXDNL\n", + " NT5E\n", " 0.033333\n", - " NCBIGene:137902\n", - " biolink:interacts_with\n", + " NCBIGene:4907\n", + " biolink:affects\n", " biolink:gene_associated_with_condition\n", - " PXDNL\n", + " NT5E\n", " \n", " \n", - " THBD\n", + " H2BC21\n", " 0.033333\n", - " NCBIGene:7056\n", - " biolink:affects; biolink:physically_interacts_...\n", + " NCBIGene:8349\n", + " biolink:physically_interacts_with\n", " biolink:gene_associated_with_condition\n", - " THBD\n", + " H2BC21\n", " \n", " \n", "\n", @@ -270,44 +279,44 @@ "" ], "text/plain": [ - " score output_node \\\n", - "PDCD1 0.133333 NCBIGene:5133 \n", - "TNF 0.133333 NCBIGene:7124 \n", - "IL13 0.133333 NCBIGene:3596 \n", - "NLRP3 0.133333 NCBIGene:114548 \n", - "IL17A 0.133333 NCBIGene:3605 \n", - "... ... ... \n", - "LIF 0.033333 NCBIGene:3976 \n", - "FAS 0.033333 NCBIGene:355 \n", - "MEFV 0.033333 NCBIGene:4210 \n", - "PXDNL 0.033333 NCBIGene:137902 \n", - "THBD 0.033333 NCBIGene:7056 \n", + " score output_node \\\n", + "PDCD1 0.133333 NCBIGene:5133 \n", + "IL17A 0.133333 NCBIGene:3605 \n", + "NLRP3 0.133333 NCBIGene:114548 \n", + "IL13 0.133333 NCBIGene:3596 \n", + "TNF 0.133333 NCBIGene:7124 \n", + "... ... ... \n", + "IFIT2 0.033333 NCBIGene:3433 \n", + "GPX3 0.033333 NCBIGene:2878 \n", + "RETNLB 0.033333 NCBIGene:84666 \n", + "NT5E 0.033333 NCBIGene:4907 \n", + "H2BC21 0.033333 NCBIGene:8349 \n", "\n", - " predicates1 \\\n", - "PDCD1 biolink:interacts_with; biolink:affects \n", - "TNF biolink:genetically_interacts_with; biolink:in... \n", - "IL13 biolink:interacts_with; biolink:affects \n", - "NLRP3 biolink:affects; biolink:physically_interacts_... \n", - "IL17A biolink:interacts_with; biolink:affects \n", - "... ... \n", - "LIF biolink:affects \n", - "FAS biolink:regulates; biolink:affects \n", - "MEFV biolink:affects \n", - "PXDNL biolink:interacts_with \n", - "THBD biolink:affects; biolink:physically_interacts_... \n", + " predicates1 \\\n", + "PDCD1 biolink:interacts_with; biolink:affects \n", + "IL17A biolink:interacts_with; biolink:affects \n", + "NLRP3 biolink:physically_interacts_with; biolink:aff... \n", + "IL13 biolink:interacts_with; biolink:affects \n", + "TNF biolink:genetically_interacts_with; biolink:in... \n", + "... ... \n", + "IFIT2 biolink:physically_interacts_with \n", + "GPX3 biolink:physically_interacts_with \n", + "RETNLB biolink:interacts_with; biolink:physically_int... \n", + "NT5E biolink:affects \n", + "H2BC21 biolink:physically_interacts_with \n", "\n", - " predicates2 output_node_name \n", - "PDCD1 biolink:related_to; biolink:gene_associated_wi... PDCD1 \n", - "TNF biolink:gene_associated_with_condition; biolin... TNF \n", - "IL13 biolink:related_to; biolink:gene_associated_wi... IL13 \n", - "NLRP3 biolink:related_to; biolink:gene_associated_wi... NLRP3 \n", - "IL17A biolink:related_to; biolink:gene_associated_wi... IL17A \n", - "... ... ... \n", - "LIF biolink:gene_associated_with_condition LIF \n", - "FAS biolink:gene_associated_with_condition FAS \n", - "MEFV biolink:gene_associated_with_condition MEFV \n", - "PXDNL biolink:gene_associated_with_condition PXDNL \n", - "THBD biolink:gene_associated_with_condition THBD \n", + " predicates2 output_node_name \n", + "PDCD1 biolink:related_to; biolink:gene_associated_wi... PDCD1 \n", + "IL17A biolink:related_to; biolink:gene_associated_wi... IL17A \n", + "NLRP3 biolink:related_to; biolink:gene_associated_wi... NLRP3 \n", + "IL13 biolink:related_to; biolink:gene_associated_wi... IL13 \n", + "TNF biolink:gene_associated_with_condition; biolin... TNF \n", + "... ... ... \n", + "IFIT2 biolink:gene_associated_with_condition IFIT2 \n", + "GPX3 biolink:gene_associated_with_condition GPX3 \n", + "RETNLB biolink:gene_associated_with_condition RETNLB \n", + "NT5E biolink:gene_associated_with_condition NT5E \n", + "H2BC21 biolink:gene_associated_with_condition H2BC21 \n", "\n", "[680 rows x 5 columns]" ] @@ -344,9 +353,180 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "9847dbb5-0d63-496b-8969-4dd330f3897c", "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'attributes': [{'attribute_source': 'infores:rtx-kg2',\n", + " 'attribute_type_id': 'biolink:original_predicate',\n", + " 'description': 'The IDs of the original RTX-KG2pre edge(s) corresponding to this edge prior to any synonymization or remapping.',\n", + " 'value': ['UMLS:C0017337---SEMMEDDB:interacts_with---None---None---None---UMLS:C0021745---SEMMEDDB:',\n", + " 'UMLS:C0017337---SEMMEDDB:interacts_with---None---None---None---UMLS:C1334085---SEMMEDDB:'],\n", + " 'value_type_id': 'metatype:String'},\n", + " {'attribute_source': 'infores:rtx-kg2',\n", + " 'attribute_type_id': 'biolink:knowledge_level',\n", + " 'value': 'prediction'},\n", + " {'attribute_source': 'infores:rtx-kg2',\n", + " 'attribute_type_id': 'biolink:publications',\n", + " 'value': ['PMID:25676343',\n", + " 'PMID:3934559',\n", + " 'PMID:35453072',\n", + " 'PMID:36111345'],\n", + " 'value_type_id': 'biolink:Uriorcurie'},\n", + " {'attribute_source': 'infores:rtx-kg2',\n", + " 'attribute_type_id': 'biolink:agent_type',\n", + " 'value': 'text_mining_agent'},\n", + " {'attribute_source': 'infores:rtx-kg2',\n", + " 'attribute_type_id': 'biolink:supporting_text',\n", + " 'value': {'PMID:25676343': {'object score': '851',\n", + " 'publication date': '2015 Mar',\n", + " 'sentence': 'OBJECTIVES: Atypical familial mycobacteriosis (AFM, OMIM #209950) is caused by mutations in genes regulating IL12/IFNG pathway.',\n", + " 'subject score': '1000'},\n", + " 'PMID:35453072': {'object score': '1000',\n", + " 'publication date': '2022 Apr 18',\n", + " 'sentence': 'Innate immune responses were attenuated reflected by decreased expression of genes involved in interferon-gamma, leukocyte migration and neutrophil mediated immune response in convalescent COVID-19 patients.',\n", + " 'subject score': '1000'},\n", + " 'PMID:36111345': {'object score': '901',\n", + " 'publication date': '2022',\n", + " 'sentence': 'Differentially expressed genes (DEGs) between groups were enriched in allograft rejection, hypoxia, glycolysis, TNFalpha signaling via NF-kappaB, and interferon-gamma responses via Gene set enrichment analysis (GSEA).',\n", + " 'subject score': '790'},\n", + " 'PMID:3934559': {'object score': '1000',\n", + " 'publication date': '1985 Nov 21-27',\n", + " 'sentence': 'This gene controls a function or a product necessary for the action of gamma-interferon on class II genes.',\n", + " 'subject score': '1000'}}}],\n", + " 'object': 'NCBIGene:3458',\n", + " 'predicate': 'biolink:interacts_with',\n", + " 'sources': [{'resource_id': 'infores:semmeddb',\n", + " 'resource_role': 'primary_knowledge_source'},\n", + " {'resource_id': 'infores:rtx-kg2',\n", + " 'resource_role': 'aggregator_knowledge_source',\n", + " 'upstream_resource_ids': ['infores:semmeddb']}],\n", + " 'subject': 'UMLS:C0017337'}" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list(formatted_output['knowledge_graph']['edges'].values())[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "c2ac8ad6-218f-4805-8c72-8cf21df4ac7c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['12026540',\n", + " '13008760',\n", + " '13008998',\n", + " '1451206',\n", + " '25948818',\n", + " '12006224',\n", + " '12009572',\n", + " '12011840',\n", + " '12014211',\n", + " '12034620']" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list(formatted_output['auxiliary_graphs'].values())[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "94377dae-4f2a-4cc4-bdc0-8d7c380ed152", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'resource_id': 'infores:semmeddb',\n", + " 'resource_role': 'primary_knowledge_source'},\n", + " {'resource_id': 'infores:rtx-kg2',\n", + " 'resource_role': 'aggregator_knowledge_source',\n", + " 'upstream_resource_ids': ['infores:semmeddb']}]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formatted_output['knowledge_graph']['edges']['12026540']['sources']" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "56886736-9e0a-4e9a-9773-308447fcce3a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'resource_id': 'infores:semmeddb',\n", + " 'resource_role': 'primary_knowledge_source'},\n", + " {'resource_id': 'infores:rtx-kg2',\n", + " 'resource_role': 'aggregator_knowledge_source',\n", + " 'upstream_resource_ids': ['infores:semmeddb']}]" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formatted_output['knowledge_graph']['edges']['13008760']['sources']" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "8540fc14-dd13-444f-b9d9-afae72b31b49", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'attributes': None,\n", + " 'path_bindings': {'p0': [{'id': 'aux_1_UMLS:C0017337'}]},\n", + " 'resource_id': 'infores:tct',\n", + " 'score': 0.14285714285714285,\n", + " 'scoring_method': None,\n", + " 'support_graphs': None}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formatted_output['results'][0]['analyses'][0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a6ba8e09-c1aa-4010-86cf-722bc9c27058", + "metadata": {}, "outputs": [], "source": [] } From 43df311158a789dc148f8ff6cf012ec716354ec3 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 30 Apr 2026 18:20:54 -0700 Subject: [PATCH 03/33] add nodes to TCT_pathfinder --- TCT/TCT_pathfinder.py | 76 ++++-- TCT/name_resolver.py | 49 +++- notebooks/Pathfinder_new.ipynb | 441 +++++++++++++++++---------------- 3 files changed, 326 insertions(+), 240 deletions(-) diff --git a/TCT/TCT_pathfinder.py b/TCT/TCT_pathfinder.py index eff8128..435a125 100644 --- a/TCT/TCT_pathfinder.py +++ b/TCT/TCT_pathfinder.py @@ -143,36 +143,59 @@ def generate_score_results(results, method='infores'): def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dict, result2:dict, start_node_categories=None, end_node_categories=None, + get_node_info=True, scoring_method='infores'): """ Converts the results of two TRAPI queries into the same general json format as the other pathfinder APIs. scoring_method is how the node scores are generated, and could be 'infores' or 'edges'. """ - # TODO: parse results... # nodes + # TODO: get some node info? node attributes + node_info = {} # edges is a dict of intermediate nodes intermediate_node_edges = {} for k, v in result1.items(): i1 = v['subject'] i2 = v['object'] + s_o = 'object' if i1 == start_node_id: intermediate_node_id = i2 + s_o = 'object' elif i2 == start_node_id: intermediate_node_id = i1 + s_o = 'subject' else: continue if (i1 == start_node_id or i2 == start_node_id) and intermediate_node_id in intermediate_node_edges: intermediate_node_edges[intermediate_node_id].append((k, v)) else: intermediate_node_edges[intermediate_node_id] = [(k, v)] + # add node dict + if intermediate_node_id not in node_info: + node_dict = { + } + node_info[intermediate_node_id] = node_dict + else: + node_dict = node_info[intermediate_node_id] + for attribute in v['attributes']: + if attribute['attribute_type_id'] == f'{s_o}_category': + if 'categories' not in node_dict: + node_dict['categories'] = set([attribute['value']]) + else: + node_dict['categories'].add(attribute['value']) + if attribute['attribute_type_id'] == f'{s_o}_name' and 'name' not in node_dict: + node_dict['name'] = attribute['value'] + node_info[intermediate_node_id] = node_dict connecting_intermediate_nodes = {} for k, v in result2.items(): i1 = v['subject'] i2 = v['object'] if i1 == end_node_id: intermediate_node_id = i2 + s_o = 'object' elif i2 == end_node_id: intermediate_node_id = i1 + s_o = 'subject' else: continue if (i1 == end_node_id or i2 == end_node_id) and intermediate_node_id in intermediate_node_edges: @@ -180,6 +203,24 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic connecting_intermediate_nodes[intermediate_node_id]['e2'].append((k, v)) else: connecting_intermediate_nodes[intermediate_node_id] = {'e1': intermediate_node_edges[intermediate_node_id], 'e2' : [(k, v)]} + if intermediate_node_id not in node_info: + node_dict = { + } + node_info[intermediate_node_id] = node_dict + else: + node_dict = node_info[intermediate_node_id] + for attribute in v['attributes']: + if attribute['attribute_type_id'] == f'{s_o}_category': + if 'categories' not in node_dict: + node_dict['categories'] = set([attribute['value']]) + else: + node_dict['categories'].add(attribute['value']) + if attribute['attribute_type_id'] == f'{s_o}_name' and 'name' not in node_dict: + node_dict['name'] = attribute['value'] + node_info[intermediate_node_id] = node_dict + for k, v in node_info.items(): + if 'categories' in v: + v['categories'] = list(v['categories']) all_edges = {} all_auxiliary_graphs = {} i = 1 @@ -198,7 +239,8 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic # generate output json output = { 'query_graph': build_query_graph(start_node_id, end_node_id, start_node_categories, end_node_categories), - 'knowledge_graph': {'nodes': {x: {} for x in connection_counts.keys()}, + # TODO: don't drop the nodes + 'knowledge_graph': {'nodes': {x: node_info[x] for x in connection_counts.keys()}, 'edges': all_edges, }, 'results': [{'analyses': []}], @@ -206,6 +248,16 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic } graph_scores, graph_scores_formatted = generate_score_results(output, method=scoring_method) output['results'][0]['analyses'] = graph_scores_formatted + if get_node_info: + from .node_normalizer import get_normalized_nodes + nodes_to_add = [] + for k, v in output['knowledge_graph']['nodes'].items(): + if 'name' not in v or 'categories' not in v: + nodes_to_add.append(k) + normalized_nodes = get_normalized_nodes(nodes_to_add, mode='post') + for node_id in nodes_to_add: + nn = normalized_nodes[node_id] + output['knowledge_graph']['nodes'][node_id] = {'name': nn.label, 'categories': nn.types} return output @@ -257,27 +309,13 @@ def pathfinder(input_node1_id:str, input_node2_id:str, APInames=APInames, API_predicates=API_predicates, max_workers=len(sele_APIs2)) - - result_parsed1 = parse_KG(result1) - # Step 7: Ranking the results. This ranking method is based on the number of unique - # primary infores. It can only be used to rank the results with one defined node. - result_ranked_by_primary_infores1 = rank_by_primary_infores(result_parsed1, input_node1_id) # input_node1_id is the curie id of the - - result_parsed2 = parse_KG(result2) - result_ranked_by_primary_infores2 = rank_by_primary_infores(result_parsed2, input_node2_id) # input_node2_id is the curie id of the - - possible_paths = len(set(result_ranked_by_primary_infores1['output_node']).intersection(set(result_ranked_by_primary_infores2['output_node']))) - print("Number of possible paths: ", possible_paths) - - paths = merge_ranking_by_number_of_infores(result_ranked_by_primary_infores1, result_ranked_by_primary_infores2, - plot=False) - output = parse_results_for_pathfinder(input_node1_id, input_node2_id, result1, result2, start_node_categories=input_node1_category, end_node_categories=input_node2_category, - scoring_method=scoring_method) + scoring_method=scoring_method, + get_node_info=True) - return result1, result2, output, paths + return result1, result2, output diff --git a/TCT/name_resolver.py b/TCT/name_resolver.py index 387698e..cf78e6a 100644 --- a/TCT/name_resolver.py +++ b/TCT/name_resolver.py @@ -72,14 +72,14 @@ def lookup(query: str, return_top_response:bool=True, return_synonyms:bool=False raise requests.RequestException('Response from server had error, code ' + str(response.status_code) + ' ' + str(response)) -def synonyms(query: str, **kwargs): +def synonyms(query: str|list, **kwargs): """ - A wrapper around the `synonyms` api endpoint. Given a list of CURIEs, this returns a dict of CURIE id : TranslatorNode for all synonyms for the given query. + A wrapper around the `synonyms` api endpoint. Given a CURIE or a list of CURIEs, this returns a dict of CURIE id : TranslatorNode for all synonyms for the given query. Parameters ---------- - query : str - Query CURIE + query : str|list + Query CURIE or list of CURIEs **kwargs Other arguments to `synonyms` @@ -93,7 +93,7 @@ def synonyms(query: str, **kwargs): if response.status_code == 200: result = response.json() if len(result) == 0: - raise LookupError('No matching CURIE found for the given string ' + query) + raise LookupError('No matching CURIE found for the given string ' + str(query)) else: all_nodes = {} for k, node in result.items(): @@ -172,3 +172,42 @@ def batch_lookup(strings:list[str], size: int=25, return_top_response:bool=True, else: raise requests.RequestException('Response from server had error, code ' + str(response.status_code) + ' ' + str(response)) return curies + + +def batch_synonyms(strings:list[str], size:int=50, **kwargs) -> dict: + """ + A wrapper around the `synonyms` API endpoint, using POST. Given a list of CURIEs, this returns a dict of CURIE:TranslatorNode, where each TranslatorNode contains all synonyms for the given CURIE. + + Parameters + ---------- + strings : list[str] + List of CURIEs. + size : int + Desired chunking size, default is 50. + + Returns + ------- + Dict of CURIE : TranslatorNode + """ + chunks = chunk_list(strings, size) + path = urllib.parse.urljoin(URL, 'synonyms') + curies = {} + for chunk in chunks: + # set autocomplete to be false by default + response = requests.post(path, json={'preferred_curies': chunk, **kwargs}) + if response.status_code == 200: + result = response.json() + if len(result) == 0: + raise LookupError('No matching CURIE found for the given CURIEs ' + str(chunks)) + else: + for k, node in result.items(): + if not node: + # If node is empty or None. + curies[k] = None + else: + curies[k] = TranslatorNode.from_dict(node, return_synonyms=True) + else: + raise requests.RequestException('Response from server had error, code ' + str(response.status_code) + ' ' + str(response)) + return curies + + diff --git a/notebooks/Pathfinder_new.ipynb b/notebooks/Pathfinder_new.ipynb index 6e33b5f..c4c1db1 100644 --- a/notebooks/Pathfinder_new.ipynb +++ b/notebooks/Pathfinder_new.ipynb @@ -108,33 +108,24 @@ "output_type": "stream", "text": [ "MONDO:0100096\n", - "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0: Success!\n", - "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", "Automat-genome-alliance(Trapi v1.5.0): Success!\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", + "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0: Success!\n", "RTX KG2 - TRAPI 1.5.0: Success!\n", "Automat-cam-kp(Trapi v1.5.0): Success!\n", "Automat-hetionet(Trapi v1.5.0): Success!\n", + "Automat-robokop(Trapi v1.5.0): Success!\n", "Service Provider TRAPI: Success!\n", "BioThings Explorer (BTE) TRAPI: Success!\n", - "Automat-robokop(Trapi v1.5.0): Success!\n", "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", "Clinical Trials KP - TRAPI 1.5.0: Success!\n", "Microbiome KP - TRAPI 1.5.0: Success!\n", - "RTX KG2 - TRAPI 1.5.0: Success!\n", - "ENSEMBL:ENSP00000423463: no preferred name\n", - "ENSEMBL:ENSP00000423463: no preferred name\n", - "UniProtKB:P01308-1: no preferred name\n", - "UniProtKB:P01308-1: no preferred name\n", - "UniProtKB:P12544-1: no preferred name\n", - "UniProtKB:P12544-1: no preferred name\n", - "NodeNorm does not know about these identifiers: NCIT:C16612,UniProtKB:P05113-1,UniProtKB:P05113-1\n", - "NodeNorm does not know about these identifiers: UMLS:C5911035,UMLS:C5943250,UMLS:C5959582,UMLS:C5908975,UMLS:C5926549,UMLS:C5943245,CHEMBL.TARGET:CHEMBL1697664,CHEMBL.TARGET:CHEMBL6188,CHEMBL.TARGET:CHEMBL4295579,CHEMBL.TARGET:CHEMBL1075031,CHEMBL.TARGET:CHEMBL4295609,CHEMBL.TARGET:CHEMBL1287621,CHEMBL.TARGET:CHEMBL3499,CHEMBL.TARGET:CHEMBL4295625,CHEMBL.TARGET:CHEMBL4295542,CHEMBL.TARGET:CHEMBL1741198,CHEMBL.TARGET:CHEMBL3309030,CHEMBL.TARGET:CHEMBL4882,CHEMBL.TARGET:CHEMBL3309037\n", - "Number of possible paths: 680\n" + "RTX KG2 - TRAPI 1.5.0: Success!\n" ] } ], "source": [ - "result1, result2, formatted_output, paths = TCT_pathfinder.pathfinder(input_node1_id='NCBIGene:3458', #IFNG\n", + "result1, result2, formatted_output = TCT_pathfinder.pathfinder(input_node1_id='NCBIGene:3458', #IFNG\n", " input_node2_id= 'MONDO:0100096', #COVID-19\n", " intermediate_categories=['biolink:Protein', 'biolink:Gene' ], \n", " APInames=select_APIs, \n", @@ -153,172 +144,13 @@ { "cell_type": "code", "execution_count": 5, - "id": "c1e3f672-a900-4e45-b197-8874a8f44c32", + "id": "fcfb4342-ed1b-401d-8ffa-862978f0c275", "metadata": {}, "outputs": [ { "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
scoreoutput_nodepredicates1predicates2output_node_name
PDCD10.133333NCBIGene:5133biolink:interacts_with; biolink:affectsbiolink:related_to; biolink:gene_associated_wi...PDCD1
IL17A0.133333NCBIGene:3605biolink:interacts_with; biolink:affectsbiolink:related_to; biolink:gene_associated_wi...IL17A
NLRP30.133333NCBIGene:114548biolink:physically_interacts_with; biolink:aff...biolink:related_to; biolink:gene_associated_wi...NLRP3
IL130.133333NCBIGene:3596biolink:interacts_with; biolink:affectsbiolink:related_to; biolink:gene_associated_wi...IL13
TNF0.133333NCBIGene:7124biolink:genetically_interacts_with; biolink:in...biolink:gene_associated_with_condition; biolin...TNF
..................
IFIT20.033333NCBIGene:3433biolink:physically_interacts_withbiolink:gene_associated_with_conditionIFIT2
GPX30.033333NCBIGene:2878biolink:physically_interacts_withbiolink:gene_associated_with_conditionGPX3
RETNLB0.033333NCBIGene:84666biolink:interacts_with; biolink:physically_int...biolink:gene_associated_with_conditionRETNLB
NT5E0.033333NCBIGene:4907biolink:affectsbiolink:gene_associated_with_conditionNT5E
H2BC210.033333NCBIGene:8349biolink:physically_interacts_withbiolink:gene_associated_with_conditionH2BC21
\n", - "

680 rows × 5 columns

\n", - "
" - ], "text/plain": [ - " score output_node \\\n", - "PDCD1 0.133333 NCBIGene:5133 \n", - "IL17A 0.133333 NCBIGene:3605 \n", - "NLRP3 0.133333 NCBIGene:114548 \n", - "IL13 0.133333 NCBIGene:3596 \n", - "TNF 0.133333 NCBIGene:7124 \n", - "... ... ... \n", - "IFIT2 0.033333 NCBIGene:3433 \n", - "GPX3 0.033333 NCBIGene:2878 \n", - "RETNLB 0.033333 NCBIGene:84666 \n", - "NT5E 0.033333 NCBIGene:4907 \n", - "H2BC21 0.033333 NCBIGene:8349 \n", - "\n", - " predicates1 \\\n", - "PDCD1 biolink:interacts_with; biolink:affects \n", - "IL17A biolink:interacts_with; biolink:affects \n", - "NLRP3 biolink:physically_interacts_with; biolink:aff... \n", - "IL13 biolink:interacts_with; biolink:affects \n", - "TNF biolink:genetically_interacts_with; biolink:in... \n", - "... ... \n", - "IFIT2 biolink:physically_interacts_with \n", - "GPX3 biolink:physically_interacts_with \n", - "RETNLB biolink:interacts_with; biolink:physically_int... \n", - "NT5E biolink:affects \n", - "H2BC21 biolink:physically_interacts_with \n", - "\n", - " predicates2 output_node_name \n", - "PDCD1 biolink:related_to; biolink:gene_associated_wi... PDCD1 \n", - "IL17A biolink:related_to; biolink:gene_associated_wi... IL17A \n", - "NLRP3 biolink:related_to; biolink:gene_associated_wi... NLRP3 \n", - "IL13 biolink:related_to; biolink:gene_associated_wi... IL13 \n", - "TNF biolink:gene_associated_with_condition; biolin... TNF \n", - "... ... ... \n", - "IFIT2 biolink:gene_associated_with_condition IFIT2 \n", - "GPX3 biolink:gene_associated_with_condition GPX3 \n", - "RETNLB biolink:gene_associated_with_condition RETNLB \n", - "NT5E biolink:gene_associated_with_condition NT5E \n", - "H2BC21 biolink:gene_associated_with_condition H2BC21 \n", - "\n", - "[680 rows x 5 columns]" + "dict_keys(['query_graph', 'knowledge_graph', 'results', 'auxiliary_graphs'])" ] }, "execution_count": 5, @@ -327,19 +159,59 @@ } ], "source": [ - "paths" + "formatted_output.keys()" ] }, { "cell_type": "code", "execution_count": 6, - "id": "fcfb4342-ed1b-401d-8ffa-862978f0c275", + "id": "9847dbb5-0d63-496b-8969-4dd330f3897c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "dict_keys(['query_graph', 'knowledge_graph', 'results', 'auxiliary_graphs'])" + "{'sources': [{'resource_id': 'infores:automat-cam-kp',\n", + " 'resource_role': 'aggregator_knowledge_source',\n", + " 'upstream_resource_ids': ['infores:cam-kp']},\n", + " {'resource_id': 'infores:ctd',\n", + " 'resource_role': 'primary_knowledge_source',\n", + " 'upstream_resource_ids': []},\n", + " {'resource_id': 'infores:cam-kp',\n", + " 'resource_role': 'aggregator_knowledge_source',\n", + " 'upstream_resource_ids': ['infores:ctd']}],\n", + " 'qualifiers': [],\n", + " 'predicate': 'biolink:affects',\n", + " 'attributes': [{'attribute_type_id': 'biolink:xref',\n", + " 'value': ['http://ctdbase.org/detail.go?type=relationship&ixnId=4118485',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=3478223',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=8453602',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=2683440',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=7638084',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=2746570',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=3269154',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=6583144',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=2763529',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=2691105',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=2749488',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=4935193',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=2763531',\n", + " 'http://ctdbase.org/detail.go?type=relationship&ixnId=8453590'],\n", + " 'original_attribute_name': 'xref'},\n", + " {'attribute_type_id': 'biolink:knowledge_level',\n", + " 'value': 'knowledge_assertion',\n", + " 'original_attribute_name': 'knowledge_level'},\n", + " {'attribute_type_id': 'biolink:agent_type',\n", + " 'value': 'manual_agent',\n", + " 'original_attribute_name': 'agent_type'},\n", + " {'attribute_type_id': 'biolink:original_object',\n", + " 'value': 'NCBIGene:7124',\n", + " 'original_attribute_name': 'original_object'},\n", + " {'attribute_type_id': 'biolink:original_subject',\n", + " 'value': 'NCBIGene:3458',\n", + " 'original_attribute_name': 'original_subject'}],\n", + " 'subject': 'NCBIGene:3458',\n", + " 'object': 'NCBIGene:7124'}" ] }, "execution_count": 6, @@ -348,14 +220,83 @@ } ], "source": [ - "formatted_output.keys()" + "list(formatted_output['knowledge_graph']['edges'].values())[0]" ] }, { "cell_type": "code", "execution_count": 7, - "id": "9847dbb5-0d63-496b-8969-4dd330f3897c", + "id": "c2ac8ad6-218f-4805-8c72-8cf21df4ac7c", "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['19a467d8',\n", + " 'e_222',\n", + " '6ab7f02f',\n", + " '82968adc',\n", + " '978f6ce1',\n", + " '3571016d',\n", + " '119d5072',\n", + " '73f57667f20d4136d56ce1c56180ed4d',\n", + " '64df3ca7c1bb4570261ba9a485ab6ea2',\n", + " '5866d665014fe74cbd4e9d8b5744d6d0',\n", + " '9983f5c2918b0090337d2d597305d8c2',\n", + " 'd15478a27e98d66ab143989bd157dce5',\n", + " '946805402aa3b12a8a80e5c8ef4833cd',\n", + " 'a846d99d439b616b0e14a474f8254349',\n", + " '710009b429dc63bbd2c32329e1df16ec',\n", + " 'b5c61c0cce4e6273234ff58e111c06a2',\n", + " '26c765858975b8618f2184804a19ba05',\n", + " '3f01ede548609170f5828b6ffaf7d972',\n", + " 'e82906ca6f38a7ead24a067a3e435b38',\n", + " '0169afa0ab05defb81aafa9fce39e242',\n", + " '58d466d9f807a877150013e0691a25fc',\n", + " 'b21949aec9d249b6da58d3c67c8df73e',\n", + " 'd1e2ef5eec04efbc499889be6ce1eea7',\n", + " '4e5d8e79b1308e3ae15fb55298536387',\n", + " 'bf585df1c25702eb7449d34671891147',\n", + " '60975f91744b9f127a59a6322c2f7cb7',\n", + " '665990a36b9cba77e5e6d6645b19bbc3',\n", + " '78e8ccbbb83c35759418c71decafc356',\n", + " '109a1f3bfa18c2975ea82a36c31255e8',\n", + " '3c660b48a0849cc783ad03cbfded02ab',\n", + " '3f0b12128de418c82724fefb0452b2eb',\n", + " '3a5203d87d6f9e6f584b9843155aac05',\n", + " '28d7f20f51ddf666407ab90ae87bc55b',\n", + " 'e02741c698e72353f95c4a529ba01438',\n", + " 'f35a81cd97153cce97d982d7710b558c',\n", + " '712ff9a3be50edc0901d3e02757589f2',\n", + " 'fbe597bca092f6478afb3d2f8f31ee86',\n", + " '34d8d05a6d2bdd0541f72690b8f2f6e9',\n", + " 'd6f6af8c653dd95f918f99e15b4c0b0a',\n", + " '84e026bbdab961e56f2bdf6f30f9486b',\n", + " 'bb54be6d72593ab41809f3c7294a31a7',\n", + " '7b393fa1d78193a0e6e05fd1b67f6352',\n", + " '10e45932c3590ec64fd0dce9f7f69468',\n", + " '86de16e01a16264dcae011be9ba31b2e',\n", + " 'e97a340841d8f91890e6d10fb8def2d1',\n", + " '45319800',\n", + " '8155745']" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list(formatted_output['auxiliary_graphs'].values())[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "e63554d9-5d04-4636-8c37-3e7aaf2ab641", + "metadata": { + "scrolled": true + }, "outputs": [ { "data": { @@ -407,43 +348,13 @@ " 'subject': 'UMLS:C0017337'}" ] }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "list(formatted_output['knowledge_graph']['edges'].values())[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "c2ac8ad6-218f-4805-8c72-8cf21df4ac7c", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['12026540',\n", - " '13008760',\n", - " '13008998',\n", - " '1451206',\n", - " '25948818',\n", - " '12006224',\n", - " '12009572',\n", - " '12011840',\n", - " '12014211',\n", - " '12034620']" - ] - }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "list(formatted_output['auxiliary_graphs'].values())[0]" + "formatted_output['knowledge_graph']['edges']['12026540']" ] }, { @@ -498,7 +409,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "id": "8540fc14-dd13-444f-b9d9-afae72b31b49", "metadata": {}, "outputs": [ @@ -506,14 +417,14 @@ "data": { "text/plain": [ "{'attributes': None,\n", - " 'path_bindings': {'p0': [{'id': 'aux_1_UMLS:C0017337'}]},\n", + " 'path_bindings': {'p0': [{'id': 'aux_1_NCBIGene:7124'}]},\n", " 'resource_id': 'infores:tct',\n", - " 'score': 0.14285714285714285,\n", + " 'score': 0.7391304347826086,\n", " 'scoring_method': None,\n", " 'support_graphs': None}" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -524,9 +435,107 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "id": "a6ba8e09-c1aa-4010-86cf-722bc9c27058", "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'attributes': [{'attribute_source': 'infores:catrax-pharmacogenomics',\n", + " 'attribute_type_id': 'biolink:publications',\n", + " 'value': 'PMID:36243968|PMID:9397972',\n", + " 'value_type_id': 'biolink:Uriorcurie'},\n", + " {'attribute_type_id': 'knowledge_source', 'value': 'SIGNOR-267487'},\n", + " {'attribute_type_id': 'subject_category', 'value': 'biolink:Gene'},\n", + " {'attribute_source': 'infores:catrax-pharmacogenomics',\n", + " 'attribute_type_id': 'biolink:knowledge_level',\n", + " 'value': 'knowledge_assertion'},\n", + " {'attribute_type_id': 'object_name', 'value': 'DIO1'},\n", + " {'attribute_type_id': 'subject_name', 'value': 'IFNG'},\n", + " {'attribute_source': 'infores:catrax-pharmacogenomics',\n", + " 'attribute_type_id': 'biolink:agent_type',\n", + " 'value': 'automated_agent'},\n", + " {'attribute_type_id': 'object_category', 'value': 'biolink:Gene'},\n", + " {'attribute_type_id': 'provided_by', 'value': 'SIGNOR'}],\n", + " 'object': 'NCBIGene:1733',\n", + " 'predicate': 'biolink:regulates',\n", + " 'qualifiers': [{'qualifier_type_id': 'biolink:object_direction_qualifier',\n", + " 'qualifier_value': 'downregulated'}],\n", + " 'sources': [{'resource_id': 'infores:catrax-pharmacogenomics',\n", + " 'resource_role': 'primary_knowledge_source'},\n", + " {'resource_id': 'N/A', 'resource_role': 'supporting_data_source'}],\n", + " 'subject': 'NCBIGene:3458'}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result1['01a09566-2a29-5eae-9160-e44a18241c09']" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "baa9a580-c3e8-4b27-834f-d7c5c1c297d8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6822" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(result1)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "ad5eaf3e-205d-43cb-8c53-d14b489ba5a5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2658" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(result2)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "51fe55e0-5871-4714-ae46-8fe0647a6c99", + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "with open('result.json', 'w') as f:\n", + " json.dump(formatted_output, f)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f6460b38-8bab-4247-b693-ef90c5a4e3d7", + "metadata": {}, "outputs": [], "source": [] } From 384c56a3e8ae39edafcbd2161f8cf8908a4c25fa Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 30 Apr 2026 18:37:43 -0700 Subject: [PATCH 04/33] start on neighborhood finder --- TCT/neighborhood_finder.py | 324 +++++++++++++++++++++++++++++++++++++ 1 file changed, 324 insertions(+) create mode 100644 TCT/neighborhood_finder.py diff --git a/TCT/neighborhood_finder.py b/TCT/neighborhood_finder.py new file mode 100644 index 0000000..5310794 --- /dev/null +++ b/TCT/neighborhood_finder.py @@ -0,0 +1,324 @@ + + +def format_query_json_for_pathfinder(subject_ids, object_ids=None, + subject_categories=None, + object_categories=None, + predicates=None): + ''' + Example input: + subject_ids = ["NCBIGene:3845"] + object_ids = [] + subject_categories = ["biolink:Gene"] + object_categories = ["biolink:Gene"] + predicates = ["biolink:positively_correlated_with", "biolink:physically_interacts_with"] + ''' + query_json_temp = { + "message": { + "query_graph": { + + "edges": { + "e00": { + "subject": "n00", + "object": "n01", + "predicates": predicates + } + }, + "nodes": { + "n00": { + "ids":subject_ids, # required + #"categories":[] # optional, if not provided, it will be empty + }, + "n01": { + #"ids":[], + "categories":[] # required + } + } + } + } + } + + if len(subject_ids) > 0: + query_json_temp["message"]["query_graph"]["nodes"]["n00"]["ids"] = subject_ids + + if object_ids is not None and len(object_ids) > 0: + query_json_temp["message"]["query_graph"]["nodes"]["n01"]["ids"] = object_ids + + if subject_categories is not None and len(subject_categories) > 0: + query_json_temp["message"]["query_graph"]["nodes"]["n00"]["categories"] = subject_categories + + if object_categories is not None and len(object_categories) > 0: + query_json_temp["message"]["query_graph"]["nodes"]["n01"]["categories"] = object_categories + + if predicates is not None and len(predicates) > 0: + query_json_temp["message"]["query_graph"]["edges"]["e00"]["predicates"] = predicates + + return query_json_temp + + +def build_query_graph(start_node_id, end_node_id, start_node_categories=None, end_node_categories=None): + """ + start_node_categories and end_node_categories are lists of categories. + """ + q = { + "nodes": { + "on": { + "categories": end_node_categories, + "constraints": [], + "ids": [ + end_node_id + ], + "is_set": False, + "option_group_id": None, + "set_id": None, + "set_interpretation": "BATCH" + }, + "sn": { + "categories": start_node_categories, + "constraints": [], + "ids": [ + start_node_id + ], + "is_set": False, + "option_group_id": None, + "set_id": None, + "set_interpretation": "BATCH" + } + }, + "paths": { + "p0": { + "constraints": None, + "object": "on", + "predicates": None, + "subject": "sn" + } + } + } + return q + + +def generate_score_results(results, method='infores'): + """ + Generates a score dict, and a list of "analyses". + method can be 'infores' or 'edges' + """ + graph_scores = {} + max_score = 0 + auxiliary_graphs = results['auxiliary_graphs'] + for k, graph in auxiliary_graphs.items(): + if method == 'infores': + sources = set() + for edge_index in graph: + edge = results['knowledge_graph']['edges'][edge_index] + for resource in edge['sources']: + sources.add(resource['resource_id']) + score = len(sources) + if score > max_score: + max_score = score + else: + score = len(graph) + if score > max_score: + max_score = score + graph_scores[k] = score + graph_scores_formatted = [] + for k in graph_scores.keys(): + graph_scores[k] = graph_scores[k]/max_score + graph_scores_formatted.append({ + 'attributes': None, + 'path_bindings': { + 'p0': [{'id': k}]}, + 'resource_id': 'infores:tct', + 'score': graph_scores[k], + 'scoring_method': None, + 'support_graphs': None + }) + return graph_scores, graph_scores_formatted + + +def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dict, result2:dict, + start_node_categories=None, end_node_categories=None, + get_node_info=True, + scoring_method='infores'): + """ + Converts the results of two TRAPI queries into the same general json format as the other pathfinder APIs. + scoring_method is how the node scores are generated, and could be 'infores' or 'edges'. + """ + # nodes + # TODO: get some node info? node attributes + node_info = {} + # edges is a dict of intermediate nodes + intermediate_node_edges = {} + for k, v in result1.items(): + i1 = v['subject'] + i2 = v['object'] + s_o = 'object' + if i1 == start_node_id: + intermediate_node_id = i2 + s_o = 'object' + elif i2 == start_node_id: + intermediate_node_id = i1 + s_o = 'subject' + else: + continue + if (i1 == start_node_id or i2 == start_node_id) and intermediate_node_id in intermediate_node_edges: + intermediate_node_edges[intermediate_node_id].append((k, v)) + else: + intermediate_node_edges[intermediate_node_id] = [(k, v)] + # add node dict + if intermediate_node_id not in node_info: + node_dict = { + } + node_info[intermediate_node_id] = node_dict + else: + node_dict = node_info[intermediate_node_id] + for attribute in v['attributes']: + if attribute['attribute_type_id'] == f'{s_o}_category': + if 'categories' not in node_dict: + node_dict['categories'] = set([attribute['value']]) + else: + node_dict['categories'].add(attribute['value']) + if attribute['attribute_type_id'] == f'{s_o}_name' and 'name' not in node_dict: + node_dict['name'] = attribute['value'] + node_info[intermediate_node_id] = node_dict + connecting_intermediate_nodes = {} + for k, v in result2.items(): + i1 = v['subject'] + i2 = v['object'] + if i1 == end_node_id: + intermediate_node_id = i2 + s_o = 'object' + elif i2 == end_node_id: + intermediate_node_id = i1 + s_o = 'subject' + else: + continue + if (i1 == end_node_id or i2 == end_node_id) and intermediate_node_id in intermediate_node_edges: + if intermediate_node_id in connecting_intermediate_nodes: + connecting_intermediate_nodes[intermediate_node_id]['e2'].append((k, v)) + else: + connecting_intermediate_nodes[intermediate_node_id] = {'e1': intermediate_node_edges[intermediate_node_id], 'e2' : [(k, v)]} + if intermediate_node_id not in node_info: + node_dict = { + } + node_info[intermediate_node_id] = node_dict + else: + node_dict = node_info[intermediate_node_id] + for attribute in v['attributes']: + if attribute['attribute_type_id'] == f'{s_o}_category': + if 'categories' not in node_dict: + node_dict['categories'] = set([attribute['value']]) + else: + node_dict['categories'].add(attribute['value']) + if attribute['attribute_type_id'] == f'{s_o}_name' and 'name' not in node_dict: + node_dict['name'] = attribute['value'] + node_info[intermediate_node_id] = node_dict + for k, v in node_info.items(): + if 'categories' in v: + v['categories'] = list(v['categories']) + all_edges = {} + all_auxiliary_graphs = {} + i = 1 + # sort connecting_intermediate_nodes by total number of connections + connection_counts = Counter({k: len(v['e1'])*len(v['e2']) for k, v in connecting_intermediate_nodes.items()}) + for i1, count in connection_counts.most_common(): + kv = connecting_intermediate_nodes[i1] + e1s = kv['e1'] + e2s = kv['e2'] + edges = {k: v for k, v in e1s} + edges.update({k: v for k, v in e2s}) + all_edges.update(edges) + keys = [x[0] for x in e1s] + [x[0] for x in e2s] + all_auxiliary_graphs[f'aux_{i}_{i1}'] = keys + i += 1 + # generate output json + output = { + 'query_graph': build_query_graph(start_node_id, end_node_id, start_node_categories, end_node_categories), + # TODO: don't drop the nodes + 'knowledge_graph': {'nodes': {x: node_info[x] for x in connection_counts.keys()}, + 'edges': all_edges, + }, + 'results': [{'analyses': []}], + 'auxiliary_graphs': all_auxiliary_graphs + } + graph_scores, graph_scores_formatted = generate_score_results(output, method=scoring_method) + output['results'][0]['analyses'] = graph_scores_formatted + if get_node_info: + from .node_normalizer import get_normalized_nodes + nodes_to_add = [] + for k, v in output['knowledge_graph']['nodes'].items(): + if 'name' not in v or 'categories' not in v: + nodes_to_add.append(k) + normalized_nodes = get_normalized_nodes(nodes_to_add, mode='post') + for node_id in nodes_to_add: + nn = normalized_nodes[node_id] + output['knowledge_graph']['nodes'][node_id] = {'name': nn.label, 'categories': nn.types} + return output + +def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_predicates, input_node_category = []): + """ + This function is used to find the neighborhood of a given input node with intermediate categories. + + -------------- + Parameters: + input_node (str): The input node - should be a CURIE id. + node2_categories (list): A list of intermediate categories to be used in the neighborhood finding process. + APInames (dict): A dictionary containing the names of the APIs to be used. + metaKG (DataFrame): The metadata knowledge graph containing information about the APIs and their predicates. + API_predicates (dict): A dictionary containing the predicates for each API. + input_node_category (list): Optional. A list of categories for the input node. If empty, it will be derived from the input node's types. + + -------------- + Returns: + input_node_id (str): The curie id of the input node. + result (dict): The result of the query for the input node. + result_parsed (DataFrame): The parsed results for the input node. + result_ranked_by_primary_infores (DataFrame): The ranked results based on primary infores. + + -------------- + Example: + >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = Neighborhood_finder('MONDO:0008170', #Ovarian Cancer + node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], + APInames = APInames, + metaKG = metaKG, + API_predicates = API_predicates) + -------------- + + """ + from . import node_normalizer + from . import translator_query + + input_node_id = input_node + # Step 1: Resolve the input node to get its curie id and categories + input_node_info = node_normalizer.get_normalized_nodes(input_node_id) + print(input_node_id) + + if len(input_node_category) == 0: + input_node_category = input_node_info.types + else: + input_node_category = list(set(input_node_category).intersection(set(input_node_info.types))) + if len(input_node_category) == 0: + input_node_category = input_node_info.types + + # Step 2: Select predicates and APIs based on the intermediate categories + sele_predicates, sele_APIs, API_URLs = sele_predicates_API(input_node_category, + node2_categories, + metaKG, APInames) + + # Step 3: Format the query JSON for the input node + query_json = format_query_json([input_node_id], [], + [input_node_category], + node2_categories, + sele_predicates) + + # Step 4: Query the APIs in parallel + result = translator_query.parallel_api_query(query_json=query_json, + select_APIs= sele_APIs, + APInames=APInames, + API_predicates=API_predicates, + max_workers=len(sele_APIs)) + result_parsed = parse_KG(result) + # Step 7: Ranking the results. This ranking method is based on the number of unique + # primary infores. It can only be used to rank the results with one defined node. + result_ranked_by_primary_infores1 = rank_by_primary_infores(result_parsed, input_node_id) # input_node1_id is the curie id of the + return input_node_id, result, result_parsed, result_ranked_by_primary_infores1 + + From d712fe3c1bce366c2c58a66db0ca214417fb31a7 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 30 Apr 2026 19:47:10 -0700 Subject: [PATCH 05/33] neighborhood finder - new output type --- TCT/neighborhood_finder.py | 72 +++++++++++--------------------------- 1 file changed, 20 insertions(+), 52 deletions(-) diff --git a/TCT/neighborhood_finder.py b/TCT/neighborhood_finder.py index 5310794..03ca8c9 100644 --- a/TCT/neighborhood_finder.py +++ b/TCT/neighborhood_finder.py @@ -1,6 +1,9 @@ +from collections import Counter +from .TCT import sele_predicates_API, format_query_json, parse_KG, rank_by_primary_infores -def format_query_json_for_pathfinder(subject_ids, object_ids=None, + +def format_query_json_for_neighborhood_finder(subject_ids, object_ids=None, subject_categories=None, object_categories=None, predicates=None): @@ -134,7 +137,7 @@ def generate_score_results(results, method='infores'): return graph_scores, graph_scores_formatted -def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dict, result2:dict, +def parse_results_for_neighborhood_finder(start_node_id:str, results:dict, start_node_categories=None, end_node_categories=None, get_node_info=True, scoring_method='infores'): @@ -143,11 +146,10 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic scoring_method is how the node scores are generated, and could be 'infores' or 'edges'. """ # nodes - # TODO: get some node info? node attributes node_info = {} # edges is a dict of intermediate nodes - intermediate_node_edges = {} - for k, v in result1.items(): + node_edges = {} + for k, v in results.items(): i1 = v['subject'] i2 = v['object'] s_o = 'object' @@ -159,10 +161,10 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic s_o = 'subject' else: continue - if (i1 == start_node_id or i2 == start_node_id) and intermediate_node_id in intermediate_node_edges: - intermediate_node_edges[intermediate_node_id].append((k, v)) + if (i1 == start_node_id or i2 == start_node_id) and intermediate_node_id in node_edges: + node_edges[intermediate_node_id].append((k, v)) else: - intermediate_node_edges[intermediate_node_id] = [(k, v)] + node_edges[intermediate_node_id] = [(k, v)] # add node dict if intermediate_node_id not in node_info: node_dict = { @@ -179,38 +181,6 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic if attribute['attribute_type_id'] == f'{s_o}_name' and 'name' not in node_dict: node_dict['name'] = attribute['value'] node_info[intermediate_node_id] = node_dict - connecting_intermediate_nodes = {} - for k, v in result2.items(): - i1 = v['subject'] - i2 = v['object'] - if i1 == end_node_id: - intermediate_node_id = i2 - s_o = 'object' - elif i2 == end_node_id: - intermediate_node_id = i1 - s_o = 'subject' - else: - continue - if (i1 == end_node_id or i2 == end_node_id) and intermediate_node_id in intermediate_node_edges: - if intermediate_node_id in connecting_intermediate_nodes: - connecting_intermediate_nodes[intermediate_node_id]['e2'].append((k, v)) - else: - connecting_intermediate_nodes[intermediate_node_id] = {'e1': intermediate_node_edges[intermediate_node_id], 'e2' : [(k, v)]} - if intermediate_node_id not in node_info: - node_dict = { - } - node_info[intermediate_node_id] = node_dict - else: - node_dict = node_info[intermediate_node_id] - for attribute in v['attributes']: - if attribute['attribute_type_id'] == f'{s_o}_category': - if 'categories' not in node_dict: - node_dict['categories'] = set([attribute['value']]) - else: - node_dict['categories'].add(attribute['value']) - if attribute['attribute_type_id'] == f'{s_o}_name' and 'name' not in node_dict: - node_dict['name'] = attribute['value'] - node_info[intermediate_node_id] = node_dict for k, v in node_info.items(): if 'categories' in v: v['categories'] = list(v['categories']) @@ -218,21 +188,16 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic all_auxiliary_graphs = {} i = 1 # sort connecting_intermediate_nodes by total number of connections - connection_counts = Counter({k: len(v['e1'])*len(v['e2']) for k, v in connecting_intermediate_nodes.items()}) + connection_counts = Counter({k: len(v) for k, v in node_edges.items()}) for i1, count in connection_counts.most_common(): - kv = connecting_intermediate_nodes[i1] - e1s = kv['e1'] - e2s = kv['e2'] - edges = {k: v for k, v in e1s} - edges.update({k: v for k, v in e2s}) - all_edges.update(edges) - keys = [x[0] for x in e1s] + [x[0] for x in e2s] + edges = node_edges[i1] + all_edges.update({k: v for k, v in edges}) + keys = [x[0] for x in edges] all_auxiliary_graphs[f'aux_{i}_{i1}'] = keys i += 1 # generate output json output = { - 'query_graph': build_query_graph(start_node_id, end_node_id, start_node_categories, end_node_categories), - # TODO: don't drop the nodes + 'query_graph': build_query_graph(start_node_id, '', start_node_categories, end_node_categories), 'knowledge_graph': {'nodes': {x: node_info[x] for x in connection_counts.keys()}, 'edges': all_edges, }, @@ -250,9 +215,11 @@ def parse_results_for_pathfinder(start_node_id:str, end_node_id:str, result1:dic normalized_nodes = get_normalized_nodes(nodes_to_add, mode='post') for node_id in nodes_to_add: nn = normalized_nodes[node_id] - output['knowledge_graph']['nodes'][node_id] = {'name': nn.label, 'categories': nn.types} + if nn is not None: + output['knowledge_graph']['nodes'][node_id] = {'name': nn.label, 'categories': nn.types} return output + def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_predicates, input_node_category = []): """ This function is used to find the neighborhood of a given input node with intermediate categories. @@ -319,6 +286,7 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred # Step 7: Ranking the results. This ranking method is based on the number of unique # primary infores. It can only be used to rank the results with one defined node. result_ranked_by_primary_infores1 = rank_by_primary_infores(result_parsed, input_node_id) # input_node1_id is the curie id of the - return input_node_id, result, result_parsed, result_ranked_by_primary_infores1 + parsed_results = parse_results_for_neighborhood_finder(input_node_id, result, input_node_category, node2_categories) + return input_node_id, result, parsed_results, result_ranked_by_primary_infores1 From 3b097a9a7a1dd1f3cf9ae3ae9f64b99fa04ae7d5 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 30 Apr 2026 19:48:24 -0700 Subject: [PATCH 06/33] removed extraneous function --- TCT/neighborhood_finder.py | 55 -------------------------------------- 1 file changed, 55 deletions(-) diff --git a/TCT/neighborhood_finder.py b/TCT/neighborhood_finder.py index 03ca8c9..41f822a 100644 --- a/TCT/neighborhood_finder.py +++ b/TCT/neighborhood_finder.py @@ -3,61 +3,6 @@ from .TCT import sele_predicates_API, format_query_json, parse_KG, rank_by_primary_infores -def format_query_json_for_neighborhood_finder(subject_ids, object_ids=None, - subject_categories=None, - object_categories=None, - predicates=None): - ''' - Example input: - subject_ids = ["NCBIGene:3845"] - object_ids = [] - subject_categories = ["biolink:Gene"] - object_categories = ["biolink:Gene"] - predicates = ["biolink:positively_correlated_with", "biolink:physically_interacts_with"] - ''' - query_json_temp = { - "message": { - "query_graph": { - - "edges": { - "e00": { - "subject": "n00", - "object": "n01", - "predicates": predicates - } - }, - "nodes": { - "n00": { - "ids":subject_ids, # required - #"categories":[] # optional, if not provided, it will be empty - }, - "n01": { - #"ids":[], - "categories":[] # required - } - } - } - } - } - - if len(subject_ids) > 0: - query_json_temp["message"]["query_graph"]["nodes"]["n00"]["ids"] = subject_ids - - if object_ids is not None and len(object_ids) > 0: - query_json_temp["message"]["query_graph"]["nodes"]["n01"]["ids"] = object_ids - - if subject_categories is not None and len(subject_categories) > 0: - query_json_temp["message"]["query_graph"]["nodes"]["n00"]["categories"] = subject_categories - - if object_categories is not None and len(object_categories) > 0: - query_json_temp["message"]["query_graph"]["nodes"]["n01"]["categories"] = object_categories - - if predicates is not None and len(predicates) > 0: - query_json_temp["message"]["query_graph"]["edges"]["e00"]["predicates"] = predicates - - return query_json_temp - - def build_query_graph(start_node_id, end_node_id, start_node_categories=None, end_node_categories=None): """ start_node_categories and end_node_categories are lists of categories. From 2ffe87d7dc0bad03e84f08549197dc15560762ce Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 30 Apr 2026 19:49:36 -0700 Subject: [PATCH 07/33] consolidated some duplicate functions --- TCT/neighborhood_finder.py | 81 +------------------------------------- 1 file changed, 1 insertion(+), 80 deletions(-) diff --git a/TCT/neighborhood_finder.py b/TCT/neighborhood_finder.py index 41f822a..4c8018a 100644 --- a/TCT/neighborhood_finder.py +++ b/TCT/neighborhood_finder.py @@ -1,86 +1,7 @@ from collections import Counter from .TCT import sele_predicates_API, format_query_json, parse_KG, rank_by_primary_infores - - -def build_query_graph(start_node_id, end_node_id, start_node_categories=None, end_node_categories=None): - """ - start_node_categories and end_node_categories are lists of categories. - """ - q = { - "nodes": { - "on": { - "categories": end_node_categories, - "constraints": [], - "ids": [ - end_node_id - ], - "is_set": False, - "option_group_id": None, - "set_id": None, - "set_interpretation": "BATCH" - }, - "sn": { - "categories": start_node_categories, - "constraints": [], - "ids": [ - start_node_id - ], - "is_set": False, - "option_group_id": None, - "set_id": None, - "set_interpretation": "BATCH" - } - }, - "paths": { - "p0": { - "constraints": None, - "object": "on", - "predicates": None, - "subject": "sn" - } - } - } - return q - - -def generate_score_results(results, method='infores'): - """ - Generates a score dict, and a list of "analyses". - method can be 'infores' or 'edges' - """ - graph_scores = {} - max_score = 0 - auxiliary_graphs = results['auxiliary_graphs'] - for k, graph in auxiliary_graphs.items(): - if method == 'infores': - sources = set() - for edge_index in graph: - edge = results['knowledge_graph']['edges'][edge_index] - for resource in edge['sources']: - sources.add(resource['resource_id']) - score = len(sources) - if score > max_score: - max_score = score - else: - score = len(graph) - if score > max_score: - max_score = score - graph_scores[k] = score - graph_scores_formatted = [] - for k in graph_scores.keys(): - graph_scores[k] = graph_scores[k]/max_score - graph_scores_formatted.append({ - 'attributes': None, - 'path_bindings': { - 'p0': [{'id': k}]}, - 'resource_id': 'infores:tct', - 'score': graph_scores[k], - 'scoring_method': None, - 'support_graphs': None - }) - return graph_scores, graph_scores_formatted - +from .TCT_pathfinder import generate_score_results, build_query_graph def parse_results_for_neighborhood_finder(start_node_id:str, results:dict, start_node_categories=None, end_node_categories=None, From 2b8d4dd05fa7931f9c1f4e43926a2e4308b00760 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 7 May 2026 14:06:21 -0700 Subject: [PATCH 08/33] renamed file --- TCT/{neighborhood_finder.py => TCT_neighborhood_finder.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename TCT/{neighborhood_finder.py => TCT_neighborhood_finder.py} (100%) diff --git a/TCT/neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py similarity index 100% rename from TCT/neighborhood_finder.py rename to TCT/TCT_neighborhood_finder.py From 83261b079160641f6ac040a101cebe6eba8c31d6 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Mon, 18 May 2026 11:53:51 -0700 Subject: [PATCH 09/33] add attribute constraints to translator_query.build_query_json --- TCT/TCT_neighborhood_finder.py | 3 +- TCT/TCT_pathfinder.py | 60 ++---------------------- TCT/translator_query.py | 84 ++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 58 deletions(-) diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index 4c8018a..068a56d 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -1,7 +1,8 @@ from collections import Counter -from .TCT import sele_predicates_API, format_query_json, parse_KG, rank_by_primary_infores +from .TCT import sele_predicates_API, parse_KG, rank_by_primary_infores from .TCT_pathfinder import generate_score_results, build_query_graph +from .translator_query import format_query_json def parse_results_for_neighborhood_finder(start_node_id:str, results:dict, start_node_categories=None, end_node_categories=None, diff --git a/TCT/TCT_pathfinder.py b/TCT/TCT_pathfinder.py index 435a125..1378e91 100644 --- a/TCT/TCT_pathfinder.py +++ b/TCT/TCT_pathfinder.py @@ -5,61 +5,7 @@ from . import node_normalizer from . import translator_query -from .TCT import sele_predicates_API, parse_KG, rank_by_primary_infores, merge_ranking_by_number_of_infores - -def format_query_json_for_pathfinder(subject_ids, object_ids=None, - subject_categories=None, - object_categories=None, - predicates=None): - ''' - Example input: - subject_ids = ["NCBIGene:3845"] - object_ids = [] - subject_categories = ["biolink:Gene"] - object_categories = ["biolink:Gene"] - predicates = ["biolink:positively_correlated_with", "biolink:physically_interacts_with"] - ''' - query_json_temp = { - "message": { - "query_graph": { - - "edges": { - "e00": { - "subject": "n00", - "object": "n01", - "predicates": predicates - } - }, - "nodes": { - "n00": { - "ids":subject_ids, # required - #"categories":[] # optional, if not provided, it will be empty - }, - "n01": { - #"ids":[], - "categories":[] # required - } - } - } - } - } - - if len(subject_ids) > 0: - query_json_temp["message"]["query_graph"]["nodes"]["n00"]["ids"] = subject_ids - - if object_ids is not None and len(object_ids) > 0: - query_json_temp["message"]["query_graph"]["nodes"]["n01"]["ids"] = object_ids - - if subject_categories is not None and len(subject_categories) > 0: - query_json_temp["message"]["query_graph"]["nodes"]["n00"]["categories"] = subject_categories - - if object_categories is not None and len(object_categories) > 0: - query_json_temp["message"]["query_graph"]["nodes"]["n01"]["categories"] = object_categories - - if predicates is not None and len(predicates) > 0: - query_json_temp["message"]["query_graph"]["edges"]["e00"]["predicates"] = predicates - - return query_json_temp +from .TCT import sele_predicates_API def build_query_graph(start_node_id, end_node_id, start_node_categories=None, end_node_categories=None): @@ -286,14 +232,14 @@ def pathfinder(input_node1_id:str, input_node2_id:str, sele_predicates2, sele_APIs2, API_URLs2 = sele_predicates_API(intermediate_categories, input_node2_category, metaKG, APInames) - query_json1 = format_query_json_for_pathfinder(input_node1_list, # a list of identifiers for input node1 + query_json1 = translator_query.format_query_json(input_node1_list, # a list of identifiers for input node1 [], # id list for the intermediate node, it can be empty list if only want to query node1 input_node1_category, # a list of categories of input node1 intermediate_categories, # a list of categories of the intermediate node sele_predicates1) # a list of predicates # for the second hop, we want the predicates to be... - query_json2 = format_query_json_for_pathfinder([], + query_json2 = translator_query.format_query_json([], input_node2_list, intermediate_categories, # a list of categories of input node2 input_node2_category, # a list of categories of the intermediate node diff --git a/TCT/translator_query.py b/TCT/translator_query.py index 870b153..9baaac8 100644 --- a/TCT/translator_query.py +++ b/TCT/translator_query.py @@ -43,6 +43,90 @@ def get_translator_API_predicates() -> tuple[dict, pandas.DataFrame, dict]: return APInames, metaKG, API_predicates + +def build_attribute_constraint(attribute_id, operator, value, name=None, is_not=False): + """ + This creates an attribute constraint for a TRAPI query dict. + """ + if name is None: + name = '' + output = { + 'id': attribute_id, + 'operator': operator, + 'value': value, + 'name': name + } + if is_not: + output['not'] = True + return output + + +def format_query_json(subject_ids:list[str], + object_ids:list[str]|None = None, + subject_categories:list[str]|None = None, + object_categories:list[str]|None = None, + predicates:list[str]|None = None, + attribute_constraints:list[dict]|None = None, + ) -> dict: + ''' + Formats a query dict, with optional constraints. + + Example input: + subject_ids = ["NCBIGene:3845"] + object_ids = [] + subject_categories = ["biolink:Gene"] + object_categories = ["biolink:Gene"] + predicates = ["biolink:positively_correlated_with", "biolink:physically_interacts_with"] + attribute_constraints = [build_attribute_constraint('biolink:has_total', '>', 2)] + ''' + #edited Dec 5, 2023 + query_json_temp = { + "message": { + "query_graph": { + + "edges": { + "e00": { + #"e1": { + "subject": "n01", + "object": "n00", + "predicates": predicates + } + }, + "nodes": { + "n00": { + "ids":subject_ids, # required + #"categories":[] # optional, if not provided, it will be empty + }, + "n01": { + #"ids":[], + "categories":[] # required + }} + } + } + } + + if attribute_constraints is not None and len(attribute_constraints) > 0: + query_json_temp['message']['query_graph']['edges']['attribute_constraints'] = attribute_constraints + + if subject_ids is not None and len(subject_ids) > 0: + query_json_temp["message"]["query_graph"]["nodes"]["n00"]["ids"] = subject_ids + + if object_ids is not None and len(object_ids) > 0: + query_json_temp["message"]["query_graph"]["nodes"]["n01"]["ids"] = object_ids + + if subject_categories is not None and len(subject_categories) > 0: + query_json_temp["message"]["query_graph"]["nodes"]["n01"]["categories"] = subject_categories + + if object_categories is not None and len(object_categories) > 0: + query_json_temp["message"]["query_graph"]["nodes"]["n01"]["categories"] = object_categories + + if predicates is not None and len(predicates) > 0: + query_json_temp["message"]["query_graph"]["edges"]["e00"]["predicates"] = predicates + + return query_json_temp + + + def optimize_query_json(query_json, API_name_cur, API_predicates): ''' Optimize the query JSON by removing predicates that are not supported by the selected APIs. From f135e792515d5dd2328e9a86eccc03316582d692 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Wed, 20 May 2026 19:10:06 -0700 Subject: [PATCH 10/33] testing queries with constraints --- TCT/TCT_neighborhood_finder.py | 3 +- notebooks/queries_with_constraints.ipynb | 55 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 notebooks/queries_with_constraints.ipynb diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index 068a56d..57f36dd 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -87,7 +87,8 @@ def parse_results_for_neighborhood_finder(start_node_id:str, results:dict, return output -def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_predicates, input_node_category = []): +def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_predicates, input_node_category = [], + attribute_constraints=None): """ This function is used to find the neighborhood of a given input node with intermediate categories. diff --git a/notebooks/queries_with_constraints.ipynb b/notebooks/queries_with_constraints.ipynb new file mode 100644 index 0000000..8eab9fb --- /dev/null +++ b/notebooks/queries_with_constraints.ipynb @@ -0,0 +1,55 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "288c8700-efa9-4df6-a464-fe1d6e3cad6a", + "metadata": {}, + "source": [ + "# Queries with constraints\n", + "\n", + "Trying queries with constraints...\n", + "\n", + "2026-05-20" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "21f7674f-6215-41b7-8234-16e6b8b73178", + "metadata": {}, + "outputs": [], + "source": [ + "from TCT import name_resolver, TCT_neighborhood_finder, TCT_pathfinder" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9d8cea40-e383-4892-afdb-1004d5116f66", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From f1de54a77304b43e1fc13f9a241cda16165ffb14 Mon Sep 17 00:00:00 2001 From: Yue Zhang Date: Fri, 22 May 2026 05:24:54 -0700 Subject: [PATCH 11/33] notebook for queries with constraints --- notebooks/queries_with_constraints.ipynb | 79 +++++++++++++++++++++++- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/notebooks/queries_with_constraints.ipynb b/notebooks/queries_with_constraints.ipynb index 8eab9fb..90751f5 100644 --- a/notebooks/queries_with_constraints.ipynb +++ b/notebooks/queries_with_constraints.ipynb @@ -14,18 +14,91 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 7, "id": "21f7674f-6215-41b7-8234-16e6b8b73178", "metadata": {}, "outputs": [], "source": [ - "from TCT import name_resolver, TCT_neighborhood_finder, TCT_pathfinder" + "from TCT import translator_metakg, translator_query, name_resolver, TCT_neighborhood_finder, TCT_pathfinder" + ] + }, + { + "cell_type": "markdown", + "id": "9ba58579-189d-4576-936e-aa3c1349a15d", + "metadata": {}, + "source": [ + "## Neighborhood Finder with constraints" + ] + }, + { + "cell_type": "markdown", + "id": "4d5b8cf7-7749-4315-aaed-757293a37c5a", + "metadata": {}, + "source": [ + "### Get Meta-KGs" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "d486ba4c-e379-41bb-abd9-cdd361b649e4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Skipping server without x-maturity: {'url': '/sipr'}\n", + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n" + ] + } + ], + "source": [ + "APInames, metaKG, Translator_KP_info= translator_metakg.load_translator_resources()\n", + "\n", + "All_predicates = list(set(metaKG['Predicate']))\n", + "All_categories = list((set(list(set(metaKG['Subject']))+list(set(metaKG['Object'])))))\n", + "API_withMetaKG = list(set(metaKG['API']))\n", + "\n", + " # generate a dictionary of API and its predicates\n", + "API_predicates = {}\n", + "for api in API_withMetaKG:\n", + " API_predicates[api] = list(set(metaKG[metaKG['API'] == api]['Predicate']))" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "7aff9213-1d6d-42c8-90ac-c23444170f7c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(22568, 5)\n" + ] + } + ], + "source": [ + "# select a list of APIs to use and a list of predicates to use\n", + "selected_APIlist = []\n", + "\n", + "if len(selected_APIlist) == 0:\n", + " select_APIs = APInames\n", + "else:\n", + " select_APIs = {k: APInames[k] for k in selected_APIlist if k in APInames}\n", + "\n", + "selected_metaKG = metaKG[metaKG['API'].isin(select_APIs.keys())]\n", + "#print(select_APIs)\n", + "print(selected_metaKG.shape)\n" ] }, { "cell_type": "code", "execution_count": null, - "id": "9d8cea40-e383-4892-afdb-1004d5116f66", + "id": "7ca909ba-d667-4535-94e9-5a814d9326e5", "metadata": {}, "outputs": [], "source": [] From c188e400092df17b96d19d2a1cda8d16702c2d61 Mon Sep 17 00:00:00 2001 From: Yue Zhang Date: Fri, 22 May 2026 18:44:24 -0700 Subject: [PATCH 12/33] neighborhood finder with constraints --- TCT/TCT_neighborhood_finder.py | 8 +- notebooks/queries_with_constraints.ipynb | 155 ++++++++++++++++++++++- 2 files changed, 159 insertions(+), 4 deletions(-) diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index 57f36dd..2774eb5 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -87,7 +87,9 @@ def parse_results_for_neighborhood_finder(start_node_id:str, results:dict, return output -def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_predicates, input_node_category = [], +def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_predicates, + input_node_category = [], + predicates_subset=None, attribute_constraints=None): """ This function is used to find the neighborhood of a given input node with intermediate categories. @@ -139,8 +141,8 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred metaKG, APInames) # Step 3: Format the query JSON for the input node - query_json = format_query_json([input_node_id], [], - [input_node_category], + query_json = format_query_json([input_node_id], None, + None, node2_categories, sele_predicates) diff --git a/notebooks/queries_with_constraints.ipynb b/notebooks/queries_with_constraints.ipynb index 90751f5..e16713b 100644 --- a/notebooks/queries_with_constraints.ipynb +++ b/notebooks/queries_with_constraints.ipynb @@ -95,10 +95,163 @@ "print(selected_metaKG.shape)\n" ] }, + { + "cell_type": "markdown", + "id": "a85dec7c-f8ac-4125-90c7-abc575b3a0f7", + "metadata": {}, + "source": [ + "### Generating attribute constraints" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "b60ddba9-424e-4904-a46c-5c388df4a1ac", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m\n", + "\u001b[0mtranslator_query\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuild_attribute_constraint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mattribute_id\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0moperator\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mis_not\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDocstring:\u001b[0m This creates an attribute constraint for a TRAPI query dict.\n", + "\u001b[0;31mFile:\u001b[0m ~/isb/Translator_component_toolkit/TCT/translator_query.py\n", + "\u001b[0;31mType:\u001b[0m function" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "translator_query.build_attribute_constraint?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5814ee9c-3657-4483-b519-804f3dea0167", + "metadata": {}, + "outputs": [], + "source": [ + "c1 = translator_query.build_attribute_constraint" + ] + }, + { + "cell_type": "markdown", + "id": "fcc5ad84-bfc1-436a-8bf2-9a2b28d75848", + "metadata": {}, + "source": [ + "### Run neighborhood finder" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "91834806-bcc9-4149-a449-674abe511ea6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m\n", + "\u001b[0mTCT_neighborhood_finder\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mneighborhood_finder\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0minput_node\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mnode2_categories\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mAPInames\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mmetaKG\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mAPI_predicates\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0minput_node_category\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mattribute_constraints\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDocstring:\u001b[0m\n", + "This function is used to find the neighborhood of a given input node with intermediate categories.\n", + "\n", + "--------------\n", + "Parameters:\n", + "input_node (str): The input node - should be a CURIE id.\n", + "node2_categories (list): A list of intermediate categories to be used in the neighborhood finding process.\n", + "APInames (dict): A dictionary containing the names of the APIs to be used.\n", + "metaKG (DataFrame): The metadata knowledge graph containing information about the APIs and their predicates.\n", + "API_predicates (dict): A dictionary containing the predicates for each API.\n", + "input_node_category (list): Optional. A list of categories for the input node. If empty, it will be derived from the input node's types.\n", + "\n", + "--------------\n", + "Returns:\n", + "input_node_id (str): The curie id of the input node.\n", + "result (dict): The result of the query for the input node.\n", + "result_parsed (DataFrame): The parsed results for the input node.\n", + "result_ranked_by_primary_infores (DataFrame): The ranked results based on primary infores.\n", + "\n", + "--------------\n", + "Example:\n", + ">>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = Neighborhood_finder('MONDO:0008170', #Ovarian Cancer\n", + " node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'],\n", + " APInames = APInames,\n", + " metaKG = metaKG,\n", + " API_predicates = API_predicates)\n", + "--------------\n", + "\u001b[0;31mFile:\u001b[0m ~/isb/Translator_component_toolkit/TCT/TCT_neighborhood_finder.py\n", + "\u001b[0;31mType:\u001b[0m function" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "TCT_neighborhood_finder.neighborhood_finder?" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "1924ac50-b5b5-49d4-bbe8-ba378fb2e14c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "NCBIGene:3458\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", + "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0: Success!\n", + "Automat-cam-kp(Trapi v1.5.0): Success!\n", + "RTX KG2 - TRAPI 1.5.0: Success!\n", + "Automat-genome-alliance(Trapi v1.5.0): Success!\n", + "Automat-robokop(Trapi v1.5.0): Success!\n", + "Automat-hetionet(Trapi v1.5.0): Success!\n", + "Service Provider TRAPI: Success!\n", + "BioThings Explorer (BTE) TRAPI: Success!\n" + ] + } + ], + "source": [ + "input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = TCT_neighborhood_finder.neighborhood_finder(input_node='NCBIGene:3458', #IFNG\n", + " node2_categories=['biolink:Gene'],\n", + " APInames=APInames,\n", + " metaKG=metaKG,\n", + " API_predicates=API_predicates)" + ] + }, + { + "cell_type": "markdown", + "id": "0d6058a4-c257-478b-97e1-3cf0e67e2b2c", + "metadata": {}, + "source": [ + "## Queries with attribute constraints" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "7ca909ba-d667-4535-94e9-5a814d9326e5", + "id": "6ee85543-c5e9-4f93-a819-d7c68804d361", "metadata": {}, "outputs": [], "source": [] From cff04670374f57baff46e8a68d7082723306baad Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 28 May 2026 15:41:36 -0700 Subject: [PATCH 13/33] update docs to include neighborhood/pathfinder --- docs/source/index.rst | 2 ++ docs/source/neighborhood.rst | 4 ++-- docs/source/pathfinder.rst | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 99f6828..41ef254 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -19,6 +19,8 @@ Welcome to Translator Component Toolkit's documentation! translator_query translator_node TCT + neighborhood + pathfinder Indices and tables ================== diff --git a/docs/source/neighborhood.rst b/docs/source/neighborhood.rst index 81490c0..d8dae53 100644 --- a/docs/source/neighborhood.rst +++ b/docs/source/neighborhood.rst @@ -1,4 +1,4 @@ -TCT.neighborhood +TCT.TCT_neighborhood_finder ================= -.. automodule:: TCT.neighborhood +.. automodule:: TCT.TCT_neighborhood_finder :members: diff --git a/docs/source/pathfinder.rst b/docs/source/pathfinder.rst index ce413a5..6b70739 100644 --- a/docs/source/pathfinder.rst +++ b/docs/source/pathfinder.rst @@ -1,4 +1,4 @@ -TCT.pathfinder +TCT.TCT_pathfinder ================= -.. automodule:: TCT.pathfinder +.. automodule:: TCT.TCT_pathfinder :members: From 0c00041d19d69f641caa7da298f11d5e61e7c5eb Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 28 May 2026 15:45:02 -0700 Subject: [PATCH 14/33] notebook --- notebooks/queries_with_constraints.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notebooks/queries_with_constraints.ipynb b/notebooks/queries_with_constraints.ipynb index e16713b..52a577d 100644 --- a/notebooks/queries_with_constraints.ipynb +++ b/notebooks/queries_with_constraints.ipynb @@ -254,7 +254,9 @@ "id": "6ee85543-c5e9-4f93-a819-d7c68804d361", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "translator_query" + ] } ], "metadata": { From 4a87c870bb578347badd0edbd77343fb416b7836 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 28 May 2026 17:31:31 -0700 Subject: [PATCH 15/33] queries with constraints, updating docs --- TCT/TCT_neighborhood_finder.py | 43 ++++--- TCT/translator_query.py | 3 + notebooks/queries_with_constraints.ipynb | 138 ++++++++++++++++++++--- 3 files changed, 151 insertions(+), 33 deletions(-) diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index 2774eb5..3d9b673 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -94,25 +94,37 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred """ This function is used to find the neighborhood of a given input node with intermediate categories. - -------------- - Parameters: - input_node (str): The input node - should be a CURIE id. - node2_categories (list): A list of intermediate categories to be used in the neighborhood finding process. - APInames (dict): A dictionary containing the names of the APIs to be used. - metaKG (DataFrame): The metadata knowledge graph containing information about the APIs and their predicates. - API_predicates (dict): A dictionary containing the predicates for each API. - input_node_category (list): Optional. A list of categories for the input node. If empty, it will be derived from the input node's types. + Parameters + ---------- + input_node (str) + The input node - should be a CURIE id. + node2_categories (list) + A list of intermediate categories to be used in the neighborhood finding process. + APInames (dict) + A dictionary containing the names of the APIs to be used. + metaKG (DataFrame) + The metadata knowledge graph containing information about the APIs and their predicates. + API_predicates (dict) + A dictionary containing the predicates for each API. + input_node_category (list) + Optional. A list of categories for the input node. If empty, it will be derived from the input node's types. + attribute_constraints (list) + Optional. List of outputs of translator_query.build_attribute_constraint + Returns -------------- - Returns: - input_node_id (str): The curie id of the input node. - result (dict): The result of the query for the input node. - result_parsed (DataFrame): The parsed results for the input node. - result_ranked_by_primary_infores (DataFrame): The ranked results based on primary infores. + input_node_id (str) + The curie id of the input node. + result (dict) + The result of the query for the input node. + result_parsed (DataFrame) + The parsed results for the input node. + result_ranked_by_primary_infores (DataFrame) + The ranked results based on primary infores. -------------- Example: - >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = Neighborhood_finder('MONDO:0008170', #Ovarian Cancer + >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], APInames = APInames, metaKG = metaKG, @@ -144,7 +156,8 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred query_json = format_query_json([input_node_id], None, None, node2_categories, - sele_predicates) + sele_predicates, + attribute_constraints=attribute_constraints) # Step 4: Query the APIs in parallel result = translator_query.parallel_api_query(query_json=query_json, diff --git a/TCT/translator_query.py b/TCT/translator_query.py index 9baaac8..0337780 100644 --- a/TCT/translator_query.py +++ b/TCT/translator_query.py @@ -47,6 +47,9 @@ def get_translator_API_predicates() -> tuple[dict, pandas.DataFrame, dict]: def build_attribute_constraint(attribute_id, operator, value, name=None, is_not=False): """ This creates an attribute constraint for a TRAPI query dict. + + Example + ------- """ if name is None: name = '' diff --git a/notebooks/queries_with_constraints.ipynb b/notebooks/queries_with_constraints.ipynb index 52a577d..517b168 100644 --- a/notebooks/queries_with_constraints.ipynb +++ b/notebooks/queries_with_constraints.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 1, "id": "21f7674f-6215-41b7-8234-16e6b8b73178", "metadata": {}, "outputs": [], @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "id": "d486ba4c-e379-41bb-abd9-cdd361b649e4", "metadata": {}, "outputs": [ @@ -69,7 +69,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "id": "7aff9213-1d6d-42c8-90ac-c23444170f7c", "metadata": {}, "outputs": [ @@ -77,7 +77,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "(22568, 5)\n" + "(22528, 5)\n" ] } ], @@ -105,7 +105,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 4, "id": "b60ddba9-424e-4904-a46c-5c388df4a1ac", "metadata": {}, "outputs": [ @@ -121,8 +121,8 @@ "\u001b[0;34m\u001b[0m \u001b[0mis_not\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mDocstring:\u001b[0m This creates an attribute constraint for a TRAPI query dict.\n", - "\u001b[0;31mFile:\u001b[0m ~/isb/Translator_component_toolkit/TCT/translator_query.py\n", - "\u001b[0;31mType:\u001b[0m function" + "\u001b[0;31mFile:\u001b[0m ~/Translator_component_toolkit/TCT/translator_query.py\n", + "\u001b[0;31mType:\u001b[0m function\n" ] }, "metadata": {}, @@ -135,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "5814ee9c-3657-4483-b519-804f3dea0167", "metadata": {}, "outputs": [], @@ -153,7 +153,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 6, "id": "91834806-bcc9-4149-a449-674abe511ea6", "metadata": {}, "outputs": [ @@ -168,6 +168,7 @@ "\u001b[0;34m\u001b[0m \u001b[0mmetaKG\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mAPI_predicates\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0minput_node_category\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mpredicates_subset\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mattribute_constraints\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mDocstring:\u001b[0m\n", @@ -197,8 +198,8 @@ " metaKG = metaKG,\n", " API_predicates = API_predicates)\n", "--------------\n", - "\u001b[0;31mFile:\u001b[0m ~/isb/Translator_component_toolkit/TCT/TCT_neighborhood_finder.py\n", - "\u001b[0;31mType:\u001b[0m function" + "\u001b[0;31mFile:\u001b[0m ~/Translator_component_toolkit/TCT/TCT_neighborhood_finder.py\n", + "\u001b[0;31mType:\u001b[0m function\n" ] }, "metadata": {}, @@ -211,7 +212,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 7, "id": "1924ac50-b5b5-49d4-bbe8-ba378fb2e14c", "metadata": {}, "outputs": [ @@ -220,15 +221,17 @@ "output_type": "stream", "text": [ "NCBIGene:3458\n", - "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", + "Automat-robokop(Trapi v1.5.0): Success!\n", "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0: Success!\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", "Automat-cam-kp(Trapi v1.5.0): Success!\n", "RTX KG2 - TRAPI 1.5.0: Success!\n", "Automat-genome-alliance(Trapi v1.5.0): Success!\n", - "Automat-robokop(Trapi v1.5.0): Success!\n", "Automat-hetionet(Trapi v1.5.0): Success!\n", "Service Provider TRAPI: Success!\n", - "BioThings Explorer (BTE) TRAPI: Success!\n" + "BioThings Explorer (BTE) TRAPI: Success!\n", + "NCBIGene:3497: no preferred name\n", + "NodeNorm does not know about these identifiers: UniProtKB:Q8NF90,UniProtKB:Q8WWJ7\n" ] } ], @@ -250,13 +253,112 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "6ee85543-c5e9-4f93-a819-d7c68804d361", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m\n", + "\u001b[0mtranslator_query\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuild_attribute_constraint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mattribute_id\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0moperator\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mis_not\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDocstring:\u001b[0m This creates an attribute constraint for a TRAPI query dict.\n", + "\u001b[0;31mFile:\u001b[0m ~/Translator_component_toolkit/TCT/translator_query.py\n", + "\u001b[0;31mType:\u001b[0m function\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "translator_query" + "translator_query.build_attribute_constraint?" ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "eb51bcf1-cbc3-4fde-9d5a-8b43f18f6693", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m\n", + "\u001b[0mtranslator_query\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat_query_json\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0msubject_ids\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mobject_ids\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0msubject_categories\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mobject_categories\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mpredicates\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mattribute_constraints\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mdict\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m|\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDocstring:\u001b[0m\n", + "Formats a query dict, with optional constraints.\n", + "\n", + "Example input:\n", + "subject_ids = [\"NCBIGene:3845\"]\n", + "object_ids = []\n", + "subject_categories = [\"biolink:Gene\"]\n", + "object_categories = [\"biolink:Gene\"]\n", + "predicates = [\"biolink:positively_correlated_with\", \"biolink:physically_interacts_with\"]\n", + "attribute_constraints = [build_attribute_constraint('biolink:has_total', '>', 2)]\n", + "\u001b[0;31mFile:\u001b[0m ~/Translator_component_toolkit/TCT/translator_query.py\n", + "\u001b[0;31mType:\u001b[0m function\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "translator_query.format_query_json?" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "d9d6bc4a-129d-4c09-89d1-173787f2e758", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m\n", + "\u001b[0mtranslator_query\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mquery_KP\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mAPI_name_cur\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mquery_json\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mAPInames\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mAPI_predicates\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDocstring:\u001b[0m\n", + "Query an individual API with a TRAPI 1.5.0 query JSON,\n", + "without modifying the original query_json.\n", + "\u001b[0;31mFile:\u001b[0m ~/Translator_component_toolkit/TCT/translator_query.py\n", + "\u001b[0;31mType:\u001b[0m function\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "translator_query.query_KP?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "739d2845-37f8-4fbf-a63f-eb6babc84be8", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From 1c4727f8ec982e0e903639c44c133cc0ad7ac868 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Mon, 1 Jun 2026 21:07:57 -0700 Subject: [PATCH 16/33] fixed some potential bugs with neighborhood finder --- TCT/TCT_neighborhood_finder.py | 2 + TCT/node_normalizer.py | 2 + notebooks/queries_with_constraints.ipynb | 98 ++++++++++++++++++------ 3 files changed, 79 insertions(+), 23 deletions(-) diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index 3d9b673..8cbe467 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -39,6 +39,8 @@ def parse_results_for_neighborhood_finder(start_node_id:str, results:dict, node_info[intermediate_node_id] = node_dict else: node_dict = node_info[intermediate_node_id] + if 'attributes' not in v: + v['attributes'] = [] for attribute in v['attributes']: if attribute['attribute_type_id'] == f'{s_o}_category': if 'categories' not in node_dict: diff --git a/TCT/node_normalizer.py b/TCT/node_normalizer.py index 1c46cdc..bb7e374 100644 --- a/TCT/node_normalizer.py +++ b/TCT/node_normalizer.py @@ -58,6 +58,8 @@ def get_normalized_nodes(query: str | list[str], json_query = [query] else: json_query = query + if len(json_query) == 0: + return {} response = requests.post(path, json={'curies': json_query, **kwargs}) else: response = requests.get(path, params={'curie': query, **kwargs}) diff --git a/notebooks/queries_with_constraints.ipynb b/notebooks/queries_with_constraints.ipynb index 517b168..9d0b3e8 100644 --- a/notebooks/queries_with_constraints.ipynb +++ b/notebooks/queries_with_constraints.ipynb @@ -77,7 +77,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "(22528, 5)\n" + "(22568, 5)\n" ] } ], @@ -120,7 +120,11 @@ "\u001b[0;34m\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mis_not\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mDocstring:\u001b[0m This creates an attribute constraint for a TRAPI query dict.\n", + "\u001b[0;31mDocstring:\u001b[0m\n", + "This creates an attribute constraint for a TRAPI query dict.\n", + "\n", + "Example\n", + "-------\n", "\u001b[0;31mFile:\u001b[0m ~/Translator_component_toolkit/TCT/translator_query.py\n", "\u001b[0;31mType:\u001b[0m function\n" ] @@ -174,25 +178,37 @@ "\u001b[0;31mDocstring:\u001b[0m\n", "This function is used to find the neighborhood of a given input node with intermediate categories.\n", "\n", - "--------------\n", - "Parameters:\n", - "input_node (str): The input node - should be a CURIE id.\n", - "node2_categories (list): A list of intermediate categories to be used in the neighborhood finding process.\n", - "APInames (dict): A dictionary containing the names of the APIs to be used.\n", - "metaKG (DataFrame): The metadata knowledge graph containing information about the APIs and their predicates.\n", - "API_predicates (dict): A dictionary containing the predicates for each API.\n", - "input_node_category (list): Optional. A list of categories for the input node. If empty, it will be derived from the input node's types.\n", + "Parameters\n", + "----------\n", + "input_node (str)\n", + " The input node - should be a CURIE id.\n", + "node2_categories (list)\n", + " A list of intermediate categories to be used in the neighborhood finding process.\n", + "APInames (dict)\n", + " A dictionary containing the names of the APIs to be used.\n", + "metaKG (DataFrame)\n", + " The metadata knowledge graph containing information about the APIs and their predicates.\n", + "API_predicates (dict)\n", + " A dictionary containing the predicates for each API.\n", + "input_node_category (list)\n", + " Optional. A list of categories for the input node. If empty, it will be derived from the input node's types.\n", + "attribute_constraints (list)\n", + " Optional. List of outputs of translator_query.build_attribute_constraint\n", "\n", + "Returns\n", "--------------\n", - "Returns:\n", - "input_node_id (str): The curie id of the input node.\n", - "result (dict): The result of the query for the input node.\n", - "result_parsed (DataFrame): The parsed results for the input node.\n", - "result_ranked_by_primary_infores (DataFrame): The ranked results based on primary infores.\n", + "input_node_id (str)\n", + " The curie id of the input node.\n", + "result (dict)\n", + " The result of the query for the input node.\n", + "result_parsed (DataFrame)\n", + " The parsed results for the input node.\n", + "result_ranked_by_primary_infores (DataFrame)\n", + " The ranked results based on primary infores.\n", "\n", "--------------\n", "Example:\n", - ">>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = Neighborhood_finder('MONDO:0008170', #Ovarian Cancer\n", + ">>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer\n", " node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'],\n", " APInames = APInames,\n", " metaKG = metaKG,\n", @@ -221,14 +237,13 @@ "output_type": "stream", "text": [ "NCBIGene:3458\n", - "Automat-robokop(Trapi v1.5.0): Success!\n", - "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0: Success!\n", + "Automat-genome-alliance(Trapi v1.5.0): Success!\n", "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", - "Automat-cam-kp(Trapi v1.5.0): Success!\n", + "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0: Success!\n", "RTX KG2 - TRAPI 1.5.0: Success!\n", - "Automat-genome-alliance(Trapi v1.5.0): Success!\n", "Automat-hetionet(Trapi v1.5.0): Success!\n", - "Service Provider TRAPI: Success!\n", + "Automat-cam-kp(Trapi v1.5.0): Success!\n", + "Automat-robokop(Trapi v1.5.0): Success!\n", "BioThings Explorer (BTE) TRAPI: Success!\n", "NCBIGene:3497: no preferred name\n", "NodeNorm does not know about these identifiers: UniProtKB:Q8NF90,UniProtKB:Q8WWJ7\n" @@ -268,7 +283,11 @@ "\u001b[0;34m\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mis_not\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mDocstring:\u001b[0m This creates an attribute constraint for a TRAPI query dict.\n", + "\u001b[0;31mDocstring:\u001b[0m\n", + "This creates an attribute constraint for a TRAPI query dict.\n", + "\n", + "Example\n", + "-------\n", "\u001b[0;31mFile:\u001b[0m ~/Translator_component_toolkit/TCT/translator_query.py\n", "\u001b[0;31mType:\u001b[0m function\n" ] @@ -354,9 +373,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, + "id": "3d0a13a5-759b-4ce3-866e-e742aed24fb8", + "metadata": {}, + "outputs": [], + "source": [ + "constraint1 = translator_query.build_attribute_constraint('biolink:has_total', '>', 4, name='has_total')" + ] + }, + { + "cell_type": "code", + "execution_count": 13, "id": "739d2845-37f8-4fbf-a63f-eb6babc84be8", "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "NCBIGene:3458\n" + ] + } + ], + "source": [ + "input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = TCT_neighborhood_finder.neighborhood_finder(input_node='NCBIGene:3458', #IFNG\n", + " node2_categories=['biolink:Gene'],\n", + " APInames=APInames,\n", + " metaKG=metaKG,\n", + " API_predicates=API_predicates,\n", + " attribute_constraints=[constraint1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0d6e26a8-f532-44ad-ad12-115feb5a89c0", + "metadata": {}, "outputs": [], "source": [] } From 471c8a0f63af3ec6f9736c59b4d1f89cb8c61893 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Mon, 1 Jun 2026 21:32:33 -0700 Subject: [PATCH 17/33] working on updating the metakg query... --- TCT/translator_metakg.py | 23 ++++-- notebooks/metakg_tests.ipynb | 140 +++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 notebooks/metakg_tests.ipynb diff --git a/TCT/translator_metakg.py b/TCT/translator_metakg.py index 200b15f..e98af08 100644 --- a/TCT/translator_metakg.py +++ b/TCT/translator_metakg.py @@ -3,15 +3,21 @@ import pandas as pd -def find_link(name): +def find_link(name, use_new_url=True): #pre = "https://dev.smart-api.info/api/metakg/consolidated?size=2000&q=%28api.x-translator.component%3AKP+AND+api.name%3A" # This works for the previous version - pre = "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3A" - end = "%5C%28Trapi+v1.5.0%5C%29%29" + print(name) + if use_new_url: + pre = "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:" + end = ")&facet_size=300&aggs=object.raw,subject.raw" + else: + pre = "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3A" + end = "%5C%28Trapi+v1.5.0%5C%29%29" if '(Trapi v1.5.0)' in name: url = pre name_raw = name.split("(")[0] words = name_raw.split(" ") + # TODO: replace '(Trapi v1.5.0)' with '\(Trapi+v1.5.0\)' length = len(words) if length == 1: url = url + words[0] + end @@ -19,7 +25,6 @@ def find_link(name): for i in range(0,length-1): url = url + words[i] + "+" url = url+words[length-1]+end - else: words = name.split(" ") url = pre @@ -27,8 +32,14 @@ def find_link(name): for i in range(0,length-1): url = url + words[i] + "+" - url = url+words[length-1]+"%29" - return(url) + + url = url+words[length-1] + if use_new_url: + url += end + else: + url = url+"%29" + print(url) + return url def get_KP_metadata(APInames:dict[str, str]) -> pd.DataFrame: diff --git a/notebooks/metakg_tests.ipynb b/notebooks/metakg_tests.ipynb new file mode 100644 index 0000000..8567a93 --- /dev/null +++ b/notebooks/metakg_tests.ipynb @@ -0,0 +1,140 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "212ec96a-2f6a-47d6-996a-18dadec8a3a1", + "metadata": {}, + "source": [ + "# Translator MetaKGs\n", + "\n", + "See: https://github.com/NCATSTranslator/Translator_component_toolkit/issues/38\n", + "\n", + "2026-06-01" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "f0eef37d-44b6-4a97-bf64-7b7bf29734fd", + "metadata": {}, + "outputs": [], + "source": [ + "from TCT import translator_metakg, translator_query, name_resolver, TCT_neighborhood_finder, TCT_pathfinder" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "357ec484-d07c-4e2a-9ae0-4179ee6872af", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Skipping server without x-maturity: {'url': '/sipr'}\n", + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", + "Genetics Data Provider for NCATS Biomedical Translator Reasoners\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Genetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners%29\n", + "Microbiome KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Microbiome+KP+-+TRAPI+1.5.0%29\n", + "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:CATRAX+BigGIM+DrugResponse+Performance+Phase+KP+-+TRAPI+1.5.0%29\n", + "ARAX Translator Reasoner - TRAPI 1.6.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:ARAX+Translator+Reasoner+-+TRAPI+1.6.0%29\n", + "Drug Approvals KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Drug+Approvals+KP+-+TRAPI+1.5.0%29\n", + "Service Provider TRAPI\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Service+Provider+TRAPI%29\n", + "Text Mined Cooccurrence API\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Text+Mined+Cooccurrence+API%29\n", + "Shepherd SIPR\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd+SIPR%29\n", + "Multiomics KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Multiomics+KP+-+TRAPI+1.5.0%29\n", + "mediKanren\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:mediKanren%29\n", + "COHD TRAPI\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:COHD+TRAPI%29\n", + "BioThings Explorer (BTE) TRAPI\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:BioThings+Explorer+(BTE)+TRAPI%29\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:CATRAX+Pharmacogenomics+KP+-+TRAPI+1.5.0%29\n", + "imProving Agent for TRAPI 1.5\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:imProving+Agent+for+TRAPI+1.5%29\n", + "Connections Hypothesis Provider API\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Connections+Hypothesis+Provider+API%29\n", + "Clinical Trials KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Clinical+Trials+KP+-+TRAPI+1.5.0%29\n", + "Retriever\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Retriever%29\n", + "Gene-List Network Enrichment Analysis\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Gene-List+Network+Enrichment+Analysis%29\n", + "MolePro\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:MolePro%29\n", + "SPOKE KP for TRAPI 1.5\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:SPOKE+KP+for+TRAPI+1.5%29\n", + "Automat-ubergraph(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ubergraph)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-drug-central(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-drug-central)&facet_size=300&aggs=object.raw,subject.raw\n", + "OpenPredict API\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:OpenPredict+API%29\n", + "Sri-node-normalizer(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Sri-node-normalizer)&facet_size=300&aggs=object.raw,subject.raw\n" + ] + }, + { + "ename": "KeyError", + "evalue": "'hits'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [2]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m APInames, metaKG, Translator_KP_info\u001b[38;5;241m=\u001b[39m \u001b[43mtranslator_metakg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload_translator_resources\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/Translator_component_toolkit/TCT/translator_metakg.py:266\u001b[0m, in \u001b[0;36mload_translator_resources\u001b[0;34m()\u001b[0m\n\u001b[1;32m 264\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtranslator_kpinfo\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m get_translator_kp_info\n\u001b[1;32m 265\u001b[0m Translator_KP_info, APInames \u001b[38;5;241m=\u001b[39m get_translator_kp_info()\n\u001b[0;32m--> 266\u001b[0m metaKG \u001b[38;5;241m=\u001b[39m \u001b[43mget_KP_metadata\u001b[49m\u001b[43m(\u001b[49m\u001b[43mAPInames\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 268\u001b[0m APInames, metaKG \u001b[38;5;241m=\u001b[39m add_plover_API(APInames, metaKG)\n\u001b[1;32m 269\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m APInames, metaKG, Translator_KP_info\n", + "File \u001b[0;32m~/Translator_component_toolkit/TCT/translator_metakg.py:77\u001b[0m, in \u001b[0;36mget_KP_metadata\u001b[0;34m(APInames)\u001b[0m\n\u001b[1;32m 74\u001b[0m text \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mget(find_link(KP))\u001b[38;5;241m.\u001b[39mtext\n\u001b[1;32m 75\u001b[0m json_text \u001b[38;5;241m=\u001b[39m json\u001b[38;5;241m.\u001b[39mloads(text)\n\u001b[0;32m---> 77\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m (\u001b[43mjson_text\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mhits\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m):\n\u001b[1;32m 78\u001b[0m Predicate_list\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mbiolink:\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m+\u001b[39mi[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_id\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m)[\u001b[38;5;241m1\u001b[39m])\n\u001b[1;32m 79\u001b[0m API_list\u001b[38;5;241m.\u001b[39mappend(KP)\n", + "\u001b[0;31mKeyError\u001b[0m: 'hits'" + ] + } + ], + "source": [ + "APInames, metaKG, Translator_KP_info= translator_metakg.load_translator_resources()\n" + ] + }, + { + "cell_type": "raw", + "id": "e9cf0d27-76a0-43ee-ae6c-9b7774a85f18", + "metadata": {}, + "source": [ + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AGenetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners%29\n", + "\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-ehr-clinical-connections-kp%5C%28Trapi+v1.5.0%5C%29%29" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From ce5e7396f19710f26ccad666ba7ff36d4cb0700a Mon Sep 17 00:00:00 2001 From: yjzhang Date: Mon, 1 Jun 2026 21:32:57 -0700 Subject: [PATCH 18/33] working on updating the metakg query... --- notebooks/metakg_tests.ipynb | 52 +++--------------------------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/notebooks/metakg_tests.ipynb b/notebooks/metakg_tests.ipynb index 8567a93..3c93415 100644 --- a/notebooks/metakg_tests.ipynb +++ b/notebooks/metakg_tests.ipynb @@ -38,53 +38,9 @@ "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", "Genetics Data Provider for NCATS Biomedical Translator Reasoners\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Genetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners%29\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Genetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners)&facet_size=300&aggs=object.raw,subject.raw\n", "Microbiome KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Microbiome+KP+-+TRAPI+1.5.0%29\n", - "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:CATRAX+BigGIM+DrugResponse+Performance+Phase+KP+-+TRAPI+1.5.0%29\n", - "ARAX Translator Reasoner - TRAPI 1.6.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:ARAX+Translator+Reasoner+-+TRAPI+1.6.0%29\n", - "Drug Approvals KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Drug+Approvals+KP+-+TRAPI+1.5.0%29\n", - "Service Provider TRAPI\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Service+Provider+TRAPI%29\n", - "Text Mined Cooccurrence API\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Text+Mined+Cooccurrence+API%29\n", - "Shepherd SIPR\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd+SIPR%29\n", - "Multiomics KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Multiomics+KP+-+TRAPI+1.5.0%29\n", - "mediKanren\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:mediKanren%29\n", - "COHD TRAPI\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:COHD+TRAPI%29\n", - "BioThings Explorer (BTE) TRAPI\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:BioThings+Explorer+(BTE)+TRAPI%29\n", - "CATRAX Pharmacogenomics KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:CATRAX+Pharmacogenomics+KP+-+TRAPI+1.5.0%29\n", - "imProving Agent for TRAPI 1.5\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:imProving+Agent+for+TRAPI+1.5%29\n", - "Connections Hypothesis Provider API\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Connections+Hypothesis+Provider+API%29\n", - "Clinical Trials KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Clinical+Trials+KP+-+TRAPI+1.5.0%29\n", - "Retriever\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Retriever%29\n", - "Gene-List Network Enrichment Analysis\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Gene-List+Network+Enrichment+Analysis%29\n", - "MolePro\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:MolePro%29\n", - "SPOKE KP for TRAPI 1.5\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:SPOKE+KP+for+TRAPI+1.5%29\n", - "Automat-ubergraph(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ubergraph)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-drug-central(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-drug-central)&facet_size=300&aggs=object.raw,subject.raw\n", - "OpenPredict API\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:OpenPredict+API%29\n", - "Sri-node-normalizer(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Sri-node-normalizer)&facet_size=300&aggs=object.raw,subject.raw\n" + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Microbiome+KP+-+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n" ] }, { @@ -95,8 +51,8 @@ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "Input \u001b[0;32mIn [2]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m APInames, metaKG, Translator_KP_info\u001b[38;5;241m=\u001b[39m \u001b[43mtranslator_metakg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload_translator_resources\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/Translator_component_toolkit/TCT/translator_metakg.py:266\u001b[0m, in \u001b[0;36mload_translator_resources\u001b[0;34m()\u001b[0m\n\u001b[1;32m 264\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtranslator_kpinfo\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m get_translator_kp_info\n\u001b[1;32m 265\u001b[0m Translator_KP_info, APInames \u001b[38;5;241m=\u001b[39m get_translator_kp_info()\n\u001b[0;32m--> 266\u001b[0m metaKG \u001b[38;5;241m=\u001b[39m \u001b[43mget_KP_metadata\u001b[49m\u001b[43m(\u001b[49m\u001b[43mAPInames\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 268\u001b[0m APInames, metaKG \u001b[38;5;241m=\u001b[39m add_plover_API(APInames, metaKG)\n\u001b[1;32m 269\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m APInames, metaKG, Translator_KP_info\n", - "File \u001b[0;32m~/Translator_component_toolkit/TCT/translator_metakg.py:77\u001b[0m, in \u001b[0;36mget_KP_metadata\u001b[0;34m(APInames)\u001b[0m\n\u001b[1;32m 74\u001b[0m text \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mget(find_link(KP))\u001b[38;5;241m.\u001b[39mtext\n\u001b[1;32m 75\u001b[0m json_text \u001b[38;5;241m=\u001b[39m json\u001b[38;5;241m.\u001b[39mloads(text)\n\u001b[0;32m---> 77\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m (\u001b[43mjson_text\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mhits\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m):\n\u001b[1;32m 78\u001b[0m Predicate_list\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mbiolink:\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m+\u001b[39mi[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_id\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m)[\u001b[38;5;241m1\u001b[39m])\n\u001b[1;32m 79\u001b[0m API_list\u001b[38;5;241m.\u001b[39mappend(KP)\n", + "File \u001b[0;32m~/Translator_component_toolkit/TCT/translator_metakg.py:271\u001b[0m, in \u001b[0;36mload_translator_resources\u001b[0;34m()\u001b[0m\n\u001b[1;32m 269\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtranslator_kpinfo\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m get_translator_kp_info\n\u001b[1;32m 270\u001b[0m Translator_KP_info, APInames \u001b[38;5;241m=\u001b[39m get_translator_kp_info()\n\u001b[0;32m--> 271\u001b[0m metaKG \u001b[38;5;241m=\u001b[39m \u001b[43mget_KP_metadata\u001b[49m\u001b[43m(\u001b[49m\u001b[43mAPInames\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 273\u001b[0m APInames, metaKG \u001b[38;5;241m=\u001b[39m add_plover_API(APInames, metaKG)\n\u001b[1;32m 274\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m APInames, metaKG, Translator_KP_info\n", + "File \u001b[0;32m~/Translator_component_toolkit/TCT/translator_metakg.py:82\u001b[0m, in \u001b[0;36mget_KP_metadata\u001b[0;34m(APInames)\u001b[0m\n\u001b[1;32m 79\u001b[0m text \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mget(find_link(KP))\u001b[38;5;241m.\u001b[39mtext\n\u001b[1;32m 80\u001b[0m json_text \u001b[38;5;241m=\u001b[39m json\u001b[38;5;241m.\u001b[39mloads(text)\n\u001b[0;32m---> 82\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m (\u001b[43mjson_text\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mhits\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m):\n\u001b[1;32m 83\u001b[0m Predicate_list\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mbiolink:\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m+\u001b[39mi[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_id\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m)[\u001b[38;5;241m1\u001b[39m])\n\u001b[1;32m 84\u001b[0m API_list\u001b[38;5;241m.\u001b[39mappend(KP)\n", "\u001b[0;31mKeyError\u001b[0m: 'hits'" ] } From 33114e63a1ef5a240b9df01a641890340c72c2ac Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 2 Jun 2026 14:01:05 -0700 Subject: [PATCH 19/33] add new metakg api url --- TCT/translator_metakg.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/TCT/translator_metakg.py b/TCT/translator_metakg.py index e98af08..cb1661d 100644 --- a/TCT/translator_metakg.py +++ b/TCT/translator_metakg.py @@ -12,6 +12,7 @@ def find_link(name, use_new_url=True): else: pre = "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3A" end = "%5C%28Trapi+v1.5.0%5C%29%29" + name = name.replace(' - ', ' ') if '(Trapi v1.5.0)' in name: url = pre name_raw = name.split("(")[0] @@ -42,7 +43,7 @@ def find_link(name, use_new_url=True): return url -def get_KP_metadata(APInames:dict[str, str]) -> pd.DataFrame: +def get_KP_metadata(APInames:dict[str, str], use_new_url=True) -> pd.DataFrame: ''' This function is used to get the metadata of the KPs in the APInames dictionary. @@ -75,10 +76,12 @@ def get_KP_metadata(APInames:dict[str, str]) -> pd.DataFrame: if KP == "RTX KG2 - TRAPI 1.5.0": text =requests.get("https://smart-api.info/api/metakg/consolidated?size=20&q=%28api.x-translator.component%3AKP+AND+api.name%3ARTX+KG2+%5C-+TRAPI+1%5C.4%5C.0%29").text # This works for the previous version json_text = json.loads(text) - else: - text = requests.get(find_link(KP)).text + else: + text = requests.get(find_link(KP, use_new_url=use_new_url)).text json_text = json.loads(text) - + if 'hits' not in json_text: + text = requests.get(find_link(KP, use_new_url=False)).text + json_text = json.loads(text) for i in (json_text['hits']): Predicate_list.append("biolink:"+i['_id'].split("-")[1]) API_list.append(KP) @@ -256,10 +259,15 @@ def add_plover_API(APInames:dict[str, str], metaKG:pd.DataFrame) -> tuple[dict[s return APInames, metaKG -def load_translator_resources(): +def load_translator_resources(use_new_metakg_url=True): """ Load the necessary resources for the Translator. + Params + ------ + use_new_metakg_url + If True, this uses https://smart-api.info/api/metakg. If False, this uses https://smart-api.info/api/metakg/consolidated? + Returns ------- APInames @@ -268,7 +276,7 @@ def load_translator_resources(): """ from .translator_kpinfo import get_translator_kp_info Translator_KP_info, APInames = get_translator_kp_info() - metaKG = get_KP_metadata(APInames) + metaKG = get_KP_metadata(APInames, use_new_url=use_new_metakg_url) APInames, metaKG = add_plover_API(APInames, metaKG) return APInames, metaKG, Translator_KP_info From f8ea041710a770d02f6c4a1bcb0aaf73d532e15e Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 2 Jun 2026 14:03:35 -0700 Subject: [PATCH 20/33] metakg stuff --- notebooks/metakg_tests.ipynb | 473 ++++++++++++++++++++++++++++++++++- 1 file changed, 460 insertions(+), 13 deletions(-) diff --git a/notebooks/metakg_tests.ipynb b/notebooks/metakg_tests.ipynb index 3c93415..9d5b966 100644 --- a/notebooks/metakg_tests.ipynb +++ b/notebooks/metakg_tests.ipynb @@ -37,28 +37,475 @@ "Skipping server without x-maturity: {'url': '/sipr'}\n", "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", + "ARAX Translator Reasoner - TRAPI 1.6.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:ARAX+Translator+Reasoner+TRAPI+1.6.0)&facet_size=300&aggs=object.raw,subject.raw\n", "Genetics Data Provider for NCATS Biomedical Translator Reasoners\n", "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Genetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners)&facet_size=300&aggs=object.raw,subject.raw\n", + "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:CATRAX+BigGIM+DrugResponse+Performance+Phase+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", + "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACATRAX+BigGIM+DrugResponse+Performance+Phase+KP+TRAPI+1.5.0%29\n", "Microbiome KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Microbiome+KP+-+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n" + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Microbiome+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", + "mediKanren\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:mediKanren)&facet_size=300&aggs=object.raw,subject.raw\n", + "mediKanren\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AmediKanren%29\n", + "Drug Approvals KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Drug+Approvals+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", + "Service Provider TRAPI\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Service+Provider+TRAPI)&facet_size=300&aggs=object.raw,subject.raw\n", + "Shepherd SIPR\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd+SIPR)&facet_size=300&aggs=object.raw,subject.raw\n", + "Shepherd SIPR\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd+SIPR%29\n", + "BioThings Explorer (BTE) TRAPI\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:BioThings+Explorer+(BTE)+TRAPI)&facet_size=300&aggs=object.raw,subject.raw\n", + "Multiomics KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Multiomics+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:CATRAX+Pharmacogenomics+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACATRAX+Pharmacogenomics+KP+TRAPI+1.5.0%29\n", + "COHD TRAPI\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:COHD+TRAPI)&facet_size=300&aggs=object.raw,subject.raw\n", + "Text Mined Cooccurrence API\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Text+Mined+Cooccurrence+API)&facet_size=300&aggs=object.raw,subject.raw\n", + "imProving Agent for TRAPI 1.5\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:imProving+Agent+for+TRAPI+1.5)&facet_size=300&aggs=object.raw,subject.raw\n", + "imProving Agent for TRAPI 1.5\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AimProving+Agent+for+TRAPI+1.5%29\n", + "Connections Hypothesis Provider API\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Connections+Hypothesis+Provider+API)&facet_size=300&aggs=object.raw,subject.raw\n", + "OpenPredict API\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:OpenPredict+API)&facet_size=300&aggs=object.raw,subject.raw\n", + "OpenPredict API\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AOpenPredict+API%29\n", + "Gene-List Network Enrichment Analysis\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Gene-List+Network+Enrichment+Analysis)&facet_size=300&aggs=object.raw,subject.raw\n", + "MolePro\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:MolePro)&facet_size=300&aggs=object.raw,subject.raw\n", + "Retriever\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Retriever)&facet_size=300&aggs=object.raw,subject.raw\n", + "Sri-node-normalizer(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Sri-node-normalizer)&facet_size=300&aggs=object.raw,subject.raw\n", + "Sri-node-normalizer(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASri-node-normalizer%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-gtopdb(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-gtopdb)&facet_size=300&aggs=object.raw,subject.raw\n", + "Knowledge Collaboratory API\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Knowledge+Collaboratory+API)&facet_size=300&aggs=object.raw,subject.raw\n", + "Knowledge Collaboratory API\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AKnowledge+Collaboratory+API%29\n", + "SPOKE KP for TRAPI 1.5\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:SPOKE+KP+for+TRAPI+1.5)&facet_size=300&aggs=object.raw,subject.raw\n", + "SPOKE KP for TRAPI 1.5\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASPOKE+KP+for+TRAPI+1.5%29\n", + "Clinical Trials KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Clinical+Trials+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-ubergraph(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ubergraph)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-drug-central(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-drug-central)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-human-goa(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-human-goa)&facet_size=300&aggs=object.raw,subject.raw\n", + "Cqs(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Cqs)&facet_size=300&aggs=object.raw,subject.raw\n", + "Cqs(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACqs%5C%28Trapi+v1.5.0%5C%29%29\n", + "Shepherd-aragorn(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd-aragorn)&facet_size=300&aggs=object.raw,subject.raw\n", + "Shepherd-aragorn(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-aragorn%5C%28Trapi+v1.5.0%5C%29%29\n", + "Shepherd-arax(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd-arax)&facet_size=300&aggs=object.raw,subject.raw\n", + "Shepherd-arax(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-arax%5C%28Trapi+v1.5.0%5C%29%29\n", + "Aragorn(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Aragorn)&facet_size=300&aggs=object.raw,subject.raw\n", + "Aragorn(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAragorn%5C%28Trapi+v1.5.0%5C%29%29\n", + "Answer-coalesce(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Answer-coalesce)&facet_size=300&aggs=object.raw,subject.raw\n", + "Answer-coalesce(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAnswer-coalesce%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-reactome(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-reactome)&facet_size=300&aggs=object.raw,subject.raw\n", + "Autonomous Relay System (ARS) TRAPI\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Autonomous+Relay+System+(ARS)+TRAPI)&facet_size=300&aggs=object.raw,subject.raw\n", + "Autonomous Relay System (ARS) TRAPI\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutonomous+Relay+System+(ARS)+TRAPI%29\n", + "Automat-viral-proteome(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-viral-proteome)&facet_size=300&aggs=object.raw,subject.raw\n", + "Shepherd-bte(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd-bte)&facet_size=300&aggs=object.raw,subject.raw\n", + "Shepherd-bte(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-bte%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-ctd(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ctd)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-icees-kg(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-icees-kg)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-hetionet(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-hetionet)&facet_size=300&aggs=object.raw,subject.raw\n", + "Workflow-runner(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Workflow-runner)&facet_size=300&aggs=object.raw,subject.raw\n", + "Workflow-runner(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AWorkflow-runner%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-ehr-may-treat-kp(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ehr-may-treat-kp)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-intact(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-intact)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-pharos(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-pharos)&facet_size=300&aggs=object.raw,subject.raw\n", + "Aragorn(Trapi v1.6.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Aragorn(Trapi+v1.6.0))&facet_size=300&aggs=object.raw,subject.raw\n", + "Aragorn(Trapi v1.6.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAragorn(Trapi+v1.6.0)%29\n", + "Automat-genome-alliance(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-genome-alliance)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-hmdb(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-hmdb)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-binding-db(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-binding-db)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-string-db(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-string-db)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-gtex(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-gtex)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-panther(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-panther)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-monarchinitiative(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-monarchinitiative)&facet_size=300&aggs=object.raw,subject.raw\n", + "Sri-answer-appraiser(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Sri-answer-appraiser)&facet_size=300&aggs=object.raw,subject.raw\n", + "Sri-answer-appraiser(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASri-answer-appraiser%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-robokop(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-robokop)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-cam-kp(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-cam-kp)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-hgnc(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-hgnc)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-gwas-catalog(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-gwas-catalog)&facet_size=300&aggs=object.raw,subject.raw\n", + "Automat-ehr-clinical-connections-kp(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ehr-clinical-connections-kp)&facet_size=300&aggs=object.raw,subject.raw\n" ] - }, + } + ], + "source": [ + "APInames, metaKG, Translator_KP_info= translator_metakg.load_translator_resources(use_new_metakg_url=True)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "f7487987-082b-469c-8269-82d96bbd5cf1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
APIPredicateSubjectObjectURL
0ARAX Translator Reasoner - TRAPI 1.6.0biolink:diagnosesbiolink:SmallMoleculebiolink:PhenotypicFeaturehttps://arax.transltr.io/api/arax/v1.4/query/
1ARAX Translator Reasoner - TRAPI 1.6.0biolink:derives_frombiolink:MolecularMixturebiolink:MolecularMixturehttps://arax.transltr.io/api/arax/v1.4/query/
2ARAX Translator Reasoner - TRAPI 1.6.0biolink:disruptsbiolink:ChemicalEntitybiolink:Genehttps://arax.transltr.io/api/arax/v1.4/query/
3ARAX Translator Reasoner - TRAPI 1.6.0biolink:same_asbiolink:ChemicalEntitybiolink:Proteinhttps://arax.transltr.io/api/arax/v1.4/query/
4ARAX Translator Reasoner - TRAPI 1.6.0biolink:affectsbiolink:Cellbiolink:Genehttps://arax.transltr.io/api/arax/v1.4/query/
..................
31140RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:NamedThingbiolink:Diseasehttps://kg2cploverdb.ci.transltr.io/kg2c/query
31141RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:NamedThingbiolink:PhenotypicFeaturehttps://kg2cploverdb.ci.transltr.io/kg2c/query
31142RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:NamedThingbiolink:BehavioralFeaturehttps://kg2cploverdb.ci.transltr.io/kg2c/query
31143RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:ChemicalEntitybiolink:BehavioralFeaturehttps://kg2cploverdb.ci.transltr.io/kg2c/query
31144RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:MolecularMixturebiolink:BehavioralFeaturehttps://kg2cploverdb.ci.transltr.io/kg2c/query
\n", + "

31145 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " API Predicate \\\n", + "0 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:diagnoses \n", + "1 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:derives_from \n", + "2 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:disrupts \n", + "3 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:same_as \n", + "4 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:affects \n", + "... ... ... \n", + "31140 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", + "31141 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", + "31142 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", + "31143 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", + "31144 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", + "\n", + " Subject Object \\\n", + "0 biolink:SmallMolecule biolink:PhenotypicFeature \n", + "1 biolink:MolecularMixture biolink:MolecularMixture \n", + "2 biolink:ChemicalEntity biolink:Gene \n", + "3 biolink:ChemicalEntity biolink:Protein \n", + "4 biolink:Cell biolink:Gene \n", + "... ... ... \n", + "31140 biolink:NamedThing biolink:Disease \n", + "31141 biolink:NamedThing biolink:PhenotypicFeature \n", + "31142 biolink:NamedThing biolink:BehavioralFeature \n", + "31143 biolink:ChemicalEntity biolink:BehavioralFeature \n", + "31144 biolink:MolecularMixture biolink:BehavioralFeature \n", + "\n", + " URL \n", + "0 https://arax.transltr.io/api/arax/v1.4/query/ \n", + "1 https://arax.transltr.io/api/arax/v1.4/query/ \n", + "2 https://arax.transltr.io/api/arax/v1.4/query/ \n", + "3 https://arax.transltr.io/api/arax/v1.4/query/ \n", + "4 https://arax.transltr.io/api/arax/v1.4/query/ \n", + "... ... \n", + "31140 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31141 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31142 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31143 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31144 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "\n", + "[31145 rows x 5 columns]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "metaKG" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "463c2b19-64b8-45b7-af78-957176f5d5fd", + "metadata": { + "scrolled": true + }, + "outputs": [ { - "ename": "KeyError", - "evalue": "'hits'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "Input \u001b[0;32mIn [2]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m APInames, metaKG, Translator_KP_info\u001b[38;5;241m=\u001b[39m \u001b[43mtranslator_metakg\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload_translator_resources\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/Translator_component_toolkit/TCT/translator_metakg.py:271\u001b[0m, in \u001b[0;36mload_translator_resources\u001b[0;34m()\u001b[0m\n\u001b[1;32m 269\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtranslator_kpinfo\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m get_translator_kp_info\n\u001b[1;32m 270\u001b[0m Translator_KP_info, APInames \u001b[38;5;241m=\u001b[39m get_translator_kp_info()\n\u001b[0;32m--> 271\u001b[0m metaKG \u001b[38;5;241m=\u001b[39m \u001b[43mget_KP_metadata\u001b[49m\u001b[43m(\u001b[49m\u001b[43mAPInames\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 273\u001b[0m APInames, metaKG \u001b[38;5;241m=\u001b[39m add_plover_API(APInames, metaKG)\n\u001b[1;32m 274\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m APInames, metaKG, Translator_KP_info\n", - "File \u001b[0;32m~/Translator_component_toolkit/TCT/translator_metakg.py:82\u001b[0m, in \u001b[0;36mget_KP_metadata\u001b[0;34m(APInames)\u001b[0m\n\u001b[1;32m 79\u001b[0m text \u001b[38;5;241m=\u001b[39m requests\u001b[38;5;241m.\u001b[39mget(find_link(KP))\u001b[38;5;241m.\u001b[39mtext\n\u001b[1;32m 80\u001b[0m json_text \u001b[38;5;241m=\u001b[39m json\u001b[38;5;241m.\u001b[39mloads(text)\n\u001b[0;32m---> 82\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m (\u001b[43mjson_text\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mhits\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m):\n\u001b[1;32m 83\u001b[0m Predicate_list\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mbiolink:\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m+\u001b[39mi[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_id\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m)[\u001b[38;5;241m1\u001b[39m])\n\u001b[1;32m 84\u001b[0m API_list\u001b[38;5;241m.\u001b[39mappend(KP)\n", - "\u001b[0;31mKeyError\u001b[0m: 'hits'" + "name": "stdout", + "output_type": "stream", + "text": [ + "Skipping server without x-maturity: {'url': '/sipr'}\n", + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", + "ARAX Translator Reasoner - TRAPI 1.6.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AARAX+Translator+Reasoner+TRAPI+1.6.0%29\n", + "Genetics Data Provider for NCATS Biomedical Translator Reasoners\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AGenetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners%29\n", + "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACATRAX+BigGIM+DrugResponse+Performance+Phase+KP+TRAPI+1.5.0%29\n", + "Microbiome KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AMicrobiome+KP+TRAPI+1.5.0%29\n", + "mediKanren\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AmediKanren%29\n", + "Drug Approvals KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ADrug+Approvals+KP+TRAPI+1.5.0%29\n", + "Service Provider TRAPI\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AService+Provider+TRAPI%29\n", + "Shepherd SIPR\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd+SIPR%29\n", + "BioThings Explorer (BTE) TRAPI\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ABioThings+Explorer+(BTE)+TRAPI%29\n", + "Multiomics KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AMultiomics+KP+TRAPI+1.5.0%29\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACATRAX+Pharmacogenomics+KP+TRAPI+1.5.0%29\n", + "COHD TRAPI\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACOHD+TRAPI%29\n", + "Text Mined Cooccurrence API\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AText+Mined+Cooccurrence+API%29\n", + "imProving Agent for TRAPI 1.5\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AimProving+Agent+for+TRAPI+1.5%29\n", + "Connections Hypothesis Provider API\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AConnections+Hypothesis+Provider+API%29\n", + "OpenPredict API\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AOpenPredict+API%29\n", + "Gene-List Network Enrichment Analysis\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AGene-List+Network+Enrichment+Analysis%29\n", + "MolePro\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AMolePro%29\n", + "Retriever\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ARetriever%29\n", + "Sri-node-normalizer(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASri-node-normalizer%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-gtopdb(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-gtopdb%5C%28Trapi+v1.5.0%5C%29%29\n", + "Knowledge Collaboratory API\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AKnowledge+Collaboratory+API%29\n", + "SPOKE KP for TRAPI 1.5\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASPOKE+KP+for+TRAPI+1.5%29\n", + "Clinical Trials KP - TRAPI 1.5.0\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AClinical+Trials+KP+TRAPI+1.5.0%29\n", + "Automat-ubergraph(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-ubergraph%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-drug-central(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-drug-central%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-human-goa(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-human-goa%5C%28Trapi+v1.5.0%5C%29%29\n", + "Cqs(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACqs%5C%28Trapi+v1.5.0%5C%29%29\n", + "Shepherd-aragorn(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-aragorn%5C%28Trapi+v1.5.0%5C%29%29\n", + "Shepherd-arax(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-arax%5C%28Trapi+v1.5.0%5C%29%29\n", + "Aragorn(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAragorn%5C%28Trapi+v1.5.0%5C%29%29\n", + "Answer-coalesce(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAnswer-coalesce%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-reactome(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-reactome%5C%28Trapi+v1.5.0%5C%29%29\n", + "Autonomous Relay System (ARS) TRAPI\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutonomous+Relay+System+(ARS)+TRAPI%29\n", + "Automat-viral-proteome(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-viral-proteome%5C%28Trapi+v1.5.0%5C%29%29\n", + "Shepherd-bte(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-bte%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-ctd(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-ctd%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-icees-kg(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-icees-kg%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-hetionet(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-hetionet%5C%28Trapi+v1.5.0%5C%29%29\n", + "Workflow-runner(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AWorkflow-runner%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-ehr-may-treat-kp(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-ehr-may-treat-kp%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-intact(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-intact%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-pharos(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-pharos%5C%28Trapi+v1.5.0%5C%29%29\n", + "Aragorn(Trapi v1.6.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAragorn(Trapi+v1.6.0)%29\n", + "Automat-genome-alliance(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-genome-alliance%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-hmdb(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-hmdb%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-binding-db(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-binding-db%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-string-db(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-string-db%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-gtex(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-gtex%5C%28Trapi+v1.5.0%5C%29%29\n", + "Automat-panther(Trapi v1.5.0)\n", + "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-panther%5C%28Trapi+v1.5.0%5C%29%29\n" ] } ], "source": [ - "APInames, metaKG, Translator_KP_info= translator_metakg.load_translator_resources()\n" + "APInames_old, metaKG_old, Translator_KP_info_old = translator_metakg.load_translator_resources(use_new_metakg_url=False)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d6de83ff-b242-41c3-a252-c7b848df59c2", + "metadata": {}, + "outputs": [], + "source": [ + "metaKG_old" ] }, { From 3cb26e83146ba669202aa8f082c3d0feca35cea5 Mon Sep 17 00:00:00 2001 From: Yue Zhang Date: Wed, 3 Jun 2026 15:00:20 -0700 Subject: [PATCH 21/33] using new metaKG URL --- TCT/translator_metakg.py | 11 +- notebooks/metakg_tests.ipynb | 607 ++++++++++++++++------------------- uv.lock | 128 ++++++++ 3 files changed, 415 insertions(+), 331 deletions(-) diff --git a/TCT/translator_metakg.py b/TCT/translator_metakg.py index cb1661d..7cf9c53 100644 --- a/TCT/translator_metakg.py +++ b/TCT/translator_metakg.py @@ -5,7 +5,6 @@ def find_link(name, use_new_url=True): #pre = "https://dev.smart-api.info/api/metakg/consolidated?size=2000&q=%28api.x-translator.component%3AKP+AND+api.name%3A" # This works for the previous version - print(name) if use_new_url: pre = "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:" end = ")&facet_size=300&aggs=object.raw,subject.raw" @@ -39,7 +38,6 @@ def find_link(name, use_new_url=True): url += end else: url = url+"%29" - print(url) return url @@ -80,8 +78,13 @@ def get_KP_metadata(APInames:dict[str, str], use_new_url=True) -> pd.DataFrame: text = requests.get(find_link(KP, use_new_url=use_new_url)).text json_text = json.loads(text) if 'hits' not in json_text: - text = requests.get(find_link(KP, use_new_url=False)).text - json_text = json.loads(text) + if use_new_url: + print(KP, '- no hits found in new metakg URL, trying old URL pattern') + text = requests.get(find_link(KP, use_new_url=False)).text + json_text = json.loads(text) + else: + print(KP, '- no hits found') + continue for i in (json_text['hits']): Predicate_list.append("biolink:"+i['_id'].split("-")[1]) API_list.append(KP) diff --git a/notebooks/metakg_tests.ipynb b/notebooks/metakg_tests.ipynb index 9d5b966..d038351 100644 --- a/notebooks/metakg_tests.ipynb +++ b/notebooks/metakg_tests.ipynb @@ -37,158 +37,25 @@ "Skipping server without x-maturity: {'url': '/sipr'}\n", "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", - "ARAX Translator Reasoner - TRAPI 1.6.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:ARAX+Translator+Reasoner+TRAPI+1.6.0)&facet_size=300&aggs=object.raw,subject.raw\n", - "Genetics Data Provider for NCATS Biomedical Translator Reasoners\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Genetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners)&facet_size=300&aggs=object.raw,subject.raw\n", - "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:CATRAX+BigGIM+DrugResponse+Performance+Phase+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", - "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACATRAX+BigGIM+DrugResponse+Performance+Phase+KP+TRAPI+1.5.0%29\n", - "Microbiome KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Microbiome+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", - "mediKanren\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:mediKanren)&facet_size=300&aggs=object.raw,subject.raw\n", - "mediKanren\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AmediKanren%29\n", - "Drug Approvals KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Drug+Approvals+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", - "Service Provider TRAPI\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Service+Provider+TRAPI)&facet_size=300&aggs=object.raw,subject.raw\n", - "Shepherd SIPR\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd+SIPR)&facet_size=300&aggs=object.raw,subject.raw\n", - "Shepherd SIPR\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd+SIPR%29\n", - "BioThings Explorer (BTE) TRAPI\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:BioThings+Explorer+(BTE)+TRAPI)&facet_size=300&aggs=object.raw,subject.raw\n", - "Multiomics KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Multiomics+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", - "CATRAX Pharmacogenomics KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:CATRAX+Pharmacogenomics+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", - "CATRAX Pharmacogenomics KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACATRAX+Pharmacogenomics+KP+TRAPI+1.5.0%29\n", - "COHD TRAPI\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:COHD+TRAPI)&facet_size=300&aggs=object.raw,subject.raw\n", - "Text Mined Cooccurrence API\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Text+Mined+Cooccurrence+API)&facet_size=300&aggs=object.raw,subject.raw\n", - "imProving Agent for TRAPI 1.5\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:imProving+Agent+for+TRAPI+1.5)&facet_size=300&aggs=object.raw,subject.raw\n", - "imProving Agent for TRAPI 1.5\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AimProving+Agent+for+TRAPI+1.5%29\n", - "Connections Hypothesis Provider API\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Connections+Hypothesis+Provider+API)&facet_size=300&aggs=object.raw,subject.raw\n", - "OpenPredict API\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:OpenPredict+API)&facet_size=300&aggs=object.raw,subject.raw\n", - "OpenPredict API\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AOpenPredict+API%29\n", - "Gene-List Network Enrichment Analysis\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Gene-List+Network+Enrichment+Analysis)&facet_size=300&aggs=object.raw,subject.raw\n", - "MolePro\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:MolePro)&facet_size=300&aggs=object.raw,subject.raw\n", - "Retriever\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Retriever)&facet_size=300&aggs=object.raw,subject.raw\n", - "Sri-node-normalizer(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Sri-node-normalizer)&facet_size=300&aggs=object.raw,subject.raw\n", - "Sri-node-normalizer(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASri-node-normalizer%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-gtopdb(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-gtopdb)&facet_size=300&aggs=object.raw,subject.raw\n", - "Knowledge Collaboratory API\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Knowledge+Collaboratory+API)&facet_size=300&aggs=object.raw,subject.raw\n", - "Knowledge Collaboratory API\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AKnowledge+Collaboratory+API%29\n", - "SPOKE KP for TRAPI 1.5\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:SPOKE+KP+for+TRAPI+1.5)&facet_size=300&aggs=object.raw,subject.raw\n", - "SPOKE KP for TRAPI 1.5\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASPOKE+KP+for+TRAPI+1.5%29\n", - "Clinical Trials KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Clinical+Trials+KP+TRAPI+1.5.0)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-ubergraph(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ubergraph)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-drug-central(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-drug-central)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-human-goa(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-human-goa)&facet_size=300&aggs=object.raw,subject.raw\n", - "Cqs(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Cqs)&facet_size=300&aggs=object.raw,subject.raw\n", - "Cqs(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACqs%5C%28Trapi+v1.5.0%5C%29%29\n", - "Shepherd-aragorn(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd-aragorn)&facet_size=300&aggs=object.raw,subject.raw\n", - "Shepherd-aragorn(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-aragorn%5C%28Trapi+v1.5.0%5C%29%29\n", - "Shepherd-arax(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd-arax)&facet_size=300&aggs=object.raw,subject.raw\n", - "Shepherd-arax(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-arax%5C%28Trapi+v1.5.0%5C%29%29\n", - "Aragorn(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Aragorn)&facet_size=300&aggs=object.raw,subject.raw\n", - "Aragorn(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAragorn%5C%28Trapi+v1.5.0%5C%29%29\n", - "Answer-coalesce(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Answer-coalesce)&facet_size=300&aggs=object.raw,subject.raw\n", - "Answer-coalesce(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAnswer-coalesce%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-reactome(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-reactome)&facet_size=300&aggs=object.raw,subject.raw\n", - "Autonomous Relay System (ARS) TRAPI\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Autonomous+Relay+System+(ARS)+TRAPI)&facet_size=300&aggs=object.raw,subject.raw\n", - "Autonomous Relay System (ARS) TRAPI\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutonomous+Relay+System+(ARS)+TRAPI%29\n", - "Automat-viral-proteome(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-viral-proteome)&facet_size=300&aggs=object.raw,subject.raw\n", - "Shepherd-bte(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Shepherd-bte)&facet_size=300&aggs=object.raw,subject.raw\n", - "Shepherd-bte(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-bte%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-ctd(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ctd)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-icees-kg(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-icees-kg)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-hetionet(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-hetionet)&facet_size=300&aggs=object.raw,subject.raw\n", - "Workflow-runner(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Workflow-runner)&facet_size=300&aggs=object.raw,subject.raw\n", - "Workflow-runner(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AWorkflow-runner%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-ehr-may-treat-kp(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ehr-may-treat-kp)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-intact(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-intact)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-pharos(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-pharos)&facet_size=300&aggs=object.raw,subject.raw\n", - "Aragorn(Trapi v1.6.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Aragorn(Trapi+v1.6.0))&facet_size=300&aggs=object.raw,subject.raw\n", - "Aragorn(Trapi v1.6.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAragorn(Trapi+v1.6.0)%29\n", - "Automat-genome-alliance(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-genome-alliance)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-hmdb(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-hmdb)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-binding-db(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-binding-db)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-string-db(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-string-db)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-gtex(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-gtex)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-panther(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-panther)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-monarchinitiative(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-monarchinitiative)&facet_size=300&aggs=object.raw,subject.raw\n", - "Sri-answer-appraiser(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Sri-answer-appraiser)&facet_size=300&aggs=object.raw,subject.raw\n", - "Sri-answer-appraiser(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASri-answer-appraiser%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-robokop(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-robokop)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-cam-kp(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-cam-kp)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-hgnc(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-hgnc)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-gwas-catalog(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-gwas-catalog)&facet_size=300&aggs=object.raw,subject.raw\n", - "Automat-ehr-clinical-connections-kp(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg?size=5000&q=(api.x-translator.component:KP+AND+api.name:Automat-ehr-clinical-connections-kp)&facet_size=300&aggs=object.raw,subject.raw\n" + "imProving Agent for TRAPI 1.5 - no hits found in new metakg URL, trying old URL pattern\n", + "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0 - no hits found in new metakg URL, trying old URL pattern\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0 - no hits found in new metakg URL, trying old URL pattern\n", + "OpenPredict API - no hits found in new metakg URL, trying old URL pattern\n", + "mediKanren - no hits found in new metakg URL, trying old URL pattern\n", + "Knowledge Collaboratory API - no hits found in new metakg URL, trying old URL pattern\n", + "Sri-node-normalizer(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "Shepherd SIPR - no hits found in new metakg URL, trying old URL pattern\n", + "Cqs(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "Aragorn(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "Shepherd-arax(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "Answer-coalesce(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "Shepherd-aragorn(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "Autonomous Relay System (ARS) TRAPI - no hits found in new metakg URL, trying old URL pattern\n", + "Shepherd-bte(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "SPOKE KP for TRAPI 1.5 - no hits found in new metakg URL, trying old URL pattern\n", + "Workflow-runner(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "Sri-answer-appraiser(Trapi v1.5.0) - no hits found in new metakg URL, trying old URL pattern\n", + "Aragorn(Trapi v1.6.0) - no hits found in new metakg URL, trying old URL pattern\n" ] } ], @@ -233,43 +100,43 @@ " \n", " \n", " 0\n", - " ARAX Translator Reasoner - TRAPI 1.6.0\n", - " biolink:diagnoses\n", - " biolink:SmallMolecule\n", - " biolink:PhenotypicFeature\n", - " https://arax.transltr.io/api/arax/v1.4/query/\n", + " Genetics Data Provider for NCATS Biomedical Tr...\n", + " biolink:genetic_association\n", + " biolink:Disease\n", + " biolink:Cell\n", + " https://genetics-kp.transltr.io/genetics_provi...\n", " \n", " \n", " 1\n", - " ARAX Translator Reasoner - TRAPI 1.6.0\n", - " biolink:derives_from\n", - " biolink:MolecularMixture\n", - " biolink:MolecularMixture\n", - " https://arax.transltr.io/api/arax/v1.4/query/\n", + " Genetics Data Provider for NCATS Biomedical Tr...\n", + " biolink:genetic_association\n", + " biolink:Cell\n", + " biolink:Disease\n", + " https://genetics-kp.transltr.io/genetics_provi...\n", " \n", " \n", " 2\n", - " ARAX Translator Reasoner - TRAPI 1.6.0\n", - " biolink:disrupts\n", - " biolink:ChemicalEntity\n", - " biolink:Gene\n", - " https://arax.transltr.io/api/arax/v1.4/query/\n", + " Genetics Data Provider for NCATS Biomedical Tr...\n", + " biolink:genetic_association\n", + " biolink:Cell\n", + " biolink:PhenotypicFeature\n", + " https://genetics-kp.transltr.io/genetics_provi...\n", " \n", " \n", " 3\n", - " ARAX Translator Reasoner - TRAPI 1.6.0\n", - " biolink:same_as\n", - " biolink:ChemicalEntity\n", - " biolink:Protein\n", - " https://arax.transltr.io/api/arax/v1.4/query/\n", + " Genetics Data Provider for NCATS Biomedical Tr...\n", + " biolink:genetic_association\n", + " biolink:PhenotypicFeature\n", + " biolink:Cell\n", + " https://genetics-kp.transltr.io/genetics_provi...\n", " \n", " \n", " 4\n", - " ARAX Translator Reasoner - TRAPI 1.6.0\n", - " biolink:affects\n", - " biolink:Cell\n", - " biolink:Gene\n", - " https://arax.transltr.io/api/arax/v1.4/query/\n", + " Genetics Data Provider for NCATS Biomedical Tr...\n", + " biolink:genetic_association\n", + " biolink:Disease\n", + " biolink:Pathway\n", + " https://genetics-kp.transltr.io/genetics_provi...\n", " \n", " \n", " ...\n", @@ -325,44 +192,57 @@ "" ], "text/plain": [ - " API Predicate \\\n", - "0 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:diagnoses \n", - "1 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:derives_from \n", - "2 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:disrupts \n", - "3 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:same_as \n", - "4 ARAX Translator Reasoner - TRAPI 1.6.0 biolink:affects \n", - "... ... ... \n", - "31140 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", - "31141 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", - "31142 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", - "31143 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", - "31144 RTX KG2 - TRAPI 1.5.0 biolink:applied_to_treat \n", + " API \\\n", + "0 Genetics Data Provider for NCATS Biomedical Tr... \n", + "1 Genetics Data Provider for NCATS Biomedical Tr... \n", + "2 Genetics Data Provider for NCATS Biomedical Tr... \n", + "3 Genetics Data Provider for NCATS Biomedical Tr... \n", + "4 Genetics Data Provider for NCATS Biomedical Tr... \n", + "... ... \n", + "31140 RTX KG2 - TRAPI 1.5.0 \n", + "31141 RTX KG2 - TRAPI 1.5.0 \n", + "31142 RTX KG2 - TRAPI 1.5.0 \n", + "31143 RTX KG2 - TRAPI 1.5.0 \n", + "31144 RTX KG2 - TRAPI 1.5.0 \n", + "\n", + " Predicate Subject \\\n", + "0 biolink:genetic_association biolink:Disease \n", + "1 biolink:genetic_association biolink:Cell \n", + "2 biolink:genetic_association biolink:Cell \n", + "3 biolink:genetic_association biolink:PhenotypicFeature \n", + "4 biolink:genetic_association biolink:Disease \n", + "... ... ... \n", + "31140 biolink:applied_to_treat biolink:NamedThing \n", + "31141 biolink:applied_to_treat biolink:NamedThing \n", + "31142 biolink:applied_to_treat biolink:NamedThing \n", + "31143 biolink:applied_to_treat biolink:ChemicalEntity \n", + "31144 biolink:applied_to_treat biolink:MolecularMixture \n", "\n", - " Subject Object \\\n", - "0 biolink:SmallMolecule biolink:PhenotypicFeature \n", - "1 biolink:MolecularMixture biolink:MolecularMixture \n", - "2 biolink:ChemicalEntity biolink:Gene \n", - "3 biolink:ChemicalEntity biolink:Protein \n", - "4 biolink:Cell biolink:Gene \n", - "... ... ... \n", - "31140 biolink:NamedThing biolink:Disease \n", - "31141 biolink:NamedThing biolink:PhenotypicFeature \n", - "31142 biolink:NamedThing biolink:BehavioralFeature \n", - "31143 biolink:ChemicalEntity biolink:BehavioralFeature \n", - "31144 biolink:MolecularMixture biolink:BehavioralFeature \n", + " Object \\\n", + "0 biolink:Cell \n", + "1 biolink:Disease \n", + "2 biolink:PhenotypicFeature \n", + "3 biolink:Cell \n", + "4 biolink:Pathway \n", + "... ... \n", + "31140 biolink:Disease \n", + "31141 biolink:PhenotypicFeature \n", + "31142 biolink:BehavioralFeature \n", + "31143 biolink:BehavioralFeature \n", + "31144 biolink:BehavioralFeature \n", "\n", - " URL \n", - "0 https://arax.transltr.io/api/arax/v1.4/query/ \n", - "1 https://arax.transltr.io/api/arax/v1.4/query/ \n", - "2 https://arax.transltr.io/api/arax/v1.4/query/ \n", - "3 https://arax.transltr.io/api/arax/v1.4/query/ \n", - "4 https://arax.transltr.io/api/arax/v1.4/query/ \n", - "... ... \n", - "31140 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", - "31141 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", - "31142 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", - "31143 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", - "31144 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + " URL \n", + "0 https://genetics-kp.transltr.io/genetics_provi... \n", + "1 https://genetics-kp.transltr.io/genetics_provi... \n", + "2 https://genetics-kp.transltr.io/genetics_provi... \n", + "3 https://genetics-kp.transltr.io/genetics_provi... \n", + "4 https://genetics-kp.transltr.io/genetics_provi... \n", + "... ... \n", + "31140 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31141 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31142 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31143 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31144 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", "\n", "[31145 rows x 5 columns]" ] @@ -378,7 +258,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "463c2b19-64b8-45b7-af78-957176f5d5fd", "metadata": { "scrolled": true @@ -390,107 +270,7 @@ "text": [ "Skipping server without x-maturity: {'url': '/sipr'}\n", "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", - "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", - "ARAX Translator Reasoner - TRAPI 1.6.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AARAX+Translator+Reasoner+TRAPI+1.6.0%29\n", - "Genetics Data Provider for NCATS Biomedical Translator Reasoners\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AGenetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners%29\n", - "CATRAX BigGIM DrugResponse Performance Phase KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACATRAX+BigGIM+DrugResponse+Performance+Phase+KP+TRAPI+1.5.0%29\n", - "Microbiome KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AMicrobiome+KP+TRAPI+1.5.0%29\n", - "mediKanren\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AmediKanren%29\n", - "Drug Approvals KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ADrug+Approvals+KP+TRAPI+1.5.0%29\n", - "Service Provider TRAPI\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AService+Provider+TRAPI%29\n", - "Shepherd SIPR\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd+SIPR%29\n", - "BioThings Explorer (BTE) TRAPI\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ABioThings+Explorer+(BTE)+TRAPI%29\n", - "Multiomics KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AMultiomics+KP+TRAPI+1.5.0%29\n", - "CATRAX Pharmacogenomics KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACATRAX+Pharmacogenomics+KP+TRAPI+1.5.0%29\n", - "COHD TRAPI\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACOHD+TRAPI%29\n", - "Text Mined Cooccurrence API\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AText+Mined+Cooccurrence+API%29\n", - "imProving Agent for TRAPI 1.5\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AimProving+Agent+for+TRAPI+1.5%29\n", - "Connections Hypothesis Provider API\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AConnections+Hypothesis+Provider+API%29\n", - "OpenPredict API\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AOpenPredict+API%29\n", - "Gene-List Network Enrichment Analysis\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AGene-List+Network+Enrichment+Analysis%29\n", - "MolePro\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AMolePro%29\n", - "Retriever\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ARetriever%29\n", - "Sri-node-normalizer(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASri-node-normalizer%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-gtopdb(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-gtopdb%5C%28Trapi+v1.5.0%5C%29%29\n", - "Knowledge Collaboratory API\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AKnowledge+Collaboratory+API%29\n", - "SPOKE KP for TRAPI 1.5\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ASPOKE+KP+for+TRAPI+1.5%29\n", - "Clinical Trials KP - TRAPI 1.5.0\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AClinical+Trials+KP+TRAPI+1.5.0%29\n", - "Automat-ubergraph(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-ubergraph%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-drug-central(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-drug-central%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-human-goa(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-human-goa%5C%28Trapi+v1.5.0%5C%29%29\n", - "Cqs(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3ACqs%5C%28Trapi+v1.5.0%5C%29%29\n", - "Shepherd-aragorn(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-aragorn%5C%28Trapi+v1.5.0%5C%29%29\n", - "Shepherd-arax(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-arax%5C%28Trapi+v1.5.0%5C%29%29\n", - "Aragorn(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAragorn%5C%28Trapi+v1.5.0%5C%29%29\n", - "Answer-coalesce(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAnswer-coalesce%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-reactome(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-reactome%5C%28Trapi+v1.5.0%5C%29%29\n", - "Autonomous Relay System (ARS) TRAPI\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutonomous+Relay+System+(ARS)+TRAPI%29\n", - "Automat-viral-proteome(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-viral-proteome%5C%28Trapi+v1.5.0%5C%29%29\n", - "Shepherd-bte(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AShepherd-bte%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-ctd(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-ctd%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-icees-kg(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-icees-kg%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-hetionet(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-hetionet%5C%28Trapi+v1.5.0%5C%29%29\n", - "Workflow-runner(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AWorkflow-runner%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-ehr-may-treat-kp(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-ehr-may-treat-kp%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-intact(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-intact%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-pharos(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-pharos%5C%28Trapi+v1.5.0%5C%29%29\n", - "Aragorn(Trapi v1.6.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAragorn(Trapi+v1.6.0)%29\n", - "Automat-genome-alliance(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-genome-alliance%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-hmdb(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-hmdb%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-binding-db(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-binding-db%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-string-db(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-string-db%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-gtex(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-gtex%5C%28Trapi+v1.5.0%5C%29%29\n", - "Automat-panther(Trapi v1.5.0)\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-panther%5C%28Trapi+v1.5.0%5C%29%29\n" + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n" ] } ], @@ -500,23 +280,196 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "d6de83ff-b242-41c3-a252-c7b848df59c2", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
APIPredicateSubjectObjectURL
0Genetics Data Provider for NCATS Biomedical Tr...biolink:genetic_associationbiolink:Diseasebiolink:Cellhttps://genetics-kp.transltr.io/genetics_provi...
1Genetics Data Provider for NCATS Biomedical Tr...biolink:genetic_associationbiolink:Cellbiolink:Diseasehttps://genetics-kp.transltr.io/genetics_provi...
2Genetics Data Provider for NCATS Biomedical Tr...biolink:genetic_associationbiolink:Cellbiolink:PhenotypicFeaturehttps://genetics-kp.transltr.io/genetics_provi...
3Genetics Data Provider for NCATS Biomedical Tr...biolink:genetic_associationbiolink:PhenotypicFeaturebiolink:Cellhttps://genetics-kp.transltr.io/genetics_provi...
4Genetics Data Provider for NCATS Biomedical Tr...biolink:genetic_associationbiolink:Diseasebiolink:Pathwayhttps://genetics-kp.transltr.io/genetics_provi...
..................
31140RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:NamedThingbiolink:Diseasehttps://kg2cploverdb.ci.transltr.io/kg2c/query
31141RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:NamedThingbiolink:PhenotypicFeaturehttps://kg2cploverdb.ci.transltr.io/kg2c/query
31142RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:NamedThingbiolink:BehavioralFeaturehttps://kg2cploverdb.ci.transltr.io/kg2c/query
31143RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:ChemicalEntitybiolink:BehavioralFeaturehttps://kg2cploverdb.ci.transltr.io/kg2c/query
31144RTX KG2 - TRAPI 1.5.0biolink:applied_to_treatbiolink:MolecularMixturebiolink:BehavioralFeaturehttps://kg2cploverdb.ci.transltr.io/kg2c/query
\n", + "

31145 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " API \\\n", + "0 Genetics Data Provider for NCATS Biomedical Tr... \n", + "1 Genetics Data Provider for NCATS Biomedical Tr... \n", + "2 Genetics Data Provider for NCATS Biomedical Tr... \n", + "3 Genetics Data Provider for NCATS Biomedical Tr... \n", + "4 Genetics Data Provider for NCATS Biomedical Tr... \n", + "... ... \n", + "31140 RTX KG2 - TRAPI 1.5.0 \n", + "31141 RTX KG2 - TRAPI 1.5.0 \n", + "31142 RTX KG2 - TRAPI 1.5.0 \n", + "31143 RTX KG2 - TRAPI 1.5.0 \n", + "31144 RTX KG2 - TRAPI 1.5.0 \n", + "\n", + " Predicate Subject \\\n", + "0 biolink:genetic_association biolink:Disease \n", + "1 biolink:genetic_association biolink:Cell \n", + "2 biolink:genetic_association biolink:Cell \n", + "3 biolink:genetic_association biolink:PhenotypicFeature \n", + "4 biolink:genetic_association biolink:Disease \n", + "... ... ... \n", + "31140 biolink:applied_to_treat biolink:NamedThing \n", + "31141 biolink:applied_to_treat biolink:NamedThing \n", + "31142 biolink:applied_to_treat biolink:NamedThing \n", + "31143 biolink:applied_to_treat biolink:ChemicalEntity \n", + "31144 biolink:applied_to_treat biolink:MolecularMixture \n", + "\n", + " Object \\\n", + "0 biolink:Cell \n", + "1 biolink:Disease \n", + "2 biolink:PhenotypicFeature \n", + "3 biolink:Cell \n", + "4 biolink:Pathway \n", + "... ... \n", + "31140 biolink:Disease \n", + "31141 biolink:PhenotypicFeature \n", + "31142 biolink:BehavioralFeature \n", + "31143 biolink:BehavioralFeature \n", + "31144 biolink:BehavioralFeature \n", + "\n", + " URL \n", + "0 https://genetics-kp.transltr.io/genetics_provi... \n", + "1 https://genetics-kp.transltr.io/genetics_provi... \n", + "2 https://genetics-kp.transltr.io/genetics_provi... \n", + "3 https://genetics-kp.transltr.io/genetics_provi... \n", + "4 https://genetics-kp.transltr.io/genetics_provi... \n", + "... ... \n", + "31140 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31141 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31142 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31143 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "31144 https://kg2cploverdb.ci.transltr.io/kg2c/query \n", + "\n", + "[31145 rows x 5 columns]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "metaKG_old" ] - }, - { - "cell_type": "raw", - "id": "e9cf0d27-76a0-43ee-ae6c-9b7774a85f18", - "metadata": {}, - "source": [ - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AGenetics+Data+Provider+for+NCATS+Biomedical+Translator+Reasoners%29\n", - "\n", - "https://smart-api.info/api/metakg/consolidated?size=5000&q=%28api.x-translator.component%3AKP+AND+api.name%3AAutomat-ehr-clinical-connections-kp%5C%28Trapi+v1.5.0%5C%29%29" - ] } ], "metadata": { diff --git a/uv.lock b/uv.lock index 507211d..3f4c7e0 100644 --- a/uv.lock +++ b/uv.lock @@ -795,6 +795,31 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442, upload-time = "2024-09-15T18:07:37.964Z" }, ] +[[package]] +name = "igraph" +version = "1.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "texttable" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/23/be/56bef1919005b4caf1f71522b300d359f7faeb7ae93a3b0baa9b4f146a87/igraph-1.0.0.tar.gz", hash = "sha256:2414d0be2e4d77ee5357807d100974b40f6082bb1bb71988ec46cfb6728651ee", size = 5077105, upload-time = "2025-10-23T12:22:50.127Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a5/03/3278ad0ceb3ea0e84d8ae3a85bdded4d0e57853aeb802a200feb43847b93/igraph-1.0.0-cp39-abi3-macosx_10_15_x86_64.whl", hash = "sha256:c2cbc415e02523e5a241eecee82319080bf928a70b1ba299f3b3e25bf029b6d4", size = 2257415, upload-time = "2025-10-23T12:22:27.246Z" }, + { url = "https://files.pythonhosted.org/packages/0d/bc/6281ec7f9baaf71ee57c3b1748da2d3148d15d253e1a03006f204aa68ca5/igraph-1.0.0-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:1a27753cd80680a8f676c2d5a467aaa4a95e510b30748398ec4e4aeb982130e8", size = 2048555, upload-time = "2025-10-23T12:22:29.49Z" }, + { url = "https://files.pythonhosted.org/packages/2a/38/3cd6428a4ed4c09a56df05998438e7774fd1d799ee4fb8fc481674f5f7fc/igraph-1.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:a55dc3a2a4e3fc3eba42479910c1511bfc3ecb33cdf5f0406891fd85f14b5aee", size = 5314141, upload-time = "2025-10-23T12:22:31.023Z" }, + { url = "https://files.pythonhosted.org/packages/7d/da/dd2867c25adbb41563720f14b5fc895c98bf88be682a3faff4f7b3118d2a/igraph-1.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:2d04c2c76f686fb1f554ee35dfd3085f5e73b7965ba6b4cf06d53e66b1955522", size = 5683134, upload-time = "2025-10-23T12:22:32.423Z" }, + { url = "https://files.pythonhosted.org/packages/e5/40/243c118d34ab80382d7009c4dcb99b887384c3d2ce84d29eeac19e2a007a/igraph-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:f2b52dc1757fff0fed29a9f7a276d971a11db4211569ed78b9eab36288dfcc9d", size = 6211583, upload-time = "2025-10-23T12:22:34.238Z" }, + { url = "https://files.pythonhosted.org/packages/1d/b7/88f433819c54b496cb0315fce28e658970cb20ff5dbd52a5a605ce2888de/igraph-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:05c79a2a8fca695b2f217a6fa7f2549f896f757d4db41be32a055400cb19cc30", size = 6594509, upload-time = "2025-10-23T12:22:35.831Z" }, + { url = "https://files.pythonhosted.org/packages/7b/5d/8f7f6f619d374e959aa3664ebc4b24c10abc90c2e8efbed97f2623fadaf5/igraph-1.0.0-cp39-abi3-win32.whl", hash = "sha256:c2bce3cd472fec3dd9c4d8a3ea5b6b9be65fb30edf760beb4850760dd4f2d479", size = 2725406, upload-time = "2025-10-23T12:22:37.588Z" }, + { url = "https://files.pythonhosted.org/packages/af/77/a85b3745cf40a0572bae2de8cd9c2a2a8af78e5cf3e880fc0a249114e609/igraph-1.0.0-cp39-abi3-win_amd64.whl", hash = "sha256:faeff8ede0cf15eb4ded44b0fcea6e1886740146e60504c24ad2da14e0939563", size = 3221663, upload-time = "2025-10-23T12:22:39.404Z" }, + { url = "https://files.pythonhosted.org/packages/ef/7e/5df541c37bdf6493035e89c22bd53f30d99b291bcda6c78e9a8afeecec2b/igraph-1.0.0-cp39-abi3-win_arm64.whl", hash = "sha256:b607cafc24b10a615e713ee96e58208ef27e0764af80140c7cc45d4724a3f2df", size = 2785701, upload-time = "2025-10-23T12:22:41.03Z" }, + { url = "https://files.pythonhosted.org/packages/b9/73/bf1d4dbbc9123435b3ca14bb608b243a50a4f158ecea564bf196715248d9/igraph-1.0.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:3189c1a8e8a8f58009f3f729040eb3701254d074ed37245691d529869ec940c5", size = 2246636, upload-time = "2025-10-23T12:22:42.314Z" }, + { url = "https://files.pythonhosted.org/packages/59/ac/28482f2af45cc0a0ca88a69d17a6ea694f58bdbd22cc876e7273a0379282/igraph-1.0.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:ebe9502689b946301584b3cfacdbc70c58c4d664d804e39b6daa31be5c20bf46", size = 2036101, upload-time = "2025-10-23T12:22:43.957Z" }, + { url = "https://files.pythonhosted.org/packages/56/80/806a093df1d1ddc3b30d0418b1ee56388ae7018f8ae288677ee2b3a1abaf/igraph-1.0.0-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:f117683108c54330d6dc67a708e3724c13c9989885122a29781296872989a222", size = 3053403, upload-time = "2025-10-23T12:22:45.573Z" }, + { url = "https://files.pythonhosted.org/packages/56/bf/cf7aeff230a4368c0b8bc6b02f3ea27db41db33714b51e1e8a7c1458f31b/igraph-1.0.0-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:077dbff0edb8b4ce0f9fefdf325200346d9d5db02de31872b41743de08e67a16", size = 3262472, upload-time = "2025-10-23T12:22:47.248Z" }, + { url = "https://files.pythonhosted.org/packages/d8/ca/dbc06072d5eea402a6dc81f387afb1b7e0c415f1d8a75232943fc4d1bfdb/igraph-1.0.0-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:fe7c693b2a84a4e03ca31e65aa05a2ecd8728137fa9909ccbf6453b4200b856d", size = 3218861, upload-time = "2025-10-23T12:22:48.46Z" }, +] + [[package]] name = "iniconfig" version = "2.1.0" @@ -2764,6 +2789,7 @@ source = { editable = "." } dependencies = [ { name = "click" }, { name = "fastmcp" }, + { name = "igraph" }, { name = "ipycytoscape" }, { name = "ipykernel" }, { name = "jsons" }, @@ -2777,6 +2803,7 @@ dependencies = [ { name = "pyvis" }, { name = "requests" }, { name = "seaborn" }, + { name = "zstandard" }, ] [package.dev-dependencies] @@ -2792,6 +2819,7 @@ dev = [ requires-dist = [ { name = "click", specifier = ">=8.2.1" }, { name = "fastmcp", specifier = ">=2.12.2" }, + { name = "igraph" }, { name = "ipycytoscape" }, { name = "ipykernel" }, { name = "jsons" }, @@ -2803,6 +2831,7 @@ requires-dist = [ { name = "pyvis" }, { name = "requests" }, { name = "seaborn" }, + { name = "zstandard" }, ] [package.metadata.requires-dev] @@ -2814,6 +2843,15 @@ dev = [ { name = "ruff", specifier = ">=0.1.0" }, ] +[[package]] +name = "texttable" +version = "1.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1c/dc/0aff23d6036a4d3bf4f1d8c8204c5c79c4437e25e0ae94ffe4bbb55ee3c2/texttable-1.7.0.tar.gz", hash = "sha256:2d2068fb55115807d3ac77a4ca68fa48803e84ebb0ee2340f858107a36522638", size = 12831, upload-time = "2023-10-03T09:48:12.272Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/24/99/4772b8e00a136f3e01236de33b0efda31ee7077203ba5967fcc76da94d65/texttable-1.7.0-py2.py3-none-any.whl", hash = "sha256:72227d592c82b3d7f672731ae73e4d1f88cd8e2ef5b075a7a7f01a23a3743917", size = 10768, upload-time = "2023-10-03T09:48:10.434Z" }, +] + [[package]] name = "tomli" version = "2.2.1" @@ -2983,3 +3021,93 @@ sdist = { url = "https://files.pythonhosted.org/packages/41/53/2e0253c5efd69c965 wheels = [ { url = "https://files.pythonhosted.org/packages/ca/51/5447876806d1088a0f8f71e16542bf350918128d0a69437df26047c8e46f/widgetsnbextension-4.0.14-py3-none-any.whl", hash = "sha256:4875a9eaf72fbf5079dc372a51a9f268fc38d46f767cbf85c43a36da5cb9b575", size = 2196503, upload-time = "2025-04-10T13:01:23.086Z" }, ] + +[[package]] +name = "zstandard" +version = "0.25.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fd/aa/3e0508d5a5dd96529cdc5a97011299056e14c6505b678fd58938792794b1/zstandard-0.25.0.tar.gz", hash = "sha256:7713e1179d162cf5c7906da876ec2ccb9c3a9dcbdffef0cc7f70c3667a205f0b", size = 711513, upload-time = "2025-09-14T22:15:54.002Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/56/7a/28efd1d371f1acd037ac64ed1c5e2b41514a6cc937dd6ab6a13ab9f0702f/zstandard-0.25.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e59fdc271772f6686e01e1b3b74537259800f57e24280be3f29c8a0deb1904dd", size = 795256, upload-time = "2025-09-14T22:15:56.415Z" }, + { url = "https://files.pythonhosted.org/packages/96/34/ef34ef77f1ee38fc8e4f9775217a613b452916e633c4f1d98f31db52c4a5/zstandard-0.25.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4d441506e9b372386a5271c64125f72d5df6d2a8e8a2a45a0ae09b03cb781ef7", size = 640565, upload-time = "2025-09-14T22:15:58.177Z" }, + { url = "https://files.pythonhosted.org/packages/9d/1b/4fdb2c12eb58f31f28c4d28e8dc36611dd7205df8452e63f52fb6261d13e/zstandard-0.25.0-cp310-cp310-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:ab85470ab54c2cb96e176f40342d9ed41e58ca5733be6a893b730e7af9c40550", size = 5345306, upload-time = "2025-09-14T22:16:00.165Z" }, + { url = "https://files.pythonhosted.org/packages/73/28/a44bdece01bca027b079f0e00be3b6bd89a4df180071da59a3dd7381665b/zstandard-0.25.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:e05ab82ea7753354bb054b92e2f288afb750e6b439ff6ca78af52939ebbc476d", size = 5055561, upload-time = "2025-09-14T22:16:02.22Z" }, + { url = "https://files.pythonhosted.org/packages/e9/74/68341185a4f32b274e0fc3410d5ad0750497e1acc20bd0f5b5f64ce17785/zstandard-0.25.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:78228d8a6a1c177a96b94f7e2e8d012c55f9c760761980da16ae7546a15a8e9b", size = 5402214, upload-time = "2025-09-14T22:16:04.109Z" }, + { url = "https://files.pythonhosted.org/packages/8b/67/f92e64e748fd6aaffe01e2b75a083c0c4fd27abe1c8747fee4555fcee7dd/zstandard-0.25.0-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:2b6bd67528ee8b5c5f10255735abc21aa106931f0dbaf297c7be0c886353c3d0", size = 5449703, upload-time = "2025-09-14T22:16:06.312Z" }, + { url = "https://files.pythonhosted.org/packages/fd/e5/6d36f92a197c3c17729a2125e29c169f460538a7d939a27eaaa6dcfcba8e/zstandard-0.25.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4b6d83057e713ff235a12e73916b6d356e3084fd3d14ced499d84240f3eecee0", size = 5556583, upload-time = "2025-09-14T22:16:08.457Z" }, + { url = "https://files.pythonhosted.org/packages/d7/83/41939e60d8d7ebfe2b747be022d0806953799140a702b90ffe214d557638/zstandard-0.25.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:9174f4ed06f790a6869b41cba05b43eeb9a35f8993c4422ab853b705e8112bbd", size = 5045332, upload-time = "2025-09-14T22:16:10.444Z" }, + { url = "https://files.pythonhosted.org/packages/b3/87/d3ee185e3d1aa0133399893697ae91f221fda79deb61adbe998a7235c43f/zstandard-0.25.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:25f8f3cd45087d089aef5ba3848cd9efe3ad41163d3400862fb42f81a3a46701", size = 5572283, upload-time = "2025-09-14T22:16:12.128Z" }, + { url = "https://files.pythonhosted.org/packages/0a/1d/58635ae6104df96671076ac7d4ae7816838ce7debd94aecf83e30b7121b0/zstandard-0.25.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3756b3e9da9b83da1796f8809dd57cb024f838b9eeafde28f3cb472012797ac1", size = 4959754, upload-time = "2025-09-14T22:16:14.225Z" }, + { url = "https://files.pythonhosted.org/packages/75/d6/57e9cb0a9983e9a229dd8fd2e6e96593ef2aa82a3907188436f22b111ccd/zstandard-0.25.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:81dad8d145d8fd981b2962b686b2241d3a1ea07733e76a2f15435dfb7fb60150", size = 5266477, upload-time = "2025-09-14T22:16:16.343Z" }, + { url = "https://files.pythonhosted.org/packages/d1/a9/ee891e5edf33a6ebce0a028726f0bbd8567effe20fe3d5808c42323e8542/zstandard-0.25.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:a5a419712cf88862a45a23def0ae063686db3d324cec7edbe40509d1a79a0aab", size = 5440914, upload-time = "2025-09-14T22:16:18.453Z" }, + { url = "https://files.pythonhosted.org/packages/58/08/a8522c28c08031a9521f27abc6f78dbdee7312a7463dd2cfc658b813323b/zstandard-0.25.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:e7360eae90809efd19b886e59a09dad07da4ca9ba096752e61a2e03c8aca188e", size = 5819847, upload-time = "2025-09-14T22:16:20.559Z" }, + { url = "https://files.pythonhosted.org/packages/6f/11/4c91411805c3f7b6f31c60e78ce347ca48f6f16d552fc659af6ec3b73202/zstandard-0.25.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:75ffc32a569fb049499e63ce68c743155477610532da1eb38e7f24bf7cd29e74", size = 5363131, upload-time = "2025-09-14T22:16:22.206Z" }, + { url = "https://files.pythonhosted.org/packages/ef/d6/8c4bd38a3b24c4c7676a7a3d8de85d6ee7a983602a734b9f9cdefb04a5d6/zstandard-0.25.0-cp310-cp310-win32.whl", hash = "sha256:106281ae350e494f4ac8a80470e66d1fe27e497052c8d9c3b95dc4cf1ade81aa", size = 436469, upload-time = "2025-09-14T22:16:25.002Z" }, + { url = "https://files.pythonhosted.org/packages/93/90/96d50ad417a8ace5f841b3228e93d1bb13e6ad356737f42e2dde30d8bd68/zstandard-0.25.0-cp310-cp310-win_amd64.whl", hash = "sha256:ea9d54cc3d8064260114a0bbf3479fc4a98b21dffc89b3459edd506b69262f6e", size = 506100, upload-time = "2025-09-14T22:16:23.569Z" }, + { url = "https://files.pythonhosted.org/packages/2a/83/c3ca27c363d104980f1c9cee1101cc8ba724ac8c28a033ede6aab89585b1/zstandard-0.25.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:933b65d7680ea337180733cf9e87293cc5500cc0eb3fc8769f4d3c88d724ec5c", size = 795254, upload-time = "2025-09-14T22:16:26.137Z" }, + { url = "https://files.pythonhosted.org/packages/ac/4d/e66465c5411a7cf4866aeadc7d108081d8ceba9bc7abe6b14aa21c671ec3/zstandard-0.25.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a3f79487c687b1fc69f19e487cd949bf3aae653d181dfb5fde3bf6d18894706f", size = 640559, upload-time = "2025-09-14T22:16:27.973Z" }, + { url = "https://files.pythonhosted.org/packages/12/56/354fe655905f290d3b147b33fe946b0f27e791e4b50a5f004c802cb3eb7b/zstandard-0.25.0-cp311-cp311-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:0bbc9a0c65ce0eea3c34a691e3c4b6889f5f3909ba4822ab385fab9057099431", size = 5348020, upload-time = "2025-09-14T22:16:29.523Z" }, + { url = "https://files.pythonhosted.org/packages/3b/13/2b7ed68bd85e69a2069bcc72141d378f22cae5a0f3b353a2c8f50ef30c1b/zstandard-0.25.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:01582723b3ccd6939ab7b3a78622c573799d5d8737b534b86d0e06ac18dbde4a", size = 5058126, upload-time = "2025-09-14T22:16:31.811Z" }, + { url = "https://files.pythonhosted.org/packages/c9/dd/fdaf0674f4b10d92cb120ccff58bbb6626bf8368f00ebfd2a41ba4a0dc99/zstandard-0.25.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:5f1ad7bf88535edcf30038f6919abe087f606f62c00a87d7e33e7fc57cb69fcc", size = 5405390, upload-time = "2025-09-14T22:16:33.486Z" }, + { url = "https://files.pythonhosted.org/packages/0f/67/354d1555575bc2490435f90d67ca4dd65238ff2f119f30f72d5cde09c2ad/zstandard-0.25.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:06acb75eebeedb77b69048031282737717a63e71e4ae3f77cc0c3b9508320df6", size = 5452914, upload-time = "2025-09-14T22:16:35.277Z" }, + { url = "https://files.pythonhosted.org/packages/bb/1f/e9cfd801a3f9190bf3e759c422bbfd2247db9d7f3d54a56ecde70137791a/zstandard-0.25.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9300d02ea7c6506f00e627e287e0492a5eb0371ec1670ae852fefffa6164b072", size = 5559635, upload-time = "2025-09-14T22:16:37.141Z" }, + { url = "https://files.pythonhosted.org/packages/21/88/5ba550f797ca953a52d708c8e4f380959e7e3280af029e38fbf47b55916e/zstandard-0.25.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bfd06b1c5584b657a2892a6014c2f4c20e0db0208c159148fa78c65f7e0b0277", size = 5048277, upload-time = "2025-09-14T22:16:38.807Z" }, + { url = "https://files.pythonhosted.org/packages/46/c0/ca3e533b4fa03112facbe7fbe7779cb1ebec215688e5df576fe5429172e0/zstandard-0.25.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f373da2c1757bb7f1acaf09369cdc1d51d84131e50d5fa9863982fd626466313", size = 5574377, upload-time = "2025-09-14T22:16:40.523Z" }, + { url = "https://files.pythonhosted.org/packages/12/9b/3fb626390113f272abd0799fd677ea33d5fc3ec185e62e6be534493c4b60/zstandard-0.25.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6c0e5a65158a7946e7a7affa6418878ef97ab66636f13353b8502d7ea03c8097", size = 4961493, upload-time = "2025-09-14T22:16:43.3Z" }, + { url = "https://files.pythonhosted.org/packages/cb/d3/23094a6b6a4b1343b27ae68249daa17ae0651fcfec9ed4de09d14b940285/zstandard-0.25.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:c8e167d5adf59476fa3e37bee730890e389410c354771a62e3c076c86f9f7778", size = 5269018, upload-time = "2025-09-14T22:16:45.292Z" }, + { url = "https://files.pythonhosted.org/packages/8c/a7/bb5a0c1c0f3f4b5e9d5b55198e39de91e04ba7c205cc46fcb0f95f0383c1/zstandard-0.25.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:98750a309eb2f020da61e727de7d7ba3c57c97cf6213f6f6277bb7fb42a8e065", size = 5443672, upload-time = "2025-09-14T22:16:47.076Z" }, + { url = "https://files.pythonhosted.org/packages/27/22/503347aa08d073993f25109c36c8d9f029c7d5949198050962cb568dfa5e/zstandard-0.25.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:22a086cff1b6ceca18a8dd6096ec631e430e93a8e70a9ca5efa7561a00f826fa", size = 5822753, upload-time = "2025-09-14T22:16:49.316Z" }, + { url = "https://files.pythonhosted.org/packages/e2/be/94267dc6ee64f0f8ba2b2ae7c7a2df934a816baaa7291db9e1aa77394c3c/zstandard-0.25.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:72d35d7aa0bba323965da807a462b0966c91608ef3a48ba761678cb20ce5d8b7", size = 5366047, upload-time = "2025-09-14T22:16:51.328Z" }, + { url = "https://files.pythonhosted.org/packages/7b/a3/732893eab0a3a7aecff8b99052fecf9f605cf0fb5fb6d0290e36beee47a4/zstandard-0.25.0-cp311-cp311-win32.whl", hash = "sha256:f5aeea11ded7320a84dcdd62a3d95b5186834224a9e55b92ccae35d21a8b63d4", size = 436484, upload-time = "2025-09-14T22:16:55.005Z" }, + { url = "https://files.pythonhosted.org/packages/43/a3/c6155f5c1cce691cb80dfd38627046e50af3ee9ddc5d0b45b9b063bfb8c9/zstandard-0.25.0-cp311-cp311-win_amd64.whl", hash = "sha256:daab68faadb847063d0c56f361a289c4f268706b598afbf9ad113cbe5c38b6b2", size = 506183, upload-time = "2025-09-14T22:16:52.753Z" }, + { url = "https://files.pythonhosted.org/packages/8c/3e/8945ab86a0820cc0e0cdbf38086a92868a9172020fdab8a03ac19662b0e5/zstandard-0.25.0-cp311-cp311-win_arm64.whl", hash = "sha256:22a06c5df3751bb7dc67406f5374734ccee8ed37fc5981bf1ad7041831fa1137", size = 462533, upload-time = "2025-09-14T22:16:53.878Z" }, + { url = "https://files.pythonhosted.org/packages/82/fc/f26eb6ef91ae723a03e16eddb198abcfce2bc5a42e224d44cc8b6765e57e/zstandard-0.25.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7b3c3a3ab9daa3eed242d6ecceead93aebbb8f5f84318d82cee643e019c4b73b", size = 795738, upload-time = "2025-09-14T22:16:56.237Z" }, + { url = "https://files.pythonhosted.org/packages/aa/1c/d920d64b22f8dd028a8b90e2d756e431a5d86194caa78e3819c7bf53b4b3/zstandard-0.25.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:913cbd31a400febff93b564a23e17c3ed2d56c064006f54efec210d586171c00", size = 640436, upload-time = "2025-09-14T22:16:57.774Z" }, + { url = "https://files.pythonhosted.org/packages/53/6c/288c3f0bd9fcfe9ca41e2c2fbfd17b2097f6af57b62a81161941f09afa76/zstandard-0.25.0-cp312-cp312-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:011d388c76b11a0c165374ce660ce2c8efa8e5d87f34996aa80f9c0816698b64", size = 5343019, upload-time = "2025-09-14T22:16:59.302Z" }, + { url = "https://files.pythonhosted.org/packages/1e/15/efef5a2f204a64bdb5571e6161d49f7ef0fffdbca953a615efbec045f60f/zstandard-0.25.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6dffecc361d079bb48d7caef5d673c88c8988d3d33fb74ab95b7ee6da42652ea", size = 5063012, upload-time = "2025-09-14T22:17:01.156Z" }, + { url = "https://files.pythonhosted.org/packages/b7/37/a6ce629ffdb43959e92e87ebdaeebb5ac81c944b6a75c9c47e300f85abdf/zstandard-0.25.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:7149623bba7fdf7e7f24312953bcf73cae103db8cae49f8154dd1eadc8a29ecb", size = 5394148, upload-time = "2025-09-14T22:17:03.091Z" }, + { url = "https://files.pythonhosted.org/packages/e3/79/2bf870b3abeb5c070fe2d670a5a8d1057a8270f125ef7676d29ea900f496/zstandard-0.25.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6a573a35693e03cf1d67799fd01b50ff578515a8aeadd4595d2a7fa9f3ec002a", size = 5451652, upload-time = "2025-09-14T22:17:04.979Z" }, + { url = "https://files.pythonhosted.org/packages/53/60/7be26e610767316c028a2cbedb9a3beabdbe33e2182c373f71a1c0b88f36/zstandard-0.25.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5a56ba0db2d244117ed744dfa8f6f5b366e14148e00de44723413b2f3938a902", size = 5546993, upload-time = "2025-09-14T22:17:06.781Z" }, + { url = "https://files.pythonhosted.org/packages/85/c7/3483ad9ff0662623f3648479b0380d2de5510abf00990468c286c6b04017/zstandard-0.25.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:10ef2a79ab8e2974e2075fb984e5b9806c64134810fac21576f0668e7ea19f8f", size = 5046806, upload-time = "2025-09-14T22:17:08.415Z" }, + { url = "https://files.pythonhosted.org/packages/08/b3/206883dd25b8d1591a1caa44b54c2aad84badccf2f1de9e2d60a446f9a25/zstandard-0.25.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:aaf21ba8fb76d102b696781bddaa0954b782536446083ae3fdaa6f16b25a1c4b", size = 5576659, upload-time = "2025-09-14T22:17:10.164Z" }, + { url = "https://files.pythonhosted.org/packages/9d/31/76c0779101453e6c117b0ff22565865c54f48f8bd807df2b00c2c404b8e0/zstandard-0.25.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1869da9571d5e94a85a5e8d57e4e8807b175c9e4a6294e3b66fa4efb074d90f6", size = 4953933, upload-time = "2025-09-14T22:17:11.857Z" }, + { url = "https://files.pythonhosted.org/packages/18/e1/97680c664a1bf9a247a280a053d98e251424af51f1b196c6d52f117c9720/zstandard-0.25.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:809c5bcb2c67cd0ed81e9229d227d4ca28f82d0f778fc5fea624a9def3963f91", size = 5268008, upload-time = "2025-09-14T22:17:13.627Z" }, + { url = "https://files.pythonhosted.org/packages/1e/73/316e4010de585ac798e154e88fd81bb16afc5c5cb1a72eeb16dd37e8024a/zstandard-0.25.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:f27662e4f7dbf9f9c12391cb37b4c4c3cb90ffbd3b1fb9284dadbbb8935fa708", size = 5433517, upload-time = "2025-09-14T22:17:16.103Z" }, + { url = "https://files.pythonhosted.org/packages/5b/60/dd0f8cfa8129c5a0ce3ea6b7f70be5b33d2618013a161e1ff26c2b39787c/zstandard-0.25.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:99c0c846e6e61718715a3c9437ccc625de26593fea60189567f0118dc9db7512", size = 5814292, upload-time = "2025-09-14T22:17:17.827Z" }, + { url = "https://files.pythonhosted.org/packages/fc/5f/75aafd4b9d11b5407b641b8e41a57864097663699f23e9ad4dbb91dc6bfe/zstandard-0.25.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:474d2596a2dbc241a556e965fb76002c1ce655445e4e3bf38e5477d413165ffa", size = 5360237, upload-time = "2025-09-14T22:17:19.954Z" }, + { url = "https://files.pythonhosted.org/packages/ff/8d/0309daffea4fcac7981021dbf21cdb2e3427a9e76bafbcdbdf5392ff99a4/zstandard-0.25.0-cp312-cp312-win32.whl", hash = "sha256:23ebc8f17a03133b4426bcc04aabd68f8236eb78c3760f12783385171b0fd8bd", size = 436922, upload-time = "2025-09-14T22:17:24.398Z" }, + { url = "https://files.pythonhosted.org/packages/79/3b/fa54d9015f945330510cb5d0b0501e8253c127cca7ebe8ba46a965df18c5/zstandard-0.25.0-cp312-cp312-win_amd64.whl", hash = "sha256:ffef5a74088f1e09947aecf91011136665152e0b4b359c42be3373897fb39b01", size = 506276, upload-time = "2025-09-14T22:17:21.429Z" }, + { url = "https://files.pythonhosted.org/packages/ea/6b/8b51697e5319b1f9ac71087b0af9a40d8a6288ff8025c36486e0c12abcc4/zstandard-0.25.0-cp312-cp312-win_arm64.whl", hash = "sha256:181eb40e0b6a29b3cd2849f825e0fa34397f649170673d385f3598ae17cca2e9", size = 462679, upload-time = "2025-09-14T22:17:23.147Z" }, + { url = "https://files.pythonhosted.org/packages/35/0b/8df9c4ad06af91d39e94fa96cc010a24ac4ef1378d3efab9223cc8593d40/zstandard-0.25.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ec996f12524f88e151c339688c3897194821d7f03081ab35d31d1e12ec975e94", size = 795735, upload-time = "2025-09-14T22:17:26.042Z" }, + { url = "https://files.pythonhosted.org/packages/3f/06/9ae96a3e5dcfd119377ba33d4c42a7d89da1efabd5cb3e366b156c45ff4d/zstandard-0.25.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a1a4ae2dec3993a32247995bdfe367fc3266da832d82f8438c8570f989753de1", size = 640440, upload-time = "2025-09-14T22:17:27.366Z" }, + { url = "https://files.pythonhosted.org/packages/d9/14/933d27204c2bd404229c69f445862454dcc101cd69ef8c6068f15aaec12c/zstandard-0.25.0-cp313-cp313-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:e96594a5537722fdfb79951672a2a63aec5ebfb823e7560586f7484819f2a08f", size = 5343070, upload-time = "2025-09-14T22:17:28.896Z" }, + { url = "https://files.pythonhosted.org/packages/6d/db/ddb11011826ed7db9d0e485d13df79b58586bfdec56e5c84a928a9a78c1c/zstandard-0.25.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:bfc4e20784722098822e3eee42b8e576b379ed72cca4a7cb856ae733e62192ea", size = 5063001, upload-time = "2025-09-14T22:17:31.044Z" }, + { url = "https://files.pythonhosted.org/packages/db/00/87466ea3f99599d02a5238498b87bf84a6348290c19571051839ca943777/zstandard-0.25.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:457ed498fc58cdc12fc48f7950e02740d4f7ae9493dd4ab2168a47c93c31298e", size = 5394120, upload-time = "2025-09-14T22:17:32.711Z" }, + { url = "https://files.pythonhosted.org/packages/2b/95/fc5531d9c618a679a20ff6c29e2b3ef1d1f4ad66c5e161ae6ff847d102a9/zstandard-0.25.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:fd7a5004eb1980d3cefe26b2685bcb0b17989901a70a1040d1ac86f1d898c551", size = 5451230, upload-time = "2025-09-14T22:17:34.41Z" }, + { url = "https://files.pythonhosted.org/packages/63/4b/e3678b4e776db00f9f7b2fe58e547e8928ef32727d7a1ff01dea010f3f13/zstandard-0.25.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8e735494da3db08694d26480f1493ad2cf86e99bdd53e8e9771b2752a5c0246a", size = 5547173, upload-time = "2025-09-14T22:17:36.084Z" }, + { url = "https://files.pythonhosted.org/packages/4e/d5/ba05ed95c6b8ec30bd468dfeab20589f2cf709b5c940483e31d991f2ca58/zstandard-0.25.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3a39c94ad7866160a4a46d772e43311a743c316942037671beb264e395bdd611", size = 5046736, upload-time = "2025-09-14T22:17:37.891Z" }, + { url = "https://files.pythonhosted.org/packages/50/d5/870aa06b3a76c73eced65c044b92286a3c4e00554005ff51962deef28e28/zstandard-0.25.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:172de1f06947577d3a3005416977cce6168f2261284c02080e7ad0185faeced3", size = 5576368, upload-time = "2025-09-14T22:17:40.206Z" }, + { url = "https://files.pythonhosted.org/packages/5d/35/398dc2ffc89d304d59bc12f0fdd931b4ce455bddf7038a0a67733a25f550/zstandard-0.25.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:3c83b0188c852a47cd13ef3bf9209fb0a77fa5374958b8c53aaa699398c6bd7b", size = 4954022, upload-time = "2025-09-14T22:17:41.879Z" }, + { url = "https://files.pythonhosted.org/packages/9a/5c/36ba1e5507d56d2213202ec2b05e8541734af5f2ce378c5d1ceaf4d88dc4/zstandard-0.25.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1673b7199bbe763365b81a4f3252b8e80f44c9e323fc42940dc8843bfeaf9851", size = 5267889, upload-time = "2025-09-14T22:17:43.577Z" }, + { url = "https://files.pythonhosted.org/packages/70/e8/2ec6b6fb7358b2ec0113ae202647ca7c0e9d15b61c005ae5225ad0995df5/zstandard-0.25.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0be7622c37c183406f3dbf0cba104118eb16a4ea7359eeb5752f0794882fc250", size = 5433952, upload-time = "2025-09-14T22:17:45.271Z" }, + { url = "https://files.pythonhosted.org/packages/7b/01/b5f4d4dbc59ef193e870495c6f1275f5b2928e01ff5a81fecb22a06e22fb/zstandard-0.25.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:5f5e4c2a23ca271c218ac025bd7d635597048b366d6f31f420aaeb715239fc98", size = 5814054, upload-time = "2025-09-14T22:17:47.08Z" }, + { url = "https://files.pythonhosted.org/packages/b2/e5/fbd822d5c6f427cf158316d012c5a12f233473c2f9c5fe5ab1ae5d21f3d8/zstandard-0.25.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4f187a0bb61b35119d1926aee039524d1f93aaf38a9916b8c4b78ac8514a0aaf", size = 5360113, upload-time = "2025-09-14T22:17:48.893Z" }, + { url = "https://files.pythonhosted.org/packages/8e/e0/69a553d2047f9a2c7347caa225bb3a63b6d7704ad74610cb7823baa08ed7/zstandard-0.25.0-cp313-cp313-win32.whl", hash = "sha256:7030defa83eef3e51ff26f0b7bfb229f0204b66fe18e04359ce3474ac33cbc09", size = 436936, upload-time = "2025-09-14T22:17:52.658Z" }, + { url = "https://files.pythonhosted.org/packages/d9/82/b9c06c870f3bd8767c201f1edbdf9e8dc34be5b0fbc5682c4f80fe948475/zstandard-0.25.0-cp313-cp313-win_amd64.whl", hash = "sha256:1f830a0dac88719af0ae43b8b2d6aef487d437036468ef3c2ea59c51f9d55fd5", size = 506232, upload-time = "2025-09-14T22:17:50.402Z" }, + { url = "https://files.pythonhosted.org/packages/d4/57/60c3c01243bb81d381c9916e2a6d9e149ab8627c0c7d7abb2d73384b3c0c/zstandard-0.25.0-cp313-cp313-win_arm64.whl", hash = "sha256:85304a43f4d513f5464ceb938aa02c1e78c2943b29f44a750b48b25ac999a049", size = 462671, upload-time = "2025-09-14T22:17:51.533Z" }, + { url = "https://files.pythonhosted.org/packages/3d/5c/f8923b595b55fe49e30612987ad8bf053aef555c14f05bb659dd5dbe3e8a/zstandard-0.25.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:e29f0cf06974c899b2c188ef7f783607dbef36da4c242eb6c82dcd8b512855e3", size = 795887, upload-time = "2025-09-14T22:17:54.198Z" }, + { url = "https://files.pythonhosted.org/packages/8d/09/d0a2a14fc3439c5f874042dca72a79c70a532090b7ba0003be73fee37ae2/zstandard-0.25.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:05df5136bc5a011f33cd25bc9f506e7426c0c9b3f9954f056831ce68f3b6689f", size = 640658, upload-time = "2025-09-14T22:17:55.423Z" }, + { url = "https://files.pythonhosted.org/packages/5d/7c/8b6b71b1ddd517f68ffb55e10834388d4f793c49c6b83effaaa05785b0b4/zstandard-0.25.0-cp314-cp314-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:f604efd28f239cc21b3adb53eb061e2a205dc164be408e553b41ba2ffe0ca15c", size = 5379849, upload-time = "2025-09-14T22:17:57.372Z" }, + { url = "https://files.pythonhosted.org/packages/a4/86/a48e56320d0a17189ab7a42645387334fba2200e904ee47fc5a26c1fd8ca/zstandard-0.25.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:223415140608d0f0da010499eaa8ccdb9af210a543fac54bce15babbcfc78439", size = 5058095, upload-time = "2025-09-14T22:17:59.498Z" }, + { url = "https://files.pythonhosted.org/packages/f8/ad/eb659984ee2c0a779f9d06dbfe45e2dc39d99ff40a319895df2d3d9a48e5/zstandard-0.25.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2e54296a283f3ab5a26fc9b8b5d4978ea0532f37b231644f367aa588930aa043", size = 5551751, upload-time = "2025-09-14T22:18:01.618Z" }, + { url = "https://files.pythonhosted.org/packages/61/b3/b637faea43677eb7bd42ab204dfb7053bd5c4582bfe6b1baefa80ac0c47b/zstandard-0.25.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:ca54090275939dc8ec5dea2d2afb400e0f83444b2fc24e07df7fdef677110859", size = 6364818, upload-time = "2025-09-14T22:18:03.769Z" }, + { url = "https://files.pythonhosted.org/packages/31/dc/cc50210e11e465c975462439a492516a73300ab8caa8f5e0902544fd748b/zstandard-0.25.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e09bb6252b6476d8d56100e8147b803befa9a12cea144bbe629dd508800d1ad0", size = 5560402, upload-time = "2025-09-14T22:18:05.954Z" }, + { url = "https://files.pythonhosted.org/packages/c9/ae/56523ae9c142f0c08efd5e868a6da613ae76614eca1305259c3bf6a0ed43/zstandard-0.25.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:a9ec8c642d1ec73287ae3e726792dd86c96f5681eb8df274a757bf62b750eae7", size = 4955108, upload-time = "2025-09-14T22:18:07.68Z" }, + { url = "https://files.pythonhosted.org/packages/98/cf/c899f2d6df0840d5e384cf4c4121458c72802e8bda19691f3b16619f51e9/zstandard-0.25.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a4089a10e598eae6393756b036e0f419e8c1d60f44a831520f9af41c14216cf2", size = 5269248, upload-time = "2025-09-14T22:18:09.753Z" }, + { url = "https://files.pythonhosted.org/packages/1b/c0/59e912a531d91e1c192d3085fc0f6fb2852753c301a812d856d857ea03c6/zstandard-0.25.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:f67e8f1a324a900e75b5e28ffb152bcac9fbed1cc7b43f99cd90f395c4375344", size = 5430330, upload-time = "2025-09-14T22:18:11.966Z" }, + { url = "https://files.pythonhosted.org/packages/a0/1d/7e31db1240de2df22a58e2ea9a93fc6e38cc29353e660c0272b6735d6669/zstandard-0.25.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:9654dbc012d8b06fc3d19cc825af3f7bf8ae242226df5f83936cb39f5fdc846c", size = 5811123, upload-time = "2025-09-14T22:18:13.907Z" }, + { url = "https://files.pythonhosted.org/packages/f6/49/fac46df5ad353d50535e118d6983069df68ca5908d4d65b8c466150a4ff1/zstandard-0.25.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4203ce3b31aec23012d3a4cf4a2ed64d12fea5269c49aed5e4c3611b938e4088", size = 5359591, upload-time = "2025-09-14T22:18:16.465Z" }, + { url = "https://files.pythonhosted.org/packages/c2/38/f249a2050ad1eea0bb364046153942e34abba95dd5520af199aed86fbb49/zstandard-0.25.0-cp314-cp314-win32.whl", hash = "sha256:da469dc041701583e34de852d8634703550348d5822e66a0c827d39b05365b12", size = 444513, upload-time = "2025-09-14T22:18:20.61Z" }, + { url = "https://files.pythonhosted.org/packages/3a/43/241f9615bcf8ba8903b3f0432da069e857fc4fd1783bd26183db53c4804b/zstandard-0.25.0-cp314-cp314-win_amd64.whl", hash = "sha256:c19bcdd826e95671065f8692b5a4aa95c52dc7a02a4c5a0cac46deb879a017a2", size = 516118, upload-time = "2025-09-14T22:18:17.849Z" }, + { url = "https://files.pythonhosted.org/packages/f0/ef/da163ce2450ed4febf6467d77ccb4cd52c4c30ab45624bad26ca0a27260c/zstandard-0.25.0-cp314-cp314-win_arm64.whl", hash = "sha256:d7541afd73985c630bafcd6338d2518ae96060075f9463d7dc14cfb33514383d", size = 476940, upload-time = "2025-09-14T22:18:19.088Z" }, +] From 3be3ad1a407815b8394374d5973c431769392db8 Mon Sep 17 00:00:00 2001 From: Yue Zhang Date: Wed, 3 Jun 2026 15:23:54 -0700 Subject: [PATCH 22/33] remove json files from codespell checks --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a3a16c2..df95010 100644 --- a/Makefile +++ b/Makefile @@ -10,11 +10,11 @@ test: # Run spell checking spell: - uv run codespell --skip=metaData,notebooks,htmlcov --ignore-words-list=EHR + uv run codespell --skip=metaData,notebooks,htmlcov,*.json --ignore-words-list=EHR # Run spell checking interactively (allows fixing) spell-fix: - uv run codespell --interactive 3 --skip=metaData,notebooks,htmlcov --ignore-words-list=EHR + uv run codespell --interactive 3 --skip=metaData,notebooks,htmlcov,*.json --ignore-words-list=EHR # Run linting lint: @@ -47,4 +47,4 @@ help: @echo " lint-notebooks - Run code linting on notebooks (informational)" @echo " format - Format code" @echo " check - Run all checks (lint, spell, test)" - @echo " help - Show this help message" \ No newline at end of file + @echo " help - Show this help message" From 7f2ca921287d979222e24faaf7b5c6fc8590028f Mon Sep 17 00:00:00 2001 From: Yue Zhang Date: Thu, 4 Jun 2026 14:25:02 -0700 Subject: [PATCH 23/33] merged --- TCT/translator_metakg.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/TCT/translator_metakg.py b/TCT/translator_metakg.py index a69e0cb..9827c16 100644 --- a/TCT/translator_metakg.py +++ b/TCT/translator_metakg.py @@ -262,11 +262,7 @@ def add_plover_API(APInames:dict[str, str], metaKG:pd.DataFrame) -> tuple[dict[s return APInames, metaKG -<<<<<<< HEAD -def load_translator_resources(use_new_metakg_url=True): -======= def load_translator_resources(use_new_metakg_url=False): ->>>>>>> 0380a61416c49cb575cf0ec2d9e69b733004dcc6 """ Load the necessary resources for the Translator. From eed4b91b477e2a5ec00212e6b97174527433919c Mon Sep 17 00:00:00 2001 From: yjzhang Date: Thu, 18 Jun 2026 18:44:27 -0700 Subject: [PATCH 24/33] neighborhood finder with multiple input nodes --- TCT/TCT_neighborhood_finder.py | 183 ++++++++++++++++ TCT/TCT_pathfinder.py | 4 +- .../Neighborhood_finder_multiple_nodes.ipynb | 207 ++++++++++++++++++ 3 files changed, 391 insertions(+), 3 deletions(-) create mode 100644 notebooks/Neighborhood_finder_multiple_nodes.ipynb diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index 3f26050..bdef854 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -95,6 +95,97 @@ def parse_results_for_neighborhood_finder(start_node_id:str, results:dict, return output +# TODO: can we use multiple input nodes? +def parse_results_for_neighborhood_finder_multiple_inputs(start_node_ids:list[str], results:dict, + start_node_categories=None, end_node_categories=None, + get_node_info=True, + scoring_method='infores'): + """ + Converts the results of two TRAPI queries into the same general json format as the other pathfinder APIs. + scoring_method is how the node scores are generated, and could be 'infores' or 'edges'. + """ + # nodes + node_info = {} + # edges is a dict of intermediate nodes + node_edges = {} + for k, v in results.items(): + i1 = v['subject'] + i2 = v['object'] + s_o = 'object' + if i1 in start_node_ids: + intermediate_node_id = i2 + s_o = 'object' + elif i2 in start_node_ids: + intermediate_node_id = i1 + s_o = 'subject' + else: + continue + if (i1 in start_node_ids or i2 in start_node_ids) and intermediate_node_id in node_edges: + node_edges[intermediate_node_id].append((k, v)) + else: + node_edges[intermediate_node_id] = [(k, v)] + # add node dict + if intermediate_node_id not in node_info: + node_dict = { + } + node_info[intermediate_node_id] = node_dict + else: + node_dict = node_info[intermediate_node_id] + if 'attributes' not in v: + v['attributes'] = [] + for attribute in v['attributes']: + if attribute['attribute_type_id'] == f'{s_o}_category': + if 'categories' not in node_dict: + node_dict['categories'] = set([attribute['value']]) + else: + node_dict['categories'].add(attribute['value']) + if attribute['attribute_type_id'] == f'{s_o}_name' and 'name' not in node_dict: + node_dict['name'] = attribute['value'] + node_info[intermediate_node_id] = node_dict + for k, v in node_info.items(): + if 'categories' in v: + v['categories'] = list(v['categories']) + all_edges = {} + all_auxiliary_graphs = {} + i = 1 + # sort connecting_intermediate_nodes by total number of connections + connection_counts = Counter({k: len(v) for k, v in node_edges.items()}) + for i1, count in connection_counts.most_common(): + edges = node_edges[i1] + all_edges.update({k: v for k, v in edges}) + keys = [x[0] for x in edges] + all_auxiliary_graphs[f'aux_{i}_{i1}'] = keys + i += 1 + # generate output json + output = { + 'query_graph': build_query_graph(start_node_ids, '', start_node_categories, end_node_categories), + 'knowledge_graph': {'nodes': {x: node_info[x] for x in connection_counts.keys()}, + 'edges': all_edges, + }, + 'results': [{'analyses': []}], + 'auxiliary_graphs': all_auxiliary_graphs + } + graph_scores, graph_scores_formatted = generate_score_results(output, method=scoring_method) + output['results'][0]['analyses'] = graph_scores_formatted + if get_node_info: + from .node_normalizer import get_normalized_nodes + nodes_to_add = [] + for k, v in output['knowledge_graph']['nodes'].items(): + if 'name' not in v or 'categories' not in v: + nodes_to_add.append(k) + if nodes_to_add: + batch_limit = 1000 + all_normalized_nodes = {} + for idx in range(0, len(nodes_to_add), batch_limit): + batch = nodes_to_add[idx:idx + batch_limit] + batch_result = get_normalized_nodes(batch, mode='post') + all_normalized_nodes.update(batch_result) + for node_id in nodes_to_add: + nn = all_normalized_nodes.get(node_id) + if nn is not None: + output['knowledge_graph']['nodes'][node_id] = {'name': nn.label, 'categories': nn.types} + return output + def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_predicates, input_node_category = [], predicates_subset=None, @@ -191,3 +282,95 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred return input_node_id, result, parsed_results, result_ranked_by_primary_infores1 +def neighborhood_finder_multiple_inputs(input_nodes:list[str], node2_categories:list[str], APInames, metaKG, API_predicates, + input_node_category = [], + predicates_subset=None, + attribute_constraints=None): + """ + This function is used to find the neighborhood of a given input node with intermediate categories. + + Parameters + ---------- + input_nodes (list[str]) + The input nodes - should be a list of CURIE ids. + node2_categories (list) + A list of intermediate categories to be used in the neighborhood finding process. + APInames (dict) + A dictionary containing the names of the APIs to be used. + metaKG (DataFrame) + The metadata knowledge graph containing information about the APIs and their predicates. + API_predicates (dict) + A dictionary containing the predicates for each API. + input_node_category (list) + Optional. A list of categories for the input node. If empty, it will be derived from the input node's types. + attribute_constraints (list) + Optional. List of outputs of translator_query.build_attribute_constraint + + Returns + -------------- + input_node_id (str) + The curie id of the input node. + result (dict) + The result of the query for the input node. + result_parsed (DataFrame) + The parsed results for the input node. + result_ranked_by_primary_infores (DataFrame) + The ranked results based on primary infores. + + -------------- + Example: + >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer + node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], + APInames = APInames, + metaKG = metaKG, + API_predicates = API_predicates) + -------------- + + """ + from . import node_normalizer + from . import translator_query + + # Step 1: Resolve the input nodes to get its curie id and categories + input_nodes_info = node_normalizer.get_normalized_nodes(input_nodes) + print(input_nodes) + + if len(input_node_category) == 0: + input_node_category = input_nodes_info[input_nodes[0]].types + else: + input_node_info = input_nodes_info[input_nodes[0]] + input_node_category = list(set(input_node_category).intersection(set(input_node_info.types))) + if len(input_node_category) == 0: + input_node_category = input_node_info.types + + # Step 2: Select predicates and APIs based on the intermediate categories + sele_predicates, sele_APIs, API_URLs = sele_predicates_API(input_node_category, + node2_categories, + metaKG, APInames) + + if len(sele_predicates) ==0: + sele_predicates = ["biolink:related_to"] + + # Step 3: Format the query JSON for the input node + #query_json = format_query_json([input_node_id], + # None, + # None, + # node2_categories, + # sele_predicates, + # attribute_constraints=attribute_constraints) + query_json = format_query_json(subject_ids = input_nodes, + object_ids = None, + subject_categories = None, + object_categories = node2_categories, + predicates = sele_predicates, + attribute_constraints = attribute_constraints, + ) + # Step 4: Query the APIs in parallel + result = translator_query.parallel_api_query(query_json=query_json, + select_APIs= sele_APIs, + APInames=APInames, + API_predicates=API_predicates, + max_workers=len(sele_APIs)) + parsed_results = parse_results_for_neighborhood_finder_multiple_inputs(input_nodes, result, input_node_category, node2_categories) + return result, parsed_results + + diff --git a/TCT/TCT_pathfinder.py b/TCT/TCT_pathfinder.py index a36b1c9..6ace116 100644 --- a/TCT/TCT_pathfinder.py +++ b/TCT/TCT_pathfinder.py @@ -81,9 +81,7 @@ def build_query_graph(start_node_id, end_node_id, start_node_categories=None, en "sn": { "categories": start_node_categories, "constraints": [], - "ids": [ - start_node_id - ], + "ids": [start_node_id] if isinstance(start_node_id, str) else start_node_id, "is_set": False, "option_group_id": None, "set_id": None, diff --git a/notebooks/Neighborhood_finder_multiple_nodes.ipynb b/notebooks/Neighborhood_finder_multiple_nodes.ipynb new file mode 100644 index 0000000..4934627 --- /dev/null +++ b/notebooks/Neighborhood_finder_multiple_nodes.ipynb @@ -0,0 +1,207 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "60c9628e-63ee-42f7-95d2-f1840b321aa3", + "metadata": {}, + "source": [ + "# Neighborhood finder with multiple starting nodes" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "f1df4a59-caf9-4477-a789-ad6aba33ba90", + "metadata": {}, + "outputs": [], + "source": [ + "from TCT import node_normalizer\n", + "from TCT import name_resolver\n", + "from TCT import translator_metakg\n", + "from TCT import translator_kpinfo\n", + "from TCT import translator_query\n", + "from TCT import TCT_neighborhood_finder\n", + "\n", + "from TCT import TCT" + ] + }, + { + "cell_type": "markdown", + "id": "3e033e2c-eb38-406a-ac84-2edb790ec1e5", + "metadata": {}, + "source": [ + "## Load Translator resources" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "ab0711e0-bc03-48f2-8282-65bbe9ea30d5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", + "Skipping server without x-maturity: {'description': 'Local dev', 'url': 'http://127.0.0.1:5001'}\n", + "Skipping server without x-maturity: {'url': '/sipr'}\n" + ] + } + ], + "source": [ + "APInames, metaKG, Translator_KP_info= translator_metakg.load_translator_resources(use_new_metakg_url=True)\n", + "\n", + "All_predicates = list(set(metaKG['Predicate']))\n", + "All_categories = list((set(list(set(metaKG['Subject']))+list(set(metaKG['Object'])))))\n", + "API_withMetaKG = list(set(metaKG['API']))\n", + "\n", + "API_predicates = {}\n", + "for api in API_withMetaKG:\n", + " API_predicates[api] = list(set(metaKG[metaKG['API'] == api]['Predicate']))" + ] + }, + { + "cell_type": "markdown", + "id": "d1fb3e34-590f-48a1-9383-839dc3eae98f", + "metadata": {}, + "source": [ + "## Run Neighborhood finder with multiple inputs\n", + "\n", + "Here, we will run neighborhood_finder_multiple_inputs with multiple gene inputs, and find all drugs that are connected to any of these genes." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "db84f120-b946-4bdd-a282-f9af575f9642", + "metadata": {}, + "outputs": [], + "source": [ + "input_identifiers = ['NCBIGene:2290', 'NCBIGene:4869', 'NCBIGene:1956']" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "b68f54d0-dfa5-4ef1-a2cc-da31bc5f18aa", + "metadata": {}, + "outputs": [], + "source": [ + "input_node_info = node_normalizer.get_normalized_nodes(input_identifiers)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "bafe102e-d03c-4d9d-a93e-f960a7e4f2d6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'NCBIGene:2290': TranslatorNode(curie='NCBIGene:2290', label='FOXG1', types=['biolink:Gene', 'biolink:GeneOrGeneProduct', 'biolink:GenomicEntity', 'biolink:ChemicalEntityOrGeneOrGeneProduct', 'biolink:PhysicalEssence', 'biolink:OntologyClass', 'biolink:BiologicalEntity', 'biolink:ThingWithTaxon', 'biolink:NamedThing', 'biolink:PhysicalEssenceOrOccurrent', 'biolink:MacromolecularMachineMixin', 'biolink:Protein', 'biolink:GeneProductMixin', 'biolink:Polypeptide', 'biolink:ChemicalEntityOrProteinOrPolypeptide'], synonyms=None, curie_synonyms=None, attributes=None, taxa=None),\n", + " 'NCBIGene:4869': TranslatorNode(curie='NCBIGene:4869', label='NPM1', types=['biolink:Gene', 'biolink:GeneOrGeneProduct', 'biolink:GenomicEntity', 'biolink:ChemicalEntityOrGeneOrGeneProduct', 'biolink:PhysicalEssence', 'biolink:OntologyClass', 'biolink:BiologicalEntity', 'biolink:ThingWithTaxon', 'biolink:NamedThing', 'biolink:PhysicalEssenceOrOccurrent', 'biolink:MacromolecularMachineMixin', 'biolink:Protein', 'biolink:GeneProductMixin', 'biolink:Polypeptide', 'biolink:ChemicalEntityOrProteinOrPolypeptide'], synonyms=None, curie_synonyms=None, attributes=None, taxa=None),\n", + " 'NCBIGene:1956': TranslatorNode(curie='NCBIGene:1956', label='EGFR', types=['biolink:Gene', 'biolink:GeneOrGeneProduct', 'biolink:GenomicEntity', 'biolink:ChemicalEntityOrGeneOrGeneProduct', 'biolink:PhysicalEssence', 'biolink:OntologyClass', 'biolink:BiologicalEntity', 'biolink:ThingWithTaxon', 'biolink:NamedThing', 'biolink:PhysicalEssenceOrOccurrent', 'biolink:MacromolecularMachineMixin', 'biolink:Protein', 'biolink:GeneProductMixin', 'biolink:Polypeptide', 'biolink:ChemicalEntityOrProteinOrPolypeptide'], synonyms=None, curie_synonyms=None, attributes=None, taxa=None)}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "input_node_info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "53790f21-90f2-49d0-823f-78b60565be69", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7fc5df9e-2d59-4cec-acf4-78d74a69b5b7", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "45f0ddbb-0368-4a2e-9b19-ed4969a51718", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['NCBIGene:2290', 'NCBIGene:4869', 'NCBIGene:1956']\n", + "CATRAX Pharmacogenomics KP - TRAPI 1.5.0: Success!\n", + "RTX KG2 - TRAPI 1.5.0: Success!\n", + "Retriever: Success!\n", + "Automat-robokop(Trapi v1.5.0): Success!\n", + "ARAX Translator Reasoner - TRAPI 1.6.0: Success!\n" + ] + } + ], + "source": [ + "result, result_parsed = TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(input_identifiers,\n", + " node2_categories = ['biolink:Drug'],\n", + " APInames = APInames,\n", + " metaKG = metaKG,\n", + " API_predicates = API_predicates) " + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "8682160f-ee2b-4cb0-925e-1f6dcd9c8264", + "metadata": {}, + "outputs": [], + "source": [ + "# write a result to a json file\n", + "import json\n", + "# add a timestamp to the file name\n", + "import datetime\n", + "\n", + "timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')\n", + "with open('TCT_neighborhood_finder_result_'+'_'+timestamp+'.json', 'w') as f:\n", + " json.dump(result_parsed, f)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cbdd2163-7cca-47d9-ad8d-e3c075d82835", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 18ab87499550940a1d2c980d727f8298a310ba27 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 07:39:25 -0700 Subject: [PATCH 25/33] remove certain requirements --- pyproject.toml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1c31044..645c128 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,15 +29,14 @@ dependencies = [ "ipycytoscape", "networkx", "numpy", - "openai", + #"openai", "ipykernel", - "fastmcp>=2.12.2", - "click>=8.2.1", + #"fastmcp>=2.12.2", + #"click>=8.2.1", 'networkx', 'igraph', 'pyvis', 'zstandard', - 'copy' ] [project.scripts] From b07e6fb946a56e84db844b1941c17228ed003a64 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 07:43:51 -0700 Subject: [PATCH 26/33] restore requirements --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 645c128..9365cd9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,10 +29,10 @@ dependencies = [ "ipycytoscape", "networkx", "numpy", - #"openai", + "openai", "ipykernel", - #"fastmcp>=2.12.2", - #"click>=8.2.1", + "fastmcp>=2.12.2", + "click>=8.2.1", 'networkx', 'igraph', 'pyvis', From f65f805d0c7a30f9e54f5f7760191f5680a31779 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 07:53:38 -0700 Subject: [PATCH 27/33] fix typo, fix docs --- TCT/TCT_network_annotator.py | 4 ++-- docs/source/index.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/TCT/TCT_network_annotator.py b/TCT/TCT_network_annotator.py index ce012c1..c0b1d0a 100644 --- a/TCT/TCT_network_annotator.py +++ b/TCT/TCT_network_annotator.py @@ -169,7 +169,7 @@ def network_annotator(gene_list, def get_connected_graph(result_parsed, input_identifiers): """ - This function is used to extract the connected graph from the returned graph based on neiborhood finder from multiple inputs. + This function is used to extract the connected graph from the returned graph based on neighborhood finder from multiple inputs. It will only include the input nodes and the nodes that are connected to the input nodes with degree greater than 1. @@ -269,4 +269,4 @@ def get_connected_graph(result_parsed, input_identifiers): if key not in selected_nodes: del result_parsed_copy['knowledge_graph']['nodes'][key] - return result_parsed_copy \ No newline at end of file + return result_parsed_copy diff --git a/docs/source/index.rst b/docs/source/index.rst index fedb998..62ee746 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -22,6 +22,7 @@ Welcome to Translator Component Toolkit's documentation! neighborhood pathfinder network_annotator + node_annotator Indices and tables ================== From 452677758b2fb6b5b91355fcdf6bc2a615100020 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 07:56:42 -0700 Subject: [PATCH 28/33] fix typos --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1f94d36..202cf1e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ To install TCT as a python library: ```bash pip install TCT -# TCT is in development, to get the most recent update, user can install it throught the github repo +# TCT is in development, to get the most recent update, user can install it through the github repo ``` **This the recommended approach for installation.** @@ -90,8 +90,8 @@ API should be developed following the standard from [TRAPI](https://github.com/N An example notebook for add a user's API can be found [here](https://github.com/NCATSTranslator/Translator_component_toolkit/blob/main/notebooks/Connecting_userAPI.ipynb).
**Note: It does not work if no user' API is established**
-### Visulize the results -After each pipleline, it will generate a result file for visualization. A user can use **[the Visualization html](https://github.com/NCATSTranslator/Translator_component_toolkit/blob/main/notebooks/visulize_path_finder_results.html)** file to visulaize the results. +### Visualize the results +After each pipeline, it will generate a result file for visualization. A user can use **[the Visualization html](https://github.com/NCATSTranslator/Translator_component_toolkit/blob/main/notebooks/visulize_path_finder_results.html)** file to visulaize the results. ## Key Translator components Connecting to key Translator components can be found [here](https://github.com/NCATSTranslator/Translator_component_toolkit/blob/main/TranslatorComponentsIntroduction.md) From f1a66321568794f4af88d8bc01de9502a6233403 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 08:02:49 -0700 Subject: [PATCH 29/33] move ipycytoscape imports to inside function --- TCT/TCT.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TCT/TCT.py b/TCT/TCT.py index d0d22ea..48434f4 100644 --- a/TCT/TCT.py +++ b/TCT/TCT.py @@ -3,7 +3,6 @@ import pandas as pd import seaborn as sns import matplotlib.pyplot as plt -import ipycytoscape import networkx as nx import numpy as np #import openai @@ -1875,6 +1874,7 @@ def plot_graph_by_predicates(for_plot): ] + import ipycytoscape undirected = ipycytoscape.CytoscapeWidget() undirected.graph.add_graph_from_networkx(graph) undirected.set_layout(title='Path', nodeSpacing=80, edgeLengthVal=50, ) @@ -1923,6 +1923,7 @@ def plot_graph_by_infores(for_plot): ] + import ipycytoscape undirected = ipycytoscape.CytoscapeWidget() undirected.graph.add_graph_from_networkx(graph) undirected.set_layout(title='Path', nodeSpacing=80, edgeLengthVal=50, ) @@ -1971,6 +1972,7 @@ def plot_graph_by_API(for_plot): ] + import ipycytoscape undirected = ipycytoscape.CytoscapeWidget() undirected.graph.add_graph_from_networkx(graph) undirected.set_layout(title='Path', nodeSpacing=80, edgeLengthVal=50, ) @@ -2258,6 +2260,7 @@ def visulize_path(input_node1_id, intermediate_node, input_node3_id, result, res }}, ] + import ipycytoscape pathgraph = ipycytoscape.CytoscapeWidget() pathgraph.graph.add_graph_from_networkx(graph) pathgraph.set_layout(title='Path', nodeSpacing=80, edgeLengthVal=50, ) From 9570fc00f63e50979f04bfa01356cf8221a9f292 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 09:13:32 -0700 Subject: [PATCH 30/33] fix docstring formatting --- TCT/TCT_neighborhood_finder.py | 51 ++++++++++++++++------------------ TCT/TCT_network_annotator.py | 33 ++++++++++------------ TCT/TCT_pathfinder.py | 19 +++++++------ 3 files changed, 49 insertions(+), 54 deletions(-) diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index bdef854..1fd6c45 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -195,41 +195,39 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred Parameters ---------- - input_node (str) + input_node : str The input node - should be a CURIE id. - node2_categories (list) + node2_categories : list A list of intermediate categories to be used in the neighborhood finding process. - APInames (dict) + APInames : dict A dictionary containing the names of the APIs to be used. - metaKG (DataFrame) + metaKG : DataFrame The metadata knowledge graph containing information about the APIs and their predicates. - API_predicates (dict) + API_predicates : dict A dictionary containing the predicates for each API. - input_node_category (list) + input_node_category : list Optional. A list of categories for the input node. If empty, it will be derived from the input node's types. - attribute_constraints (list) + attribute_constraints : list Optional. List of outputs of translator_query.build_attribute_constraint Returns - -------------- - input_node_id (str) + ------- + input_node_id : str The curie id of the input node. - result (dict) + result : dict The result of the query for the input node. - result_parsed (DataFrame) + result_parsed : DataFrame The parsed results for the input node. - result_ranked_by_primary_infores (DataFrame) + result_ranked_by_primary_infores : DataFrame The ranked results based on primary infores. - -------------- - Example: + Example + ------- >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], APInames = APInames, metaKG = metaKG, API_predicates = API_predicates) - -------------- - """ from . import node_normalizer from . import translator_query @@ -291,23 +289,23 @@ def neighborhood_finder_multiple_inputs(input_nodes:list[str], node2_categories: Parameters ---------- - input_nodes (list[str]) + input_nodes : list[str] The input nodes - should be a list of CURIE ids. - node2_categories (list) + node2_categories : list A list of intermediate categories to be used in the neighborhood finding process. - APInames (dict) + APInames : dict A dictionary containing the names of the APIs to be used. - metaKG (DataFrame) + metaKG : DataFrame The metadata knowledge graph containing information about the APIs and their predicates. - API_predicates (dict) + API_predicates : dict A dictionary containing the predicates for each API. - input_node_category (list) + input_node_category : list Optional. A list of categories for the input node. If empty, it will be derived from the input node's types. - attribute_constraints (list) + attribute_constraints : list Optional. List of outputs of translator_query.build_attribute_constraint Returns - -------------- + ------- input_node_id (str) The curie id of the input node. result (dict) @@ -317,14 +315,13 @@ def neighborhood_finder_multiple_inputs(input_nodes:list[str], node2_categories: result_ranked_by_primary_infores (DataFrame) The ranked results based on primary infores. - -------------- - Example: + Examples + -------= >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], APInames = APInames, metaKG = metaKG, API_predicates = API_predicates) - -------------- """ from . import node_normalizer diff --git a/TCT/TCT_network_annotator.py b/TCT/TCT_network_annotator.py index c0b1d0a..4a28bb5 100644 --- a/TCT/TCT_network_annotator.py +++ b/TCT/TCT_network_annotator.py @@ -175,36 +175,33 @@ def get_connected_graph(result_parsed, input_identifiers): Parameters ---------- - result_parsed (dict) + result_parsed : dict The parsed results for results from TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(). - input_identifiers (list) + input_identifiers : list A list of input node identifiers, which are also input for TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(). Returns - -------------- - result_parsed (dict) + ------- + result_parsed : dict The connected graph extracted from the parsed results. - -------------- - Example: - >>> - input_identifiers = ['NCBIGene:6774', 'NCBIGene:4170','NCBIGene:4792','NCBIGene:4288','NCBIGene:596','NCBIGene:581','NCBIGene:836','NCBIGene:6777','NCBIGene:4790','NCBIGene:545'] + Example + ------- + >>> input_identifiers = ['NCBIGene:6774', 'NCBIGene:4170','NCBIGene:4792','NCBIGene:4288','NCBIGene:596','NCBIGene:581','NCBIGene:836','NCBIGene:6777','NCBIGene:4790','NCBIGene:545'] - result, result_parsed = TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(input_identifiers, + >>> result, result_parsed = TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(input_identifiers, node2_categories = ['biolink:Gene','biolink:Protein'], APInames = APInames, metaKG = metaKG, API_predicates = API_predicates) - result = TCT_network_annotator.get_connected_graph(result_parsed, input_identifiers) - import datetime - import json - timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S') - with open('./PathFinder_testing_results/'+'TCT_neighborhood_finder_result_'+'_'+timestamp+'.json', 'w') as f: - json.dump(result, f) - # visualize the result using the TCT visualization tool (https://github.com/NCATSTranslator/Translator_component_toolkit/blob/main/notebooks/visulize_path_finder_results.html). - -------------- - + >>> result = TCT_network_annotator.get_connected_graph(result_parsed, input_identifiers) + >>> import datetime + >>> import json + >>> timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S') + >>> with open('./PathFinder_testing_results/'+'TCT_neighborhood_finder_result_'+'_'+timestamp+'.json', 'w') as f: + >>> json.dump(result, f) + >>> # visualize the result using the TCT visualization tool (https://github.com/NCATSTranslator/Translator_component_toolkit/blob/main/notebooks/visulize_path_finder_results.html). """ result_parsed_copy = result_parsed.copy() diff --git a/TCT/TCT_pathfinder.py b/TCT/TCT_pathfinder.py index 2a0dd6f..b4e4d27 100644 --- a/TCT/TCT_pathfinder.py +++ b/TCT/TCT_pathfinder.py @@ -31,20 +31,21 @@ def format_query_json_for_pathfinder_with_constraints(subject_ids, a list of predicates for the edge between subject and object nodes constraints : list a list of intermediate categories for the pathfinder pipeline, currently only one intermediate category is allowed in the constraints list. + Returns ------- query_json_temp : dict a query json for pathfinder pipeline - Example - ------- - query_json_temp = format_query_json_for_pathfinder_with_constraints( - subject_ids='NCBIGene:6774', - object_ids='NCBIGene:4170', - subject_categories=['biolink:Gene'], - object_categories=['biolink:Gene'], - predicates=['biolink:related_to'], - constraints=['biolink:Protein'] + Example + ------- + >>> query_json_temp = format_query_json_for_pathfinder_with_constraints( + subject_ids='NCBIGene:6774', + object_ids='NCBIGene:4170', + subject_categories=['biolink:Gene'], + object_categories=['biolink:Gene'], + predicates=['biolink:related_to'], + constraints=['biolink:Protein']) """ if constraints is None or len(constraints) == 0: constraints_intermediate_category = None From 530700675e58226bf453efd260388fa8949df063 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 09:21:45 -0700 Subject: [PATCH 31/33] updated docstrings --- TCT/TCT_neighborhood_finder.py | 6 +++--- TCT/TCT_network_annotator.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index 1fd6c45..9d948a5 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -221,7 +221,7 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred result_ranked_by_primary_infores : DataFrame The ranked results based on primary infores. - Example + Examples ------- >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], @@ -315,14 +315,14 @@ def neighborhood_finder_multiple_inputs(input_nodes:list[str], node2_categories: result_ranked_by_primary_infores (DataFrame) The ranked results based on primary infores. + Examples - -------= + -------- >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], APInames = APInames, metaKG = metaKG, API_predicates = API_predicates) - """ from . import node_normalizer from . import translator_query diff --git a/TCT/TCT_network_annotator.py b/TCT/TCT_network_annotator.py index 4a28bb5..00dc63c 100644 --- a/TCT/TCT_network_annotator.py +++ b/TCT/TCT_network_annotator.py @@ -185,8 +185,8 @@ def get_connected_graph(result_parsed, input_identifiers): result_parsed : dict The connected graph extracted from the parsed results. - Example - ------- + Examples + -------- >>> input_identifiers = ['NCBIGene:6774', 'NCBIGene:4170','NCBIGene:4792','NCBIGene:4288','NCBIGene:596','NCBIGene:581','NCBIGene:836','NCBIGene:6777','NCBIGene:4790','NCBIGene:545'] >>> result, result_parsed = TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(input_identifiers, From 414dccfe48c048cffbe884279183815c943a7354 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 09:29:52 -0700 Subject: [PATCH 32/33] update docstrings --- TCT/TCT_neighborhood_finder.py | 12 ++++++------ TCT/TCT_network_annotator.py | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/TCT/TCT_neighborhood_finder.py b/TCT/TCT_neighborhood_finder.py index 9d948a5..31c0fc2 100644 --- a/TCT/TCT_neighborhood_finder.py +++ b/TCT/TCT_neighborhood_finder.py @@ -222,7 +222,7 @@ def neighborhood_finder(input_node, node2_categories, APInames, metaKG, API_pred The ranked results based on primary infores. Examples - ------- + -------- >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], APInames = APInames, @@ -318,11 +318,11 @@ def neighborhood_finder_multiple_inputs(input_nodes:list[str], node2_categories: Examples -------- - >>> input_node_id, result, result_parsed, result_ranked_by_primary_infores1 = neighborhood_finder('MONDO:0008170', #Ovarian Cancer - node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], - APInames = APInames, - metaKG = metaKG, - API_predicates = API_predicates) + >>> result, result_parsed = neighborhood_finder_multiple_inputs(['NCBIGene:6774', 'NCBIGene:4170', 'NCBIGene:4792'], + node2_categories = ['biolink:SmallMolecule', 'biolink:Drug', 'biolink:ChemicalEntity'], + APInames = APInames, + metaKG = metaKG, + API_predicates = API_predicates) """ from . import node_normalizer from . import translator_query diff --git a/TCT/TCT_network_annotator.py b/TCT/TCT_network_annotator.py index 00dc63c..0dff740 100644 --- a/TCT/TCT_network_annotator.py +++ b/TCT/TCT_network_annotator.py @@ -188,13 +188,11 @@ def get_connected_graph(result_parsed, input_identifiers): Examples -------- >>> input_identifiers = ['NCBIGene:6774', 'NCBIGene:4170','NCBIGene:4792','NCBIGene:4288','NCBIGene:596','NCBIGene:581','NCBIGene:836','NCBIGene:6777','NCBIGene:4790','NCBIGene:545'] - >>> result, result_parsed = TCT_neighborhood_finder.neighborhood_finder_multiple_inputs(input_identifiers, node2_categories = ['biolink:Gene','biolink:Protein'], APInames = APInames, metaKG = metaKG, API_predicates = API_predicates) - >>> result = TCT_network_annotator.get_connected_graph(result_parsed, input_identifiers) >>> import datetime >>> import json From a5d9086f04cba119a945a4eedb0582b2512f8cb8 Mon Sep 17 00:00:00 2001 From: yjzhang Date: Tue, 7 Jul 2026 09:42:45 -0700 Subject: [PATCH 33/33] docstring examples --- TCT/TCT_pathfinder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TCT/TCT_pathfinder.py b/TCT/TCT_pathfinder.py index b4e4d27..77cbcad 100644 --- a/TCT/TCT_pathfinder.py +++ b/TCT/TCT_pathfinder.py @@ -37,8 +37,8 @@ def format_query_json_for_pathfinder_with_constraints(subject_ids, query_json_temp : dict a query json for pathfinder pipeline - Example - ------- + Examples + -------- >>> query_json_temp = format_query_json_for_pathfinder_with_constraints( subject_ids='NCBIGene:6774', object_ids='NCBIGene:4170',