def select(self, bnds):
     #bonds of carbon bonded to 3 nitrogens
     c_bnds = self.CSel.select(bnds)
     c3_bnds = self.Sel3.select(c_bnds)
     #n_bnds = self.NSel.select(c3_bnds)
     #nb without lambda expression, this selected PRO bonds N-CA, N-CD
     #    and CYS C-N, THR C-N
     #c3_ats = AtomSet(filter(lambda x:x.element=='C', self.getAtoms(c3_bnds)))
     cats = self.getAtoms(c3_bnds)
     c3_ats = cats.get(lambda x: len(x.bonds)==3)
     cycle_bonds = CycleBondSelector().select(bnds)
     ansBnds = BondSet()
     for at in c3_ats:
         incycle_ct = 0  #keep track of bonds in cycles for vina tutorial ligand.pdb
         ok = True
         for b in at.bonds:
             at2 = b.neighborAtom(at)
             if at2.element!='N':
                 ok=0
             if b in cycle_bonds:
                 incycle_ct += 1
         if ok and incycle_ct<2: 
             #if 2 of 3 this carbon's bonds are in cycle, NOT guanidinium
             for b in at.bonds:
                 if b in bnds:
                     ansBnds.append(b)
     return self.makeUniq(ansBnds)
 def select(self, bnds):
     #bonds of carbon bonded to 3 nitrogens
     c_bnds = self.CSel.select(bnds)
     c3_bnds = self.Sel3.select(c_bnds)
     #n_bnds = self.NSel.select(c3_bnds)
     #nb without lambda expression, this selected PRO bonds N-CA, N-CD
     #    and CYS C-N, THR C-N
     #c3_ats = AtomSet(filter(lambda x:x.element=='C', self.getAtoms(c3_bnds)))
     cats = self.getAtoms(c3_bnds)
     c3_ats = cats.get(lambda x: len(x.bonds) == 3)
     cycle_bonds = CycleBondSelector().select(bnds)
     ansBnds = BondSet()
     for at in c3_ats:
         incycle_ct = 0  #keep track of bonds in cycles for vina tutorial ligand.pdb
         ok = True
         for b in at.bonds:
             at2 = b.neighborAtom(at)
             if at2.element != 'N':
                 ok = 0
             if b in cycle_bonds:
                 incycle_ct += 1
         if ok and incycle_ct < 2:
             #if 2 of 3 this carbon's bonds are in cycle, NOT guanidinium
             for b in at.bonds:
                 if b in bnds:
                     ansBnds.append(b)
     return self.makeUniq(ansBnds)
    def select(self, bnds):
        resSet = self.getAtoms(bnds).parent.uniq()
        aromResSet = resSet.get(lambda x: x.type in list(self.aromDict.keys()))
        if not aromResSet:
            return BondSet()
        bondDict = {}
        pep_arom = BondSet()
        for i in range(len(aromResSet)):
            res = aromResSet[i]
            keys = self.aromDict[res.type]
            res_bnds = bondDict[i + 1] = res.atoms.get(lambda x, keys=keys: x.name in keys).bonds[0]

            for b in res_bnds:
                b.cyclenum = i + 1
                b.aromatic = 1  # ???
                if b in bnds:
                    pep_arom.append(b)
        return pep_arom
    def select(self, bnds):
        resSet = self.getAtoms(bnds).parent.uniq()
        aromResSet = resSet.get(lambda x: x.type in self.aromDict.keys())
        if not aromResSet:
            return BondSet()
        bondDict = {}
        pep_arom = BondSet()
        for i in range(len(aromResSet)):
            res = aromResSet[i]
            keys = self.aromDict[res.type]
            res_bnds = bondDict[i+1] = res.atoms.get(lambda x, \
                                keys = keys:x.name in keys).bonds[0]

            for b in res_bnds:
                b.cyclenum = i + 1
                b.aromatic = 1  #???
                if b in bnds:
                    pep_arom.append(b)
        return pep_arom
 def select(self, bnds):
     n_bnds = self.NSel.select(bnds)
     #bonds between Nitrogens and Carbons
     nc_bnds = self.CSel.select(n_bnds)
     ansBnds = BondSet()
     for b in nc_bnds:
         a0 = b.atom1
         a2 = b.atom2
         if a0.element=='N':
             a2 = b.atom1
             a0 = b.atom2
         if len(a0.bonds)==3:
             #get bonds from this carbon to oxygen
             o_bnds = self.OSel.select(BondSet(a0.bonds))
             if not len(o_bnds):
                 continue
             #get bonds from this carbon to leaf oxygen
             resBnds = self.lSel.select(o_bnds)
             if len(resBnds):
                 ansBnds.append(b)
     return self.makeUniq(ansBnds)
 def select(self, bnds):
     n_bnds = self.NSel.select(bnds)
     #bonds between Nitrogens and Carbons
     nc_bnds = self.CSel.select(n_bnds)
     ansBnds = BondSet()
     for b in nc_bnds:
         a0 = b.atom1
         a2 = b.atom2
         if a0.element == 'N':
             a2 = b.atom1
             a0 = b.atom2
         if len(a0.bonds) == 3:
             #get bonds from this carbon to oxygen
             o_bnds = self.OSel.select(BondSet(a0.bonds))
             if not len(o_bnds):
                 continue
             #get bonds from this carbon to leaf oxygen
             resBnds = self.lSel.select(o_bnds)
             if len(resBnds):
                 ansBnds.append(b)
     return self.makeUniq(ansBnds)
 def select(self, bnds):
     #bonds of carbon bonded to 3 nitrogens
     c_bnds = self.CSel.select(bnds)
     c3_bnds = self.Sel3.select(c_bnds)
     #n_bnds = self.NSel.select(c3_bnds)
     #nb without lambda expression, this selected PRO bonds N-CA, N-CD
     #    and CYS C-N, THR C-N
     #c3_ats = AtomSet(filter(lambda x:x.element=='C', self.getAtoms(c3_bnds)))
     cats = self.getAtoms(c3_bnds)
     c3_ats = cats.get(lambda x: len(x.bonds)==3)
     ansBnds = BondSet()
     for at in c3_ats:
         ok = True
         for b in at.bonds:
             at2 = b.atom1
             if at2==at: at2 = b.atom2
             if at2.element!='N':
                 ok=0
         if ok:
             for b in at.bonds:
                 if b in bnds:
                     ansBnds.append(b)
     return self.makeUniq(ansBnds)
    def select(self, bnds, cutoff=7.5):
        cutoffValue = math.cos(cutoff*math.pi/180.)
        #print "cutoffValue=", cutoffValue
        aromaticCs = AtomSet([])
        atD = {}
        ctr = 1
        aromaticBnds = BondSet()

        #taken from autotorsCommands
        ats = self.getAtoms(bnds)
        rf = RingFinder()
        rf.findRings2(ats, bnds)
        cyclecount = rf.ringCount
        aromatic_cycles = []
        ct = 1
        for ring in rf.rings:
            blist = ring['bonds']
            for bnd in blist:
                at = bnd.atom1
                #next find the other bond in this cycle with at as one of the atoms:
                z2 = filter(lambda x:x!=bnd and x.atom1==at or x.atom2==at, blist)
                bnd.nextbond = z2[0]
                neighbor = z2[0].atom1
                if neighbor==at:
                    neighbor = z2[0].atom2
                bnd.next1 = neighbor
                #print "set ", bnd.atom1.name,'-', bnd.atom2.name,".next1 to ", neighbor.name
                #now each bond has 3 atoms specified for it: its own two and the next1 to atom1
                at1 = bnd.next1
                at2 = bnd.atom1
                at3 = bnd.atom2
                pt1 = at1.coords
                pt2 = at2.coords
                pt3 = at3.coords
                a1 = Numeric.subtract(pt2,pt1)
                b1 = Numeric.subtract(pt3,pt2)
                p = [a1[1]*b1[2]-a1[2]*b1[1],a1[2]*b1[0]-a1[0]*b1[2],a1[0]*b1[1]-a1[1]*b1[0]]
                result0 = Numeric.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2])
                bnd.nrmsize = result0
                result1 = p
                bnd.nrms = result1
                #next find the other bond w/atom2:
                z2 = filter(lambda x,bnd=bnd, at2=bnd.atom2, blist=blist:x!=bnd and x.atom1==at2 or x.atom2==at2, blist)
                #finally, return the other atom in this bond
                bnd.nextbond2 = z2[0]
                if bnd.nextbond2==bnd:
                    bnd.nextbond2 = z2[1]
                #neighbor2 = self._getnxtAtom(b.atom2,b.nextbond2)
                neighbor2 = bnd.nextbond2.atom1
                if neighbor2==bnd.atom2:
                    neighbor2 = bnd.nextbond2.atom2
                bnd.next2 = neighbor2
                #next have to check whether the normals are parallel
                #check each pair in each bond, how to keep track??
                #have to get normal at b's atom2: so have to get next2 for this bond:
            #have to loop twice to make sure neighbor has nrms
            for bnd in blist:
                p = bnd.nrms
                psize = bnd.nrmsize
                q = bnd.nextbond2.nrms
                qsize = bnd.nextbond2.nrmsize
                #theta is the critical test for planarity:
                #if angle between 2 nrms is 0, atoms are planar
                #NB>test is comparing theta,cos(angle), w/zero
                bnd.theta = Numeric.dot(p,q)/(psize*qsize)
            #NB: REPEAT STUFF FROM HERE TO THE END IF aromaticCutOff changes
            ct = 0
            for bnd in blist:
                #these are values for the default 7.5degrees:
                #if theta>=0.997 or theta<=-0.997:
                #print bnd.atom1.name, '-', bnd.atom2.name, '->', bnd.theta 
                if bnd.theta>=cutoffValue or bnd.theta<=-cutoffValue:
                    bnd.posAromatic = 1
                    ct = ct + 1
                else:
                    bnd.posAromatic = 0
                #print ' posAromatic=', bnd.posAromatic
            #after checking all the bonds in current cycle, compare #posAromatic w/number
            if ct==len(blist):
                #print ctr," cycle is aromatic"
                #NB: only C=C bonds are considered aromatic 
                #    could change the name and autodock_element here....
                for bnd in blist:
                    # THIS IS WRONG!!!
                    #if bnd.atom1.element=='C' and bnd.atom2.element=='C':
                    #    aromaticBnds.append(bnd)
                    aromaticBnds.append(bnd)
            ctr = ctr + 1
            #print "len(aromaticBnds)=", len(aromaticBnds)
        #for b in aromaticBnds:
        #    print b.atom1.name, '-', b.atom2.name
        return aromaticBnds
    def select(self, bnds, cutoff=7.5):
        cutoffValue = math.cos(cutoff * math.pi / 180.)
        #print "cutoffValue=", cutoffValue
        aromaticCs = AtomSet([])
        atD = {}
        ctr = 1
        aromaticBnds = BondSet()

        #taken from autotorsCommands
        ats = self.getAtoms(bnds)
        rf = RingFinder()
        rf.findRings2(ats, bnds)
        cyclecount = rf.ringCount
        aromatic_cycles = []
        ct = 1
        for ring in rf.rings:
            blist = ring['bonds']
            for bnd in blist:
                at = bnd.atom1
                #next find the other bond in this cycle with at as one of the atoms:
                z2 = filter(
                    lambda x: x != bnd and x.atom1 == at or x.atom2 == at,
                    blist)
                bnd.nextbond = z2[0]
                neighbor = z2[0].atom1
                if neighbor == at:
                    neighbor = z2[0].atom2
                bnd.next1 = neighbor
                #print "set ", bnd.atom1.name,'-', bnd.atom2.name,".next1 to ", neighbor.name
                #now each bond has 3 atoms specified for it: its own two and the next1 to atom1
                at1 = bnd.next1
                at2 = bnd.atom1
                at3 = bnd.atom2
                pt1 = at1.coords
                pt2 = at2.coords
                pt3 = at3.coords
                a1 = Numeric.subtract(pt2, pt1)
                b1 = Numeric.subtract(pt3, pt2)
                p = [
                    a1[1] * b1[2] - a1[2] * b1[1],
                    a1[2] * b1[0] - a1[0] * b1[2],
                    a1[0] * b1[1] - a1[1] * b1[0]
                ]
                result0 = Numeric.sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2])
                bnd.nrmsize = result0
                result1 = p
                bnd.nrms = result1
                #next find the other bond w/atom2:
                z2 = filter(lambda x, bnd=bnd, at2=bnd.atom2, blist=blist: x !=
                            bnd and x.atom1 == at2 or x.atom2 == at2,
                            blist)
                #finally, return the other atom in this bond
                bnd.nextbond2 = z2[0]
                if bnd.nextbond2 == bnd:
                    bnd.nextbond2 = z2[1]
                #neighbor2 = self._getnxtAtom(b.atom2,b.nextbond2)
                neighbor2 = bnd.nextbond2.atom1
                if neighbor2 == bnd.atom2:
                    neighbor2 = bnd.nextbond2.atom2
                bnd.next2 = neighbor2
                #next have to check whether the normals are parallel
                #check each pair in each bond, how to keep track??
                #have to get normal at b's atom2: so have to get next2 for this bond:
            #have to loop twice to make sure neighbor has nrms
            for bnd in blist:
                p = bnd.nrms
                psize = bnd.nrmsize
                q = bnd.nextbond2.nrms
                qsize = bnd.nextbond2.nrmsize
                #theta is the critical test for planarity:
                #if angle between 2 nrms is 0, atoms are planar
                #NB>test is comparing theta,cos(angle), w/zero
                bnd.theta = Numeric.dot(p, q) / (psize * qsize)
            #NB: REPEAT STUFF FROM HERE TO THE END IF aromaticCutOff changes
            ct = 0
            for bnd in blist:
                #these are values for the default 7.5degrees:
                #if theta>=0.997 or theta<=-0.997:
                #print bnd.atom1.name, '-', bnd.atom2.name, '->', bnd.theta
                if bnd.theta >= cutoffValue or bnd.theta <= -cutoffValue:
                    bnd.posAromatic = 1
                    ct = ct + 1
                else:
                    bnd.posAromatic = 0
                #print ' posAromatic=', bnd.posAromatic
            #after checking all the bonds in current cycle, compare #posAromatic w/number
            if ct == len(blist):
                #print ctr," cycle is aromatic"
                #NB: only C=C bonds are considered aromatic
                #    could change the name and autodock_element here....
                for bnd in blist:
                    # THIS IS WRONG!!!
                    #if bnd.atom1.element=='C' and bnd.atom2.element=='C':
                    #    aromaticBnds.append(bnd)
                    aromaticBnds.append(bnd)
            ctr = ctr + 1
            #print "len(aromaticBnds)=", len(aromaticBnds)
        #for b in aromaticBnds:
        #    print b.atom1.name, '-', b.atom2.name
        return aromaticBnds