Closed itssahil closed 2 years ago
sorry for the delayed reply. It seems the server is timing out because is a pretty big query (>6000 document ids). I would recommend sending smaller batches in the second query.
from chembl_webresource_client.new_client import new_client
document = new_client.document
docs = document.filter(journal="Bioorg. Med. Chem.").only('document_chembl_id')
compound_record = new_client.compound_record
doc_ids = [doc['document_chembl_id'] for doc in docs]
# send only 1000
records = compound_record.filter(document_chembl_id__in=doc_ids[0:1000]).only(['document_chembl_id', 'molecule_chembl_id'])
records
I am trying to download data from the ChEMBL database with the simple code below and getting the following error when I try to download data for "Bioorg. Med. Chem."
Code: from chembl_webresource_client.new_client import new_client document = new_client.document docs = document.filter(journal="Bioorg. Med. Chem.").only('document_chembl_id') compound_record = new_client.compound_record records = compound_record.filter(document_chembl_id__in=[doc['document_chembl_id'] for doc in docs]).only(['document_chembl_id', 'molecule_chembl_id']) records
Error: HttpApplicationError Traceback (most recent call last) /cluster/app/Python/3.7.2/lib/python3.7/site-packages/IPython/core/formatters.py in call(self, obj) 700 type_pprinters=self.type_printers, 701 deferred_pprinters=self.deferred_printers) --> 702 printer.pretty(obj) 703 printer.flush() 704 return stream.getvalue()
/cluster/app/Python/3.7.2/lib/python3.7/site-packages/IPython/lib/pretty.py in pretty(self, obj) 400 if cls is not object \ 401 and callable(cls.dict.get('repr')): --> 402 return _repr_pprint(obj, self, cycle) 403 404 return _default_pprint(obj, self, cycle)
/cluster/app/Python/3.7.2/lib/python3.7/site-packages/IPython/lib/pretty.py in _reprpprint(obj, p, cycle) 695 """A pprint that just redirects to the normal repr function.""" 696 # Find newlines and replace them with p.break() --> 697 output = repr(obj) 698 for idx,output_line in enumerate(output.splitlines()): 699 if idx:
~/.local/lib/python3.7/site-packages/chembl_webresource_client/query_set.py in repr(self) 76 return '{0} resource'.format(self.model.name) 77 clone = self._clone() ---> 78 data = list(clone[:Settings.Instance().REPR_OUTPUT_SIZE]) 79 length = len(self) 80 if length > Settings.Instance().REPR_OUTPUT_SIZE:
~/.local/lib/python3.7/site-packages/chembl_webresource_client/query_set.py in next(self) 125 126 def next(self): --> 127 return self.next() 128 129 #-----------------------------------------------------------------------------------------------------------------------
~/.local/lib/python3.7/site-packages/chembl_webresource_client/query_set.py in next(self) 111 return None 112 if not self.chunk and not self.current_index: --> 113 self.chunk = self.query.get_page() 114 if not self.chunk or self.current_index >= len(self.chunk): 115 self.chunk = self.query.next_page()
~/.local/lib/python3.7/site-packages/chembl_webresource_client/url_query.py in get_page(self) 392 self.logger.info('From cache: {0}'.format(res.from_cache if hasattr(res, 'from_cache') else False)) 393 if not res.ok: --> 394 handle_http_error(res) 395 if self.frmt == 'json': 396 json_data = res.json()
~/.local/lib/python3.7/site-packages/chembl_webresource_client/http_errors.py in handle_http_error(request) 111 exception_class = status_to_exception.get(request.status_code, BaseHttpException) 112 if request.text: --> 113 raise exception_class(request.url, request.text) 114 raise exception_class(request.url, request.content) 115
HttpApplicationError: Error for url https://www.ebi.ac.uk/chembl/api/data/compound_record.json, server response: <!doctype html>
Server error
Something has gone wrong with our web server
Our web server says this is a 500 internal server error: the request cannot be carried out by the server.
This problem means that the service you are trying to access is currently unavailable. We're very sorry.
Please try again but if it keeps happening, you can contact us and we will try to help you.