示例#1
0
 def test_rotated(self):
     """Rotating a molecule around the first euler angle should not affect its rmsd."""
     global tolerance, num_test
     for idx in xrange(num_test):
         some_methane = methane_sample()
         before = self.rmsd(some_methane, some_methane)
         after = self.rmsd(some_methane, cm.rotate_euler(some_methane, random.random() * math.pi, random.random() * math.pi, random.random() * math.pi))
         assert abs(before - after) <= tolerance, "rotating the molecule affected its rmsd. before = %s, rmsd = %s, idx = %s" % (before, after, idx)
示例#2
0
    def test_known_rotated(self):
        """RMSD for a specific case should evaluate as I expect."""
        global tolerance, num_test
        for idx in xrange(num_test):
            first_mol = randomize_mol(np.array([0.0, 0.0, -1.0, 0.0, 0.0, 1.0]))

            second_mol = randomize_mol(np.array([0.0, 0.0, -2.0, 0.0, 0.0, 3.0]))

            # translation_vector = np.array([random.random() * 10.0 + 5.0 for i in xrange(3)])

            rmsd = self.rmsd(first_mol, cm.rotate_euler(second_mol, random.random() * math.pi, random.random() * math.pi, random.random() * math.pi))
            expected = 1.5
            assert abs(rmsd - expected) < tolerance, "rmsd was not as expected: %s != %s" % (rmsd, 1.0)
示例#3
0
def randomize_mol(mol):
    """Randomly move a molecule around."""
    translation_vector = np.array([random.random() * 10.0 + 5.0 for i in xrange(3)])
    (rot_alpha, rot_beta, rot_gamma) = [random.random() * 2 * math.pi for i in xrange(3)]
    return cm.translate(cm.rotate_euler(mol, rot_alpha, rot_beta, rot_gamma), translation_vector)