# $CVSHeader: pal8e/src/DSSP.py,v 1.2 2005/02/15 01:10:25 indraneel Rel $

# basic DSSP file handler

import os
from string import split

class DSSP(dict):
    def store(self, fname):
        if not os.path.isfile(fname): return 'Err'
        fh = file(fname)
        lines = fh.readlines()
        fh.close()
        for (i,line) in enumerate(lines):
            if line[2] == '#':
                break
        lines = lines[i+1:]
        ctr = 0
        for line in lines:
            aa = line[13]
            if aa == '!': continue
            chain = line[11]
            resid = int(split(line[6:10])[0])
            icode = line[10]
            structure=line[16]
            if not self.has_key(chain):
                self[chain]={}
            ctr += 1
            self[chain][(resid, icode)] = {'#':ctr, 'AA':aa, 'SS':[structure]}
    
