haddocking / pdb-tools

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

pdb_reres removes the MODEL tag from multi-model PDB files #68

Closed PhilippJunk closed 4 years ago

PhilippJunk commented 4 years ago

Describe the bug When working on an NMR structure with pdb-tools, the usage of pdb_reres causes an error in pdb_splitmodel afterwards. Looking at the PDB files, it seems that pdb_reres removes the MODEL tag during the renumbering, thereby causing the error in pdb_splitmodel.

To Reproduce This causes an error in pdb_splitmodels

pdb_fetch.py 2MSE | pdb_tidy.py | pdb_selchain.py -D | pdb_reres.py -1 > 2MSE_reres.pdb
pdb_splitmodel.py 2MSE_reres.pdb 
Traceback (most recent call last):
  File "/usr/local/bin/pdb_splitmodel", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/pdbtools/pdb_splitmodel.py", line 103, in main
    split_model(pdbfh)
  File "/usr/local/lib/python3.6/dist-packages/pdbtools/pdb_splitmodel.py", line 91, in split_model
    fh.write(''.join(model_lines))
UnboundLocalError: local variable 'fh' referenced before assignment

Not using pdb_reres does not cause an error:

pdb_fetch.py 2MSE | pdb_tidy.py | pdb_selchain.py -D > 2MSE_orgres.pdb
pdb_splitmodel.py 2MSE_orgres.pdb 

Looking at the pdb files, it seems that pdb_reres removes the MODEL tag in the pdb file. Without renumbering:

grep "MODEL" 2MSE_orgres.pdb
TITLE     NMR DATA-DRIVEN MODEL OF GTPASE KRAS-GNP:ARAFRBD COMPLEX TETHERED TO A
REMARK 210  SPECTROMETER MODEL             : AVANCE                             
REMARK 465   MODELS 1-10                                                        
REMARK 500 (M=MODEL NUMBER; RES=RESIDUE NAME; C=CHAIN IDENTIFIER;               
MODEL        1                                                                  
MODEL        2                                                                  
MODEL        3                                                                  
MODEL        4                                                                  
MODEL        5                                                                  
MODEL        6                                                                  
MODEL        7                                                                  
MODEL        8                                                                  
MODEL        9                                                                  
MODEL       10                                                                  

With renumbering, the MODEL tags are gone.

grep "MODEL" 2MSE_reres.pdb
TITLE     NMR DATA-DRIVEN MODEL OF GTPASE KRAS-GNP:ARAFRBD COMPLEX TETHERED TO A
REMARK 210  SPECTROMETER MODEL             : AVANCE                             
REMARK 465   MODELS 1-10                                                        
REMARK 500 (M=MODEL NUMBER; RES=RESIDUE NAME; C=CHAIN IDENTIFIER;               

This behaviour could be reproduced with different PDB files containing multiple models.

Expected behavior pdb_reres is not expected to remove the model tags.

Desktop (please complete the following information):

joaomcteixeira commented 4 years ago

Hello @PhilippJunk ,

69 should address your issue properly.

I see that you are calling pdb-tools with the .py extension, so you are calling the files directly instead of the global symlinks created on installation. Is this so because you know what you are doing, or because you miss something during the installation process?

Remember you can install pdb-tools through pip:

pip install pdb-tools==2.0.5

or github.

git clone https://github.com/haddocking/pdb-tools/
cd pdb-tools
python setup.py develop

with this setup then you just need to update the pdb-tools github local folder to have the latest version:

git pull

With both ways, you should have available the pdb_* command lines. If you need any help installing pdb-tools just let us know.

joaomcteixeira commented 4 years ago

I always forget to link the issue before the PR is merged :stuck_out_tongue_closed_eyes: @PhilippJunk #69 solved this issue. Let us know if we can provide you any additional help. Best,

PhilippJunk commented 4 years ago

Hi @joaomcteixeira,

thank you for the quick fix in particular, and for developing and support this really useful collection of tools in general. With version 2.0.6, I don't encounter the bug anymore.

On my machine, the tools are installed with pip, and I am calling them without the extensions. I only added them to this issue because I wanted to keep as close as possible to the template for bug reports you were proposing ;)

Thanks for helping me out, kind regards Philipp

joaomcteixeira commented 4 years ago

Perfect, :stuck_out_tongue_winking_eye: In that case, it is better to not write the .py in the bug reports because what we do is directly copy+paste your commands in our terminal and see what happens :-)

Enjoy the tools and let us know if you find any other bug. Cheers,