This project has moved. For the latest updates, please go here.

Populating secondary structure in a chain and its residues from a DSSP file

Oct 16, 2012 at 2:15 PM

Greetings, all.

I've come this far in my attempt at populating secondary structure information in a PDB structure using a DSSP file as my information source.

 

from csb.bio.io.wwpdb import StructureParser
from csb.bio.io.dssp import DSSPParser
from csb.bio.structure import SecondaryStructure, SecStructures

pdbs = StructureParser("2TRX.pdb").parse_structure()

dssp = DSSPParser().parse("pdb2trx.dssp")

for chain in pdbs.items:
    ss = []
    for residue in chain.residues:
        try:
            ss_type = dssp[chain.id][residue.id].secondary_structure
            ss.append(ss_type)
        except KeyError:
            ss.append(SecStructures.Gap)

    ss_string = ''.join(map(str, ss))
    chain.secondary_structure = SecondaryStructure.parse(ss_string)

 

 

When running this code, I get this error:

TypeError: [<Gap: 1-1>, <Turn: 2-3>, <Strand: 4-6>, <Gap: 7-8>, <Turn: 9-11>, <Helix: 12-15>, <Turn: 16-18>, <Gap: 19-19>, <Bend: 20-21>, <Strand: 22-28>, <Gap: 29-29>, <Turn: 30-31>, <Gap: 32-32>, <Helix: 33-48>, <Turn: 49-52>, <Strand: 53-59>, <Turn: 60-62>, <Gap: 63-63>, <Turn: 64-65>, <Helix: 66-69>, <Turn: 70-71>, <Gap: 72-73>, <Bend: 74-76>, <Strand: 77-82>, <Turn: 83-84>, <Strand: 85-91>, <Bend: 92-92>, <Gap: 93-95>, <Helix: 96-107>, <Gap: 108-108>]

 

 

What am I doing wrong?

Thanks in advance!

Coordinator
Oct 16, 2012 at 2:29 PM

Sorry, the last line is wrong, just change it to:

 

chain.secondary_structure = SecondaryStructure(ss_string)

 

Oct 16, 2012 at 3:01 PM

Ah, that was easy.

Thanks!