<p>Unfortunately, PDB numbering can be one of different schemes. The main three:</p>
<ul>
<li>Uniprot numbering (canonical isoform)</li>
<li>Construct numbering with or without tag removal</li>
<li>Start from 1 for what has density</li>
</ul>
<p>However, the are many many corner cases. In Proteopedia there is <a href="https://proteopedia.org/wiki/index.php/Unusual_sequence_numbering" rel="nofollow noreferrer">a lovely article about weird PDB numbering</a>.</p>
<p>The best way to find the details about what part of the sequence is covered is to use the <a href="https://swissmodel.expasy.org/docs/smr_openapi" rel="nofollow noreferrer">Swissmodel API</a>. It's actually better than either the PDBe and RCSB PDB APIs. Swissmodel is a homology modelling service that maintains close threaded models (&gt;30% ID), but also has PDB data. Here is a Python3 method I use, (<code>provider='pdb'</code>) is what is required here).</p>
<pre><code>def get_data(uniprot: str, provider='swissmodel') -&gt; List[dict]:
        &quot;&quot;&quot;
        Gets data from Swissmodel. Convert each entry with convert_SM_entry
        &quot;&quot;&quot;
    assert provider in ('swissmodel', 'pdb'), 'Provider has to be swissmodel or pdb'
        url = f'https://swissmodel.expasy.org/repository/uniprot/{uniprot.strip()}.json?provider={provider.strip()}'
        data = requests.get(url).json()
        return data['result']['structures']  # [0] # from to coordinates description
</code></pre>
<p>The returned dictionary contains a start and end of the uniprot &lt;--&gt; PDB. It does not however, say where the missing density residues are. But in <em>deposited</em> structures the PDB numbering skips where these residues ought to be... So might not be an important problem.</p>
<p>Another database of interest is <a href="https://www.ebi.ac.uk/pdbe/docs/sifts/" rel="nofollow noreferrer">SIFTS</a>.</p>
<p>To make a multiple sequence alignment of a non-deposited PDB, you need to extract the sequence and do the alignment here is a snippet using <a href="https://anaconda.org/schrodinger/pymol" rel="nofollow noreferrer">pymol module (from conda)</a>:</p>
<pre><code>import pymol2

pdbfile = '' #your pdb file name..
selector = 'chain A' # or whatever chain you want
with pymol2.PyMOL() as pymol:
    pymol.cmd.load(pdbfile)
    fasta = pymol.cmd.get_fastastr(selector)

seq = ''.join(fasta.replace('?','').split('\n')[1:]) # remove header and non AA residues
</code></pre>
<p>Biopython has a dozen sequence alignment tools. But the original one still works fine</p>
<pre><code>from Bio import pairwise2
from Bio.Seq import Seq

alignment = pairwise2.align.globalxx(''.join(seq).replace('?',''), &quot;ACQQG&quot;)[0]
</code></pre>
<p><code>alignments</code> is a tuple of the MSA sequences.</p>
<p>If you want to do the latter without coding. Extract the sequence from the PDB using PyMOL the normal application and load the pdb and then <code>print cmd.get_fastastr('chain A')</code> in the command line part of the GUI. Copy this. Go to <a href="https://www.ebi.ac.uk/Tools/msa/muscle/" rel="nofollow noreferrer">Muscle</a> or other onliner aligner and align!</p>

CC BY-SA 4.0
2020-08-23T16:26:30.140Z
Thanks @MatteoFerla. The swissmodel API is an interesting one. However, since the rcsb fasta does not have a UniProtKB id, perhaps I have to do an additional alignment to obtain the UniProtKB id? I am surprised rcsb has the sequence data (with the alignment, UnitProtKB id, missing residues, etc), but there is no API/downloadable available.
Simon
CC BY-SA 4.0
2020-08-24T10:14:10.997Z
To go from PDB 4-letter code to Uniprot accession use the [SIFTS API](https://www.ebi.ac.uk/pdbe/api/doc/sifts.html) or mapping table from their FTP site. Or look manually at the PDB entry.
Do note that a uniprot record has an accession number, say for HRas `P01112`, and a entry name `RASH_HUMAN`. The "id" word is an ambiguous and can refer to either, but use to mean the latter. To confuse further, the entry name can change if it is moved from Trembl to Swissprot —say the genome of that organism was sequenced and before the protein was known from an EST read or something.
Matteo Ferla
CC BY-SA 4.0
2020-08-24T10:18:10.763Z
The RCSB PDB has changed recently, dropping a few annotation from its protein viewer, which I am guessing will be re-added —once that happens I assume a sensible API will appear. How it used to work was that HTML/JS chunks were assembled in the backend, so there was no API for uniprot data and you could not reverse-engineer an ajax call into an API.
Matteo Ferla
CC BY-SA 4.0
2020-08-24T16:58:09.797Z
Thank you so much. It is indeed a very comprehensive explanation.
Simon
CC BY-SA 4.0
2020-08-22T13:43:35.660Z
2020-08-22T14:01:37.303Z
2020-08-22T14:01:37.303Z
Matteo Ferla
<p>The residue numbering in PDB (in my understanding) coincides with UniProtKB align. However, this might not be consistent with that in PDB fasta file. To complicate it further, UniProtKB align can be a few mutations away from the PDB sequence. Disordered/unidentified residues in structures also create gaps in numbering.</p>
<p>Is there a way/suggestion to create a matched residue numbering between sequence and structure? For example</p>
<pre><code>12345678 (residue numbering)
ATPWQMSQ (sequence)
---W-MSQ (PDB residues) &quot;-&quot; for missing residue in structure
</code></pre>

<proteins>
PDB residue numbering
# PDB residue numbering

(Asked by: username_0 on 2020-08-21)

The residue numbering in PDB (in my understanding) coincides with UniProtKB align. However, this might not be consistent with that in PDB fasta file. To complicate it further, UniProtKB align can be a few mutations away from the PDB sequence. Disordered/unidentified residues in structures also create gaps in numbering.
Is there a way/suggestion to create a matched residue numbering between sequence and structure? For example
12345678 (residue numbering)
ATPWQMSQ (sequence)
---W-MSQ (PDB residues) "-" for missing residue in structure

**Tags:** proteins

---

## 1 answers

### Answer by username_1 on 2020-08-22. Score: 2 | Accepted answer

Unfortunately, PDB numbering can be one of different schemes. The main three:

Uniprot numbering (canonical isoform)
Construct numbering with or without tag removal
Start from 1 for what has density

However, the are many many corner cases. In Proteopedia there is a lovely article about weird PDB numbering.
The best way to find the details about what part of the sequence is covered is to use the Swissmodel API. It's actually better than either the PDBe and RCSB PDB APIs. Swissmodel is a homology modelling service that maintains close threaded models (>30% ID), but also has PDB data. Here is a Python3 method I use, (provider='pdb') is what is required here).
def get_data(uniprot: str, provider='swissmodel') -> List[dict]:
        """
        Gets data from Swissmodel. Convert each entry with convert_SM_entry
        """
    assert provider in ('swissmodel', 'pdb'), 'Provider has to be swissmodel or pdb'
        url = f'https://swissmodel.expasy.org/repository/uniprot/{uniprot.strip()}.json?provider={provider.strip()}'
        data = requests.get(url).json()
        return data['result']['structures']  # [0] # from to coordinates description

The returned dictionary contains a start and end of the uniprot <--> PDB. It does not however, say where the missing density residues are. But in deposited structures the PDB numbering skips where these residues ought to be... So might not be an important problem.
Another database of interest is SIFTS.
To make a multiple sequence alignment of a non-deposited PDB, you need to extract the sequence and do the alignment here is a snippet using pymol module (from conda):
import pymol2

pdbfile = '' #your pdb file name..
selector = 'chain A' # or whatever chain you want
with pymol2.PyMOL() as pymol:
    pymol.cmd.load(pdbfile)
    fasta = pymol.cmd.get_fastastr(selector)

seq = ''.join(fasta.replace('?','').split('\n')[1:]) # remove header and non AA residues

Biopython has a dozen sequence alignment tools. But the original one still works fine
from Bio import pairwise2
from Bio.Seq import Seq

alignment = pairwise2.align.globalxx(''.join(seq).replace('?',''), "ACQQG")[0]

alignments is a tuple of the MSA sequences.
If you want to do the latter without coding. Extract the sequence from the PDB using PyMOL the normal application and load the pdb and then print cmd.get_fastastr('chain A') in the command line part of the GUI. Copy this. Go to Muscle or other onliner aligner and align!

> **Comments:**
> **username_0**: Thanks @MatteoFerla. The swissmodel API is an interesting one. However, since the rcsb fasta does not have a UniProtKB id, perhaps I have to do an additional alignment to obtain the UniProtKB id? I am surprised rcsb has the sequence data (with the alignment, UnitProtKB id, missing residues, etc), but there is no API/downloadable available.  
> **username_1**: To go from PDB 4-letter code to Uniprot accession use the [SIFTS API](https://www.ebi.ac.uk/pdbe/api/doc/sifts.html) or mapping table from their FTP site. Or look manually at the PDB entry. Do note that a uniprot record has an accession number, say for HRas `P01112`, and a entry name `RASH_HUMAN`. The "id" word is an ambiguous and can refer to either, but use to mean the latter. To confuse further, the entry name can change if it is moved from Trembl to Swissprot —say the genome of that organism was sequenced and before the protein was known from an EST read or something.  
> **username_1**: The RCSB PDB has changed recently, dropping a few annotation from its protein viewer, which I am guessing will be re-added —once that happens I assume a sensible API will appear. How it used to work was that HTML/JS chunks were assembled in the backend, so there was no API for uniprot data and you could not reverse-engineer an ajax call into an API.  
> **username_0**: Thank you so much. It is indeed a very comprehensive explanation.  

---

