haddocking / pdb-tools

A dependency-free cross-platform swiss army knife for PDB files.
https://haddocking.github.io/pdb-tools/
Apache License 2.0
372 stars 113 forks source link

pdb_reatom misaligning with TER lines #79

Closed edarl closed 3 years ago

edarl commented 3 years ago

Describe the bug I'm using pdb_reatom and in PDBs which don't have anything on TER lines except the TER statement. The reatoming prints the atom number on the line below the TER line.

ATOM   1761  C2   DG C  54      -4.483   5.846  44.656  1.00 19.29           C
ATOM   1762  N2   DG C  54      -5.602   6.488  44.306  1.00 19.87           N
ATOM   1763  N3   DG C  54      -3.587   5.523  43.715  1.00 19.53           N
ATOM   1764  C4   DG C  54      -2.495   4.892  44.221  1.00 19.98           C
TER
 1765ATOM   1766  P    DC C  55       0.470   6.191  38.221  1.00 32.28           P
ATOM   1767  OP1  DC C  55       0.309   5.296  37.053  1.00 35.01           O

I just read the PDB guidelines on what the TER line should look like and I now know that it's supposed to have the res name and info preceding it in the line. But I'm also using software to modify the PDBs and after checking the PDBs produced by two of them (PYMOL and RING2.0), both are producing PDBs with TER and nothing else in TER lines.

I changed the script to be below and it fixed the problem for me.

elif line.startswith('TER'):
            yield line[:6]
            serial += 1

Now I know the empty TER lines aren't proper PDB format I don't know if you want to change your script or not but thought I'd report the behaviour anyway.

Desktop (please complete the following information):

JoaoRodrigues commented 3 years ago

Thanks @edarl ! Can you see if running pdb_tidy before running pdb_reatom work? e.g. pdb_tidy your.pdb | pdb_reatom > your-out.pdb

The tidy script should fix your TER statements automatically. The issue you have is because some programs trim lines in PDB files when they should be always padded to 80 characters. So, even an empty TER statement (not perfect, but it's OK!) should have 77 empty spaces afterwards.

edarl commented 3 years ago

Tidying fixed it! Thanks!

I now know I can't trust the PDBs output by any software.

JoaoRodrigues commented 3 years ago

Rule number 1 indeed: never trust PDBs, not even from the PDB itself ;)

Glad it worked!