def test_drms(self): """ Test drms measure """ m = IMP.Model() sel = atom.CAlphaPDBSelector() prot1 = atom.read_pdb(self.open_input_file("mini.pdb"), m, sel) prot2 = atom.read_pdb(self.open_input_file("mini.pdb"), m, sel) xyzs1 = core.XYZs(atom.get_leaves(prot1)) xyzs2 = core.XYZs(atom.get_leaves(prot2)) drms = atom.get_drms(xyzs1, xyzs2) # Molecule with itself self.assertAlmostEqual(drms, 0) R = IMP.algebra.get_random_rotation_3d() v = IMP.algebra.get_random_vector_in( IMP.algebra.get_unit_bounding_box_3d()) T = IMP.algebra.Transformation3D(R, v) for x in xyzs2: core.transform(x, T) drms = atom.get_drms(xyzs1, xyzs2) # Same thing after transformation self.assertAlmostEqual(drms, 0) # for x in xyzs2: R = IMP.algebra.get_random_rotation_3d() T = IMP.algebra.Transformation3D(R, v) core.transform(x, T) drms = atom.get_drms(xyzs1, xyzs2) self.assertTrue(drms > 0)
def test_drms(self): """ Test drms measure """ m = IMP.kernel.Model() sel = atom.CAlphaPDBSelector() prot1 = atom.read_pdb(self.open_input_file("mini.pdb"), m, sel) prot2 = atom.read_pdb(self.open_input_file("mini.pdb"), m, sel) xyzs1 = core.XYZs(atom.get_leaves(prot1)) xyzs2 = core.XYZs(atom.get_leaves(prot2)) drms = atom.get_drms(xyzs1, xyzs2) # Molecule with itself self.assertAlmostEqual(drms, 0) R = IMP.algebra.get_random_rotation_3d() v = IMP.algebra.get_random_vector_in( IMP.algebra.get_unit_bounding_box_3d()) T = IMP.algebra.Transformation3D(R, v) for x in xyzs2: core.transform(x, T) drms = atom.get_drms(xyzs1, xyzs2) # Same thing after transformation self.assertAlmostEqual(drms, 0) # for x in xyzs2: R = IMP.algebra.get_random_rotation_3d() T = IMP.algebra.Transformation3D(R, v) core.transform(x, T) drms = atom.get_drms(xyzs1, xyzs2) self.assertTrue(drms > 0)
def test__rigid_bodies_drms(self): """ Test drms measure taking into account rigid bodies""" m = IMP.Model() sel = atom.CAlphaPDBSelector() prot1 = atom.read_pdb(self.open_input_file("mini.pdb"), m, sel) prot2 = atom.read_pdb(self.open_input_file("mini.pdb"), m, sel) hchains1 = atom.get_by_type(prot1, atom.CHAIN_TYPE) hchains2 = atom.get_by_type(prot2, atom.CHAIN_TYPE) xyzs1 = core.XYZs(atom.get_leaves(prot1)) xyzs2 = core.XYZs(atom.get_leaves(prot2)) x = 0 ranges = [] for h in hchains1: ls1 = (atom.get_leaves(h)) y = x + len(ls1) ranges.append((x, y)) x = y drms = atom.get_drms(xyzs1, xyzs2) rb_drms = atom.get_rigid_bodies_drms(xyzs1, xyzs2, ranges) self.assertAlmostEqual(rb_drms, 0) self.assertAlmostEqual(drms, rb_drms, delta=1e-3, msg="rb_drms != drms") # Same thing after transformation of each of the chains for h in hchains2: R = alg.get_random_rotation_3d() v = alg.get_random_vector_in(alg.get_unit_bounding_box_3d()) T = alg.Transformation3D(R, v) ls = atom.get_leaves(h) for l in ls: core.transform(l.get_as_xyz(), T) drms = atom.get_drms(xyzs1, xyzs2) rb_drms = atom.get_rigid_bodies_drms(xyzs1, xyzs2, ranges) self.assertAlmostEqual(drms, rb_drms, delta=0.3, msg="rb_drms != drms")
def test__rigid_bodies_drms(self): """ Test drms measure taking into account rigid bodies""" m = IMP.kernel.Model() sel = atom.CAlphaPDBSelector() prot1 = atom.read_pdb(self.open_input_file("mini.pdb"), m, sel) prot2 = atom.read_pdb(self.open_input_file("mini.pdb"), m, sel) hchains1 = atom.get_by_type(prot1, atom.CHAIN_TYPE) hchains2 = atom.get_by_type(prot2, atom.CHAIN_TYPE) xyzs1 = core.XYZs(atom.get_leaves(prot1)) xyzs2 = core.XYZs(atom.get_leaves(prot2)) x = 0 ranges = [] for h in hchains1: ls1 = (atom.get_leaves(h)) y = x + len(ls1) ranges.append((x, y)) x = y drms = atom.get_drms(xyzs1, xyzs2) rb_drms = atom.get_rigid_bodies_drms(xyzs1, xyzs2, ranges) self.assertAlmostEqual(rb_drms, 0) self.assertAlmostEqual( drms, rb_drms, delta=1e-3, msg="rb_drms != drms") # Same thing after transformation of each of the chains for h in hchains2: R = alg.get_random_rotation_3d() v = alg.get_random_vector_in(alg.get_unit_bounding_box_3d()) T = alg.Transformation3D(R, v) ls = atom.get_leaves(h) for l in ls: core.transform(l.get_as_xyz(), T) drms = atom.get_drms(xyzs1, xyzs2) rb_drms = atom.get_rigid_bodies_drms(xyzs1, xyzs2, ranges) self.assertAlmostEqual(drms, rb_drms, delta=0.3, msg="rb_drms != drms")
def measure_model(assembly, native_assembly, rbs, native_rbs): """ Get the drms, cdrms and crmsd for a model @param assembly Hierachy for an assembly @param native_assembly Hierarchy of the native structure @param rbs Rigid bodies for the components of the assembly @param native_rbs Rigid bodies for the components of the native structure @return cdrms, cdrms, crmsd - drms - typical drms measure - cdrms - drms for the centroids of the rigid bodies of the components of the assembly - crmsd - rmsd for the centroids """ drms = comparisons.get_drms_for_backbone(assembly, native_assembly) RFs = [rb.get_reference_frame() for rb in rbs] vs = [r.get_transformation_to().get_translation() for r in RFs] nRFs = [rb.get_reference_frame() for rb in native_rbs] nvs = [r.get_transformation_to().get_translation() for r in nRFs] cdrms = atom.get_drms(vs, nvs) crmsd, RFs = alignments.align_centroids_using_pca(RFs, nRFs) log.debug("drms %s cdrms %s crmsd %s",drms,cdrms,crmsd) return [drms, cdrms, crmsd]
def measure_model(assembly, native_assembly, rbs, native_rbs): """ Get the drms, cdrms and crmsd for a model @param assembly Hierarchy for an assembly @param native_assembly Hierarchy of the native structure @param rbs Rigid bodies for the components of the assembly @param native_rbs Rigid bodies for the components of the native structure @return cdrms, cdrms, crmsd - drms - typical drms measure - cdrms - drms for the centroids of the rigid bodies of the components of the assembly - crmsd - rmsd for the centroids """ log.debug("Measure model") drms = comparisons.get_drms_for_backbone(assembly, native_assembly) RFs = [rb.get_reference_frame() for rb in rbs] vs = [r.get_transformation_to().get_translation() for r in RFs] nRFs = [rb.get_reference_frame() for rb in native_rbs] nvs = [r.get_transformation_to().get_translation() for r in nRFs] cdrms = atom.get_drms(vs, nvs) crmsd, RFs = alignments.align_centroids_using_pca(RFs, nRFs) log.debug("drms %s cdrms %s crmsd %s", drms, cdrms, crmsd) return [drms, cdrms, crmsd]