What are a 'Structure' and a 'Model' in BioPython?
Why did they incorporate 'structure' and 'model' instead of 'Protein' as objects?
What are a 'Structure' and a 'Model' in BioPython?
Why did they incorporate 'structure' and 'model' instead of 'Protein' as objects?
From How does BioPython generate IDs for atoms, residues, chains, and structures? accepted answer (answer link) :
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 :
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 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.