コード例 #1
0
def ExtrudeNA(chain):
    """Computes ribbons for DNA/RNA"""
    coord = []
    coord.append(chain.residues[0].atoms[0].coords)
    NA_type = chain.residues[0].type.strip()
    atoms = chain.residues[0].atoms
    if NA_type in ["A", "G"]:
        N9 = Numeric.array(atoms.objectsFromString("N9")[0].coords)
        C8 = Numeric.array(atoms.objectsFromString("C8")[0].coords)
        C4 = Numeric.array(atoms.objectsFromString("C4")[0].coords)
        N9_C8 = C8 - N9
        N9_C4 = C4 - N9
        normal = Numeric.array(crossProduct(N9_C8, N9_C4, normal=True))
    else:
        N1 = Numeric.array(atoms.objectsFromString("N1")[0].coords)
        C2 = Numeric.array(atoms.objectsFromString("C2")[0].coords)
        C6 = Numeric.array(atoms.objectsFromString("C6")[0].coords)
        N1_C2 = C2 - N1
        N1_C6 = C6 - N1
        normal = Numeric.array(crossProduct(N1_C2, N1_C6, normal=True))
    base_normal = Numeric.array(chain.residues[0].atoms[0].coords)
    coord.append((base_normal + normal).tolist())
    for res in chain.residues[1:]:

        if res.atoms.objectsFromString("P"):
            P_coord = res.atoms.objectsFromString("P")[0].coords
            coord.append(P_coord)
        else:  # this in case last residue does not have P
            P_coord = res.atoms.objectsFromString("C5\*")[0].coords
        NA_type = res.type.strip()
        atoms = res.atoms
        if NA_type in ["A", "G"]:
            N9 = Numeric.array(atoms.objectsFromString("N9")[0].coords)
            C8 = Numeric.array(atoms.objectsFromString("C8")[0].coords)
            C4 = Numeric.array(atoms.objectsFromString("C4")[0].coords)
            N9_C8 = C8 - N9
            N9_C4 = C4 - N9
            normal = Numeric.array(crossProduct(N9_C8, N9_C4, normal=True))
        else:
            N1 = Numeric.array(atoms.objectsFromString("N1")[0].coords)
            C2 = Numeric.array(atoms.objectsFromString("C2")[0].coords)
            C6 = Numeric.array(atoms.objectsFromString("C6")[0].coords)
            N1_C2 = C2 - N1
            N1_C6 = C6 - N1
            normal = Numeric.array(crossProduct(N1_C2, N1_C6, normal=True))

        base_normal = Numeric.array(P_coord)
        coord.append((base_normal + normal).tolist())

    chain.sheet2D["ssSheet2D"] = Sheet2D()
    chain.sheet2D["ssSheet2D"].compute(
        coord, len(chain.residues) * (False,), width=2.0, off_c=0.9, offset=0.0, nbchords=4
    )
    chain.sheet2D["ssSheet2D"].resInSheet = chain.residues
コード例 #2
0
def make_purine(residue, height = 0.4, scale = 1.2):
    """Creates vertices and normals for purines: Adenine Guanine"""
    atoms = residue.atoms
    names = [name.split("@")[0] for name in atoms.name]    
    idx=names.index('N9'); N9 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C8'); C8 =  Numeric.array(atoms[idx].coords)
    idx=names.index('N7'); N7 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C5'); C5 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C4'); C4 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C6'); C6 =  Numeric.array(atoms[idx].coords)
    idx=names.index('N1'); N1 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C2'); C2 =  Numeric.array(atoms[idx].coords)
    idx=names.index('N3'); N3 =  Numeric.array(atoms[idx].coords)
    N9_C8 = C8-N9
    N9_C4 = C4-N9
    C8_C4 = height*norm(C4-C8)
    normal = height*Numeric.array(crossProduct(N9_C8, N9_C4, normal=True))
    #center1 = (N9+C8+N7+C4+C5)/5.0
    #center2 = (C4+C5+C6+N1+C2+N3)/6.0    
    center2 = (C4+C5+C6+N1+C2+N3+N9+C8+N7)/9.0    
    center1 = center2
    vertices = Numeric.zeros((20,3),Numeric.Float)

    vertices[0] = scale*(C8 - normal - center1) + center1
    vertices[1] = scale*(N7 - normal - center1) + center1
    vertices[2] = scale*(C5 - normal - center2) + center2
    vertices[3] = scale*(C4 - normal - center2) + center2
    vertices[4] = scale*(C6 - normal - center2) + center2
    vertices[5] = scale*(N1 - normal - center2) + center2      
    vertices[6] = scale*(C2 - normal - center2) + center2      
    vertices[7] = scale*(N3 - normal - center2) + center2    
    
    vertices[8] = scale*(C8 + normal - center1) + center1
    vertices[9] = scale*(N7 + normal - center1) + center1
    vertices[10] = scale*(C5 + normal - center2) + center2
    vertices[11] = scale*(C4 + normal - center2) + center2
    vertices[12] = scale*(C6 + normal - center2) + center2      
    vertices[13] = scale*(N1 + normal - center2) + center2      
    vertices[14] = scale*(C2 + normal - center2) + center2
    vertices[15] = scale*(N3 + normal - center2) + center2    
    
    vertices[16] = scale*(N9 - C8_C4 - normal - center1) + center1     
    vertices[17] = scale*(N9 - C8_C4 + normal - center1) + center1     
    vertices[18] = scale*(N9 + C8_C4 + normal - center1) + center1     
    vertices[19] = scale*(N9 + C8_C4 - normal - center1) + center1

    
    faces = Numeric.array([[19,3,2,1,0,16,16],
                       [17,8,9,10,11,18,18], 
                       [3,7,6,5,4,2,2],
                       [10,12,13,14,15,11,11],
                       [16,0,8,17,17,17,17], [0,1,9,8,8,8,8], [1,2,10,9,9,9,9], 
                           [2,4,12,10,10,10,10], 
                       [4,5,13,12,12,12,12], [5,6,14,13,13,13,13], 
                           [6,7,15,14,14,14,14],
                           [7,3,11,15,15,15,15],
                       [3,19,18,11,11,11,11] ])
    return vertices,faces
コード例 #3
0
ファイル: NucleicBases.py プロジェクト: lisarosalina/App
def make_pyrimidine(residue, height=0.4, scale=1.2):
    """Creates vertices and normals for pyrimidines:Thymine  Uracil  Cytosine"""
    atoms = residue.atoms
    names = [name.split("@")[0] for name in atoms.name]
    idx = names.index('N1')
    N1 = Numeric.array(atoms[idx].coords)
    idx = names.index('C2')
    C2 = Numeric.array(atoms[idx].coords)
    idx = names.index('N3')
    N3 = Numeric.array(atoms[idx].coords)
    idx = names.index('C4')
    C4 = Numeric.array(atoms[idx].coords)
    idx = names.index('C5')
    C5 = Numeric.array(atoms[idx].coords)
    idx = names.index('C6')
    C6 = Numeric.array(atoms[idx].coords)
    N1_C2 = C2 - N1
    N1_C6 = C6 - N1
    C2_C6 = height * norm(C6 - C2)
    normal = height * Numeric.array(crossProduct(N1_C2, N1_C6, normal=True))
    center = (N1 + C2 + N3 + C4 + C5 + C6) / 6.0
    vertices = Numeric.zeros((14, 3), Numeric.Float)
    vertices[0] = scale * (C2 - normal - center) + center
    vertices[1] = scale * (N3 - normal - center) + center
    vertices[2] = scale * (C4 - normal - center) + center
    vertices[3] = scale * (C5 - normal - center) + center
    vertices[4] = scale * (C6 - normal - center) + center

    vertices[5] = scale * (C2 + normal - center) + center
    vertices[6] = scale * (N3 + normal - center) + center
    vertices[7] = scale * (C4 + normal - center) + center
    vertices[8] = scale * (C5 + normal - center) + center
    vertices[9] = scale * (C6 + normal - center) + center
    vertices[10] = scale * (N1 - C2_C6 - normal - center) + center
    vertices[11] = scale * (N1 - C2_C6 + normal - center) + center
    vertices[12] = scale * (N1 + C2_C6 + normal - center) + center
    vertices[13] = scale * (N1 + C2_C6 - normal - center) + center

    faces = Numeric.array([[13, 4, 3, 2, 1, 0, 10], [11, 5, 6, 7, 8, 9, 12],
                           [0, 5, 11, 10, 10, 10, 10], [
                               1,
                               6,
                               5,
                               0,
                               0,
                               0,
                               0,
                           ], [2, 7, 6, 1, 1, 1, 1], [3, 8, 7, 2, 2, 2, 2],
                           [4, 9, 8, 3, 3, 3, 3], [13, 12, 9, 4, 4, 4, 4]])
    return vertices, faces
コード例 #4
0
def make_pyrimidine(residue, height = 0.4, scale = 1.2):
    """Creates vertices and normals for pyrimidines:Thymine  Uracil  Cytosine"""
    atoms = residue.atoms
    names = [name.split("@")[0] for name in atoms.name]    
    idx=names.index('N1'); N1 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C2'); C2 =  Numeric.array(atoms[idx].coords)
    idx=names.index('N3'); N3 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C4'); C4 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C5'); C5 =  Numeric.array(atoms[idx].coords)
    idx=names.index('C6'); C6 =  Numeric.array(atoms[idx].coords)
    N1_C2 = C2-N1
    N1_C6 = C6-N1
    C2_C6 = height*norm(C6-C2)
    normal = height*Numeric.array(crossProduct(N1_C2, N1_C6, normal=True))
    center = (N1+C2+N3+C4+C5+C6)/6.0
    vertices = Numeric.zeros((14,3),Numeric.Float)
    vertices[0] = scale*(C2 - normal - center) + center
    vertices[1] = scale*(N3 - normal - center) + center
    vertices[2] = scale*(C4 - normal - center) + center
    vertices[3] = scale*(C5 - normal - center) + center
    vertices[4] = scale*(C6 - normal - center) + center
    
    vertices[5] = scale*(C2 + normal - center) + center
    vertices[6] = scale*(N3 + normal - center) + center
    vertices[7] = scale*(C4 + normal - center) + center
    vertices[8] = scale*(C5 + normal - center) + center
    vertices[9] = scale*(C6 + normal - center) + center
    vertices[10] = scale*(N1 - C2_C6 - normal - center) + center
    vertices[11] = scale*(N1 - C2_C6 + normal - center) + center
    vertices[12] = scale*(N1 + C2_C6 + normal - center) + center
    vertices[13] = scale*(N1 + C2_C6 - normal - center) + center
    
    faces = Numeric.array([[13,4,3,2,1,0,10],
                           [11,5,6,7,8,9,12],
                           [0,5,11,10,10,10,10], [1,6,5,0,0,0,0,], [2,7,6,1,1,1,1], 
                           [3,8,7,2,2,2,2], [4,9,8,3,3,3,3], [13,12,9,4,4,4,4]])
    return vertices, faces
コード例 #5
0
 def detectPiInteractions(self, tolerance=0.95, debug=False, use_all_cycles=False):
     if debug: print("in detectPiInteractions")
     self.results['pi_pi'] = []        #stacked rings...?
     self.results['t_shaped'] = []     #one ring perpendicular to the other
     self.results['cation_pi'] = []    #
     self.results['pi_cation'] = []    #
     self.results['macro_cations'] = []#
     self.results['lig_cations'] = []  #
     #at this point have self.results
     if not len(self.results['lig_close_atoms']):
         return
     lig_atoms = self.results['lig_close_atoms'].parent.uniq().atoms
     macro_res = self.results['macro_close_atoms'].parent.uniq()
     if not len(macro_res):
         return
     macro_atoms = macro_res.atoms
     l_rf = RingFinder()
     #Ligand
     l_rf.findRings2(lig_atoms, lig_atoms.bonds[0])
     #rf.rings is list of dictionaries, one per ring, with keys 'bonds' and 'atoms'
     if debug: print("LIG: len(l_rf.rings)=", len(l_rf.rings))
     if not len(l_rf.rings):
         if debug: print("no lig rings found by l_rf!")
         return
     acbs = self.aromatic_cycle_bond_selector
     #acbs = AromaticCycleBondSelector()
     lig_rings = []
     for r in l_rf.rings:
         ring_bnds = r['bonds']
         if use_all_cycles: 
             lig_rings.append(ring_bnds)
         else:
             arom_bnds = acbs.select(ring_bnds)
             if len(arom_bnds)>4:
                 lig_rings.append(arom_bnds)
     if debug: print("LIG: len(lig_arom_rings)=", len(lig_rings))
     self.results['lig_rings'] = lig_rings
     self.results['lig_ring_atoms'] = AtomSet()
     #only check for pi-cation if lig_rings exist
     if len(lig_rings):
         macro_cations = self.results['macro_cations'] = self.getCations(macro_atoms)
         macro_cations = macro_cations.get(lambda x: x.element!='H')
         lig_ring_atoms = AtomSet()
         u = {}
         for r in lig_rings:
             for a in BondSet(r).getAtoms():
                 u[a] = 1
         if len(u): 
             lig_ring_atoms = AtomSet(list(u.keys()))
             lig_ring_atoms.sort()
             self.results['lig_ring_atoms'] = lig_ring_atoms
         if len(macro_cations):
             if debug: print("check distances from lig_rings to macro_cations here")
             #macro cations->lig rings
             pairDict2 = self.distanceSelector.select(lig_ring_atoms,macro_cations)
             z = {}
             for key,v in list(pairDict2.items()):
                 val = v.tolist()[0]
                 if val in macro_cations:
                     z[val] = [key]
             if len(z):
                 self.results['pi_cation'] = (list(z.items()))
             else:
                 self.results['pi_cation'] = []
     #check the distance between the rings and the macro_cations
     self.results['lig_cations'] = self.getCations(lig_atoms)
     lig_cations = self.results['lig_cations'] 
     #remove hydrogens
     lig_cations = lig_cations.get(lambda x: x.element!='H')
     #Macromolecule
     m_rf = RingFinder()
     m_rf.findRings2(macro_res.atoms, macro_res.atoms.bonds[0])
     #rf.rings is list of dictionaries, one per ring, with keys 'bonds' and 'atoms'
     if debug: print("MACRO: len(m_rf.rings)=", len(m_rf.rings))
     if not len(m_rf.rings):
         if debug: print("no macro rings found by m_rf!")
         return
     macro_rings = []
     for r in m_rf.rings:
         ring_bnds = r['bonds']
         if use_all_cycles: 
             macro_rings.append(ring_bnds)
         else:
             arom_bnds = acbs.select(ring_bnds)
             if len(arom_bnds)>4:
                 macro_rings.append(arom_bnds)
     if debug: print("len(macro_arom_rings)=", len(macro_rings))
     self.results['macro_rings'] = macro_rings
     self.results['macro_ring_atoms'] = AtomSet()
     #only check for pi-cation if macro_rings exist
     if len(macro_rings):
         macro_ring_atoms = AtomSet()
         u = {}
         for r in macro_rings:
             for a in BondSet(r).getAtoms(): #new method of bondSets
                 u[a] = 1
         if len(u):
             macro_ring_atoms = AtomSet(list(u.keys()))
             macro_ring_atoms.sort()
             self.results['macro_ring_atoms'] = macro_ring_atoms
         if len(lig_cations):
             if debug: print("check distances from macro_rings to lig_cations here")
             pairDict3 = self.distanceSelector.select(macro_ring_atoms,lig_cations)
             z = {}
             for x in list(pairDict3.items()):
                 #lig cations->macro rings
                 z.setdefault(x[1].tolist()[0], []).append(x[0])
             if len(z):
                 self.results['cation_pi'] = (list(z.items()))
             else:
                 self.results['cation_pi'] = []
             #macro_pi_atoms = AtomSet(pairDict3.keys())
             #l_cations = AtomSet()
             #for v in pairDict3.values():
             #    for x in v:
             #        l_cations.append(x)
             #self.results['cation_pi'] = pairDict3.items()
             #self.results['cation_pi'] = (l_cations, macro_pi_atoms)
     #check for intermol distance <6 Angstrom (J.ComputChem 29:275-279, 2009)
     #compare each lig_ring vs each macro_ring
     for lig_ring_bnds in lig_rings:
         lig_atoms = acbs.getAtoms(lig_ring_bnds)
         lig_atoms.sort()
         if debug: print("len(lig_atoms)=", len(lig_atoms))
         #---------------------------------
         # compute the normal to lig ring
         #---------------------------------
         a1 = numpy.array(lig_atoms[0].coords)
         a2 = numpy.array(lig_atoms[2].coords)
         a3 = numpy.array(lig_atoms[4].coords)
         if debug: print("a1,a2, a3=", a1.tolist(), a2.tolist(), a3.tolist())
         for macro_ring_bnds in macro_rings:
             macro_atoms = acbs.getAtoms(macro_ring_bnds)
             macro_atoms.sort()
             if debug: print("len(macro_atoms)=", len(macro_atoms))
             pD_dist = self.distanceSelectorWithCutoff.select(macro_ring_atoms, lig_atoms, cutoff=self.dist_cutoff)
             if not len(pD_dist[0]):
                 if debug: 
                     print("skipping ligand ring ", lig_rings.index(lig_ring_bnds), " vs ", end=' ')
                     print("macro ring", macro_rings.index(macro_ring_bnds))
                 continue
             #---------------------------------
             # compute the normal to macro ring
             #---------------------------------
             b1 = numpy.array(macro_atoms[0].coords)
             b2 = numpy.array(macro_atoms[2].coords)
             b3 = numpy.array(macro_atoms[4].coords)
             if debug: print("b1,b2, b3=", b1.tolist(), b2.tolist(), b3.tolist())
             # check for stacking 
             a2_1 = a2-a1
             a3_1 = a3-a1
             b2_1 = b2-b1
             b3_1 = b3-b1
             if debug: print("a2_1 = ", a2-a1)
             if debug: print("a3_1 = ", a3-a1)
             if debug: print("b2_1 = ", b2-b1)
             if debug: print("b3_1 = ", b3-b1)
             n1 = crossProduct(a3_1,a2_1) #to get the normal for the first ring
             n2 = crossProduct(b3_1,b2_1) #to get the normal for the second ring
             if debug: print("n1=", n1)
             if debug: print("n2=", n2)
             n1 = numpy.array(n1)
             n2 = numpy.array(n2)
             n1_dot_n2 = numpy.dot(n1,n2)
             if debug: print("n1_dot_n2", numpy.dot(n1,n2))
             if abs(n1_dot_n2) >= 1*tolerance: 
                 if debug: print("The rings are stacked vertically") 
                 new_result = (acbs.getAtoms(lig_ring_bnds), acbs.getAtoms(macro_ring_bnds))
                 self.results['pi_pi'].append(new_result)
             if abs(n1_dot_n2) <= 0.01*tolerance: 
                 if debug: print("The rings are stacked perpendicularly") 
                 new_result = (acbs.getAtoms(lig_ring_bnds), acbs.getAtoms(macro_ring_bnds))
                 self.results['t_shaped'].append(new_result)
コード例 #6
0
def ExtrudeNA(chain):
    """Computes ribbons for DNA/RNA"""
    coord = []
    coord.append(chain.DNARes[0].atoms[0].coords)
    NA_type = chain.DNARes[0].type.strip()                        
    atoms = chain.DNARes[0].atoms
    missingAts = False
    normal = Numeric.array([0.,1.,0.])
    if NA_type in ['A', 'G']:
        listesel = ['N9.*','C8.*','C4.*']
        listeCoord,missingAts = getAtsRes(atoms,listesel)
        if not missingAts :
            N9 =  listeCoord[0]#Numeric.array(atoms.objectsFromString('N9.*')[0].coords)
            C8 =  listeCoord[1]#Numeric.array(atoms.objectsFromString('C8.*')[0].coords)
            C4 =  listeCoord[2]#Numeric.array(atoms.objectsFromString('C4.*')[0].coords)
            N9_C8 = C8-N9
            N9_C4 = C4-N9
            normal = Numeric.array(crossProduct(N9_C8, N9_C4, normal=True))
    else:
        listesel = ['N1.*','C2.*','C6.*']
        listeCoord = []
        listeCoord,missingAts = getAtsRes(atoms,listesel)
        if not missingAts :
            N1 =  listeCoord[0]#Numeric.array(atoms.objectsFromString('N1.*')[0].coords)
            C2 =  listeCoord[1]#Numeric.array(atoms.objectsFromString('C2.*')[0].coords)
            C6 =  listeCoord[2]#Numeric.array(atoms.objectsFromString('C6.*')[0].coords)
            N1_C2 = C2-N1
            N1_C6 = C6-N1
            normal = Numeric.array(crossProduct(N1_C2, N1_C6, normal=True))
    base_normal = Numeric.array(chain.DNARes[0].atoms[0].coords)
    coord.append((base_normal + normal).tolist())

    for res in chain.DNARes[1:]:
        normal = Numeric.array([0.,1.,0.])
        if res.atoms.objectsFromString('P.*'):
            P_coord = res.atoms.objectsFromString('P.*')[0].coords
            coord.append(P_coord)
        else: # this in case last residue does not have P
            P_coord = res.atoms[0].coords
        NA_type = res.type.strip()      
        atoms = res.atoms
        if NA_type in ['A', 'G']:
            listesel = ['N9.*','C8.*','C4.*']
            listeCoord,missingAts = getAtsRes(atoms,listesel)
            if not missingAts :
                N9 =  listeCoord[0]#Numeric.array(atoms.objectsFromString('N9.*')[0].coords)
                C8 =  listeCoord[1]#Numeric.array(atoms.objectsFromString('C8.*')[0].coords)
                C4 =  listeCoord[2]#Numeric.array(atoms.objectsFromString('C4.*')[0].coords)
                N9_C8 = C8-N9
                N9_C4 = C4-N9
                normal = Numeric.array(crossProduct(N9_C8, N9_C4, normal=True))
        else:
            listesel = ['N1.*','C2.*','C6.*']
            listeCoord = []
            listeCoord,missingAts = getAtsRes(atoms,listesel)
            if not missingAts :
                N1 =  listeCoord[0]#Numeric.array(atoms.objectsFromString('N1.*')[0].coords)
                C2 =  listeCoord[1]#Numeric.array(atoms.objectsFromString('C2.*')[0].coords)
                C6 =  listeCoord[2]#Numeric.array(atoms.objectsFromString('C6.*')[0].coords)
                N1_C2 = C2-N1
                N1_C6 = C6-N1
                normal = Numeric.array(crossProduct(N1_C2, N1_C6, normal=True))
        base_normal = Numeric.array(P_coord)
        coord.append((base_normal + normal).tolist())
        
    chain.sheet2D['ssSheet2D'] = Sheet2D()
    chain.sheet2D['ssSheet2D'].compute(coord, len(chain.DNARes)*(False,), 
                             width = 2.0,off_c = 0.9,offset=0.0, nbchords=4)
    chain.sheet2D['ssSheet2D'].resInSheet = chain.DNARes
コード例 #7
0
 def detectPiInteractions(self, tolerance=0.95, debug=False, use_all_cycles=False):
     if debug: print "in detectPiInteractions"
     self.results['pi_pi'] = []        #stacked rings...?
     self.results['t_shaped'] = []     #one ring perpendicular to the other
     self.results['cation_pi'] = []    #
     self.results['pi_cation'] = []    #
     self.results['macro_cations'] = []#
     self.results['lig_cations'] = []  #
     #at this point have self.results
     lig_res = self.results['lig_close_res']
     if not len(lig_res):
         return
     lig_atoms = lig_res.atoms
     macro_res = self.results['macro_close_res']
     if not len(macro_res):
         return
     macro_atoms = macro_res.atoms
     l_rf = RingFinder()
     #Ligand
     l_rf.findRings2(lig_res.atoms, lig_res.atoms.bonds[0])
     #rf.rings is list of dictionaries, one per ring, with keys 'bonds' and 'atoms'
     if debug: print "LIG: len(l_rf.rings)=", len(l_rf.rings)
     if not len(l_rf.rings):
         if debug: print "no lig rings found by l_rf!"
         return
     acbs = AromaticCycleBondSelector()
     lig_rings = []
     for r in l_rf.rings:
         ring_bnds = r['bonds']
         if use_all_cycles: 
             lig_rings.append(ring_bnds)
         else:
             arom_bnds = acbs.select(ring_bnds)
             if len(arom_bnds)>4:
                 lig_rings.append(arom_bnds)
     if debug: print "LIG: len(lig_arom_rings)=", len(lig_rings)
     self.results['lig_rings'] = lig_rings
     self.results['lig_ring_atoms'] = AtomSet()
     #only check for pi-cation if lig_rings exist
     if len(lig_rings):
         macro_cations = self.results['macro_cations'] = self.getCations(macro_atoms)
         lig_ring_atoms = AtomSet()
         u = {}
         for r in lig_rings:
             for a in BondSet(r).getAtoms():
                 u[a] = 1
         if len(u): 
             lig_ring_atoms = AtomSet(u.keys())
             lig_ring_atoms.sort()
             self.results['lig_ring_atoms'] = lig_ring_atoms
         if len(macro_cations):
             if debug: print "check distances from lig_rings to macro_cations here"
             #macro cations->lig rings
             pairDict2 = self.distanceSelector.select(lig_ring_atoms,macro_cations)
             z = {}
             for key,v in pairDict2.items():
                 val = v.tolist()[0]
                 if val in macro_cations:
                     z[val] = [key]
             if len(z):
                 self.results['pi_cation'] = (z.items())
             else:
                 self.results['pi_cation'] = []
     #check the distance between the rings and the macro_cations
     self.results['lig_cations'] = self.getCations(lig_atoms)
     #Macromolecule
     m_rf = RingFinder()
     m_rf.findRings2(macro_res.atoms, macro_res.atoms.bonds[0])
     #rf.rings is list of dictionaries, one per ring, with keys 'bonds' and 'atoms'
     if debug: print "MACRO: len(m_rf.rings)=", len(m_rf.rings)
     if not len(m_rf.rings):
         if debug: print "no macro rings found by m_rf!"
         return
     macro_rings = []
     for r in m_rf.rings:
         ring_bnds = r['bonds']
         if use_all_cycles: 
             macro_rings.append(ring_bnds)
         else:
             arom_bnds = acbs.select(ring_bnds)
             if len(arom_bnds)>4:
                 macro_rings.append(arom_bnds)
     if debug: print "len(macro_arom_rings)=", len(macro_rings)
     self.results['macro_rings'] = macro_rings
     self.results['macro_ring_atoms'] = AtomSet()
     #only check for pi-cation if macro_rings exist
     if len(macro_rings):
         lig_cations = self.results['lig_cations'] = self.getCations(lig_atoms)
         macro_ring_atoms = AtomSet()
         u = {}
         for r in macro_rings:
             for a in BondSet(r).getAtoms(): #new method of bondSets
                 u[a] = 1
         if len(u):
             macro_ring_atoms = AtomSet(u.keys())
             macro_ring_atoms.sort()
             self.results['macro_ring_atoms'] = macro_ring_atoms
         if len(lig_cations):
             if debug: print "check distances from macro_rings to lig_cations here"
             pairDict3 = self.distanceSelector.select(macro_ring_atoms,lig_cations)
             z = {}
             for x in pairDict3.items():
                 #lig cations->macro rings
                 z.setdefault(x[1].tolist()[0], []).append(x[0])
             if len(z):
                 self.results['cation_pi'] = (z.items())
             else:
                 self.results['cation_pi'] = []
             #macro_pi_atoms = AtomSet(pairDict3.keys())
             #l_cations = AtomSet()
             #for v in pairDict3.values():
             #    for x in v:
             #        l_cations.append(x)
             #self.results['cation_pi'] = pairDict3.items()
             #self.results['cation_pi'] = (l_cations, macro_pi_atoms)
     #check for intermol distance <6 Angstrom (J.ComputChem 29:275-279, 2009)
     #compare each lig_ring vs each macro_ring
     for lig_ring_bnds in lig_rings:
         lig_atoms = acbs.getAtoms(lig_ring_bnds)
         lig_atoms.sort()
         if debug: print "len(lig_atoms)=", len(lig_atoms)
         #---------------------------------
         # compute the normal to lig ring
         #---------------------------------
         a1 = Numeric.array(lig_atoms[0].coords)
         a2 = Numeric.array(lig_atoms[2].coords)
         a3 = Numeric.array(lig_atoms[4].coords)
         if debug: print "a1,a2, a3=", a1.tolist(), a2.tolist(), a3.tolist()
         for macro_ring_bnds in macro_rings:
             macro_atoms = acbs.getAtoms(macro_ring_bnds)
             macro_atoms.sort()
             if debug: print "len(macro_atoms)=", len(macro_atoms)
             pD_dist = self.distanceSelectorWithCutoff.select(macro_ring_atoms, lig_atoms, cutoff=self.dist_cutoff)
             if not len(pD_dist[0]):
                 if debug: 
                     print "skipping ligand ring ", lig_rings.index(lig_ring_bnds), " vs ",
                     print "macro ring", macro_rings.index(macro_ring_bnds)
                 continue
             #---------------------------------
             # compute the normal to macro ring
             #---------------------------------
             b1 = Numeric.array(macro_atoms[0].coords)
             b2 = Numeric.array(macro_atoms[2].coords)
             b3 = Numeric.array(macro_atoms[4].coords)
             if debug: print "b1,b2, b3=", b1.tolist(), b2.tolist(), b3.tolist()
             # check for stacking 
             a2_1 = a2-a1
             a3_1 = a3-a1
             b2_1 = b2-b1
             b3_1 = b3-b1
             if debug: print "a2_1 = ", a2-a1
             if debug: print "a3_1 = ", a3-a1
             if debug: print "b2_1 = ", b2-b1
             if debug: print "b3_1 = ", b3-b1
             n1 = crossProduct(a3_1,a2_1) #to get the normal for the first ring
             n2 = crossProduct(b3_1,b2_1) #to get the normal for the second ring
             if debug: print "n1=", n1
             if debug: print "n2=", n2
             n1 = Numeric.array(n1)
             n2 = Numeric.array(n2)
             n1_dot_n2 = Numeric.dot(n1,n2)
             if debug: print "n1_dot_n2", Numeric.dot(n1,n2)
             if abs(n1_dot_n2) >= 1*tolerance: 
                 if debug: print "The rings are stacked vertically" 
                 new_result = (acbs.getAtoms(lig_ring_bnds), acbs.getAtoms(macro_ring_bnds))
                 self.results['pi_pi'].append(new_result)
             if abs(n1_dot_n2) <= 0.01*tolerance: 
                 if debug: print "The rings are stacked perpendicularly" 
                 new_result = (acbs.getAtoms(lig_ring_bnds), acbs.getAtoms(macro_ring_bnds))
                 self.results['t_shaped'].append(new_result)
コード例 #8
0
ファイル: NucleicBases.py プロジェクト: lisarosalina/App
def make_purine(residue, height=0.4, scale=1.2):
    """Creates vertices and normals for purines: Adenine Guanine"""
    atoms = residue.atoms
    names = [name.split("@")[0] for name in atoms.name]
    idx = names.index('N9')
    N9 = Numeric.array(atoms[idx].coords)
    idx = names.index('C8')
    C8 = Numeric.array(atoms[idx].coords)
    idx = names.index('N7')
    N7 = Numeric.array(atoms[idx].coords)
    idx = names.index('C5')
    C5 = Numeric.array(atoms[idx].coords)
    idx = names.index('C4')
    C4 = Numeric.array(atoms[idx].coords)
    idx = names.index('C6')
    C6 = Numeric.array(atoms[idx].coords)
    idx = names.index('N1')
    N1 = Numeric.array(atoms[idx].coords)
    idx = names.index('C2')
    C2 = Numeric.array(atoms[idx].coords)
    idx = names.index('N3')
    N3 = Numeric.array(atoms[idx].coords)
    N9_C8 = C8 - N9
    N9_C4 = C4 - N9
    C8_C4 = height * norm(C4 - C8)
    normal = height * Numeric.array(crossProduct(N9_C8, N9_C4, normal=True))
    #center1 = (N9+C8+N7+C4+C5)/5.0
    #center2 = (C4+C5+C6+N1+C2+N3)/6.0
    center2 = (C4 + C5 + C6 + N1 + C2 + N3 + N9 + C8 + N7) / 9.0
    center1 = center2
    vertices = Numeric.zeros((20, 3), Numeric.Float)

    vertices[0] = scale * (C8 - normal - center1) + center1
    vertices[1] = scale * (N7 - normal - center1) + center1
    vertices[2] = scale * (C5 - normal - center2) + center2
    vertices[3] = scale * (C4 - normal - center2) + center2
    vertices[4] = scale * (C6 - normal - center2) + center2
    vertices[5] = scale * (N1 - normal - center2) + center2
    vertices[6] = scale * (C2 - normal - center2) + center2
    vertices[7] = scale * (N3 - normal - center2) + center2

    vertices[8] = scale * (C8 + normal - center1) + center1
    vertices[9] = scale * (N7 + normal - center1) + center1
    vertices[10] = scale * (C5 + normal - center2) + center2
    vertices[11] = scale * (C4 + normal - center2) + center2
    vertices[12] = scale * (C6 + normal - center2) + center2
    vertices[13] = scale * (N1 + normal - center2) + center2
    vertices[14] = scale * (C2 + normal - center2) + center2
    vertices[15] = scale * (N3 + normal - center2) + center2

    vertices[16] = scale * (N9 - C8_C4 - normal - center1) + center1
    vertices[17] = scale * (N9 - C8_C4 + normal - center1) + center1
    vertices[18] = scale * (N9 + C8_C4 + normal - center1) + center1
    vertices[19] = scale * (N9 + C8_C4 - normal - center1) + center1

    faces = Numeric.array([[19, 3, 2, 1, 0, 16, 16],
                           [17, 8, 9, 10, 11, 18, 18], [3, 7, 6, 5, 4, 2, 2],
                           [10, 12, 13, 14, 15, 11, 11],
                           [16, 0, 8, 17, 17, 17, 17], [0, 1, 9, 8, 8, 8, 8],
                           [1, 2, 10, 9, 9, 9, 9], [2, 4, 12, 10, 10, 10, 10],
                           [4, 5, 13, 12, 12, 12, 12],
                           [5, 6, 14, 13, 13, 13, 13],
                           [6, 7, 15, 14, 14, 14, 14],
                           [7, 3, 11, 15, 15, 15, 15],
                           [3, 19, 18, 11, 11, 11, 11]])
    return vertices, faces
コード例 #9
0
ファイル: extruder.py プロジェクト: lisarosalina/App
def ExtrudeNA(chain):
    """Computes ribbons for DNA/RNA"""
    coord = []
    coord.append(chain.DNARes[0].atoms[0].coords)
    NA_type = chain.DNARes[0].type.strip()
    atoms = chain.DNARes[0].atoms
    missingAts = False
    normal = Numeric.array([0., 1., 0.])
    if NA_type in ['A', 'G']:
        listesel = ['N9.*', 'C8.*', 'C4.*']
        listeCoord, missingAts = getAtsRes(atoms, listesel)
        if not missingAts:
            N9 = listeCoord[
                0]  #Numeric.array(atoms.objectsFromString('N9.*')[0].coords)
            C8 = listeCoord[
                1]  #Numeric.array(atoms.objectsFromString('C8.*')[0].coords)
            C4 = listeCoord[
                2]  #Numeric.array(atoms.objectsFromString('C4.*')[0].coords)
            N9_C8 = C8 - N9
            N9_C4 = C4 - N9
            normal = Numeric.array(crossProduct(N9_C8, N9_C4, normal=True))
    else:
        listesel = ['N1.*', 'C2.*', 'C6.*']
        listeCoord = []
        listeCoord, missingAts = getAtsRes(atoms, listesel)
        if not missingAts:
            N1 = listeCoord[
                0]  #Numeric.array(atoms.objectsFromString('N1.*')[0].coords)
            C2 = listeCoord[
                1]  #Numeric.array(atoms.objectsFromString('C2.*')[0].coords)
            C6 = listeCoord[
                2]  #Numeric.array(atoms.objectsFromString('C6.*')[0].coords)
            N1_C2 = C2 - N1
            N1_C6 = C6 - N1
            normal = Numeric.array(crossProduct(N1_C2, N1_C6, normal=True))
    base_normal = Numeric.array(chain.DNARes[0].atoms[0].coords)
    coord.append((base_normal + normal).tolist())

    for res in chain.DNARes[1:]:
        normal = Numeric.array([0., 1., 0.])
        if res.atoms.objectsFromString('P.*'):
            P_coord = res.atoms.objectsFromString('P.*')[0].coords
            coord.append(P_coord)
        else:  # this in case last residue does not have P
            P_coord = res.atoms[0].coords
        NA_type = res.type.strip()
        atoms = res.atoms
        if NA_type in ['A', 'G']:
            listesel = ['N9.*', 'C8.*', 'C4.*']
            listeCoord, missingAts = getAtsRes(atoms, listesel)
            if not missingAts:
                N9 = listeCoord[
                    0]  #Numeric.array(atoms.objectsFromString('N9.*')[0].coords)
                C8 = listeCoord[
                    1]  #Numeric.array(atoms.objectsFromString('C8.*')[0].coords)
                C4 = listeCoord[
                    2]  #Numeric.array(atoms.objectsFromString('C4.*')[0].coords)
                N9_C8 = C8 - N9
                N9_C4 = C4 - N9
                normal = Numeric.array(crossProduct(N9_C8, N9_C4, normal=True))
        else:
            listesel = ['N1.*', 'C2.*', 'C6.*']
            listeCoord = []
            listeCoord, missingAts = getAtsRes(atoms, listesel)
            if not missingAts:
                N1 = listeCoord[
                    0]  #Numeric.array(atoms.objectsFromString('N1.*')[0].coords)
                C2 = listeCoord[
                    1]  #Numeric.array(atoms.objectsFromString('C2.*')[0].coords)
                C6 = listeCoord[
                    2]  #Numeric.array(atoms.objectsFromString('C6.*')[0].coords)
                N1_C2 = C2 - N1
                N1_C6 = C6 - N1
                normal = Numeric.array(crossProduct(N1_C2, N1_C6, normal=True))
        base_normal = Numeric.array(P_coord)
        coord.append((base_normal + normal).tolist())

    chain.sheet2D['ssSheet2D'] = Sheet2D()
    chain.sheet2D['ssSheet2D'].compute(coord,
                                       len(chain.DNARes) * (False, ),
                                       width=2.0,
                                       off_c=0.9,
                                       offset=0.0,
                                       nbchords=4)
    chain.sheet2D['ssSheet2D'].resInSheet = chain.DNARes