Fix writeNMD residue number overflow for large systems (>9999 residues)#2245
Conversation
…D PDB compatibility
karolamik13
left a comment
There was a problem hiding this comment.
Checked. See below.
The old code:
$ python test.py
@> Connecting wwPDB FTP server RCSB PDB (USA).
@> Downloading PDB files via FTP failed, trying HTTP.
@> 1tqn downloaded (1tqn.pdb.gz)
@> PDB download via HTTP completed (1 downloaded, 0 failed).
@> 468 atoms and 1 coordinate set(s) were parsed in 0.03s.
@> Hessian was built in 0.28s.
@> 5 modes were calculated in 0.15s.
$ grep '^resids' 1tqn_large_resids.nmd | head
resids 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047
New code:
$ python test.py
@> PDB file is found in working directory (1tqn.pdb.gz).
@> 468 atoms and 1 coordinate set(s) were parsed in 0.01s.
@> Hessian was built in 0.21s.
@> 5 modes were calculated in 0.13s.
$ grep '^resids' 1tqn_large_resids.nmd | head
resids 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
test.py looks like this:
from prody import *
ca = parsePDB('1tqn', subset='ca')
original_resnums = ca.getResnums()
ca.setResnums(original_resnums + 10000)
anm = calcANM(ca, n_modes=5)[0]
writeNMD('1tqn_large_resids.nmd', anm[:5], ca)
|
What happens when you open the nmd file? Does the original give the strange behaviour of atoms on a line and the fixed one not? |


NMWiz reads
residsfrom NMD files and writes a temporary PDB for VMD to load. The PDB format allocates 4 characters (columns 23–26) for residue sequence numbers, so any value ≥ 10000 overflows into adjacent coordinate columns, causing VMD to misparse atom positions — manifesting as atoms "stretched along a line" or collapsed into a plane.Change
prody/dynamics/nmdfile.py—writeNMD: Before writingresids, checkmax(resnums) > 9999. If exceeded, renumber residues per-chain sequentially starting from 1 (wrapping modulo 9999), and emit a warning. Systems with all residue numbers ≤ 9999 are unaffected.The renumbering is per-chain so that multi-chain systems (e.g. viral capsids with many subunits, each ≤ 9999 residues) preserve intra-chain relative ordering. The original residue numbers are preserved in the in-memory
AtomGroup; only the NMD file output is affected.