Пример #1
0
    def createSSstructures(self, chain, heldatas, strdatas, turndatas,
                           coildatas):
        # create a secondary structure set
        #chainStructureSet = SecondaryStructureSet()
        chain.secondarystructureset = SecondaryStructureSet()
        # helices objects
        self.buildSecondaryStructureObjects(heldatas,chain)
        # sheets objects
        self.buildSecondaryStructureObjects(strdatas,chain)
        # turns objects
        if turndatas :
            self.buildSecondaryStructureObjects(turndatas,chain)

        # coils
        self.getCoils(chain)
        if hasattr(chain,'residueInSS'):
            chain.residuesInSS = chain.residues.get(lambda x: hasattr(x, 'secondarystructure'))
    def defineSecondaryStructureSection(self, mol, origin='File'):
        """
        The Secondary structure section contains the following records:
        HELIX, SHEET, TURN
        Information will taken from either the file or the data structure
        required argument:
        origin can either be '', File or Stride

        """
        # 1- Create the SS records from the records contained in the File
        self.recordsToWrite['HELIX'] = []
        self.recordsToWrite['SHEET'] = []
        self.recordsToWrite['TURN'] = []
        if origin == 'File':
            # Directly get the records from the file if molecule comes
            # from a PDB file and the file contains the info
            parser = mol.parser
            if isinstance(parser, PdbParser):
                if not parser.hasSsDataInFile(): return
                self.recordsToWrite['HELIX'] = parser.getRecords(
                    parser.allLines, 'HELIX')
                self.recordsToWrite['SHEET'] = parser.getRecords(
                    parser.allLines, 'SHEET')
                self.recordsToWrite['TURN'] = parser.getRecords(
                    parser.allLines, 'TURN')

            # Else get it from the data structure if information has been
            # parsed
            elif mol.hasSS == ['From File']:
                allstrands = SecondaryStructureSet([])
                allhelices = SecondaryStructureSet([])
                allturns = SecondaryStructureSet([])
                for chain in mol.chains:
                    if not hasattr(chain, 'secondarystructureset'): continue
                    sSet = chain.secondarystructureset
                    helices = sSet.get(lambda x: x.name.startswith('Helix'))
                    if not helices is None: allhelices = allhelices + helices
                    strands = sSet.get(lambda x: x.name.startswith('Strand'))
                    if not strands is None: allstrands = allstrands + strands
                    turns = sSet.get(lambda x: x.name.startswith("Turn"))
                    if not turns is None: allturns = allturns + turns
                self.defineHELIXRecords(allhelices)
                self.defineSHEETRecords(allstrands)
                self.defineTURNRecords(allturns)
            else:
                return

        # 2- Create the SS record from the information generated by stride
        else:
            # only if the data structure has been created
            if not mol.hasSS in ['From Stride', "From PROSS"]: return
            else:
                allstrands = SecondaryStructureSet([])
                allhelices = SecondaryStructureSet([])
                allturns = SecondaryStructureSet([])
                for chain in mol.chains:
                    if not hasattr(chain, 'secondarystructureset'): continue
                    sSet = chain.secondarystructureset
                    helices = sSet.get(lambda x: x.name.startswith('Helix'))
                    if not helices is None: allhelices = allhelices + helices
                    strands = sSet.get(lambda x: x.name.startswith('Strand'))
                    if not strands is None: allstrands = allstrands + strands
                    turns = sSet.get(lambda x: x.name.startswith("Turn"))
                    if not turns is None: allturns = allturns + turns

                self.defineHELIXRecords(allhelices)
                self.defineSHEETRecords(allstrands)
                self.defineTURNRecords(allturns)