def test_docking_multiple_crosslinks(self): """ Test the initial docking that is done based on minimizing the distances of the cross-linking restraints """ mydock = bx.InitialDockingFromXlinks() xl = self.xlinks.get_xlinks_for_pair(("3sfdC", "3sfdD")) mydock.set_xlinks(xl) model = IMP.kernel.Model() fn_receptor = self.get_input_file_name("3sfdC.pdb") h_receptor = atom.read_pdb(fn_receptor, model, atom.NonWaterNonHydrogenPDBSelector()) fn_ligand = self.get_input_file_name("3sfdD.pdb") h_ligand = atom.read_pdb(fn_ligand, model, atom.NonWaterNonHydrogenPDBSelector()) mydock.set_hierarchies(h_receptor, h_ligand) p = IMP.kernel.Particle(model) core.RigidBody.setup_particle(p, atom.get_leaves(h_receptor)) rb_receptor = core.RigidBody(p) p = IMP.kernel.Particle(model) core.RigidBody.setup_particle(p, atom.get_leaves(h_ligand)) rb_ligand = core.RigidBody(p) mydock.set_rigid_bodies(rb_receptor, rb_ligand) mydock.move_ligand() for res1, res2 in zip([9, 78], [37, 128]): c1 = mydock.get_residue_coordinates(h_receptor, "C", res1) c2 = mydock.get_residue_coordinates(h_ligand, "D", res2) dist = alg.get_distance(c1, c2) self.assertLessEqual(dist, self.max_distance + 4.0)
def test_docking_one_crosslink(self): """ Test the initial docking that is done based on minimizing the distances of the cross-linking restraints """ mydock = bx.InitialDockingFromXlinks() xl = self.xlinks.get_xlinks_for_pair(("3sfdB", "3sfdA")) mydock.set_xlinks(xl) self.assertEqual(len(mydock.xlinks_list), 1) mydock.clear_xlinks() self.assertEqual(len(mydock.xlinks_list), 0) model = IMP.kernel.Model() fn_receptor = self.get_input_file_name("3sfdB.pdb") h_receptor = atom.read_pdb(fn_receptor, model, atom.NonWaterNonHydrogenPDBSelector()) fn_ligand = self.get_input_file_name("3sfdA.pdb") h_ligand = atom.read_pdb(fn_ligand, model, atom.NonWaterNonHydrogenPDBSelector()) mydock.set_xlinks(xl) mydock.set_hierarchies(h_receptor, h_ligand) p = IMP.kernel.Particle(model) core.RigidBody.setup_particle(p, atom.get_leaves(h_receptor)) rb_receptor = core.RigidBody(p) p = IMP.kernel.Particle(model) core.RigidBody.setup_particle(p, atom.get_leaves(h_ligand)) rb_ligand = core.RigidBody(p) mydock.set_rigid_bodies(rb_receptor, rb_ligand) mydock.move_ligand() c1 = mydock.get_residue_coordinates(h_ligand, "A", 456) c2 = mydock.get_residue_coordinates(h_receptor, "B", 23) dist = alg.get_distance(c1, c2) self.assertLessEqual(dist, self.max_distance)
def read_component(model, fn_pdb, name=False): """ Read a PDB molecule, add atoms, and set a name """ if name: log.debug("reading component %s from %s", name, fn_pdb) else: log.debug("reading component from %s", fn_pdb) hierarchy = atom.read_pdb(fn_pdb, model, atom.NonWaterNonHydrogenPDBSelector()) if name: hierarchy.set_name(name) atom.add_radii(hierarchy) return hierarchy
def test_filter_transformations(self): """ Check if the filtered conformation are the conformations that I computed before """ try: import subprocess import IMP.em2d.buildxlinks as bx except ImportError as e: self.skipTest(str(e)) dock = self.import_python_application('emagefit_dock') sel = atom.NonWaterNonHydrogenPDBSelector() ligand = IMP.kernel.Model() fn_ligand = self.get_input_file_name("3sfdB-3sfdA_initial_docking.pdb") h_ligand = atom.read_pdb(fn_ligand, ligand, sel) rb_ligand = atom.create_rigid_body(h_ligand) receptor = IMP.kernel.Model() fn_receptor = self.get_input_file_name("3sfdB.pdb") h_receptor = atom.read_pdb(fn_receptor, receptor, sel) # read_hex_transformations fn = self.get_input_file_name("hex_solutions_3sfdB-3sfdA.txt") residue_receptor = 23 residue_ligand = 456 distance = 30 xl = bx.Xlink("3sfdB", "B", residue_receptor, "3sfdA", "A", residue_ligand, distance) xlinks_list = [xl] fn_filtered = "filtered_transforms.txt" dock.filter_docking_results(h_receptor, h_ligand, xlinks_list, fn, fn_filtered) fn_stored = self.get_input_file_name( "hex_solutions_3sfdB-3sfdA_filtered.txt") filtered = dock.read_hex_transforms(fn_filtered) stored = dock.read_hex_transforms(fn_stored) # check that the filtered transforms match the stored ones self.assertEqual(len(filtered), len(stored)) for Tf, Ts in zip(filtered, stored): tf = Tf.get_translation() ts = Ts.get_translation() qf = Tf.get_rotation().get_quaternion() qs = Ts.get_rotation().get_quaternion() for k in range(3): self.assertAlmostEqual(tf[k], ts[k]) for k in range(4): self.assertAlmostEqual(qf[k], qs[k]) os.remove(fn_filtered)