chembl / chembl_webresource_client

Official Python client for accessing ChEMBL API
https://www.ebi.ac.uk/chembl/api/data/docs
Other
359 stars 95 forks source link

Http Application error #120

Closed YojanaGadiya closed 1 year ago

YojanaGadiya commented 1 year ago

Dear team,

When I am using the chembl webresource client to search for a list of proteins, I frequently get the HttpApplicationError. Is there a way to fix this issue?

Code:

final_data = defaultdict(list)

proteins=[
            'Q8NH81',
            'Q68D06',
            'Q14653',
            'Q8WVL7',
            'Q9Y258',
            'Q8IYM2',
            'P01732',
            'P00387',
]

for protein in protein_list:
  prot_data = [target.search(protein)[0]]

  # Search for protein with same synonym
  if prot_data == [None]:
      prot_data = target.filter(
          target_synonym__icontains=protein, target_organism__istartswith=organism
      ).only(['target_chembl_id', 'target_pref_name', 'molecule_chembl_id', 'molecule_pref_name'])

    for prot in tqdm(prot_data, f'Analying data for {protein}'):
                # Absence of chembl id
                if not prot['target_chembl_id']:
                    continue

                prot_activity_data = activity.filter(
                    target_chembl_id=prot['target_chembl_id'],
                    assay_type_iregex='(B|F)',
                ).only([
                    'pchembl_value', 'molecule_chembl_id', 'activity_id', 'target_pref_name', 'molecule_pref_name'
                ])

              final_data[prot].append(prot_activity_data)

Thank You.

gorostiolam commented 1 year ago

I am experiencing the same issue since last week when using any client functionality.

The main error message is: chembl_webresource_client.http_errors.HttpApplicationError: Error for url https://www.ebi.ac.uk/chembl/api/data/molecule.json, server response: <!doctype html> Followed by a very long HTML error message.

I am assuming this error is due to an update in the API for which the client has not caught up yet. Is there an estimated timeframe for solving this issue?

David-Araripe commented 1 year ago

Something seems to be wrong with the json response. The following snippet reproduces the same error reported:

from chembl_webresource_client.new_client import new_client

molecule = new_client.molecule
mols = molecule.filter(molecule_synonyms__molecule_synonym__iexact='viagra').only('molecule_chembl_id')
mols

I did a workaround by changing the url_query.py module, substituting line 40 from self.frmt = 'json' to self.frmt='xml'. After that, I could get the results without a problem by running this instead:

from chembl_webresource_client.new_client import new_client

molecule = new_client.molecule
mols = molecule.filter(molecule_synonyms__molecule_synonym__iexact='viagra').only('molecule_chembl_id')
mols.set_format(frmt='json')
piehld commented 1 year ago

From what I've observed, this appears to be due to intermittent downtime of https://www.ebi.ac.uk/chembl/api/data/molecule.json, in which case an error page ("500 internal server") is returned instead of the desired json. When the page is accessible, no errors occur.

I think it would be valuable if the chembl client was able to automatically re-try a given request if it returns a 500 internal server error rather than simply failing, since the server seems to come back up within several seconds of the initial server error.

wen19shui commented 1 year ago

Hi, when I queried the activity data related to plasma stability in chembl, I encountered the same problem. This is my error code:

HttpApplicationError: Error for url https://www.ebi.ac.uk/chembl/api/data/activity.json, server response: <!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!-- Consider adding an manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>

Do you have any solutions to this. What bothers me is the lack of such data in other relevant places. Chembl is the only database where I can find relevant content, but it seems unstable recently. Thank you. This is the code I used to query:

act_list = []
for assay_id in tqdm(Plasma_assayID_list[14:], 'Analying data for Plasma'):
    activities = activity.filter(
        assay_chembl_id=assay_id, 
    #     relation="=", assay_type="B"
    ).only(
    "assay_id",
    "assay_description",
    "molecule_chembl_id",
    "canonical_smiles",
    "document_chembl_id",
    "standard_relation",
    "standard_value",
    "standard_units",
    "standard_type",
    "target_organism",
    "target_pref_name"
    )
    for act in activities:
        act_list.append(act)
eloyfelix commented 1 year ago

sorry for the delayed reply. There was a networking issue in the EBI datacenter that affected our webservices. The issue is now solved with the help of the EBI networking team. The webservices and the webresource client should be working normally now.