Esempio n. 1
0
 def setUp(self):
     self.nrigid = 10
     self.topology = RBTopology()
     self.topology.add_sites(
         [create_tetrahedron() for _ in range(self.nrigid)])
     self.topology.finalize_setup()
     self.measure = MeasureAngleAxisCluster(self.topology)
Esempio n. 2
0
 def get_mindist(self, **kwargs):
     from pele.angleaxis import MinPermDistAACluster
     from pele.angleaxis import TransformAngleAxisCluster, MeasureAngleAxisCluster
     transform = TransformAngleAxisCluster(self.aatopology)
     measure = MeasureAngleAxisCluster(self.aatopology, transform=transform,
                                       permlist=[])
     return MinPermDistAACluster(self.aasystem, measure=measure, transform=transform, 
                                 accuracy=0.1, **kwargs)
Esempio n. 3
0
class TestAAMeasure(unittest.TestCase):
    def setUp(self):
        self.nrigid = 10
        self.topology = RBTopology()
        self.topology.add_sites(
            [create_tetrahedron() for _ in range(self.nrigid)])
        self.topology.finalize_setup()
        self.measure = MeasureAngleAxisCluster(self.topology)

    def test_cpp_align(self):
        x1 = np.array([random_aa() for _ in range(2 * self.nrigid)]).ravel()
        x2 = np.array([random_aa() for _ in range(2 * self.nrigid)]).ravel()

        x1_cpp = x1.copy()
        x2_cpp = x2.copy()
        x1_python = x1.copy()
        x2_python = x2.copy()

        ret = self.measure._align_pythonic(x1_python, x2_python)
        self.assertIsNone(ret)
        ret = self.measure.align(x1_cpp, x2_cpp)
        self.assertIsNone(ret)

        assert_arrays_almost_equal(self, x1_python, x1)
        assert_arrays_almost_equal(self, x1_cpp, x1)

        # assert that the center of mass coordinates didn't change
        assert_arrays_almost_equal(self, x2_python[:3 * self.nrigid],
                                   x2[:3 * self.nrigid])
        assert_arrays_almost_equal(self, x2_cpp[:3 * self.nrigid],
                                   x2[:3 * self.nrigid])

        # assert that x2 actually changed
        max_change = np.max(np.abs(x2_cpp - x2))
        self.assertGreater(max_change, 1e-3)

        assert_arrays_almost_equal(self, x2_python, x2_cpp)

    def test_align_bad_input(self):
        x1 = np.array([random_aa() for _ in range(2 * self.nrigid)]).ravel()
        x2 = list(x1)

        with self.assertRaises(TypeError):
            self.measure.align(x1, x2)

    def test_symmetries(self):
        tet = create_tetrahedron()
        print(tet.symmetries)
        self.assertEqual(len(tet.symmetries), 12)

    def test_align_exact(self):
        x1 = np.array([random_aa() for _ in range(2 * self.nrigid)]).ravel()
        x2 = x1.copy()
        tet = create_tetrahedron()
        mx = tet.symmetries[2].copy()
        p = x2[-3:].copy()
        x2[-3:] = rotations.rotate_aa(rotations.mx2aa(mx), p)

        self.measure._align_pythonic(x1, x2)
        assert_arrays_almost_equal(self, x1, x2)
Esempio n. 4
0
class TestAAMeasure(unittest.TestCase):
    def setUp(self):
        self.nrigid = 10
        self.topology = RBTopology()
        self.topology.add_sites([create_tetrahedron() for _ in range(self.nrigid)])
        self.topology.finalize_setup()
        self.measure = MeasureAngleAxisCluster(self.topology)
    
    def test_cpp_align(self):
        x1 = np.array([random_aa() for _ in range(2*self.nrigid)]).ravel()
        x2 = np.array([random_aa() for _ in range(2*self.nrigid)]).ravel()
        
        x1_cpp = x1.copy()
        x2_cpp = x2.copy()
        x1_python = x1.copy()
        x2_python = x2.copy()
        
        ret = self.measure._align_pythonic(x1_python, x2_python)
        self.assertIsNone(ret)
        ret = self.measure.align(x1_cpp, x2_cpp)
        self.assertIsNone(ret)
        
        assert_arrays_almost_equal(self, x1_python, x1)
        assert_arrays_almost_equal(self, x1_cpp, x1)
        
        # assert that the center of mass coordinates didn't change
        assert_arrays_almost_equal(self, x2_python[:3*self.nrigid], x2[:3*self.nrigid])
        assert_arrays_almost_equal(self, x2_cpp[:3*self.nrigid], x2[:3*self.nrigid])
        
        # assert that x2 actually changed
        max_change = np.max(np.abs(x2_cpp - x2))
        self.assertGreater(max_change, 1e-3)

        assert_arrays_almost_equal(self, x2_python, x2_cpp)

    def test_align_bad_input(self):
        x1 = np.array([random_aa() for _ in range(2*self.nrigid)]).ravel()
        x2 = list(x1)
        
        with self.assertRaises(TypeError):
            self.measure.align(x1, x2)

    def test_symmetries(self):
        tet = create_tetrahedron()
        print(tet.symmetries)
        self.assertEqual(len(tet.symmetries), 12)


    def test_align_exact(self):
        x1 = np.array([random_aa() for _ in range(2*self.nrigid)]).ravel()
        x2 = x1.copy()
        tet = create_tetrahedron()
        mx = tet.symmetries[2].copy() 
        p = x2[-3:].copy()
        x2[-3:] = rotations.rotate_aa(rotations.mx2aa(mx), p)
        
        self.measure._align_pythonic(x1, x2)
        assert_arrays_almost_equal(self, x1, x2)
Esempio n. 5
0
 def setUp(self):
     self.nrigid = 10
     self.topology = RBTopology()
     self.topology.add_sites([create_tetrahedron() for _ in range(self.nrigid)])
     self.topology.finalize_setup()
     self.measure = MeasureAngleAxisCluster(self.topology)