cokelaer / bioservices

Access to Biological Web Services from Python.
http://bioservices.readthedocs.io
Other
278 stars 60 forks source link

Debugging flag? #243

Closed wjshipman closed 1 year ago

wjshipman commented 1 year ago

Is there a way to be of assistance? I'm working on a tool leveraging BioServices and while I can hit ChEMBL through the web directly, BioServices is reporting it's inaccessible. Please let me know how to help.

https://www.ebi.ac.uk/chembl/api/data/target?target_components__accession=Q13936

WARNING [bioservices.ChEMBL:130]: The URL (https://www.ebi.ac.uk/chembl/api/data) provided cannot be reached.

wjshipman commented 1 year ago

I should clarify, I'm getting that error on the import only for ChEMBL

from bioservices.uniprot import UniProt from bioservices.chembl import ChEMBL from bioservices.chebi import ChEBI

If I persist in trying to access ChEMBL I get functionally the same outcome. Uniprot & ChEBI are both functional and operate as expected.

chembl_ws = ChEMBL() chembl_data = chembl_ws.get_molecule('CHEMBL2835')

WARNING [bioservices.ChEMBL:596]: status is not ok with Not Found

/usr/local/lib/python3.6/site-packages/bioservices/chembl.py in get_molecule(self, query, limit, offset, filters) 671 """ 672 params = {"limit": limit, "offset": offset, "filters": filters} --> 673 return self._get_this_service("molecule", query, params=params) 674 675 def get_molecule_form(self, query=None, limit=20, offset=0, filters=None):

/usr/local/lib/python3.6/site-packages/bioservices/chembl.py in _get_this_service(self, name, query, params) 477 elif isinstance(query, (str, int, float)): 478 res = self.http_get("{}/{}".format(name, query), params=params) --> 479 self._check_request(res) 480 elif isinstance(query, list): 481 assert params["limit"] <= 1000, "limit must be less than 1000"

/usr/local/lib/python3.6/site-packages/bioservices/chembl.py in _check_request(self, res) 430 # If there is no output because of wrong query, a 404 is returned. 431 if isinstance(res, int): --> 432 raise ValueError("Invalid request for {} {}. Check your query and parameters") 433 434 def _get_this_service(self, name, query, params={"limit": 20, "offset": 0}):

ValueError: Invalid request for {} {}. Check your query and parameters

cokelaer commented 1 year ago

First of all, thanks for using bioservices. I must agree that the error message is not very useful.

I believe that molecule CHEMBL2835 does not exists hence the error message.

If you try with CHEMBL24, does it work for you ?

One difficulty with the services is that you do not have the list of valid identifiers on the hood, so you need to know the correct ones.

One way is to use gte_molecule() without option but it returns by default only the first 1000 entries.

The warning message can be ignored (at the beginning); it is just a warning.

wjshipman commented 1 year ago

Of course, it's great library! Thank you for your indulgence, I'm going to chalk this up to me being a software engineer and not knowing any better. It looks like ChEMBL is providing a context-sensitive response which is a little awkward for API work in this way. But they both ChEMBL id's provide a target report card as shown below. I'll have to inquire with the chemist I'm working with to muddle through this. Thanks for the feedback.

!# appears to default to the "card view" as a "compound" https://www.ebi.ac.uk/chembl/g/#search_results/all/query=chembl24

!# defaults to "table view" as a "target" https://www.ebi.ac.uk/chembl/g/#search_results/all/query=chembl2835

https://www.ebi.ac.uk/chembl/target_report_card/CHEMBL2835/ https://www.ebi.ac.uk/chembl/target_report_card/CHEMBL24/

print(c.get_molecule('CHEMBL2835')) # FAILS

print(c.search_target('CHEMBL2835')) # SUCCEEDS