{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# include path ../src in order to import modules\n",
    "import sys\n",
    "sys.path.append('../TCT')\n",
    "import TCT as TCT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "69\n"
     ]
    }
   ],
   "source": [
    "# Step1: List all the APIs in the translator system\n",
    "APInames = TCT.list_Translator_APIs()\n",
    "print(len(APInames))\n",
    "#print(APInames.keys())\n",
    "\n",
    "# Step 2: Get metaKG and all predicates from Translator APIs\n",
    "metaKG = TCT.get_KP_metadata(APInames) # This only applies to the Translator APIs\n",
    "#print(metaKG.columns)\n",
    "#print(metaKG.shape)\n",
    "\n",
    "#metaKG.to_csv('../metaData/metaKG.csv', index=False)\n",
    "#metaKG = pd.read_csv('../metaData/metaKG.csv')\n",
    "All_predicates = list(set(metaKG['KG_category']))\n",
    "All_categories = list((set(list(set(metaKG['Subject']))+list(set(metaKG['Object'])))))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Automat-ctd(Trapi v1.4.0)': 'https://automat.transltr.io/ctd/1.4/query',\n",
       " 'BioThings Explorer (BTE) TRAPI': 'https://bte.transltr.io/v1/query',\n",
       " 'Biothings Therapeutic Target Database API': 'https://biothings.ncats.io/ttd/query',\n",
       " 'Aragorn(Trapi v1.4.0)': 'https://aragorn.transltr.io/aragorn/query',\n",
       " 'ARAX Translator Reasoner - TRAPI 1.4.0': 'https://arax.transltr.io/api/arax/v1.4/query',\n",
       " 'RTX KG2 - TRAPI 1.4.0': 'https://arax.ncats.io/api/rtxkg2/v1.4/query',\n",
       " 'SPOKE KP for TRAPI 1.4': 'https://spokekp.transltr.io/api/v1.4/query',\n",
       " 'Multiomics BigGIM-DrugResponse KP API': 'https://bte.test.transltr.io/v1/smartapi/adf20dd6ff23dfe18e8e012bde686e31/query',\n",
       " 'Multiomics ClinicalTrials KP': 'https://api.bte.ncats.io/v1/smartapi/d86a24f6027ffe778f84ba10a7a1861a/query',\n",
       " 'Multiomics Wellness KP API': 'https://api.bte.ncats.io/v1/smartapi/02af7d098ab304e80d6f4806c3527027/query',\n",
       " 'Multiomics EHR Risk KP API': 'https://api.bte.ncats.io/v1/smartapi/d86a24f6027ffe778f84ba10a7a1861a/query',\n",
       " 'Biothings Explorer (BTE)': 'https://bte.transltr.io/v1/query',\n",
       " 'Service Provider TRAPI': 'https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query',\n",
       " 'Explanatory-agent': 'https://explanatory-agent-creative.azurewebsites.net/ARA/v1.3/asyncquery',\n",
       " 'MolePro': 'https://translator.broadinstitute.org/molepro/trapi/v1.4/query',\n",
       " 'Genetics KP': 'https://genetics-kp.transltr.io/genetics_provider/trapi/v1.4/query',\n",
       " 'medikanren-unsecret': 'https://medikanren-trapi.transltr.io/query',\n",
       " 'Text Mined Cooccurrence API': 'https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query',\n",
       " 'OpenPredict API': 'https://openpredict.transltr.io/query',\n",
       " 'Agrkb(Trapi v1.4.0)': 'https://automat.transltr.io/genome-alliance/1.4/query',\n",
       " 'Automat-biolink(Trapi v1.4.0)': 'https://automat.renci.org/biolink/1.4/query',\n",
       " 'Automat-cam-kp(Trapi v1.4.0)': 'https://automat.ci.transltr.io/cam-kp/1.4/query?limit=100',\n",
       " 'Automat-drug-central(Trapi v1.4.0)': 'https://automat.ci.renci.org/drugcentral/1.4/query',\n",
       " 'Automat-gtex(Trapi v1.4.0)': 'https://automat.renci.org/gtex/1.4/query',\n",
       " 'Automat-gtopdb(Trapi v1.4.0)': 'https://automat.renci.org/gtopdb/1.4/query',\n",
       " 'Automat-gwas-catalog(Trapi v1.4.0)': 'https://automat.renci.org/gwas-catalog/1.4/query',\n",
       " 'Automat-hetio(Trapi v1.4.0)': 'https://automat.ci.transltr.io/hetio/1.4/query',\n",
       " 'Automat-hgnc(Trapi v1.4.0)': 'https://automat.renci.org/hgnc/1.4/query',\n",
       " 'Automat-hmdb(Trapi v1.4.0)': 'https://automat.renci.org/hmdb/1.4/query',\n",
       " 'Automat-human-goa(Trapi v1.4.0)': 'https://automat.renci.org/human-goa/1.4/query',\n",
       " 'Automat-icees-kg(Trapi v1.4.0)': 'https://automat.renci.org/icees-kg/1.4/query',\n",
       " 'Automat-intact(Trapi v1.4.0)': 'https://automat.renci.org/intact/1.4/query',\n",
       " 'Automat-panther(Trapi v1.4.0)': 'https://automat.renci.org/panther/1.4/query',\n",
       " 'Automat-pharos(Trapi v1.4.0)': 'https://automat.renci.org/pharos/1.4/query',\n",
       " 'Automat-robokop(Trapi v1.4.0)': 'https://ars-prod.transltr.io/ara-robokop/api/runquery',\n",
       " 'Automat-sri-reference-kp(Trapi v1.4.0)': 'https://automat.ci.transltr.io/sri-reference-kp/1.4/query',\n",
       " 'Automat-string-db(Trapi v1.4.0)': 'https://automat.ci.transltr.io/string-db/1.4/query',\n",
       " 'Automat-ubergraph(Trapi v1.4.0)': 'https://automat.ci.transltr.io/ubergraph/1.4/query',\n",
       " 'Automat-ubergraph-nonredundant(Trapi v1.4.0)': 'https://automat.ci.transltr.io/ubergraph-nonredundant/1.4/query',\n",
       " 'Automat-viral-proteome(Trapi v1.4.0)': 'https://automat.ci.transltr.io/viral-proteome/1.4/query',\n",
       " 'CTD API': 'https://automat.ci.transltr.io/ctd/1.4/query',\n",
       " 'Connections Hypothesis Provider API': 'https://chp-api.transltr.io/query',\n",
       " 'MyGene.info API': 'https://api.bte.ncats.io/v1/smartapi/59dce17363dce279d389100834e43648/query',\n",
       " 'MyDisease.info API': 'https://api.bte.ncats.io/v1/smartapi/671b45c0301c8624abbd26ae78449ca2/query',\n",
       " 'MyChem.info API': 'https://api.bte.ncats.io/v1/8f08d1446e0bb9c2b323713ce83e2bd3/query',\n",
       " 'MyVariant.info API': 'https://api.bte.ncats.io/v1/59dce17363dce279d389100834e43648/query',\n",
       " 'Ontology Lookup Service API': 'https://api.bte.ncats.io/v1/1c056ffc7ed0dd1229e71c4752239465/query',\n",
       " 'PharmGKB REST API': 'https://api.bte.ncats.io/v1/bde72db681ec0b8f9eeb67bb6b8dd72c/query',\n",
       " 'QuickGO API': 'https://api.bte.ncats.io/v1/1f277e1563fcfd124bfae2cc3c4bcdec/query',\n",
       " 'Text Mining Targeted Association API': 'https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query',\n",
       " 'BioThings BindingDB API': 'https://api.bte.ncats.io/v1/smartapi/38e9e5169a72aee3659c9ddba956790d/query',\n",
       " 'BioThings BioPlanet Pathway-Disease API': 'https://api.bte.ncats.io/v1/smartapi/55a223c6c6e0291dbd05f2faf27d16f4/query',\n",
       " 'BioThings DDinter API': 'https://api.bte.ncats.io/v1/smartapi/00fb85fc776279163199e6c50f6ddfc6/query',\n",
       " 'BioThings DGIdb API': 'https://api.bte.ncats.io/v1/smartapi/e3edd325c76f2992a111b43a907a4870/query',\n",
       " 'BioThings DISEASES API': 'https://api.bte.ncats.io/v1/smartapi/a7f784626a426d054885a5f33f17d3f8/query',\n",
       " 'BioThings EBIgene2phenotype API': 'https://api.bte.ncats.io/v1/smartapi/1f47552dabd67351d4c625adb0a10d00/query',\n",
       " 'BioThings Biological Process API': 'https://api.bte.ncats.io/v1/smartapi/cc857d5b7c8b7609b5bbb38ff990bfff/query',\n",
       " 'BioThings GO Cellular Component API': 'https://api.bte.ncats.io/v1/smartapi/f339b28426e7bf72028f60feefcd7465/query',\n",
       " 'BioThings GO Molecular Function API': 'https://api.bte.ncats.io/v1/smartapi/34bad236d77bea0a0ee6c6cba5be54a6/query',\n",
       " 'BioThings GTRx API': 'https://api.bte.ncats.io/v1/smartapi/316eab811fd9ef1097df98bcaa9f7361/query',\n",
       " 'BioThings HPO API': 'https://api.bte.ncats.io/v1/smartapi/d7d1cc9bbe04ad9936076ca5aea904fe/query',\n",
       " 'BioThings IDISK API': 'https://api.bte.ncats.io/v1/smartapi/32f36164fabed5d3abe6c2fd899c9418/query',\n",
       " 'BioThings MGIgene2phenotype API': 'https://api.bte.ncats.io/v1/smartapi/77ed27f111262d0289ed4f4071faa619/query',\n",
       " 'BioThings PFOCR API': 'https://api.bte.ncats.io/v1/smartapi/edeb26858bd27d0322af93e7a9e08761/query',\n",
       " 'Biothings RARe-SOURCE API': 'https://api.bte.ncats.io/v1/smartapi/b772ebfbfa536bba37764d7fddb11d6f/query',\n",
       " 'BioThings Rhea API': 'https://api.bte.ncats.io/v1/smartapi/03283cc2b21c077be6794e1704b1d230/query',\n",
       " 'BioThings SEMMEDDB API': 'https://api.bte.ncats.io/v1/smartapi/1d288b3a3caf75d541ffaae3aab386c8/query',\n",
       " 'BioThings SuppKG API': 'https://api.bte.ncats.io/v1/smartapi/b48c34df08d16311e3bca06b135b828d/query',\n",
       " 'BioThings UBERON API': 'https://api.bte.ncats.io/v1/smartapi/ec6d76016ef40f284359d17fbf78df20/query'}"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "APInames"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['CHEBI:31690']\n",
      "['MONDO:0004979']\n"
     ]
    }
   ],
   "source": [
    "# Step 3: set input parameters\n",
    "\n",
    "Number_of_hopes = 3\n",
    "\n",
    "# start node for query\n",
    "start_nodes_list = ['imatinib']\n",
    "start_nodes_list_ids = []\n",
    "for start_node1 in start_nodes_list:\n",
    "    start_nodes_list_ids.append(TCT.get_curie(start_node1))\n",
    "\n",
    "start_nodes_list = start_nodes_list_ids\n",
    "start_nodes_list = ['CHEBI:31690']\n",
    "start_nodes_category = ['biolink:Drug','biolink:ChemicalSubstance', 'biolink:SmallMolecule'] # Node: this has to be in a format of biolink:xxx\n",
    "print(start_nodes_list)\n",
    "# end node for query\n",
    "end_nodes_list = ['allergic asthama']\n",
    "end_nodes_list_ids = []\n",
    "for end_node1 in end_nodes_list:\n",
    "    end_nodes_list_ids.append(TCT.get_curie(end_node1))\n",
    "\n",
    "end_nodes_list = start_nodes_list_ids\n",
    "end_nodes_list = ['MONDO:0004979']\n",
    "end_node_category = ['biolink:Disease'] # Node: this has to be in a format of biolink:xxx\n",
    "print(end_nodes_list)\n",
    "\n",
    "#constrain nodes for query\n",
    "# constrain node 1\n",
    "intermediate_node2_list = []\n",
    "intermediate_node2_category = ['biolink:Gene','biolink:Protein'] # Node: this has to be in a format of biolink:xxx\n",
    "\n",
    "# constrain node 2\n",
    "intermediate_node3_list = []\n",
    "#intermediate_node3_category = ['biolink:Cell'] # Node: this has to be in a format of biolink:xxx\n",
    "intermediate_node3_category = ['biolink:Cell']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "all relevant predicates in Translator:\n",
      "46\n",
      "all relevant APIs in Translator:\n",
      "17\n",
      "all relevant predicates in Translator:\n",
      "10\n",
      "all relevant APIs in Translator:\n",
      "7\n",
      "all relevant predicates in Translator:\n",
      "17\n",
      "all relevant APIs in Translator:\n",
      "8\n"
     ]
    }
   ],
   "source": [
    "# Get all predicates for the input node1 and node2, user can furter select the predicates among this list\n",
    "sele_predicates = list(set(TCT.select_concept(sub_list=start_nodes_category,\n",
    "                                              obj_list=intermediate_node2_category,\n",
    "                                              metaKG=metaKG)))\n",
    "\n",
    "print(\"all relevant predicates in Translator:\")\n",
    "print(len(sele_predicates))\n",
    "# select predicates\n",
    "\n",
    "# Get all APIs for the input node1 and node2, user can furter select the APIs among this list\n",
    "sele_APIs_1 = TCT.select_API(sub_list=start_nodes_category,\n",
    "                             obj_list=intermediate_node2_category,\n",
    "                             metaKG=metaKG)\n",
    "print(\"all relevant APIs in Translator:\")\n",
    "print(len(sele_APIs_1))\n",
    "\n",
    "# get API URLs\n",
    "API_URLs_1 = TCT.get_Translator_API_URL(sele_APIs_1, APInames)\n",
    "\n",
    "#---------------------------------------------------------------------------------------------------------------------------------#\n",
    "\n",
    "\n",
    "# Get all predicates for the input node1 and node2, user can furter select the predicates among this list\n",
    "sele_predicates_2 = list(set(TCT.select_concept(sub_list=end_node_category,\n",
    "                                                obj_list=intermediate_node3_category,\n",
    "                                                metaKG=metaKG)))\n",
    "print(\"all relevant predicates in Translator:\")\n",
    "print(len(sele_predicates_2))\n",
    "# select predicates\n",
    "\n",
    "# Get all APIs for the input node1 and node2, user can furter select the APIs among this list\n",
    "sele_APIs_2 = TCT.select_API(sub_list=end_node_category,\n",
    "                             obj_list=intermediate_node3_category,\n",
    "                             metaKG=metaKG)\n",
    "print(\"all relevant APIs in Translator:\")\n",
    "print(len(sele_APIs_2))\n",
    "\n",
    "# get API URLs\n",
    "API_URLs_2 = TCT.get_Translator_API_URL(sele_APIs_2, \n",
    "                                      APInames)\n",
    "#---------------------------------------------------------------------------------------------------------------------------------#\n",
    "\n",
    "# Step 3:\n",
    "sele_predicates_3 = list(set(TCT.select_concept(sub_list=intermediate_node2_category,\n",
    "                                                obj_list=intermediate_node3_category,\n",
    "                                                metaKG=metaKG)))\n",
    "print(\"all relevant predicates in Translator:\")\n",
    "print(len(sele_predicates_3))\n",
    "# select predicates\n",
    "\n",
    "# Get all APIs for the input node1 and node2, user can furter select the APIs among this list\n",
    "sele_APIs_3 = TCT.select_API(sub_list=intermediate_node2_category,\n",
    "                             obj_list=intermediate_node3_category,\n",
    "                             metaKG=metaKG)\n",
    "print(\"all relevant APIs in Translator:\")\n",
    "print(len(sele_APIs_3))\n",
    "\n",
    "# get API URLs\n",
    "API_URLs_3 = TCT.get_Translator_API_URL(sele_APIs_2, \n",
    "                                      APInames)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['biolink:Drug', 'biolink:ChemicalSubstance', 'biolink:SmallMolecule']"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "start_nodes_category"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning Code:502:https://translator.broadinstitute.org/molepro/trapi/v1.4/query\n",
      "Warning Code:405:https://automat.ci.transltr.io/ctd/1.4/query\n",
      "Success!https://openpredict.transltr.io/query\n",
      "Warning Code:404:https://api.bte.ncats.io/v1/8f08d1446e0bb9c2b323713ce83e2bd3/query\n",
      "Warning Code:404:https://api.bte.ncats.io/v1/bde72db681ec0b8f9eeb67bb6b8dd72c/query\n",
      "Success!https://bte.test.transltr.io/v1/smartapi/adf20dd6ff23dfe18e8e012bde686e31/query\n",
      "Warning Code:400:https://biothings.ncats.io/ttd/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/e3edd325c76f2992a111b43a907a4870/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/38e9e5169a72aee3659c9ddba956790d/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/edeb26858bd27d0322af93e7a9e08761/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/02af7d098ab304e80d6f4806c3527027/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/1d288b3a3caf75d541ffaae3aab386c8/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query\n",
      "Success!https://bte.transltr.io/v1/query\n",
      "Success!https://bte.transltr.io/v1/query\n"
     ]
    }
   ],
   "source": [
    "# Step 4: Format query json\n",
    "query_json1 = TCT.format_query_json(start_nodes_list,  # a list of identifiers for input node1\n",
    "                                   intermediate_node2_list,  # it can be empty list if only want to query node1\n",
    "                                   start_nodes_category,  # a list of categories of input node1\n",
    "                                   intermediate_node2_category,  # a list of categories of input node2\n",
    "                                   sele_predicates) # a list of predicates\n",
    "# Step 5: Query Translator APIs and parse results\n",
    "result1 = TCT.parallel_api_query(API_URLs_1,query_json=query_json1, max_workers=len(API_URLs_1))\n",
    "# Step 6: Parse results\n",
    "result_parsed1 = TCT.parse_KG(result1)\n",
    "# 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.\n",
    "#result_ranked_by_primary_infores = TCT.rank_by_primary_infores(result_parsed, input_node1_id)   # input_node1_id is the curie id of the input node, such as \"NCBIGene:672\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning Code:502:https://translator.broadinstitute.org/molepro/trapi/v1.4/query\n",
      "Warning Code:405:https://automat.ci.transltr.io/ctd/1.4/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/1d288b3a3caf75d541ffaae3aab386c8/query\n",
      "Success!https://bte.transltr.io/v1/query\n",
      "Success!https://bte.transltr.io/v1/query\n"
     ]
    }
   ],
   "source": [
    "# Step 4: Format query json\n",
    "query_json2 = TCT.format_query_json(end_nodes_list,  # a list of identifiers for input node1\n",
    "                                   intermediate_node3_list,  # it can be empty list if only want to query node1\n",
    "                                   end_node_category,  # a list of categories of input node1\n",
    "                                   intermediate_node3_category,  # a list of categories of input node2\n",
    "                                   sele_predicates_2) # a list of predicates\n",
    "# Step 5: Query Translator APIs and parse results\n",
    "result2 = TCT.parallel_api_query(API_URLs_2,query_json=query_json2, max_workers=len(API_URLs_2))\n",
    "# Step 6: Parse results\n",
    "result_parsed2 = TCT.parse_KG(result2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The starting node is: \n",
      "imatinib\n",
      "['CHEBI:31690']\n",
      "The end node is:\n",
      "allergic asthama\n",
      "['MONDO:0004979']\n"
     ]
    }
   ],
   "source": [
    "print(\"The starting node is: \")\n",
    "print(start_node1)\n",
    "print(start_nodes_list)\n",
    "\n",
    "print(\"The end node is:\")\n",
    "print(end_node1)\n",
    "print(end_nodes_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2005\n",
      "7\n"
     ]
    }
   ],
   "source": [
    "# Now we have the nodes that are connected with the input node1 and node2 shown in result_parsed1 and result_parsed2, now we would like to see whether the intermediate nodes are connected and how they are connected.\n",
    "\n",
    "# Now parse teh intermediate nodes to get a list of intermediate nodes\n",
    "intermediate1_ids = set()\n",
    "intermediate2_ids = set()\n",
    "\n",
    "for key in result_parsed1.keys():\n",
    "    if (result_parsed1[key]['object'] not in start_nodes_list) and (result_parsed1[key]['subject'] in start_nodes_list):\n",
    "        intermediate1_ids.add(result_parsed1[key]['object'])\n",
    "    if (result_parsed1[key]['subject'] not in start_nodes_list) and (result_parsed1[key]['object'] in start_nodes_list):\n",
    "        intermediate1_ids.add(result_parsed1[key]['subject'])\n",
    "print(len(intermediate1_ids))\n",
    "\n",
    "for key in result_parsed2.keys():\n",
    "    if (result_parsed2[key]['object'] not in end_nodes_list_ids) and (result_parsed2[key]['subject']  in end_nodes_list):\n",
    "        intermediate2_ids.add(result_parsed2[key]['object'])\n",
    "    if (result_parsed2[key]['subject'] not in end_nodes_list_ids) and (result_parsed2[key]['object']  in end_nodes_list):\n",
    "        intermediate2_ids.add(result_parsed2[key]['subject'])\n",
    "print(len(intermediate2_ids))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "#print((intermediate2_ids).intersection((intermediate1_ids)))\n",
    "print(len(intermediate2_ids.intersection(intermediate1_ids)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "all relevant predicates in Translator:\n",
      "17\n",
      "all relevant APIs in Translator:\n",
      "8\n"
     ]
    }
   ],
   "source": [
    "# Step 3:\n",
    "sele_predicates_3 = list(set(TCT.select_concept(sub_list=intermediate_node2_category,\n",
    "                                                obj_list=intermediate_node3_category,\n",
    "                                                metaKG=metaKG)))\n",
    "sele_predicates_3_1 = list(set(TCT.select_concept(sub_list=intermediate_node3_category,\n",
    "                                                obj_list=intermediate_node2_category,\n",
    "                                                metaKG=metaKG)))\n",
    "sele_predicates_3 = list(set(sele_predicates_3_1 + sele_predicates_3))\n",
    "\n",
    "print(\"all relevant predicates in Translator:\")\n",
    "print(len(sele_predicates_3))\n",
    "# select predicates\n",
    "\n",
    "# Get all APIs for the input node1 and node2, user can furter select the APIs among this list\n",
    "sele_APIs_3 = TCT.select_API(sub_list=intermediate_node2_category,\n",
    "                             obj_list=intermediate_node3_category,\n",
    "                             metaKG=metaKG)\n",
    "print(\"all relevant APIs in Translator:\")\n",
    "print(len(sele_APIs_3))\n",
    "\n",
    "# get API URLs\n",
    "API_URLs_3 = TCT.get_Translator_API_URL(sele_APIs_3, \n",
    "                                      APInames)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['RTX KG2 - TRAPI 1.4.0',\n",
       " 'Multiomics BigGIM-DrugResponse KP API',\n",
       " 'Text Mined Cooccurrence API',\n",
       " 'MolePro',\n",
       " 'Service Provider TRAPI',\n",
       " 'Biothings Explorer (BTE)',\n",
       " 'BioThings SEMMEDDB API',\n",
       " 'BioThings Explorer (BTE) TRAPI']"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sele_APIs_3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'CL:0000084',\n",
       " 'CL:0000097',\n",
       " 'CL:0000771',\n",
       " 'UMLS:C0014467',\n",
       " 'UMLS:C0024880',\n",
       " 'UMLS:C0039194',\n",
       " 'UMLS:C0242633'}"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "intermediate2_ids"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "Warning Code:502:https://translator.broadinstitute.org/molepro/trapi/v1.4/query\n",
      "Warning Code:400:https://arax.ncats.io/api/rtxkg2/v1.4/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/978fe380a147a8641caf72320862697b/query\n",
      "Success!https://bte.transltr.io/v1/query\n",
      "Success!https://bte.transltr.io/v1/query\n",
      "Success!https://bte.test.transltr.io/v1/smartapi/adf20dd6ff23dfe18e8e012bde686e31/query\n",
      "Success!https://api.bte.ncats.io/v1/smartapi/1d288b3a3caf75d541ffaae3aab386c8/query\n"
     ]
    }
   ],
   "source": [
    "# Query and parse the result:\n",
    "result_path = set()\n",
    "if len(intermediate1_ids) < len(intermediate2_ids):\n",
    "    print(1)\n",
    "    sele_predicates_3 = list(set(TCT.select_concept(sub_list=intermediate_node2_category,\n",
    "                                                obj_list=intermediate_node3_category,\n",
    "                                                metaKG=metaKG)))\n",
    "    query_json3 = TCT.format_query_json(list(intermediate1_ids),  # a list of identifiers for input node1\n",
    "                                    [],  # it can be empty list if only want to query node1\n",
    "                                    intermediate_node2_category,  # a list of categories of input node1\n",
    "                                    intermediate_node3_category,  # a list of categories of input node2\n",
    "                                    sele_predicates_3) # a list of predicates\n",
    "# Step 5: Query Translator APIs and parse results\n",
    "    result3 = TCT.parallel_api_query(API_URLs_3,query_json=query_json3, max_workers=len(API_URLs_3))\n",
    "# Step 6: Parse results\n",
    "    result_parsed3 = TCT.parse_KG(result3)\n",
    "    for key in result_parsed3.keys():\n",
    "        if (result_parsed3[key]['subject'] in intermediate1_ids) and (result_parsed3[key]['object'] in intermediate2_ids):\n",
    "            result_path.add(start_node1 + ' > ' \n",
    "                            + result_parsed3[key]['subject'] + ' > ' \n",
    "                            + result_parsed3[key]['object'] + ' > ' \n",
    "                            + end_node1)\n",
    "        \n",
    "\n",
    "else:\n",
    "    print(\"2\")\n",
    "    sele_predicates_3 = list(set(TCT.select_concept(sub_list=intermediate_node3_category,\n",
    "                                                obj_list=intermediate_node2_category,\n",
    "                                                metaKG=metaKG)))\n",
    "    query_json3 = TCT.format_query_json(#list(intermediate2_ids),  # a list of identifiers for input node1\n",
    "                                    \n",
    "                                    ['CL:0000084','CL:0000097', 'CL:0000771',], \n",
    "                                    [], # it can be empty list if only want to query node1\n",
    "                                    intermediate_node3_category,  # a list of categories of input node1\n",
    "                                    intermediate_node2_category,  # a list of categories of input node2\n",
    "                                    sele_predicates_3)\n",
    "    \n",
    "    result3 = TCT.parallel_api_query(API_URLs_3,query_json=query_json3, max_workers=len(API_URLs_3))\n",
    "# Step 6: Parse results\n",
    "    result_parsed3 = TCT.parse_KG(result3)\n",
    "    for key in result_parsed3.keys():\n",
    "        if (result_parsed3[key]['subject'] in intermediate2_ids) and (result_parsed3[key]['object'] in intermediate1_ids):\n",
    "            result_path.add(start_node1 + ' > ' \n",
    "                            + result_parsed3[key]['object'] + ' > ' \n",
    "                            + result_parsed3[key]['subject'] + ' > ' \n",
    "                            + end_node1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "374\n",
      "{'imatinib > NCBIGene:6363 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7294 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7040 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3439 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3932 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100616103 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5728 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2551 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3689 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100862684 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6714 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3586 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5914 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2048 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3579 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:7490 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4803 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:50615 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4088 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:54474 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7098 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:909 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4790 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7040 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:6387 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:962 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3717 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5594 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:1901 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4982 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5293 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6786 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1385 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3725 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1956 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:90865 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6347 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:619465 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3562 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5335 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3662 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6279 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3586 > CL:0000097 > allergic asthama', 'imatinib > UMLS:C0031727 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:8030 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:941 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100862683 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4609 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3559 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3669 > CL:0000097 > allergic asthama', 'imatinib > UMLS:C0242643 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6348 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3716 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100775105 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:5293 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3815 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3559 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:4087 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:9429 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5788 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7297 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:931 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3553 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3569 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100616102 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:65125 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3091 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1432 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3669 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5465 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5906 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4690 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3682 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:22882 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6402 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5599 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:814 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7157 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100616101 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:998 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:729230 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6774 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100133941 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2048 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:112476 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:867 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5133 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:8600 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:604 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2623 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:50943 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10344 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:100862684 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3576 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:26191 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1803 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6714 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:54386 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:940 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0009325 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3630 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7018 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100616103 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:6778 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:942 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6139 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:9021 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:84868 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:596 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4067 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:7124 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3902 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:387 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:355 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:760 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:1390 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2885 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3725 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3921 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2534 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:50616 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:182 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:84876 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2314 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1786 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6776 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0031727 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:7852 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:619465 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1026 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0009325 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3576 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:140885 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:55824 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3684 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3308 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6402 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3576 > CL:0000771 > allergic asthama', 'imatinib > UMLS:C0164786 > CL:0000097 > allergic asthama', 'imatinib > UMLS:C0164786 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:929 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1088 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:9308 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3689 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3824 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:916 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1959 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1543 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2212 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6426 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6037 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:29984 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3702 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7039 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:969 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0040690 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6010 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1215 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:2309 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3627 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100775105 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7097 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2624 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:581 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:355 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:2215 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2625 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7124 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:51761 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1029 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:947 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6772 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4067 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:928 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:6646 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3578 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2069 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7040 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3643 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7100 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:961 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:9242 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1234 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:207 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:9338 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3596 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:836 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10365 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0072470 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:634 > CL:0000084 > allergic asthama', 'imatinib > MESH:D016392 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0169661 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6850 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:960 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:324 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3497 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:22806 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1432 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:23595 > CL:0000084 > allergic asthama', 'imatinib > MESH:D053148 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10657 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10673 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:27181 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:6775 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10671 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0105770 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:8651 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4602 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3845 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3497 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:2353 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:90865 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:5290 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6857 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5777 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2534 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:51014 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3552 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0920288 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:100862683 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:930 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3606 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7096 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7097 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:6347 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:613 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:29126 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:928 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100616101 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:7097 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:8795 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1437 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:501 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10563 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2353 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:5879 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7037 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2099 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6356 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:5966 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5777 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3718 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5594 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3605 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3558 > CL:0000084 > allergic asthama', 'imatinib > MESH:D016328 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2833 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6352 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:27 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4684 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:943 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4340 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5473 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6098 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:100616102 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:1154 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10534 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2214 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:969 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:207 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:6376 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6693 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6403 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:58191 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1788 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:958 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2064 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:983 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10344 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4286 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:6647 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5175 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6778 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:6513 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3429 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4760 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:841 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:644914 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7099 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0033681 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:9181 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2185 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3559 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:8878 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1493 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3669 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:7422 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:57007 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5594 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7293 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5970 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7189 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3458 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4803 > CL:0000097 > allergic asthama', 'imatinib > UMLS:C0040690 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:953 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:861 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3635 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5781 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5715 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3383 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3916 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:8999 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:59067 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3014 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7535 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:945 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5294 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:27087 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7422 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:6776 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:10018 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6932 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4780 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:970 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:962 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:64689 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10598 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1021 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:27065 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2475 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3578 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:8784 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6850 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4283 > CL:0000084 > allergic asthama', 'imatinib > UMLS:C0040690 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:324 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4193 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5896 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:952 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:10320 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:7124 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:6777 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3684 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:26762 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6352 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:90865 > CL:0000097 > allergic asthama', 'imatinib > UMLS:C0169661 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:3497 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1445 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4851 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:959 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3579 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3439 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3567 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:6404 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:27342 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3620 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5196 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3930 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:27181 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:5327 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:4803 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:760 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3265 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1019 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:54106 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:115650 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3574 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:2113 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:1437 > CL:0000771 > allergic asthama', 'imatinib > UMLS:C0009325 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:23038 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:23411 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:8626 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:5897 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6367 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:3562 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:760 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:5291 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:941 > CL:0000771 > allergic asthama', 'imatinib > NCBIGene:5972 > CL:0000097 > allergic asthama', 'imatinib > NCBIGene:3965 > CL:0000084 > allergic asthama', 'imatinib > NCBIGene:6373 > CL:0000084 > allergic asthama'}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "print(len(result_path))\n",
    "print(result_path)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "3.10.0",
   "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.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
