Ejemplo n.º 1
0
    def test_cg_rmsd3(self):
        cg1 = ftmc.CoarseGrainRNA('test/forgi/threedee/data/1GID_A.cg')
        cg2 = ftmc.CoarseGrainRNA('test/forgi/threedee/data/1GID_A.cg')
        cg2.coords.rotate(ftuv.rotation_matrix([1.,2.,3.], 22))
        cg2.twists.rotate(ftuv.rotation_matrix([1.,2.,3.], 22))

        self.assertAlmostEqual(ftme.cg_rmsd(cg1,cg2), 0)
Ejemplo n.º 2
0
 def test_around_xyz(self):
     vec = np.array([1., 2., 3.])
     nptest.assert_allclose(np.dot(ftuv.rotation_matrix(
         "x", math.radians(90)), vec), [1., 3., -2.])
     nptest.assert_allclose(np.dot(ftuv.rotation_matrix(
         "y", math.radians(90)), vec), [-3., 2., 1.])
     nptest.assert_allclose(np.dot(ftuv.rotation_matrix(
         "z", math.radians(90)), vec), [2., -1., 3.])
Ejemplo n.º 3
0
 def test_around_xyz(self):
     vec = np.array([1., 2., 3.])
     nptest.assert_allclose(
         np.dot(ftuv.rotation_matrix("x", math.radians(90)), vec),
         [1., 3., -2.])
     nptest.assert_allclose(
         np.dot(ftuv.rotation_matrix("y", math.radians(90)), vec),
         [-3., 2., 1.])
     nptest.assert_allclose(
         np.dot(ftuv.rotation_matrix("z", math.radians(90)), vec),
         [2., -1., 3.])
Ejemplo n.º 4
0
 def test_shortcut_works(self):
     nptest.assert_allclose(ftuv.rotation_matrix(
         "x", 1.3), ftuv.rotation_matrix(ftuv.standard_basis[0], 1.3))
     nptest.assert_allclose(ftuv.rotation_matrix(
         "y", -2.3), ftuv.rotation_matrix(ftuv.standard_basis[1], -2.3))
     nptest.assert_allclose(ftuv.rotation_matrix(
         "z", 0.23), ftuv.rotation_matrix(ftuv.standard_basis[2], 0.23))
Ejemplo n.º 5
0
 def test_shortcut_works(self):
     nptest.assert_allclose(
         ftuv.rotation_matrix("x", 1.3),
         ftuv.rotation_matrix(ftuv.standard_basis[0], 1.3))
     nptest.assert_allclose(
         ftuv.rotation_matrix("y", -2.3),
         ftuv.rotation_matrix(ftuv.standard_basis[1], -2.3))
     nptest.assert_allclose(
         ftuv.rotation_matrix("z", 0.23),
         ftuv.rotation_matrix(ftuv.standard_basis[2], 0.23))
Ejemplo n.º 6
0
    def test_rotate_keeps_RMSD_zero(self):
        cg1_rot = copy.deepcopy(self.cg1)
        cg1_rot.rotate(30, unit="degrees")
        # This currently uses virtual atoms, thus takes twists into account.
        self.assertLess(ftme.cg_rmsd(self.cg1, cg1_rot), 10**-6)

        cg2_rot = copy.deepcopy(self.cg2)
        cg2_rot.rotate(45, unit="degrees")

        a, b = self.cg2.get_ordered_virtual_residue_poss(True)
        log.warning("------------------------")
        c, d = cg2_rot.get_ordered_virtual_residue_poss(True)
        c2 = np.dot(c, ftuv.rotation_matrix("x", math.radians(-45)).T)
        log.warning("==================================")
        for i, coord in enumerate(a):
            if any(abs(coord - c2[i]) > 10**-4):
                log.warning("%s %s %s %s", coord, b[i], c2[i], d[i])

        self.assertLess(ftme.cg_rmsd(self.cg2, cg2_rot), 10**-6)
Ejemplo n.º 7
0
    def test_rotate_keeps_RMSD_zero(self):
        cg1_rot = copy.deepcopy(self.cg1)
        cg1_rot.rotate(30, unit="degrees")
        # This currently uses virtual atoms, thus takes twists into account.
        self.assertLess(ftme.cg_rmsd(self.cg1, cg1_rot), 10**-6)


        cg2_rot = copy.deepcopy(self.cg2)
        cg2_rot.rotate(45, unit="degrees")

        a,b = self.cg2.get_ordered_virtual_residue_poss(True)
        log.warning("------------------------")
        c,d = cg2_rot.get_ordered_virtual_residue_poss(True)
        c2 = np.dot(c, ftuv.rotation_matrix("x", math.radians(-45)).T)
        log.warning("==================================")
        for i, coord in enumerate(a):
            if any(abs(coord-c2[i])>10**-4):
                log.warning("%s %s %s %s",coord, b[i], c2[i], d[i])

        self.assertLess(ftme.cg_rmsd(self.cg2, cg2_rot), 10**-6)
Ejemplo n.º 8
0
 def test_list_or_array_works(self):
     nptest.assert_allclose(
         ftuv.rotation_matrix([2, 3., 4.], 1.43),
         ftuv.rotation_matrix(np.array([2, 3., 4.]), 1.43))
Ejemplo n.º 9
0
 def test_special_cases_xyz(self):
     nptest.assert_almost_equal(
         ftuv.rotation_matrix("x", 0.4),
         ftuv.rotation_matrix(ftuv.standard_basis[0], 0.4))
     nptest.assert_almost_equal(
         ftuv.rotation_matrix("y", 0.7),
         ftuv.rotation_matrix(ftuv.standard_basis[1], 0.7))
     nptest.assert_almost_equal(
         ftuv.rotation_matrix("z", 0.9),
         ftuv.rotation_matrix(ftuv.standard_basis[2], 0.9))
     nptest.assert_almost_equal(
         ftuv.rotation_matrix("x", 1.84),
         ftuv.rotation_matrix(ftuv.standard_basis[0], 1.84))
     nptest.assert_almost_equal(
         ftuv.rotation_matrix("y", 2.7),
         ftuv.rotation_matrix(ftuv.standard_basis[1], 2.7))
     nptest.assert_almost_equal(
         ftuv.rotation_matrix("z", 3.9),
         ftuv.rotation_matrix(ftuv.standard_basis[2], 3.9))
Ejemplo n.º 10
0
 def test_special_cases_xyz(self):
     nptest.assert_almost_equal(ftuv.rotation_matrix("x", 0.4),
                                ftuv.rotation_matrix(ftuv.standard_basis[0], 0.4))
     nptest.assert_almost_equal(ftuv.rotation_matrix("y", 0.7),
                                ftuv.rotation_matrix(ftuv.standard_basis[1], 0.7))
     nptest.assert_almost_equal(ftuv.rotation_matrix("z", 0.9),
                                ftuv.rotation_matrix(ftuv.standard_basis[2], 0.9))
     nptest.assert_almost_equal(ftuv.rotation_matrix("x", 1.84),
                                ftuv.rotation_matrix(ftuv.standard_basis[0], 1.84))
     nptest.assert_almost_equal(ftuv.rotation_matrix("y", 2.7),
                                ftuv.rotation_matrix(ftuv.standard_basis[1], 2.7))
     nptest.assert_almost_equal(ftuv.rotation_matrix("z", 3.9),
                                ftuv.rotation_matrix(ftuv.standard_basis[2], 3.9))
Ejemplo n.º 11
0
 def test_list_or_array_works(self):
     nptest.assert_allclose(ftuv.rotation_matrix(
         [2, 3., 4.], 1.43), ftuv.rotation_matrix(np.array([2, 3., 4.]), 1.43))
Ejemplo n.º 12
0
 def move(self, sm):
     self.last_axis = random.choice(["x", "y", "z"])
     self.last_angle = random.random()*2*np.pi # 0-360 degrees
     rot_mat = ftuv.rotation_matrix(self.last_axis, self.last_angle)
     sm.bg.rotate(rot_mat)
     return "{}deg{}".format(math.degrees(self.last_angle), self.last_axis)