Пример #1
0
    def create_restraints(self, chain):
        """If a residue range was specified, these residues are cut out, and """
        if self.residues:
            print '\t.. building restraints'
            first_resi = chain[0]
            last_resi = chain[-1]

            # distances between the two terminal residues
            dist_po = (self.stem5['P'] - self.stem3["O3'"])/10.0
            restraints = HarmonicDistanceRestraint(first_resi.phosphate.P, last_resi.sugar.O_3, dist_po, 10000.)
            dist_co = (self.stem5["O5'"] - self.stem3["O3'"])/10.0
            restraints += HarmonicDistanceRestraint(first_resi.sugar.O_5, last_resi.sugar.C_3, dist_co, 10000.)
            dist_cc = (self.stem5["C5'"] - self.stem3["C4'"])/10.0
            restraints += HarmonicDistanceRestraint(first_resi.sugar.C_5, last_resi.sugar.C_4, dist_cc, 10000.)

            # angles between the two terminal residues
            angle_cpo = calc_angle(self.stem5["C4'"].get_vector(), self.stem3["P"].get_vector(), self.stem3["O3'"].get_vector())
            #angle_cpo = calc_angle(self.stem3["P"].coord-self.stem5["C4'"].coord, self.stem3["P"].coord-self.stem3["O3'"].coord)
            restraints += HarmonicAngleRestraint(first_resi.sugar.C_4, last_resi.phosphate.P, last_resi.sugar.O_3, angle_cpo, 100000.)
            angle_pco1 = calc_angle(self.stem5["P"].get_vector(), self.stem3["C4'"].get_vector(), self.stem3["O3'"].get_vector())
            restraints += HarmonicAngleRestraint(first_resi.phosphate.P, last_resi.sugar.C_4, last_resi.sugar.O_3, angle_pco1, 10000.)
            angle_pco2 = calc_angle(self.stem5["P"].get_vector(), self.stem5["C4'"].get_vector(), self.stem3["O3'"].get_vector())
            restraints += HarmonicAngleRestraint(first_resi.phosphate.P, first_resi.sugar.C_4, last_resi.sugar.O_3, angle_pco2, 10000.)
            angle_pcc = calc_angle(self.stem5["P"].get_vector(), self.stem5["C4'"].get_vector(), self.stem3["C4'"].get_vector())
            restraints += HarmonicAngleRestraint(first_resi.phosphate.P, first_resi.sugar.C_4, last_resi.sugar.C_4, angle_pcc, 10000.)
            # torsion between the two terminal residues
            # THESE PRODUCE SEGMENTATION FAULTS - THE OTHERS MUST SUFFICE
            # restraints += HarmonicDihedralRestraint(first_resi.phosphate.P, first_resi.sugar.C_4, last_resi.phosphate.P, last_resi.sugar.C_4, 1.0, 10.)
            #restraints += HarmonicDihedralRestraint(first_resi.phosphate.P, first_resi.sugar.C_4, last_resi.sugar.C_4, last_resi.sugar.O_3, 0.0, 100000.)
            #restraints += HarmonicDihedralRestraint(first_resi.sugar.C_4, first_resi.sugar.O_3, last_resi.phosphate.P, last_resi.sugar.C_4, 0.0, 100000.)
            #restraints += HarmonicDihedralRestraint(first_resi.sugar.C_4, first_resi.sugar.O_3, last_resi.sugar.C_4, last_resi.sugar.O_3, 0.0, 100000.)

            return restraints
Пример #2
0
 def _test_o5c5c4_angle(self):
     """Checks whether the O5'-C5'-C4' angle is OK."""
     bb = PhosphateBuilder(self.resi1, self.resi2)
     bb.build()
     amin, amax = GeometryStandards.angles["X:O5',X:C5',X:C4'"][0]
     angle = calc_angle(self.resi2["O5'"].get_vector(),
                        self.resi2["C5'"].get_vector(),
                        self.resi2["C4'"].get_vector())
     self.assertTrue(amin < math.degrees(angle) < amax)
Пример #3
0
 def _test_o3po5_angle(self):
     """Checks whether the O3'-P-O5' angle is OK."""
     bb = PhosphateBuilder(self.resi1, self.resi2)
     bb.build()
     amin, amax = GeometryStandards.angles["X:O3',X+1:P,X+1:O5'"][0]
     angle = calc_angle(self.resi1["O3'"].get_vector(),
                        self.resi2["P"].get_vector(),
                        self.resi2["O5'"].get_vector())
     self.assertTrue(amin < math.degrees(angle) < amax)
Пример #4
0
 def __str__(self):
     d1 = abs(O3_P_DIST - float(self.o3 - self.p))
     d2 = abs(P_O5_DIST - float(self.p - self.o5))
     d3 = abs(O5_C5_DIST - float(self.o5 - self.c5))
     a1 = math.degrees(calc_angle(self.c3v, self.o3v, self.p.get_vector()))
     a2 = math.degrees(
         calc_angle(self.o3v, self.p.get_vector(), self.o5.get_vector()))
     a3 = math.degrees(
         calc_angle(self.p.get_vector(), self.o5.get_vector(),
                    self.c5.get_vector()))
     a4 = math.degrees(calc_angle(self.o5.get_vector(), self.c5v,
                                  self.c42v))
     a1 = abs(a1 - A1)
     a2 = abs(a2 - A2)
     a3 = abs(a3 - A3)
     a4 = abs(a4 - A4)
     result = "%5.2f\t%5.2f\t%5.2f\t" % (d1, d2, d3)
     result += "%5.2f\t%5.2f\t%5.2f\t%5.2f\t" % (a1, a2, a3, a4)
     result += "total %5.2f\n" % self.get_score()
     return result
Пример #5
0
 def get_score(self, max_score=0.0):
     """Returns the square deviation from reference values."""
     d2 = P_O5_DIST - float(self.p - self.o5)
     d3 = O5_C5_DIST - float(self.o5 - self.c5)
     dscore = d2 * d2 + d3 * d3
     if dscore > max_score: return dscore
     #a2 = calc_angle(self.o3v,self.pv,self.o5v)* MAKE_DEGREES
     a3 = calc_angle(self.pv, self.o5v, self.c5v) * MAKE_DEGREES
     a4 = calc_angle(self.o5v, self.c5v, self.c42v) * MAKE_DEGREES
     # calc difference to standard values
     #a2 = (a2-A2)*ANGLE_WEIGHT
     a3 = (a3 - A3) * ANGLE_WEIGHT
     a4 = (a4 - A4) * ANGLE_WEIGHT
     # using a small numpy array is slower
     #ang = array((a2, a3, a4))
     #ang = ang * MAKE_DEGREES
     #ascore = ang-STD_ANGLES
     #ascore *= ANGLE_WEIGHT
     #ascore = sum(ascore * ascore)
     ascore = a3 * a3 + a4 * a4  # a2*a2 +
     return dscore + ascore
Пример #6
0
 def get_theta_list(self):
     """List of theta angles for all 3 consecutive Calpha atoms."""
     theta_list = []
     ca_list = self.get_ca_list()
     for i in range(0, len(ca_list) - 2):
         atom_list = (ca_list[i], ca_list[i + 1], ca_list[i + 2])
         v1, v2, v3 = [a.get_vector() for a in atom_list]
         theta = calc_angle(v1, v2, v3)
         theta_list.append(theta)
         # Put tau in xtra dict of residue
         res = ca_list[i + 1].get_parent()
         res.xtra["THETA"] = theta
     return theta_list
Пример #7
0
 def get_theta_list(self):
     """List of theta angles for all 3 consecutive Calpha atoms."""
     theta_list=[]
     ca_list=self.get_ca_list()
     for i in range(0, len(ca_list)-2):
         atom_list = (ca_list[i], ca_list[i+1], ca_list[i+2])
         v1, v2, v3 = [a.get_vector() for a in atom_list]
         theta=calc_angle(v1, v2, v3)
         theta_list.append(theta)
         # Put tau in xtra dict of residue
         res=ca_list[i+1].get_parent()
         res.xtra["THETA"]=theta
     return theta_list
Пример #8
0
 def get_angles(self, expression):
     result = GeometryResult('angles of (%s)' % expression, angles=True)
     expr = GeometryExpression(expression)
     for struc in self.get_structures():
         for atom1, atom2, atom3 in expr.get_atoms(struc):
             a = calc_angle(atom1.get_vector(), atom2.get_vector(),
                            atom3.get_vector())
             #a=angle(atom2.coord-atom1.coord,atom2.coord-atom3.coord)
             a = a * 180.0 / math.pi
             a1 = self.get_atom_annotation(atom1)
             a2 = self.get_atom_annotation(atom2)
             a3 = self.get_atom_annotation(atom3)
             result.append((a, a1, a2, a3))
     return result
def from3atoms(A,B,C,alpha,beta,l,choice):
    gamma = calc_angle(B,A,C)

    Dx = l*cos(alpha)
    Dy = l*(cos(beta)-cos(alpha)*cos(gamma))/sin(gamma)
    Dz = sqrt(l**2-Dx**2-Dy**2)

    Dab   = Dx-cos(gamma)/sin(gamma)*Dy
    Dac   = Dy/sin(gamma)
    Dabac = Dz

    AB    = (B-A).normalized()
    AC    = (C-A).normalized()
    ABxAC = (AB**AC).normalized()

    if choice == 0:
        AD = AB**Dab + AC**Dac + ABxAC**Dabac
    else:
        AD = AB**Dab + AC**Dac - ABxAC**Dabac

    return A+AD
Пример #10
0
def _calculate_position_from_angles(B, A, C, alpha, beta, l):
    """ Calculate position from three vector and two angles. 
    
        - B, A and C are the vectors    
        - alpha and beta are the angles   
        - l is the bond length.    
        
    @type A: Vector
    @type B: Vector
    @type C: Vector
    
    @type alpha: float
    @type beta: float
    @type l: float
    
    """
    
    gamma = calc_angle(B, A, C)
    Dx = l * cos(alpha)
    Dy = l * (cos(beta) - cos(alpha) * cos(gamma)) / sin(gamma)

    try:
        Dz = sqrt(l * l - Dx * Dx - Dy * Dy)
    except ValueError:
        return None
    
    Dab = Dx - cos(gamma) / sin(gamma) * Dy
    Dac = Dy / sin(gamma)
    Dabac = Dz
    
    AB = (B - A).normalized()
    AC = (C - A).normalized()
    ABxAC = (AB ** AC).normalized()  
    AD = AB * Dab + AC * Dac + ABxAC * Dabac
        
    return A + AD
Пример #11
0
 def _measure(self, vec1, vec2, vec3, vec4):
     """Returns a dist,angle,torsion tuple for the given four coords."""
     dist = (vec3 - vec4).norm()
     angle = math.degrees(calc_angle(vec2, vec3, vec4))
     torsion = math.degrees(calc_dihedral(vec1, vec2, vec3, vec4))
     return dist, angle, torsion
Пример #12
0
 def _measure(self, vec1, vec2, vec3, vec4):
     """Returns a dist,angle,torsion tuple for the given four coords."""
     dist = (vec3 - vec4).norm()
     angle = math.degrees(calc_angle(vec2, vec3, vec4))
     torsion = math.degrees(calc_dihedral(vec1, vec2, vec3, vec4))
     return dist, angle, torsion
Пример #13
0
def ca_angle(pp, i):
    """alpha carbon bond angle for peptide index i"""
    n=v_(pp, i, 'N')
    ca=v_(pp, i, 'CA')
    c=v_(pp, i, 'C')
    return deg(calc_angle(n,ca,c))
Пример #14
0
def c_angle(pp, i):
    """carbon bond angle for peptide index i"""
    ca=v_(pp, i, 'CA')
    c=v_(pp, i, 'C')
    nn=v_(pp, i+1, 'N')
    return deg(calc_angle(ca,c,nn))
Пример #15
0
def n_angle(pp, i):
    """nitrogen bond angle for peptide index i"""
    cp=v_(pp, i-1, 'C')
    n=v_(pp, i, 'N')
    ca=v_(pp, i, 'CA')
    return deg(calc_angle(cp, n, ca))
Пример #16
0
 def _get_beta(self):
     return degrees(
         calc_angle(self.hydrogen, self.acceptor, self.acc_support))
Пример #17
0
 def _get_alpha(self):
     # SLOWER
     #return PDB.calc_angle(Vector(self.donor), Vector(self.hydrogen), Vector(self.acceptor))* 180.0/pi
     return degrees(calc_angle(self.donor, self.hydrogen, self.acceptor))
Пример #18
0
 def _get_gamma(self):
     return degrees(calc_angle(self.donor, self.hydrogen, self.acc_support))