[Biopython-dev] Bug: Bio.PDB.DSSP fails on PDB files with no header
Jan Kosinski
jan.kosinski at gmail.com
Tue Apr 23 04:09:30 EDT 2013
The following script:
import sys
import Bio
from Bio.PDB.DSSP import DSSP
from Bio.PDB.PDBParser import PDBParser
pdb_filename = sys.argv[1]
p = PDBParser()
structure = p.get_structure('chupacabra', pdb_filename)
model = structure[0]
biodssp = DSSP(model, pdb_filename, dssp="dssp")
will fail on files without HEADER with traceback:
Traceback (most recent call last):
File "testdssp_fail.py", line 13, in <module>
biodssp = DSSP(model, pdb_filename, dssp="dssp")
File
"/home/modorama_dev/modorama/ENV_INI/lib/python2.7/site-packages/Bio/PDB/DSSP.py",
line 200, in __init__
dssp_dict, dssp_keys = dssp_dict_from_pdb_file(pdb_file, dssp)
File
"/home/modorama_dev/modorama/ENV_INI/lib/python2.7/site-packages/Bio/PDB/DSSP.py",
line 101, in dssp_dict_from_pdb_file
out_dict, keys = make_dssp_dict(out_file.name)
File
"/home/modorama_dev/modorama/ENV_INI/lib/python2.7/site-packages/Bio/PDB/DSSP.py",
line 121, in make_dssp_dict
if sl[1] == "RESIDUE":
IndexError: list index out of range
This is because in newer dssp versions the header of DSSP output will have
empty lines if the PDB file had no HEADER and this part of make_dssp_dict
function will fail
for l in handle.readlines():
sl = l.split()
if sl[1] == "RESIDUE:
Changing it to sth like:
if len(sl) > 1 and sl[1] == "RESIDUE":
fixes the problem.
Cheers,
Jan
More information about the Biopython-dev
mailing list