Esempio n. 1
0
 def test_rebuild_one_artif_compact_CB(self):
     for dmm in range(50):
         for i in self.aas:
             scm = SCModeler([self.dm(), self.dm(i), self.dm()])
             frame, dmm1, dmm2 = self.mk_random_cas()
             res = scm.rebuild_one(frame, False)
             dist = numpy.linalg.norm(frame[1] - res[1])
             prop_dst = numpy.linalg.norm(SIDECNT['ALA'][:3])
             self.assertEqual(round(prop_dst, 3), round(dist, 3))
Esempio n. 2
0
    def test_rebuild_one_artif_scatter_CB(self):
        for dmm in range(50):
            for i in self.aas:
                scm = SCModeler([self.dm(), self.dm(i), self.dm()])
                frame, dummy1, dummy2 = self.mk_random_cas()
                res = scm.rebuild_one(frame, False)
                dist = numpy.linalg.norm(frame[1] - res[1])
                prop_dst = numpy.linalg.norm(SIDECNT['ALA'][3:])
                #~ if round(prop_dst, 3) != round(dist, 3):
                #~ scm._calc_rot_mtx(*frame, dbg=True)

                self.assertAlmostEqual(round(prop_dst, 3), round(dist, 3))
Esempio n. 3
0
    def mk_cmaps(self, ca_traj, meds, clusts, top1k_inds, thr, plots_dir):
        scmodeler = SCModeler(ca_traj.template)
        sc_traj_full = scmodeler.calculate_sc_traj(ca_traj.coordinates)
        sc_med = scmodeler.calculate_sc_traj(meds.coordinates)
        shp = sc_med.shape
        sc_med = sc_med.reshape((shp[1], shp[0]) + shp[2:])

        cmapdir = os.path.join(self.work_dir, 'contact_maps')
        try:
            os.mkdir(cmapdir)
        except OSError:
            pass

        return sc_traj_full, sc_med, cmapdir
Esempio n. 4
0
 def test_calc_trig_fnc(self):
     for i in range(100):
         v1 = self.mk_random_versor((None, None, 0))
         rot, ang = self.mk_rot_z_mtx()
         v2 = numpy.dot(rot, v1)
         cos, sin = SCModeler._calc_trig_fnc(v1, v2, numpy.array((0, 0, 1)))
         xx = numpy.linalg.norm(numpy.cross(v1, v2))
         self.assertAlmostEqual(sin, numpy.sin(ang))
         self.assertAlmostEqual(cos, numpy.cos(ang))
Esempio n. 5
0
 def test_calc_nodes_line(self):
     for i in range(100):
         v1 = self.mk_random_versor()
         rot, ang = self.mk_rot_z_mtx()
         v2 = numpy.dot(rot, v1)
         nv = SCModeler._calc_nodes_line(v1, v2)
         self.assertAlmostEqual(1, numpy.linalg.norm(nv))
         self.assertAlmostEqual(0, numpy.dot(nv, v1))
         self.assertAlmostEqual(0, numpy.dot(nv, v2))
Esempio n. 6
0
 def test_calc_rot_mtx(self):
     for i in range(100):
         scm = SCModeler([self.dm(), self.dm(), self.dm()])
         frame, vec, rot = self.mk_random_cas()
         rot, dist = scm._calc_rot_mtx(*frame)
         self.assertEqual(numpy.linalg.norm(frame[0] - frame[2]), dist)
         xp = numpy.dot(rot, (1, 0, 0))
         yp = numpy.dot(rot, (0, 1, 0))
         zp = numpy.dot(rot, (0, 0, 1))
         for tv in (xp, yp, zp):
             self.assertAlmostEqual(numpy.linalg.norm(tv), 1)
         for v in SIDECNT.values():
             v1 = v[:3]
             v2 = v[3:]
             n1 = numpy.linalg.norm(v1)
             n2 = numpy.linalg.norm(v2)
             n1p = numpy.linalg.norm(numpy.dot(rot, v1))
             n2p = numpy.linalg.norm(numpy.dot(rot, v2))
             self.assertAlmostEqual(n1, n1p)
             self.assertAlmostEqual(n2, n2p)
Esempio n. 7
0
 def test_mk_local_system(self):
     mtx = numpy.array([[0., 0., 0.], [3.2, 1.5, 0.],
                        [6.4, 0., 0.]])  # sample CA positions (scatter)
     ang = numpy.pi / 6
     rot, ang = self.mk_rot_z_mtx(ang)
     c1, c2, c3 = [numpy.dot(rot, i) for i in mtx]
     x, y, z, dst = SCModeler._mk_local_system(c1, c2, c3)
     self.assertEqual(dst, 6.4)
     for i in (x, y, z):
         self.assertEqual(1, numpy.linalg.norm(i))  # we expect versors
         for j in (x, y, z):
             if i is j: continue
             self.assertAlmostEqual(numpy.dot(i, j),
                                    0)  # versors should be orthogonal
Esempio n. 8
0
 def test_coef(self):
     for k, v in SIDECNT.items():
         if k == 'GLY': continue
         for i in numpy.arange(5, 7, .1):
             res = SCModeler._calc_scatter_coef(i)
             self.assertGreaterEqual(res, 0)
             self.assertLessEqual(res, 1)
             v1 = numpy.array(v[:3])
             v2 = numpy.array(v[3:])
             diff = numpy.linalg.norm(v1 - v2)
             av_vec = (v1 * res + v2 * (1 - res))
             av_diff1 = numpy.linalg.norm(av_vec - v1)
             av_diff2 = numpy.linalg.norm(av_vec - v2)
             self.assertLessEqual(av_diff1, diff)
             self.assertLessEqual(av_diff2, diff)
Esempio n. 9
0
 def test_init(self):
     SCModeler([self.dm(i) for i in self.aas])
     SCModeler([self.dm(random.choice(self.aas)) for i in range(100)])