PDBParser

Briefs

PDBParser facilitates the conversion between PDB files and Structure objects. It primarily offers two functions: get_structure() for converting a PDB file into a Structure object, and save_structure() for performing the inverse operation.

Input/Output

PDBParser.get_structure()

Input

path

Specifies the file path of the PDB file.

How to obtain

PDB files can be downloaded from the Protein Data Bank or acquired from experimental results.

Output

Structure()

Returns the constructed Structure object.

Tip

PDBParser fixes missing chain identifiers. For example, polymer PDB files generated by AMBER often lack chain IDs.

Arguments

Example Code

  • Generate a Structure objects from a simple PDB file

In this example, we use PDBParser to process a single-chain, single-model PDB file. We aim to import the PDB file as a Structure object.

How input is prepared

For PDBParser.get_structure(), need to prepare:

path

The file path of the PDB file. In this example, the PDB file was downloaded from the Protein Data Bank with the ID “8K4Z” and is named "./8k4z.pdb". (See PDBParser.get_structure() section)

add_solvent_list

According to the PDB file, if you want to prevent the chloride ion from being discarded as trash, you can categorize the chloride ion (named “CL” in the PDB file) as a solvent.

add_ligand_list

According to the PDB file, if you want to prevent the chloride ion from being discarded as trash, you can categorize the chloride ion (named “CL” in the PDB file) as a ligand.

from enzy_htp.structure import PDBParser

test_A="./8k4z.pdb"
test_A_struc1 = PDBParser.get_structure(path=test_A,
                                       add_solvent_list=["CL"], #In this way, the CL will not be treated as trash.
                                       remove_trash=True)

test_A_struc2 = PDBParser.get_structure(path=test_A,
                                       add_ligand_list=["CL"], #In this way, the CL will not be treated as trash.
                                       remove_trash=True)

PDBParser.save_structure()

Input

outfile

Path for saving the Structure() object as a string.

How to obtain

Define the save path as a string, e.g., outfile='./save_pro.pdb'.

stru

The Structure() object to be saved.

How to obtain

(See PDBParser.get_structure() section)

Output

str()

Path where the Structure() was saved, returned as a string.

Arguments

Example Code

  • Save a Structure objects to a PDB file

In this example, we use PDBParser to export Structure object as a new PDB file.

How input is prepared

For PDBParser.save_structure(), need to prepare:

outfile

The path to save the Structure object as a string. In this example, we save the structure as "./2v7m_new.pdb"

stru

The Structure() object obtained from PDBParser.get_structure() (See PDBParser.get_structure() section)

from enzy_htp.structure import PDBParser

test_A="./2v7m.pdb"
test_A_struc = PDBParser.get_structure(path=test_A)
test_A_saved_path = PDBParser.save_structure(outfile="./2v7m_new.pdb",
                                             stru=test_A_struc)
print(test_A_saved_path) #./2v7m_new.pdb

Author: Xingyu Ouyang <ouyangxingyu913@gmail.com>