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

import os
from DSSPElements import DSSPElements

class DSSPRunner:
    def runfile(self, logger, fname, typedef, etype, data_array, fn):
        dssp_elements = DSSPElements(logger, fname)
        dssp_elements.setType(typedef)
        elements = dssp_elements.getElements()
        for element in elements:
            if element.type != etype: continue
            fn(element, data_array)

    def rundir(self, logger, dirname, typedef, etype, data_array, fn):
        filelist = os.listdir(dirname)
        for i,filename in enumerate(filelist):
            filename = dirname + filename
            self.runfile(logger, filename, typedef, etype, data_array, fn)

