from biothings_explorer.user_query_dispatcher import FindConnection
from biothings_explorer.hint import Hint

ht = Hint()
# find all potential representations of CML
cml_hint = ht.query("MONDO:0011996")
# select the correct representation of CML
cml = cml_hint['Disease'][0]
cml

# find all potential representations of imatinib
imatinib_hint = ht.query("imatinib")
# select the correct representation of imatinib
imatinib = imatinib_hint['ChemicalSubstance'][0]
imatinib

fc = FindConnection(input_obj=cml, output_obj=imatinib, intermediate_nodes='Gene')
fc.connect(verbose=True)

"""
Explanation: Default Behavior of BTE
End of explanation
"""


from biothings_explorer.registry import Registry

reg = Registry()

reg.show_all_apis()

"""
Explanation: As you can see above, by default, BTE will query all APIs integrated.
Remove a specific API or a list of APIs from BTE
End of explanation
"""


reg.remove_apis(['biolink', 'dgidb'])

"""
Explanation: The Registry class stores all APIs used in BTE.
To remove one or more API from the registry, use the method below:
End of explanation
"""


reg.show_all_apis()

"""
Explanation: check the current api list
End of explanation
"""


fc = FindConnection(input_obj=cml, output_obj=imatinib, intermediate_nodes='Gene', registry=reg)
fc.connect(verbose=True)

"""
Explanation: So now, the "biolink" and "dgidb" are removed from the registry
We then pass the registry as a parameter to the FindConnection Class.
End of explanation
"""


reg.refine_api_list(["semmed_chemical", "semmed_disease"])

reg.show_all_apis()

fc = FindConnection(input_obj=cml, output_obj=imatinib, intermediate_nodes='Gene', registry=reg)
fc.connect(verbose=True)

"""
Explanation: If you look through the query log above, the API "biolink" and "dgidb" are no longer querid.
Specify a list of APIs to include
End of explanation
"""


