Example #1
0
 def buildCoil(self, residuesCoil, j, chain):
     start = residuesCoil[0]
     end = residuesCoil[-1]
     coil = Coil(chain=chain, index=j, start=start, end=end)
     coil.isNA = False
     return coil
Example #2
0
    def getCoils(self, chain):
        """
        gets the coils of a proteic chain by finding which AA are not yet
        in a secondary structure element
        """
        chain.ribbonType()
        if chain.ribbonType() == 'NA':
            coil = Coil(chain=chain,
                        index='Nucleic',
                        start=chain.DNARes[0],
                        end=chain.DNARes[-1])
            chain.secondarystructureset.append(coil)
            coil.parent = chain
            coil.isNA = True

        else:
            res = chain.AARes
            chainStructureSet = chain.secondarystructureset

            j = 1  # coil counter

            # loop over residues and build coils for continuous segments of
            # unassigned residues
            endedWithGap = False
            # print 'FOR CHAIN ', chain.id

            residuesCoil = []  # list of residues in current Coil
            # look over all residues to build list of residues in current Coil

            for r in res:
                # print r
                # if we hit a residue
                # cCAatom = None
                if not r.hasCA:  # we hit residue that breaks coil
                    if len(residuesCoil):
                        coil = self.buildCoil(residuesCoil, j, chain)
                        coil.gapAfter = True
                        if endedWithGap:
                            coil.gapBefore = True
                        chainStructureSet.append(coil)
                        coil.parent = chain
                        r1 = residuesCoil[0]
                        r2 = residuesCoil[-1]
                        # print '0', coil, r1, r2,coil.gapBefore, coil.gapAfter
                        endedWithGap = True
                        residuesCoil = [r]
                        j = j + 1

                else:
                    anames = r.atoms.name
                    # CA atom of current res
                    # using get('CA*')[0] handle alternate location as in
                    # THR 4 in 1KZK.pdb
                    cCAatom = r.atoms.get('CA*')[0]
                    # cNatom = r.atoms[anames.index('N')] # N atom of current res
                    # cCatom = r.atoms[anames.index('C')] # C atom of current res

                    if hasattr(r, 'secondarystructure'):
                        if len(residuesCoil):
                            coil = self.buildCoil(residuesCoil, j, chain)
                            if endedWithGap:
                                coil.gapBefore = True
                            chainStructureSet.append(coil)
                            coil.parent = chain
                            r1 = residuesCoil[0]
                            r2 = residuesCoil[-1]
                            # print '1', coil, r1, r2, coil.gapBefore, coil.gapAfter
                            endedWithGap = False
                            residuesCoil = []
                            j = j + 1

                    else:
                        if len(residuesCoil) == 0:
                            residuesCoil = [r]

                        else:
                            if self.close(pCAatom, cCAatom):
                                residuesCoil.append(r)
                                if r == res[-1]:  # last seg is coil
                                    coil = self.buildCoil(
                                        residuesCoil, j, chain)
                                    chainStructureSet.append(coil)
                                    if endedWithGap:
                                        coil.gapBefore = True
                                    coil.parent = chain

                            elif len(residuesCoil):  # distance gap
                                coil = self.buildCoil(residuesCoil, j, chain)
                                chainStructureSet.append(coil)
                                coil.gapAfter = True
                                if endedWithGap:
                                    coil.gapBefore = True
                                coil.parent = chain
                                r1 = residuesCoil[0]
                                r2 = residuesCoil[-1]
                                # print '2', coil, r1, r2,coil.gapBefore, coil.gapAfter
                                endedWithGap = True
                                residuesCoil = [r]
                                j = j + 1

                    pCAatom = cCAatom
                # pNatom = cNatom
                # pCatom = cCatom

        chain.secondarystructureset.sort(self.Compare)
 def buildCoil(self, residuesCoil, j, chain):
     start = residuesCoil[0]
     end = residuesCoil[-1]
     coil = Coil(chain=chain, index=j, start=start, end=end)
     coil.isNA = False
     return coil
    def getCoils(self, chain):
        """
        gets the coils of a proteic chain by finding which AA are not yet
        in a secondary structure element
        """
        chain.ribbonType()
        if chain.ribbonType()=='NA':
            coil = Coil(chain=chain, index='Nucleic', 
                        start=chain.DNARes[0], end=chain.DNARes[-1])
            chain.secondarystructureset.append(coil)
            coil.parent = chain
            coil.isNA = True

        else:
            res = chain.AARes
            chainStructureSet = chain.secondarystructureset

            j = 1 # coil counter
            
            # loop over residues and build coils for continuous segments of
            # unassigned residues 
            endedWithGap = False
            #print 'FOR CHAIN ', chain.id

            residuesCoil = [] # list of residues in current Coil
            # look over all residues to build list of residues in current Coil

            for r in res:
                #print r
                # if we hit a residue
                #cCAatom = None
                if not r.hasCA: # we hit residue that breaks coil
                    if len(residuesCoil):
                        coil = self.buildCoil(residuesCoil, j, chain)
                        coil.gapAfter = True
                        if endedWithGap:
                            coil.gapBefore = True
                        chainStructureSet.append(coil)
                        coil.parent = chain
                        r1 = residuesCoil[0]
                        r2 = residuesCoil[-1]
                        #print '0', coil, r1, r2,coil.gapBefore, coil.gapAfter
                        endedWithGap = True
                        residuesCoil = [r]
                        j = j+1
                        
                else:
                    anames = r.atoms.name
                    # CA atom of current res
                    # using get('CA*')[0] handle alternate location as in
                    # THR 4 in 1KZK.pdb
                    cCAatom = r.atoms.get('CA*')[0]
                    #cNatom = r.atoms[anames.index('N')] # N atom of current res
                    #cCatom = r.atoms[anames.index('C')] # C atom of current res

                    if hasattr(r, 'secondarystructure'):
                        if len(residuesCoil):
                            coil = self.buildCoil(residuesCoil, j, chain)
                            if endedWithGap:
                                coil.gapBefore = True
                            chainStructureSet.append(coil)
                            coil.parent = chain
                            r1 = residuesCoil[0]
                            r2 = residuesCoil[-1]
                            #print '1', coil, r1, r2, coil.gapBefore, coil.gapAfter
                            endedWithGap = False
                            residuesCoil = []
                            j = j+1

                    else:
                        if len(residuesCoil)==0:
                            residuesCoil = [r]

                        else:
                            if self.close(pCAatom, cCAatom):
                                residuesCoil.append(r)
                                if r==res[-1]: #last seg is coil
                                    coil = self.buildCoil(residuesCoil, j, chain)
                                    chainStructureSet.append(coil)
                                    if endedWithGap:
                                        coil.gapBefore = True
                                    coil.parent = chain
                                   
                            elif len(residuesCoil): # distance gap
                                coil = self.buildCoil(residuesCoil, j, chain)
                                chainStructureSet.append(coil)
                                coil.gapAfter = True
                                if endedWithGap:
                                    coil.gapBefore = True
                                coil.parent = chain
                                r1 = residuesCoil[0]
                                r2 = residuesCoil[-1]
                                #print '2', coil, r1, r2,coil.gapBefore, coil.gapAfter
                                endedWithGap = True
                                residuesCoil = [r]
                                j = j+1
                
                    pCAatom = cCAatom
                #pNatom = cNatom
                #pCatom = cCatom
                        
            ## res = chain.AARes

            ## chainStructureSet = chain.secondarystructureset
            ## resNum = None
            ## try:
            ##     resNum = int(res[0].number)  
            ## except:
            ##     pass

            ## j = 1 # coil counter

            ## for rn, r in enumerate(res):
            ##     print 'AAA1', r, resNum, r.number
            ##     if resNum:
            ##         if resNum != int(r.number):
            ##             if residuesCoil:
            ##                 print 'AAA2', j, len(residuesCoil)
            ##                 coil = self.buildCoil(residuesCoil, j, chain)
            ##                 chainStructureSet.append(coil)
            ##                 coil.parent = chain
            ##                 coil.gap =int(r.number) - resNum #used in secondaryStructureCommands to fix Bug 1120
            ##                 residuesCoil = [r]
            ##                 r.gap = True
            ##                 j = j+1
            ##         try:
            ##             if res[rn+1].number != r.number: #icode is not '':
            ##                 resNum = int(r.number) +1 
            ##         except IndexError:
            ##             pass

            ##     if not hasattr(r, 'secondarystructure') and r.hasCA and r.hasO:
            ##         print 'AAA3', r, len(residuesCoil), r == res[-1]
            ##         residuesCoil.append(r)
            ##         #test if this residue is the last one if yes it build the
            ##         #information on the COIL, if not i is incremented.

            ##         if r == res[-1] and residuesCoil != []:
            ##             coil = self.buildCoil(residuesCoil, j, chain)
            ##             chainStructureSet.append(coil)
            ##             coil.parent = chain
            ##             if hasattr(residuesCoil[0],'gap'):
            ##                 coil.gap = True 
            ##             residuesCoil = []
            ##             j = j+1
            ##     else:
            ##         print 'AAA4', len(residuesCoil)
            ##         if residuesCoil != []:
            ##             coil = self.buildCoil(residuesCoil, j, chain)
            ##             chainStructureSet.append(coil)
            ##             coil.parent = chain
            ##             if hasattr(residuesCoil[0],'gap'):
            ##                 coil.gap = True 
            ##             residuesCoil = []
            ##             j = j+1

        chain.secondarystructureset.sort(self.Compare)
    def getCoils(self, chain):
        """
        gets the coils of a proteic chain by finding which AA are not yet
        in a secondary structure element
        """
        chain.ribbonType()
        if chain.ribbonType()=='NA':
            coil = Coil(chain=chain, index='Nucleic', 
                        start=chain.DNARes[0], end=chain.DNARes[-1])
            chain.secondarystructureset.append(coil)
            coil.parent = chain
            coil.isNA = True

        else:
            res = chain.AARes
            chainStructureSet = chain.secondarystructureset

            j = 1 # coil counter
            
            # loop over residues and build coils for continuous segments of
            # unassigned residues 
            endedWithGap = False
            #print 'FOR CHAIN ', chain.id

            residuesCoil = [] # list of residues in current Coil
            # look over all residues to build list of residues in current Coil

            for r in res:
                #print r
                # if we hit a residue
                #cCAatom = None
                if not r.hasCA: # we hit residue that breaks coil
                    if len(residuesCoil):
                        coil = self.buildCoil(residuesCoil, j, chain)
                        coil.gapAfter = True
                        if endedWithGap:
                            coil.gapBefore = True
                        chainStructureSet.append(coil)
                        coil.parent = chain
                        r1 = residuesCoil[0]
                        r2 = residuesCoil[-1]
                        #print '0', coil, r1, r2,coil.gapBefore, coil.gapAfter
                        endedWithGap = True
                        residuesCoil = [r]
                        j = j+1
                        
                else:
                    anames = r.atoms.name
                    # CA atom of current res
                    # using get('CA*')[0] handle alternate location as in
                    # THR 4 in 1KZK.pdb
                    cCAatom = r.atoms.get('CA*')[0]
                    #cNatom = r.atoms[anames.index('N')] # N atom of current res
                    #cCatom = r.atoms[anames.index('C')] # C atom of current res

                    if hasattr(r, 'secondarystructure'):
                        if len(residuesCoil):
                            coil = self.buildCoil(residuesCoil, j, chain)
                            if endedWithGap:
                                coil.gapBefore = True
                            chainStructureSet.append(coil)
                            coil.parent = chain
                            r1 = residuesCoil[0]
                            r2 = residuesCoil[-1]
                            #print '1', coil, r1, r2, coil.gapBefore, coil.gapAfter
                            endedWithGap = False
                            residuesCoil = []
                            j = j+1

                    else:
                        if len(residuesCoil)==0:
                            residuesCoil = [r]

                        else:
                            if self.close(pCAatom, cCAatom):
                                residuesCoil.append(r)
                                if r==res[-1]: #last seg is coil
                                    coil = self.buildCoil(residuesCoil, j, chain)
                                    chainStructureSet.append(coil)
                                    if endedWithGap:
                                        coil.gapBefore = True
                                    coil.parent = chain
                                   
                            elif len(residuesCoil): # distance gap
                                coil = self.buildCoil(residuesCoil, j, chain)
                                chainStructureSet.append(coil)
                                coil.gapAfter = True
                                if endedWithGap:
                                    coil.gapBefore = True
                                coil.parent = chain
                                r1 = residuesCoil[0]
                                r2 = residuesCoil[-1]
                                #print '2', coil, r1, r2,coil.gapBefore, coil.gapAfter
                                endedWithGap = True
                                residuesCoil = [r]
                                j = j+1
                
                    pCAatom = cCAatom
                #pNatom = cNatom
                #pCatom = cCatom
                        
            ## res = chain.AARes

            ## chainStructureSet = chain.secondarystructureset
            ## resNum = None
            ## try:
            ##     resNum = int(res[0].number)  
            ## except:
            ##     pass

            ## j = 1 # coil counter

            ## for rn, r in enumerate(res):
            ##     print 'AAA1', r, resNum, r.number
            ##     if resNum:
            ##         if resNum != int(r.number):
            ##             if residuesCoil:
            ##                 print 'AAA2', j, len(residuesCoil)
            ##                 coil = self.buildCoil(residuesCoil, j, chain)
            ##                 chainStructureSet.append(coil)
            ##                 coil.parent = chain
            ##                 coil.gap =int(r.number) - resNum #used in secondaryStructureCommands to fix Bug 1120
            ##                 residuesCoil = [r]
            ##                 r.gap = True
            ##                 j = j+1
            ##         try:
            ##             if res[rn+1].number != r.number: #icode is not '':
            ##                 resNum = int(r.number) +1 
            ##         except IndexError:
            ##             pass

            ##     if not hasattr(r, 'secondarystructure') and r.hasCA and r.hasO:
            ##         print 'AAA3', r, len(residuesCoil), r == res[-1]
            ##         residuesCoil.append(r)
            ##         #test if this residue is the last one if yes it build the
            ##         #information on the COIL, if not i is incremented.

            ##         if r == res[-1] and residuesCoil != []:
            ##             coil = self.buildCoil(residuesCoil, j, chain)
            ##             chainStructureSet.append(coil)
            ##             coil.parent = chain
            ##             if hasattr(residuesCoil[0],'gap'):
            ##                 coil.gap = True 
            ##             residuesCoil = []
            ##             j = j+1
            ##     else:
            ##         print 'AAA4', len(residuesCoil)
            ##         if residuesCoil != []:
            ##             coil = self.buildCoil(residuesCoil, j, chain)
            ##             chainStructureSet.append(coil)
            ##             coil.parent = chain
            ##             if hasattr(residuesCoil[0],'gap'):
            ##                 coil.gap = True 
            ##             residuesCoil = []
            ##             j = j+1

        chain.secondarystructureset.sort(self.Compare)