This image has an empty alt attribute; its file name is Screenshot-2024-01-23-at-21.30.36.png

A previous post described Getting Ligand ID for multiple PDB files, using the PDBe API ( The result is a csv file containing the ligand PDB id, that can be used to download the molecular structures from the PDB as shown below in a Jupyter Notebook.

The first cell simply imports the needed libraries.

The next step is to identify the file containing the PDBid and import them (you will need to edit the path to the file). If you are using the file generated using the previous jupyter notebook it should be in the correct format. We also define folder into which the ligands will be downloaded.

The input file format is shown below.

The final cell is where the files are actually downloaded, first we read in the data from the input file, then looping through the file line by line. The first element on each line is the protein PDBid, we use this to create a folder within the downloads named as the protein PDBid.

We then loop through the rest of the line starting at the second element to get the Ligand PDBid, use it to construct URL and download the file. All files are downloaded as compressed zip files.

The result should be a folder called PDBLigands containing sub-folders for each of the individual protein PDBid and with each sub-folder the ligands have been downloaded.

You can download the Jupyter Notebook here.

Related Posts