<p>PDB data-files contain identifiers for all those objects. Although I'm not familiar with BioPython's PDB support, I'd expect it to be reading the IDs from the file.</p>
<p>The use of those IDs by the PDB can get a bit tricky, as the author my assign specific IDs that don't meet the typical standard, and there are ID's 'beyond' the PDB, such as the UniProt protein sequence ID of the structure being determined (which may be modified for expression or crystallisation) and the IDs of the underlying residues, which may be relative to different start positions.</p>
<p><a href="https://www.rcsb.org/docs/general-help/identifiers-in-pdb" rel="nofollow noreferrer">https://www.rcsb.org/docs/general-help/identifiers-in-pdb</a></p>

CC BY-SA 4.0
2024-04-12T09:22:29.960Z
unclear answer.
user366312
CC BY-SA 4.0
2024-04-16T15:14:06.620Z
I'm doing my best!
Dan Bolser
CC BY-SA 4.0
2024-04-12T09:08:57.843Z
2024-04-12T09:08:57.843Z
Dan Bolser
<p>When reading PDB file (&quot;<a href="https://www.rcsb.org/structure/1FAT" rel="noreferrer">1fat.pdb</a>&quot; as an example):</p>
<pre><code>from Bio.PDB import *

parser = PDBParser()
structure = parser.get_structure(&quot;PHA-L&quot;, &quot;1fat.pdb&quot;)
</code></pre>
<p>The Structure object follows the so-called SMCRA <strong>(Structure/Model/Chain/Residue/Atom)</strong> architecture :</p>
<ol>
<li>A structure consists of models</li>
<li>A model consists of chains</li>
<li>A chain consists of residues</li>
<li>A residue consists of atoms</li>
</ol>
<p>Biopython will automatically generate ids for models, chians, residues and atoms separately.</p>
<p>The <strong>model id</strong> is an integer which denotes the rank of the model in the PDB file. The model id starts at 0.</p>
<p>The <strong>chain id</strong> is specified in the PDB file, and is a single character (typically a letter).</p>
<p>The <strong>residue id</strong> is a tuple with three elements:</p>
<ol>
<li>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.</li>
<li>The sequence identifier in the chain, e.g. 100</li>
<li>The insertion code, e.g. 'A'. The insertion code is sometimes used
to preserve a certain desirable residue numbering scheme.</li>
</ol>
<p>The <strong>atom id</strong> is simply the atom name (eg. 'CA').</p>
<p>You can check the id like this:</p>
<pre><code>import itertools
# for convenience, we just check the first three id
for model in itertools.islice(structure.get_models(), 3):
    print(f&quot;Model: {model.id}&quot;)
    for chain in itertools.islice(model.get_chains(), 3):
        print(f&quot;Chain: {chain.id}&quot;)
        for residue in itertools.islice(chain.get_residues(), 3):
            print(f&quot;Residue: {residue.id}&quot;)
            for atom in itertools.islice(residue.get_atoms(), 3):
              print(f&quot;Atom: {atom.id}&quot;)
</code></pre>
<p>The output is like this:</p>
<p><a href="https://i.sstatic.net/sQEjH.png" rel="noreferrer"><img src="https://i.sstatic.net/sQEjH.png" alt="enter image description here" /></a></p>
<p>The hetero-flag and insertion code in residue id are all empty in the example.</p>

CC BY-SA 4.0
2024-04-13T17:40:37.897Z
2024-04-13T17:40:37.897Z
Bioinfotec
<p>When we read a protein databank (PDB) file using BioPython, does BioPython assign unique IDs to each atom, each residue, each chain, and each protein?</p>
<p>If so, how does BioPython generate those IDs?</p>
<p>How does BioPython make sure these IDs are unique throughout the entire protein bank?</p>

<biopython>
How does BioPython generate IDs for atoms, residues, chains, and structures?
# How does BioPython generate IDs for atoms, residues, chains, and structures?

(Asked by: username_0 on 2024-04-12)

When we read a protein databank (PDB) file using BioPython, does BioPython assign unique IDs to each atom, each residue, each chain, and each protein?

If so, how does BioPython generate those IDs?

How does BioPython make sure these IDs are unique throughout the entire protein bank?

**Tags:** biopython

---

## 2 answers

### Answer by username_2 on 2024-04-13. Score: 7 | Accepted answer

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.


---

### Answer by username_1 on 2024-04-12. Score: 1

PDB data-files contain identifiers for all those objects. Although I'm not familiar with BioPython's PDB support, I'd expect it to be reading the IDs from the file.

The use of those IDs by the PDB can get a bit tricky, as the author my assign specific IDs that don't meet the typical standard, and there are ID's 'beyond' the PDB, such as the UniProt protein sequence ID of the structure being determined (which may be modified for expression or crystallisation) and the IDs of the underlying residues, which may be relative to different start positions.

<https://www.rcsb.org/docs/general-help/identifiers-in-pdb>

> **Comments:**
> **username_0**: unclear answer.  
> **username_1**: I'm doing my best!  

---

