Exemplo n.º 1
0
 def test_dihedral_rotation(self):
     """Checks all angles in 0.2 degree intervals."""
     # constructs vectors using sin/cos and then calculates dihedrals
     precision = 5.0 # the higher the better
     v1 = array([1,0,1])
     v2 = array([0,0,1])
     v3 = array([0,0,2])
     for i in range(int(360*precision)):
         degrees = i/precision
         radians = pi*degrees/180.0
         opp_degrees = 360-degrees
         if opp_degrees == 360.0: opp_degrees = 0.0
         # construct circular motion of vector
         v4 = array([cos(radians), sin(radians),2])
         self.assertAlmostEqualAngle(dihedral(v4,v3,v2,v1), degrees, 5)
         # check rotation in the opposite direction
         self.assertAlmostEqualAngle(dihedral(v1,v2,v3,v4), degrees, 5)
Exemplo n.º 2
0
 def test_dihedral_rotation(self):
     """Checks all angles in 0.2 degree intervals."""
     # constructs vectors using sin/cos and then calculates dihedrals
     precision = 5.0  # the higher the better
     v1 = array([1, 0, 1])
     v2 = array([0, 0, 1])
     v3 = array([0, 0, 2])
     for i in range(int(360 * precision)):
         degrees = i / precision
         radians = pi * degrees / 180.0
         opp_degrees = 360 - degrees
         if opp_degrees == 360.0: opp_degrees = 0.0
         # construct circular motion of vector
         v4 = array([cos(radians), sin(radians), 2])
         self.assertAlmostEqualAngle(dihedral(v4, v3, v2, v1), degrees, 5)
         # check rotation in the opposite direction
         self.assertAlmostEqualAngle(dihedral(v1, v2, v3, v4), degrees, 5)
Exemplo n.º 3
0
 def test_dihedral_eight_basic_directions(self):
     """Checks dihedrals in all 45 degree intervals."""
     # using vectors with integer positions.
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2,-1, 0]),  0.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2,-1,-1]), 45.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 0,-1]), 90.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 1,-1]),135.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 1, 0]),180.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 1, 1]),225.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 0, 1]),270.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2,-1, 1]),315.0)
Exemplo n.º 4
0
 def test_dihedral_eight_basic_directions(self):
     """Checks dihedrals in all 45 degree intervals."""
     # using vectors with integer positions.
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2,-1, 0]),  0.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2,-1,-1]), 45.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 0,-1]), 90.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 1,-1]),135.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 1, 0]),180.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 1, 1]),225.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2, 0, 1]),270.0)
     self.assertAlmostEqualAngle(\
         dihedral([-2,-1,0], [-1,0,0], [1,0,0], [2,-1, 1]),315.0)
Exemplo n.º 5
0
 def test_dihedral_identical(self):
     """The dihedral function should fail if two vectors are the same."""
     # except for the first and last (the vectors form a triangle),
     # in which case the dihedral angle should be 0.0
     for i in range(100):
         v1 = self.get_random_array()
         v2 = self.get_random_array()
         v3 = self.get_random_array()
         self.assertRaises(DihedralGeometryError,dihedral,v1,v1,v2,v3)
         self.assertRaises(DihedralGeometryError,dihedral,v1,v2,v1,v3)
         self.assertRaises(DihedralGeometryError,dihedral,v1,v2,v2,v3)
         self.assertRaises(DihedralGeometryError,dihedral,v1,v2,v3,v3)
         self.assertRaises(DihedralGeometryError,dihedral,v1,v3,v2,v3)
         # now the triangular case
         # make sure that 359.999998 is equal to 0.0
         torsion = dihedral(v1,v2,v3,v1) + 0.000001
         if torsion > 360.0: torsion -= 360.0
         self.assertAlmostEqualAngle(torsion,0.0,5)  
Exemplo n.º 6
0
 def test_dihedral_identical(self):
     """The dihedral function should fail if two vectors are the same."""
     # except for the first and last (the vectors form a triangle),
     # in which case the dihedral angle should be 0.0
     for i in range(100):
         v1 = self.get_random_array()
         v2 = self.get_random_array()
         v3 = self.get_random_array()
         self.assertRaises(DihedralGeometryError, dihedral, v1, v1, v2, v3)
         self.assertRaises(DihedralGeometryError, dihedral, v1, v2, v1, v3)
         self.assertRaises(DihedralGeometryError, dihedral, v1, v2, v2, v3)
         self.assertRaises(DihedralGeometryError, dihedral, v1, v2, v3, v3)
         self.assertRaises(DihedralGeometryError, dihedral, v1, v3, v2, v3)
         # now the triangular case
         # make sure that 359.999998 is equal to 0.0
         torsion = dihedral(v1, v2, v3, v1) + 0.000001
         if torsion > 360.0: torsion -= 360.0
         self.assertAlmostEqualAngle(torsion, 0.0, 5)
Exemplo n.º 7
0
 def test_dihedral_samples(self):
     """Checks values measured manually from atoms in PyMOL."""
     coordinates = [
         [(-1.225,4.621,42.070),(-1.407,4.455,43.516),\
          (-2.495,4.892,44.221),(-3.587,5.523,43.715)],
         [(-2.495,4.892,44.221),(1.513,0.381,40.711),\
          (-3.091,4.715,47.723),(-0.567,3.892,44.433)],
         [(-0.349,5.577,39.446),(-1.559,3.400,41.427),\
          (-4.304,5.563,45.998),(-2.495,4.892,44.221)],
         [(-45.819,84.315,19.372),(-31.124,72.286,14.035),\
          (-27.975,58.688,7.025),(-16.238,78.659,23.731)],
         [(-29.346,66.973,24.152),(-29.977,69.635,24.580),\
          (-30.875,68.788,24.663),(-30.668,67.495,24.449)],
         [(-34.586,84.884,14.064),(-23.351,69.756,11.028),\
          (-40.924,69.442,24.630),(-30.875,68.788,24.663)]
     ]
     angles = [1.201, 304.621, 295.672, 195.184, 358.699, 246.603]
     for i in range(len(coordinates)):
         v1,v2,v3,v4 = coordinates[i]
         self.assertAlmostEqualAngle(dihedral(v1,v2,v3,v4), angles[i],3)
Exemplo n.º 8
0
 def test_dihedral_samples(self):
     """Checks values measured manually from atoms in PyMOL."""
     coordinates = [
         [(-1.225,4.621,42.070),(-1.407,4.455,43.516),\
          (-2.495,4.892,44.221),(-3.587,5.523,43.715)],
         [(-2.495,4.892,44.221),(1.513,0.381,40.711),\
          (-3.091,4.715,47.723),(-0.567,3.892,44.433)],
         [(-0.349,5.577,39.446),(-1.559,3.400,41.427),\
          (-4.304,5.563,45.998),(-2.495,4.892,44.221)],
         [(-45.819,84.315,19.372),(-31.124,72.286,14.035),\
          (-27.975,58.688,7.025),(-16.238,78.659,23.731)],
         [(-29.346,66.973,24.152),(-29.977,69.635,24.580),\
          (-30.875,68.788,24.663),(-30.668,67.495,24.449)],
         [(-34.586,84.884,14.064),(-23.351,69.756,11.028),\
          (-40.924,69.442,24.630),(-30.875,68.788,24.663)]
     ]
     angles = [1.201, 304.621, 295.672, 195.184, 358.699, 246.603]
     for i in range(len(coordinates)):
         v1, v2, v3, v4 = coordinates[i]
         self.assertAlmostEqualAngle(dihedral(v1, v2, v3, v4), angles[i], 3)