You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bio.PDB.PDBIO.save() - increment serial number of the TER record #1383
I am reporting a problem with Biopython version 1.70
Expected behaviour
When writing out in PDB format, the serial number of the TER record should be one number greater than the serial number of the ATOM/HETATM preceding the TER.
When writing out in PDB format with preserve_atom_numbering = True, the serial number of the TER record is the same as the serial number of the ATOM/HETATM preceding the TER.
Proposed Solution:
Write out the TER record with an incremented atom_number.
I agree to the current contribution being dual licensed under both the original "Biopython License Agreement" and the more widely used "3-Clause BSD License".
changed the title [-]Bio.PDB.PDBIO.py - increment serial number of the TER record[/-][+]Bio.PDB.PDBIO.save() - increment serial number of the TER record[/+]on Sep 1, 2017
This will actually cause the TER statement and the the ATOM record right after to have the same serial number. Also needs to account for when we want to preserve numbering (how do we preserve numbering then if we add statements is another very good question).
You're right, I was only considering the "preserve_atom_numbering" case!
In the not "preserve_atom_numbering" case, the serial number should be incremented after writing each record (after writing the TER as well as after writing the ATOM/HETATM records). I guess the following patch would cover both cases, because in the "preserve_atom_numbering" case, the serial number of the ATOM/HETATM records gets overwritten anyways. This assumes correct numbering of the TER record in the original PDB.
--- PDBIO.py 2017-09-01 14:33:42.000000000 -0400
+++ PDBIO.py 2017-09-05 09:12:25.000000000 -0400
@@ -218,11 +218,11 @@
s = get_atom_line(atom, hetfield, segid, atom_number, resname,
resseq, icode, chain_id)
fp.write(s)
- if not preserve_atom_numbering:
- atom_number += 1
+ atom_number += 1
if chain_residues_written:
fp.write("TER %5i %3s %c%4i%c \n"
% (atom_number, resname, chain_id, resseq, icode))
+ atom_number += 1
if model_flag and model_residues_written:
fp.write("ENDMDL\n")
Activity
[-]Bio.PDB.PDBIO.py - increment serial number of the TER record[/-][+]Bio.PDB.PDBIO.save() - increment serial number of the TER record[/+]peterjc commentedon Sep 1, 2017
@lennax could you look at this please?
Cross reference 7e185d8
JoaoRodrigues commentedon Sep 4, 2017
This will actually cause the TER statement and the the ATOM record right after to have the same serial number. Also needs to account for when we want to preserve numbering (how do we preserve numbering then if we add statements is another very good question).
ChristopheDeprez commentedon Sep 5, 2017
You're right, I was only considering the "preserve_atom_numbering" case!
In the not "preserve_atom_numbering" case, the serial number should be incremented after writing each record (after writing the TER as well as after writing the ATOM/HETATM records). I guess the following patch would cover both cases, because in the "preserve_atom_numbering" case, the serial number of the ATOM/HETATM records gets overwritten anyways. This assumes correct numbering of the TER record in the original PDB.