The Protein Data Bank ( is an invaluable repository of 3D biomolecular structures. As of writing the database contains 214,791 structures (X-ray, Cryo-EM and NMR) and over 1 million computed structure models. Many of these structures have ligands bound to active sites, these can be co-factors, inhibitors or native ligands. In addition, there are of course inorganic salts, metal ions, or solvents, buffers and detergents used in the experimental process used to generate the structure.

Sometimes it is useful to get an idea of the type of ligands that bind to a particular group of proteins, whilst you can download all the PDB files and inspect manually it is possible to do this programmatically.

PDBe is a founding member of the Worldwide Protein Data Bank (wwPDB) which collects, organises and disseminates data on biological macromolecular structures. the wwPDB Partners are RCSB PDB, PDBjBMRBEMDB. The PDBe API ( is just one of the services that is provided to access PDB information.

In this case we will be using the REST calls based on PDB entry data to access information about a particular PDB entry. In particular, the ligands call that provides a a list of modelled instances of ligands, i.e. ‘bound’ molecules that are not waters.

The is very simple as shown below where 4CTJ is the PDBid.

The data is returned in json format

{“4ctj”:[{“chain_id”:”A”,”author_residue_number”:1263,”author_insertion_code”:””,”chem_comp_id”:”SAM”,”alternate_conformers”:0,”entity_id”:2,”struct_asym_id”:”C”,”residue_number”:1,”chem_comp_name”:”S-ADENOSYLMETHIONINE”,”weight”:398.437,”carbohydrate_polymer”:false,”branch_name”:””},{“chain_id”:”C”,”author_residue_number”:1263,”author_insertion_code”:””,”chem_comp_id”:”SAM”,”alternate_conformers”:0,”entity_id”:2,”struct_asym_id”:”F”,”residue_number”:1,”chem_comp_name”:”S-ADENOSYLMETHIONINE”,”weight”:398.437,”carbohydrate_polymer”:false,”branch_name”:””},{“chain_id”:”A”,”author_residue_number”:1264,”author_insertion_code”:””,”chem_comp_id”:”3A9″,”alternate_conformers”:0,”entity_id”:3,”struct_asym_id”:”D”,”residue_number”:1,”chem_comp_name”:”2,3-dihydro-1-benzofuran-5-carboxylic acid”,”weight”:164.158,”carbohydrate_polymer”:false,”branch_name”:””},{“chain_id”:”A”,”author_residue_number”:1265,”author_insertion_code”:””,”chem_comp_id”:”NA”,”alternate_conformers”:0,”entity_id”:4,”struct_asym_id”:”E”,”residue_number”:1,”chem_comp_name”:”SODIUM ION”,”weight”:22.99,”carbohydrate_polymer”:false,”branch_name”:””}]}

Where the ligand ID is “chem_comp_id”:”SAM”. In this example there are actually 3 ligands, SAM, 3A9, NA. Not all are particularly interesting and in most cases we would only want the “drug-like” ligands.

This jupyter notebook takes a list of PDBid and uses the PDBe API to get a list of ligand ID for each PDB entry, then removes the less interesting ligands and finally exports the list to a csv file.

The first cell simply imports the necessary 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). Depending on the format of the file you will need to split the entries using newline “\n” or comma “,” as needed. Alternatively if there is only a few PDBid you might want to simply edit this line. pdb_codes = [‘4ctj’,’3EVB’]. Note the input is not case sensitive.

If you want to check the input you can uncomment the print(pdb_codes).

The next cell actually uses the PDBe API, the boring_list is simply a list of the less interesting ligands, you can modify this to your own needs. For each PDBid entry we generate the url to access the PDPe API, then post the request. Then the returned JSON is parsed to extract the required ligand ID. For each record the ligand IDs are stored in a python Set. One advantage is that Sets cannot have two items with the same value. So takes care of instances where are PDB make contain multiple examples of the ligand, for example inorganic ions or buffers. We can then simply remove the boring_list using mylist – boring_list.

Finally we convert the SET to list using mylist = sorted(mylist) and append it to the final list.

The results are then exported to a csv file.

The results look like this, the original PDBid followed by a list of ligands.


You can download a copy of the Jupyter Notebook here

Related Posts