HttpBadRequest when using assay_type__iregex
jonjoncardoso opened this issue · 3 comments
jonjoncardoso commented
Hi!
I am facing an error whenever I try to filter assay types. I thought it was something related to v0.10.7 but I downgraded to v0.10.5 and it persists.
This error can be reproduced with example 30 from the README:
from chembl_webresource_client.new_client import new_client
activity = new_client.activity
res = activity.filter(target_chembl_id='CHEMBL3938', assay_type__iregex='(B|F)')
which throws:
---------------------------------------------------------------------------
HttpBadRequest Traceback (most recent call last)
/opt/conda/lib/python3.9/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()
/opt/conda/lib/python3.9/site-packages/IPython/lib/pretty.py in pretty(self, obj)
392 if cls is not object \
393 and callable(cls.__dict__.get('__repr__')):
--> 394 return _repr_pprint(obj, self, cycle)
395
396 return _default_pprint(obj, self, cycle)
/opt/conda/lib/python3.9/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
698 """A pprint that just redirects to the normal repr function."""
699 # Find newlines and replace them with p.break_()
--> 700 output = repr(obj)
701 lines = output.splitlines()
702 with p.group():
/opt/conda/lib/python3.9/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:
/opt/conda/lib/python3.9/site-packages/chembl_webresource_client/query_set.py in __next__(self)
125
126 def __next__(self):
--> 127 return self.next()
128
129 #-----------------------------------------------------------------------------------------------------------------------
/opt/conda/lib/python3.9/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()
/opt/conda/lib/python3.9/site-packages/chembl_webresource_client/url_query.py in get_page(self)
394 self.logger.info('From cache: {0}'.format(res.from_cache if hasattr(res, 'from_cache') else False))
395 if not res.ok:
--> 396 handle_http_error(res)
397 if self.frmt == 'json':
398 json_data = res.json()
/opt/conda/lib/python3.9/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
HttpBadRequest: Error for url https://www.ebi.ac.uk/chembl/api/data/activity.json, server response: {"error_message": "'iregex' is not an allowed filter on the 'assay_type' field."}
chrisdid4 commented
I have the same issue. Does someone knows a solution please?
chrisdid4 commented
In my case I replaced the assay_type__iregex='(B|F)' with assay_type='B' and it worked
juanfmx2 commented
Unfortunately, the regex filters on the activity endpoint had to be disabled because they did not perform very well, and they we making the web services unresponsive. The best alternative is to create 2 separate requests:
assay_type='B' and assay_type='F'