Skip to content

SeqIO.PdbIO does not support residue insertion codes  #2211

Open

Description

@mukhyala

Setup

I am reporting a problem with Biopython version, Python version, and operating
system as follows:

>>> print(platform.python_implementation());
CPython
>>> print(platform.platform())
Linux-3.10.0-514.21.1.el7.x86_64-x86_64-with-centos-7.3.1611-Core
>>> print(Bio.__version__)
1.73

Expected behaviour

for record in SeqIO.parse("5nb7.pdb", "pdb-atom"):
... print(record.seq)
...
ILGGREAEAHARPYMASVQLNXGAHLCGGVLVAEQWVLSAAHCLEDAADGKVQVLLGAHSLSQPEPSKRLYDVLRAVPHPDSQPDTIDHDLLLLQLSEKATLGXXPAVRPLPWQRVDRDVAPGTLCDVAGWGIVNHAXGRRPDSLQHVLLPVLDRATCNRRTHHDGAITERLMCAESNRRDSCKGDSGGPLVCGXXXXGVLEGVVTSGSRVCGNRKKPGIYTRVASYAAWIDSVLASA

Actual behaviour

from Bio import SeqIO
for record in SeqIO.parse("/gne/data/public/pdb/all.pdb/5nb7.pdb", "pdb-atom"):
... print(record.seq)
...
***/lib/python3.7/site-packages/Bio/SeqIO/PdbIO.py:70: BiopythonParserWarning: Ignoring out-of-order residues after a gap
BiopythonParserWarning)
ILGGREAEAHARPYMASVQLNXGAHLCGGVLVAEQWVLSAAHCLED

Steps to reproduce

% python -i
Python 3.7.2 (default, Dec 29 2018, 06:19:36) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from Bio import SeqIO
>>> for record in SeqIO.parse("5nb7.pdb", "pdb-atom"):
...     print(record.seq)
... 
***/lib/python3.7/site-packages/Bio/SeqIO/PdbIO.py:70: BiopythonParserWarning: Ignoring out-of-order residues after a gap
  BiopythonParserWarning)
ILGGREAEAHARPYMASVQLNXGAHLCGGVLVAEQWVLSAAHCLED
>>> 

The bug is in line 56 of PdbIO.py:

for i, rnum in enumerate(rnumbers[:-1]): 
            if rnumbers[i + 1] != rnum + 1: 
                # It's a gap!                 
                gaps.append((i + 1, rnum, rnumbers[i + 1]))

For cases with insertion codes ex:5nb7

...
ATOM    330  OD1 ASP A  61      11.950  19.221   1.793  1.00 70.83           O
ANISOU  330  OD1 ASP A  61    11509   4074  11328   2341   -402   -240       O
ATOM    331  OD2 ASP A  61      13.111  18.343   3.561  1.00 64.69           O
ANISOU  331  OD2 ASP A  61     7591   5500  11486   3548   1468   2253       O
ATOM    332  N   ALA A  61A     16.700  16.922   0.939  1.00 31.91           N
ANISOU  332  N   ALA A  61A    3203   3061   5860    323   -762    142       N
ATOM    333  CA  ALA A  61A     17.934  16.791   1.698  1.00 31.96           C
ANISOU  333  CA  ALA A  61A    3741   3551   4851   -390   -606    342       C
ATOM    334  C   ALA A  61A     19.025  17.806   1.339  1.00 31.44           C
ANISOU  334  C   ALA A  61A    3563   4281   4101   -595    810    334       C
ATOM    335  O   ALA A  61A     20.118  17.806   1.948  1.00 31.38           O
ANISOU  335  O   ALA A  61A    5198   2714   4009   -347    -58   -545       O
ATOM    336  CB  ALA A  61A     18.466  15.386   1.470  1.00 35.26           C
ANISOU  336  CB  ALA A  61A    4105   4229   5063    454   -325  -1244       C
ATOM    337  N   ALA A  61B     18.792  18.657   0.372  1.00 33.57           N
ANISOU  337  N   ALA A  61B    4118   3113   5523   -786   -417   1060       N
...

Residue 61 followed by 61A, 61B, 61C is not a gap. So line 56 should check if the expected next residue number is greater than the current residue not if observed and expected residue numbers are not equal. So line 56 should be:

for i, rnum in enumerate(rnumbers[:-1]):
            if rnumbers[i + 1] > rnum + 1:
                # It's a gap!                                                                                
                gaps.append((i + 1, rnum, rnumbers[i + 1]))

Hope the bug and the solution are clear and can be patched soon. Gzipped test file 5nb7.pdb attached. Thanks!
5nb7.pdb.gz

Activity

  1. peterjc commented on Aug 14, 2019

    @peterjc
    Member

    Can you turn your one line fix into a pull request? You can even do this within your web-browser as GitHub will let you edit Bio/SeqIO/PdbIO.py and guide you through the process.

    I've not looked at the PDB code recently enough to comment on the change - I will defer to one of the others for that.

  2. added a commit that references this issue on Aug 15, 2019
  3. mukhyala commented on Aug 22, 2019

    @mukhyala
    ContributorAuthor

    A huge thanks to Ewout Vanden Eynden ([email protected]) for reporting this bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions