Skip to content

Write PDBIO TER records within 80 columns and with their own serial - #5391

Open
RubenChM wants to merge 1 commit into
biopython:masterfrom
RubenChM:pdbio-ter-record
Open

RubenChM wants to merge 1 commit into
biopython:masterfrom
RubenChM:pdbio-ter-record

Conversation

@RubenChM

Copy link
Copy Markdown
  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file, have run pre-commit
    locally, and understand that continuous integration checks will be used to
    confirm the Biopython unit tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

Closes #1383

PDBIO.save wrote TER records with two problems:

  • The TER format string was padded to 81 columns, one more than the 80 of a PDB
    record (the ATOM lines are 80). Tools that read PDB files as fixed 80-column
    records can mangle the following line: pdb-tools' pad_line joined the next
    ATOM line onto the TER and the atom was lost.
  • TER reused the serial of the first atom of the next chain
    (ATOM 2441, TER 2442, ATOM 2442). wwPDB files give TER its own serial
    (ATOM n, TER n+1, ATOM n+2), as reported in Bio.PDB.PDBIO.save() - increment serial number of the TER record #1383.

TER is now padded to 80 columns and the atom numbering advances after it, as in
the second patch proposed in #1383. With preserve_atom_numbering=True the
atoms keep their stored serials as before; the docstring now documents this
option.

Added test_pdbio_write_ter (two models of two chains from 1SSU_mod.pdb),
which fails without the change.

The TER format string was padded to 81 columns, one past the PDB format
line width, and the TER serial was reused for the first atom of the
following chain. Pad TER to 80 columns and advance the atom numbering
after it, as in wwPDB files (ATOM n, TER n+1, ATOM n+2).

@JoaoRodrigues JoaoRodrigues left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, thank you.

Before we merge, can you comment on if you wrote this using AI? We're debating if we accept AI contributions or not and since a decision hasn't been made, we're opting to not include them at the moment.

Comment thread Bio/PDB/PDBIO.py

Typically select is a subclass of L{Select}.

:param preserve_atom_numbering: write each atom with its stored

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause the next atom after the TER to have the same atom number as the TER. I think this is OK, weird, but OK.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bio.PDB.PDBIO.save() - increment serial number of the TER record

2 participants