Module Scientific.IO.PDB

This module provides classes that represent PDB (Protein Data Bank) files and configurations contained in PDB files. It provides access to PDB files on two levels: low-level (line by line) and high-level (chains, residues, and atoms).

Caution: The PDB file format has been heavily abused, and it is probably impossible to write code that can deal with all variants correctly. This modules tries to read the widest possible range of PDB files, but gives priority to a correct interpretation of the PDB format as defined by the Brookhaven National Laboratory.

A special problem are atom names. The PDB file format specifies that the first two letters contain the right-justified chemical element name. A later modification allowed the initial space in hydrogen names to be replaced by a digit. Many programs ignore all this and treat the name as an arbitrary left-justified four-character name. This makes it difficult to extract the chemical element accurately; most programs write the "CA" for C_alpha in such a way that it actually stands for a calcium atom! For this reason a special element field has been added later, but only few files use it.

The low-level routines in this module do not try to deal with the atom name problem; they return and expect four-character atom names including spaces in the correct positions. The high-level routines use atom names without leading or trailing spaces, but provide and use the element field whenever possible. For output, they use the element field to place the atom name correctly, and for input, they construct the element field content from the atom name if no explicit element field is found in the file.

Except where indicated, numerical values use the same units and conventions as specified in the PDB format description.

Example:
conf = Structure('example.pdb')
print conf
for residue in conf.residues:
    for atom in residue:
        print atom

Class HetAtom: HetAtom in a PDB structure

A subclass of Atom, which differs only in the return value of the method type().

Constructor: HetAtom(name, position, **properties).


Class Group: Atom group (residue or molecule) in a PDB file

This is an abstract base class. Instances can be created using one of the subclasses (Molecule, AminoAcidResidue, NucleotideResidue).

Group objects permit iteration over atoms with for-loops, as well as extraction of atoms by indexing with the atom name.

Methods:

Class Chain: Chain of PDB residues

This is an abstract base class. Instances can be created using one of the subclasses (PeptideChain, NucleotideChain).

Chain objects respond to len() and return their residues by indexing with integers.

Methods:

Class Molecule: Molecule in a PDB file

A subclass of Group.

Constructor: Molecule(name, atoms=None, number=None), where name is the PDB residue name. An optional list of atoms can be specified, otherwise the molecule is initially empty. The optional number is the PDB residue number.

Note: In PDB files, non-chain molecules are treated as residues, there is no separate molecule definition. This modules defines every residue as a molecule that is not an amino acid residue or a nucleotide residue.


Class PDBFile: PDB file with access at the record level

Constructor: PDBFile(filename, mode="r"), where filename is the file name and mode is "r" for reading and "w" for writing, The low-level file access is handled by the module Scientific.IO.TextFile, therefore compressed files and URLs (for reading) can be used as well.

Methods:

Class Atom: Atom in a PDB structure

Constructor: Atom(name, position, **properties), where name is the PDB atom name (a string), position is a atom position (a vector), and properties can include any of the other items that can be stored in an atom record.

The properties can be obtained or modified using indexing, as for Python dictionaries.

Methods:

Class AminoAcidResidue: Amino acid residue in a PDB file

A subclass of Group.

Constructor: AminoAcidResidue(name, atoms=None, number=None), where name is the PDB residue name. An optional list of atoms can be specified, otherwise the residue is initially empty. The optional number is the PDB residue number.

Methods:

Class NucleotideResidue: Nucleotide residue in a PDB file

A subclass of Group.

Constructor: NucleotideResidue(name, atoms=None, number=None), where name is the PDB residue name. An optional list of atoms can be specified, otherwise the residue is initially empty. The optional number is the PDB residue number.

Methods:

Class PeptideChain: Peptide chain in a PDB file

A subclass of Chain.

Constructor: PeptideChain(residues=None, chain_id=None, segment_id=None), where chain_id is a one-letter chain identifier and segment_id is a multi-character chain identifier, both are optional. A list of AminoAcidResidue objects can be passed as residues; by default a peptide chain is initially empty.

Methods:

Class NucleotideChain: Nucleotide chain in a PDB file

A subclass of Chain.

Constructor: NucleotideChain(residues=None, chain_id=None, segment_id=None), where chain_id is a one-letter chain identifier and segment_id is a multi-character chain identifier, both are optional. A list of NucleotideResidue objects can be passed as residues; by default a nucleotide chain is initially empty.


Class ResidueNumber: PDB residue number

Most PDB residue numbers are simple integers, but when insertion codes are used a number can consist of an integer plus a letter. Such compound residue numbers are represented by this class.

Constructor: ResidueNumber(number, insertion_code)


Class Structure: A high-level representation of the contents of a PDB file

Constructor: Structure(filename, model=0, alternate_code="A"), where filename is the name of the PDB file. Compressed files and URLs are accepted, as for class PDBFile. The two optional arguments specify which data should be read in case of a multiple-model file or in case of a file that contains alternative positions for some atoms.

The components of a system can be accessed in several ways (s is an instance of this class):

An iteration over a Structure instance by a for-loop is equivalent to an iteration over the residue list.

Methods: