When reading PDB file ("1fat.pdb" as an example):
from Bio.PDB import *
parser = PDBParser()
structure = parser.get_structure("PHA-L", "1fat.pdb")
The Structure object follows the so-called SMCRA (Structure/Model/Chain/Residue/Atom) architecture :
- A structure consists of models
- A model consists of chains
- A chain consists of residues
- A residue consists of atoms
Biopython will automatically generate ids for models, chians, residues and atoms separately.
The model id is an integer which denotes the rank of the model in the PDB file. The model id starts at 0.
The chain id is specified in the PDB file, and is a single character (typically a letter).
The residue id is a tuple with three elements:
- The hetero-flag: this is 'H_' plus the name of the hetero-residue (e.g. 'H_GLC' in the case of a glucose molecule), or 'W' in the case of a water molecule.
- The sequence identifier in the chain, e.g. 100
- The insertion code, e.g. 'A'. The insertion code is sometimes used
to preserve a certain desirable residue numbering scheme.
The atom id is simply the atom name (eg. 'CA').
You can check the id like this:
import itertools
# for convenience, we just check the first three id
for model in itertools.islice(structure.get_models(), 3):
print(f"Model: {model.id}")
for chain in itertools.islice(model.get_chains(), 3):
print(f"Chain: {chain.id}")
for residue in itertools.islice(chain.get_residues(), 3):
print(f"Residue: {residue.id}")
for atom in itertools.islice(residue.get_atoms(), 3):
print(f"Atom: {atom.id}")
The output is like this:
The hetero-flag and insertion code in residue id are all empty in the example.