I thought it would be very simple to write a code for this task given clear instructions in the BioPython file I referenced above, but it seems like that's not the case. Here is a working code that will download a structure and extract its DSSP designations. If you already have PDB files somewhere, simply skip the download and point to them in the parsing and DSSP functions.
from Bio.PDB import PDBParser
from Bio.PDB.DSSP import DSSP
from Bio.PDB import PDBList
# initialize PDB downloader
pdb_dl = PDBList()
# a list of PDB IDs to download
pdb_list = ['1ako']
# download PDB files, save them in current directory
for i in pdb_list:
pdb_dl.retrieve_pdb_file(i, pdir='./', file_format='pdb', overwrite=True)
# parse structure
p = PDBParser()
for i in pdb_list:
structure = p.get_structure(i, './pdb%s.ent' % i)
# use only the first model
model = structure[0]
# calculate DSSP
dssp = DSSP(model, './pdb%s.ent' % i, file_type='PDB')
# extract sequence and secondary structure from the DSSP tuple
sequence = ''
sec_structure = ''
for z in range(len(dssp)):
a_key = list(dssp.keys())[z]
sequence += dssp[a_key][1]
sec_structure += dssp[a_key][2]
# print extracted sequence and structure
print(i)
print(sequence)
print(sec_structure)
#
# The DSSP codes for secondary structure used here are:
# ===== ====
# Code Structure
# ===== ====
# H Alpha helix (4-12)
# B Isolated beta-bridge residue
# E Strand
# G 3-10 helix
# I Pi helix
# T Turn
# S Bend
# - None
# ===== ====
#
# if desired, convert DSSP's 8-state assignments into 3-state [C - coil, E - extended (beta-strand), H - helix]
sec_structure = sec_structure.replace('-', 'C')
sec_structure = sec_structure.replace('I', 'C')
sec_structure = sec_structure.replace('T', 'C')
sec_structure = sec_structure.replace('S', 'C')
sec_structure = sec_structure.replace('G', 'H')
sec_structure = sec_structure.replace('B', 'E')
print(sec_structure)
The printout will contain a protein sequence, its original DSSP designation, and converted DSSP assignments after replacing 8-state with 3-state characters.
1ako
MKFVSFNINGLRARPHQLEAIVEKHQPDVIGLQETKVHDDMFPLEEVAKLGYNVFYHGQKGHYGVALLTKETPIAVRRGFPGDDEEAQRRIIMAEIPSLLGNVTVINGYFPQGESRDHPIKFPAKAQFYQNLQNYLETELKRDNPVLIMGDMNISPTDLDIGIGEENRKRWLRTGKCSFLPEEREWMDRLMSWGLVDTFRHANPQTADRFSWFDYRSKGFDDNRGLRIDLLLASQPLAECCVETGIDYEIRSMEKPSDHAPVWATFRR
-EEEEEE-S-GGG-HHHHHHHHHHH--SEEEEE-----GGG--HHHHHHTT-EEEEEEETTEEEEEEEESS--SEEEESSTT--HHHHTTEEEEEEEETTEEEEEEEEE-----BTT-TTHHHHHHHHHHHHHHHHHHH--TTS-EEEEEE-----SGGGB-S-HHHHHHHHHHTBTTS-HHHHHHHHHHHHTTEEEHHHHHSTT--S--SB--TTTTHHHHT--B--EEEEEEHHHHTTEEEEEE-HHHHTSSS--SB--EEEEE--
CEEEEEECCCHHHCHHHHHHHHHHHCCCEEEEECCCCCHHHCCHHHHHHCCCEEEEEEECCEEEEEEEECCCCCEEEECCCCCCHHHHCCEEEEEEEECCEEEEEEEEECCCCCECCCCCHHHHHHHHHHHHHHHHHHHCCCCCCEEEEEECCCCCCHHHECCCHHHHHHHHHHCECCCCHHHHHHHHHHHHCCEEEHHHHHCCCCCCCCCECCCCCCHHHHCCCECCEEEEEEHHHHCCEEEEEECHHHHCCCCCCCECCEEEEECC
Hello, did you ever solve this?