diff --git a/code/ARAX/NodeSynonymizer/node_synonymizer.py b/code/ARAX/NodeSynonymizer/node_synonymizer.py index c74fe7abe..aafe89f3b 100644 --- a/code/ARAX/NodeSynonymizer/node_synonymizer.py +++ b/code/ARAX/NodeSynonymizer/node_synonymizer.py @@ -7,6 +7,7 @@ import string import sys import time +import math from collections import defaultdict, Counter from typing import Optional, Union, List, Set, Dict, Tuple @@ -297,6 +298,15 @@ def get_normalizer_results(self, entities: Optional[Union[str, Set[str], List[st entities = entities_dict.get("terms") output_format = entities_dict.get("format") + # Allow the caller to encode the max_synonyms in the input dict (used by web UI) + max_synonyms_raw = entities_dict.get("max_synonyms") + try: + max_synonyms_int = int(max_synonyms_raw) + if max_synonyms_int > 0: + max_synonyms = max_synonyms_int + except: + pass + # Convert any input curies to Set format entities_set = self._convert_to_set_format(entities) @@ -394,6 +404,17 @@ def get_normalizer_results(self, entities: Optional[Union[str, Set[str], List[st if normalizer_info: normalizer_info["knowledge_graph"] = self._get_cluster_graph(normalizer_info) + # Attempt to squash NaNs, which are not legal in JSON. Turn them into nulls + if 'knowledge_graph' in normalizer_info and 'edges' in normalizer_info["knowledge_graph"]: + for edge_name, edge_data in normalizer_info["knowledge_graph"]['edges'].items(): + if 'attributes' in edge_data: + for attribute in edge_data['attributes']: + try: + if 'value' in attribute and math.isnan(attribute['value']): + attribute['value'] = None + except: + pass + if debug: print(f"Took {round(time.time() - start, 5)} seconds") return results_dict diff --git a/code/UI/interactive/araxi.js b/code/UI/interactive/araxi.js index 75d1bff36..c9a9b51e4 100644 --- a/code/UI/interactive/araxi.js +++ b/code/UI/interactive/araxi.js @@ -1,5 +1,5 @@ // WARNING: -// This file was auto-generated by /mnt/data/orangeboard/devLM/RTX/code/UI/interactive/./dsl2json.py on: 2024-09-11 06:23:47 +// This file was auto-generated by /mnt/data/orangeboard/devLM/RTX/code/UI/interactive/./dsl2json.py on: 2024-11-01 01:58:59 // var araxi_commands = { "add_qedge()": { @@ -208,7 +208,7 @@ var araxi_commands = { "description": "Whether to omit supporting data on nodes/edges in the results (e.g., publications, description, etc.)." } }, - "description": "This command will expand (aka, answer/fill) your query graph in an edge-by-edge fashion, intelligently selecting which KPs to use for each edge. It selects KPs from the SmartAPI Registry based on the meta information provided by their TRAPI APIs, whether they have an endpoint running a matching TRAPI version, and whether they have an endpoint with matching maturity. For each QEdge, it queries the selected KPs concurrently; it will timeout for a particular KP if it decides it's taking too long to respond (this KP timeout can be controlled by the user). You may also optionally specify a particular KP to use via the 'kp' parameter (described below).\n\nCurrent candidate KPs include (for TRAPI 1.5, maturity 'development'): \ninfores:answer-coalesce, infores:automat-binding-db, infores:automat-cam-kp, infores:automat-ctd, infores:automat-drug-central, infores:automat-genome-alliance, infores:automat-gtex, infores:automat-gtopdb, infores:automat-gwas-catalog, infores:automat-hetionet, infores:automat-hgnc, infores:automat-hmdb, infores:automat-human-goa, infores:automat-icees-kg, infores:automat-intact, infores:automat-monarchinitiative, infores:automat-panther, infores:automat-pharos, infores:automat-reactome, infores:automat-robokop, infores:automat-string-db, infores:automat-ubergraph, infores:automat-viral-proteome, infores:cohd, infores:connections-hypothesis, infores:gelinea, infores:genetics-data-provider, infores:knowledge-collaboratory, infores:molepro, infores:multiomics-clinicaltrials, infores:multiomics-drugapprovals, infores:multiomics-microbiome, infores:multiomics-multiomics, infores:openpredict, infores:rtx-kg2, infores:service-provider-trapi, infores:spoke. \n\n(Note that this list of KPs may change unexpectedly based on the SmartAPI registry.)" + "description": "This command will expand (aka, answer/fill) your query graph in an edge-by-edge fashion, intelligently selecting which KPs to use for each edge. It selects KPs from the SmartAPI Registry based on the meta information provided by their TRAPI APIs, whether they have an endpoint running a matching TRAPI version, and whether they have an endpoint with matching maturity. For each QEdge, it queries the selected KPs concurrently; it will timeout for a particular KP if it decides it's taking too long to respond (this KP timeout can be controlled by the user). You may also optionally specify a particular KP to use via the 'kp' parameter (described below).\n\nCurrent candidate KPs include (for TRAPI 1.5, maturity 'development'): \ninfores:answer-coalesce, infores:automat-binding-db, infores:automat-cam-kp, infores:automat-ctd, infores:automat-drug-central, infores:automat-ehr-clinical-connections-kp, infores:automat-ehr-may-treat-kp, infores:automat-genome-alliance, infores:automat-gtex, infores:automat-gtopdb, infores:automat-gwas-catalog, infores:automat-hetionet, infores:automat-hgnc, infores:automat-hmdb, infores:automat-human-goa, infores:automat-icees-kg, infores:automat-intact, infores:automat-monarchinitiative, infores:automat-panther, infores:automat-pharos, infores:automat-reactome, infores:automat-robokop, infores:automat-string-db, infores:automat-ubergraph, infores:automat-viral-proteome, infores:cohd, infores:connections-hypothesis, infores:gelinea, infores:genetics-data-provider, infores:knowledge-collaboratory, infores:molepro, infores:multiomics-clinicaltrials, infores:multiomics-drugapprovals, infores:multiomics-microbiome, infores:multiomics-multiomics, infores:openpredict, infores:rtx-kg2, infores:service-provider-trapi, infores:spoke. \n\n(Note that this list of KPs may change unexpectedly based on the SmartAPI registry.)" }, "overlay(action=add_node_pmids)": { "parameters": { @@ -1360,32 +1360,10 @@ var araxi_commands = { "min": 1, "max": 5, "type": "integer", - "description": "The maximum edges to connect two nodes with. If not provided defaults to 2." - }, - "qnode_keys": { - "is_required": true, - "examples": [ - [ - "n01", - "n02" - ], - [] - ], - "type": "list", - "description": "List with just two qnode keys to connect. example: [n1, n2]" - }, - "node_category_constraint": { - "is_required": false, - "examples": [ - "biolink:Disease", - "biolink:Gene", - "biolink:ChemicalEntity" - ], - "type": "string", - "description": "This constraint will display paths that only pass through the user-specified category." + "description": "The maximum edges to connect two nodes with. If not provided defaults to 4." } }, - "description": "\nconnect_nodes adds paths between two nodes specified in the query.\n " + "description": "connect_nodes adds paths between two nodes specified in the query." }, "infer(action=chemical_gene_regulation_graph_expansion)": { "parameters": { @@ -1435,7 +1413,7 @@ var araxi_commands = { "qedge_id_3" ], "type": "string", - "description": "The id of the qedge you wish to perform the drug treatment/chemical regulation inference expansion." + "description": "The id of the qedge you wish to perform the chemical-gene regulation inference expansion." }, "threshold": { "is_required": false, @@ -1506,7 +1484,17 @@ var araxi_commands = { }, "infer(action=drug_treatment_graph_expansion)": { "parameters": { - "node_curie": { + "drug_curie": { + "is_required": true, + "examples": [ + "CHEMBL.COMPOUND:CHEMBL55643", + "CHEBI:8378", + "RXNORM:1011" + ], + "type": "string", + "description": "The CURIE for a drug node used to predict what potential diseases it may treat." + }, + "disease_curie": { "is_required": true, "examples": [ "DOID:9352", @@ -1514,7 +1502,7 @@ var araxi_commands = { "HP:0001945" ], "type": "string", - "description": "The curie for the node you wish to predict drugs which will treat." + "description": "The CURIE for a disease node used to predict what potential drugs can potentially treat it." }, "qedge_id": { "is_required": false, @@ -1524,7 +1512,7 @@ var araxi_commands = { "qedge_id_3" ], "type": "string", - "description": "The id of the qedge you wish to perform the drug treatment/chemical regulation inference expansion." + "description": "The id of the qedge you wish to perform the drug-disease treatment inference expansion." }, "n_drugs": { "is_required": false, @@ -1535,7 +1523,18 @@ var araxi_commands = { ], "default": 50, "type": "integer", - "description": "The number of drug nodes to return. If not provided defaults to 50. Considering the response speed, the maximum number of drugs returned is only allowed to be 50." + "description": "Given an interested disease CURIE, the number of drug nodes to return. If not provided defaults to 50. Considering the response speed, the maximum number of drugs returned is only allowed to be 50." + }, + "n_diseases": { + "is_required": false, + "examples": [ + 5, + 15, + 25 + ], + "default": 50, + "type": "integer", + "description": "Given an interested drug CURIE, The number of disease nodes to return. If not provided defaults to 50. Considering the response speed, the maximum number of diseases returned is only allowed to be 50." }, "n_paths": { "is_required": false, diff --git a/code/UI/interactive/index.html b/code/UI/interactive/index.html index 33dbb1f9a..f1ca6f3ea 100644 --- a/code/UI/interactive/index.html +++ b/code/UI/interactive/index.html @@ -4,7 +4,7 @@