Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T008: HTTPError: 403 Client Error: Forbidden for url: http://ligand-expo.rcsb.org/reports/8/8AM/ #260

Closed
khanmf opened this issue Aug 3, 2022 · 4 comments · Fixed by #259
Labels
bug Something isn't working

Comments

@khanmf
Copy link

khanmf commented Aug 3, 2022

Hi,

In T008, while running codes:

pdb_id = 5UG9

def get_ligands(pdb_id):
    info = pypdb.get_info(pdb_id)
    nonpolymers = info.get("rcsb_entry_info", {}).get("nonpolymer_bound_components", [])
    ligands = {}
    for ligand_expo_id in nonpolymers:
        r = requests.get(
            f"http://ligand-expo.rcsb.org/reports/{ligand_expo_id[0]}/{ligand_expo_id}/"
        )
        r.raise_for_status()
        html = BeautifulSoup(r.text)
        info = {}
        for table in html.find_all("table"):
            for row in table.find_all("tr"):
                cells = row.find_all("td")
                if len(cells) != 2:
                    continue
                key, value = cells
                if key.string and key.string.strip():
                    info[key.string.strip()] = "".join(value.find_all(text=True))
        # Postprocess some known values
        info["Molecular weight"] = float(info["Molecular weight"].split()[0])
        info["Formal charge"] = int(info["Formal charge"])
        info["Atom count"] = int(info["Atom count"])
        info["Chiral atom count"] = int(info["Chiral atom count"])
        info["Bond count"] = int(info["Bond count"])
        info["Aromatic bond count"] = int(info["Aromatic bond count"])
        ligands[ligand_expo_id] = info        
    return ligands

get_ligands(pdb_id)

I am getting following error:

Traceback (most recent call last):
  File "Script.py", line 405, in <module>
    ligands = get_ligands(pdb_id)
  File "Script.py", line 342, in get_ligands
    r.raise_for_status()
  File "/home/mfkhan91/anaconda3/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://ligand-expo.rcsb.org/reports/8/8AM/

Please help me in resolving the issue.

Thanks,
Faraz

@dominiquesydow
Copy link
Collaborator

dominiquesydow commented Aug 4, 2022

Hi @khanmf,

Thanks a lot for raising this issue; I noticed problems yesterday as well (the website was still ok on Tuesday). I had hoped that the issue is resolved today (sometimes waiting a day helped in the past with other webservices) but that does not seem to be the case.

  1. Search page: http://ligand-expo.rcsb.org/ld-search.html
    Entering e.g. STI in the first Search box returns now an “Oops - Search failed - “
  2. Ligand page: In one of our Jupyter notebooks, we are accessing data directly from URLs like http://ligand-expo.rcsb.org/reports/S/STI/.
    This access to these URLs is now forbidden ("You don't have permission to access…”).

I contacted the RCSB team and will update you here, once I have an answer. Until then, there is, unfortunately, nothing we can do for T008 - except for fetching the ligand metadata that you need from another resource, e.g. directly from the CIF file, if available.

If you are in a hurry: I recently learned that you can access a PDB entry's ligand data from RCSB using GraphQL. Maybe this can help you while the Ligand Expo resolves the issue (though this will only fetch a subset of all the ligand metadata that the Ligand Expo website offers). #248 (comment)

@dominiquesydow dominiquesydow changed the title HTTPError: 403 Client Error: Forbidden for url: http://ligand-expo.rcsb.org/reports/8/8AM/ T008: HTTPError: 403 Client Error: Forbidden for url: http://ligand-expo.rcsb.org/reports/8/8AM/ Aug 4, 2022
@dominiquesydow dominiquesydow linked a pull request Aug 4, 2022 that will close this issue
4 tasks
@dominiquesydow dominiquesydow added the bug Something isn't working label Aug 4, 2022
@khanmf
Copy link
Author

khanmf commented Aug 4, 2022

@dominiquesydow Thank you for your suggestions.

@dominiquesydow
Copy link
Collaborator

Good news, @khanmf, the RCSB team has resolved this issue 🎉

@khanmf
Copy link
Author

khanmf commented Aug 5, 2022

@dominiquesydow Great! Thanks for letting me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants