def test_mc_flexible_beads_disable(self): """Test disable of flexible beads""" mdl = IMP.Model() s,mol = self.init_topology1(mdl) dof = IMP.pmi.dof.DegreesOfFreedom(mdl) fb_movers = dof.create_flexible_beads(mol.get_non_atomic_residues(),max_trans=1.0) self.assertEqual(len(fb_movers),3) mvs = dof.get_movers() self.assertEqual(len(mvs),3) particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles) self.assertEqual(len(xyzs),3) self.assertEqual(len(rbs),0) mvs = dof.get_movers() self.assertEqual(len(mvs),0) dof.enable_all_movers() particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles,mover_types=[IMP.core.RigidBodyMover]) self.assertEqual(len(xyzs),0) self.assertEqual(len(rbs),0) mvs = dof.get_movers() self.assertEqual(len(mvs),3) dof.enable_all_movers() particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles,mover_types=[IMP.core.BallMover]) self.assertEqual(len(xyzs),3) self.assertEqual(len(rbs),0) mvs = dof.get_movers() self.assertEqual(len(mvs),0)
def test_mc_rigid_body_disable(self): """Test creation of rigid body and nonrigid members""" mdl = IMP.Model() s, molecule = self.init_topology1(mdl) dof = IMP.pmi.dof.DegreesOfFreedom(mdl) rb_movers, rb = dof.create_rigid_body( molecule, nonrigid_parts=molecule.get_non_atomic_residues(), name="test RB") mvs = dof.get_movers() self.assertEqual(len(mvs), 4) #fixing all particles particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles) self.assertEqual(len(xyzs), 3) self.assertEqual(len(rbs), 1) mvs = dof.get_movers() self.assertEqual(len(mvs), 0) #enabling everything dof.enable_all_movers() mvs = dof.get_movers() self.assertEqual(len(mvs), 4) #IMP.atom.show_molecular_hierarchy(s.hier) #fixing the rb particles = IMP.atom.Selection( s.hier, molecule="Prot1", residue_indexes=[1]).get_selected_particles() xyzs, rbs = dof.disable_movers(particles) self.assertEqual(len(xyzs), 0) self.assertEqual(len(rbs), 1) mvs = dof.get_movers() self.assertEqual(len(mvs), 3) #fixing one bead and the corresponding rb dof.enable_all_movers() particles = IMP.atom.Selection( s.hier, molecule="Prot1", residue_indexes=[10]).get_selected_particles() xyzs, rbs = dof.disable_movers(particles) self.assertEqual(len(xyzs), 1) self.assertEqual(len(rbs), 1) mvs = dof.get_movers() self.assertEqual(len(mvs), 2)
def test_mc_rigid_body_disable(self): """Test creation of rigid body and nonrigid members""" mdl = IMP.Model() s,molecule = self.init_topology1(mdl) dof = IMP.pmi.dof.DegreesOfFreedom(mdl) rb_movers,rb = dof.create_rigid_body(molecule, nonrigid_parts = molecule.get_non_atomic_residues(), name="test RB") mvs = dof.get_movers() self.assertEqual(len(mvs),4) #fixing all particles particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles) self.assertEqual(len(xyzs),3) self.assertEqual(len(rbs),1) mvs = dof.get_movers() self.assertEqual(len(mvs),0) #enabling everything dof.enable_all_movers() mvs = dof.get_movers() self.assertEqual(len(mvs),4) #IMP.atom.show_molecular_hierarchy(s.hier) #fixing the rb particles=IMP.atom.Selection(s.hier,molecule="Prot1",residue_indexes=[1]).get_selected_particles() xyzs,rbs=dof.disable_movers(particles) self.assertEqual(len(xyzs),0) self.assertEqual(len(rbs),1) mvs = dof.get_movers() self.assertEqual(len(mvs),3) #fixing one bead and the corresponding rb dof.enable_all_movers() particles=IMP.atom.Selection(s.hier,molecule="Prot1",residue_indexes=[10]).get_selected_particles() xyzs,rbs=dof.disable_movers(particles) self.assertEqual(len(xyzs),1) self.assertEqual(len(rbs),1) mvs = dof.get_movers() self.assertEqual(len(mvs),2)
def test_mc_flexible_beads_disable(self): """Test disable of flexible beads""" mdl = IMP.Model() s, mol = self.init_topology1(mdl) dof = IMP.pmi.dof.DegreesOfFreedom(mdl) fb_movers = dof.create_flexible_beads(mol.get_non_atomic_residues(), max_trans=1.0) self.assertEqual(len(fb_movers), 3) mvs = dof.get_movers() self.assertEqual(len(mvs), 3) particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles) self.assertEqual(len(xyzs), 3) self.assertEqual(len(rbs), 0) mvs = dof.get_movers() self.assertEqual(len(mvs), 0) dof.enable_all_movers() particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles, mover_types=[IMP.core.RigidBodyMover]) self.assertEqual(len(xyzs), 0) self.assertEqual(len(rbs), 0) mvs = dof.get_movers() self.assertEqual(len(mvs), 3) dof.enable_all_movers() particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles, mover_types=[IMP.core.BallMover]) self.assertEqual(len(xyzs), 3) self.assertEqual(len(rbs), 0) mvs = dof.get_movers() self.assertEqual(len(mvs), 0)
def test_mc_super_rigid_body_disable(self): """test disable super rigid bodies, floppy bodies and rigid bodies""" mdl = IMP.Model() s, mols = self.init_topology3(mdl) dof = IMP.pmi.dof.DegreesOfFreedom(mdl) rb1_mov, rb1 = dof.create_rigid_body( mols[0], nonrigid_parts=mols[0].get_non_atomic_residues()) rb2_mov, rb2 = dof.create_rigid_body( mols[1], nonrigid_parts=mols[1].get_non_atomic_residues()) rb3_mov, rb3 = dof.create_rigid_body( mols[2], nonrigid_parts=mols[2].get_non_atomic_residues()) srb_mover = dof.create_super_rigid_body(mols, chain_min_length=2, chain_max_length=2) ### rbX = dof.create_rigid_body([mols[0],mols[1]]) should fail # rb1:4, rb2:1, rb3:4, srbs:2 mvs = dof.get_movers() self.assertEqual(len(mvs), 11) #fixing all particles particles = IMP.atom.Selection(s.hier).get_selected_particles() xyzs, rbs = dof.disable_movers(particles) self.assertEqual(len(xyzs), 6) self.assertEqual(len(rbs), 3) mvs = dof.get_movers() self.assertEqual(len(mvs), 0) #enabling everything dof.enable_all_movers() mvs = dof.get_movers() self.assertEqual(len(mvs), 11) #fixing prot1 particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles) self.assertEqual(len(xyzs), 3) self.assertEqual(len(rbs), 1) mvs = dof.get_movers() self.assertEqual(len(mvs), 6) #fixing prot1 rb dof.enable_all_movers() particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles, mover_types=[IMP.core.RigidBodyMover]) self.assertEqual(len(xyzs), 0) self.assertEqual(len(rbs), 1) mvs = dof.get_movers() self.assertEqual(len(mvs), 10) #fixing prot1 fbs dof.enable_all_movers() particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles, mover_types=[IMP.core.BallMover]) self.assertEqual(len(xyzs), 3) self.assertEqual(len(rbs), 0) mvs = dof.get_movers() self.assertEqual(len(mvs), 8) #removing super rigid body dof.enable_all_movers() particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles, mover_types=[IMP.pmi.TransformMover]) self.assertEqual(len(xyzs), 0) self.assertEqual(len(rbs), 0) mvs = dof.get_movers() self.assertEqual(len(mvs), 10) #removing rbmv, ballmovers and super rigid movers involving prot1 dof.enable_all_movers() particles = IMP.atom.Selection( s.hier, molecule="Prot1").get_selected_particles() xyzs, rbs = dof.disable_movers(particles, mover_types=[ IMP.core.RigidBodyMover, IMP.core.BallMover, IMP.pmi.TransformMover ]) self.assertEqual(len(xyzs), 3) self.assertEqual(len(rbs), 1) mvs = dof.get_movers() self.assertEqual(len(mvs), 6) #removing rbmv, ballmovers and super rigid movers involving prot2 dof.enable_all_movers() particles = IMP.atom.Selection( s.hier, molecule="Prot2").get_selected_particles() xyzs, rbs = dof.disable_movers(particles, mover_types=[ IMP.core.RigidBodyMover, IMP.core.BallMover, IMP.pmi.TransformMover ]) self.assertEqual(len(xyzs), 0) self.assertEqual(len(rbs), 1) mvs = dof.get_movers() self.assertEqual(len(mvs), 8)
reader = IMP.pmi.topology.TopologyReader(tf.name, pdb_dir = '.', fasta_dir = '.', gmm_dir = 'gmm') bs = IMP.pmi.macros.BuildSystem(mdl) bs.add_state(reader) # note you can call this multiple times to create a multi-state system #IMP.pmi.plotting.topology.draw_component_composition(bs) hier, dof = bs.execute_macro(max_rb_trans=4.0, max_rb_rot=0.3, max_bead_trans=4.0, max_srb_trans=4.0,max_srb_rot=0.3) particles=IMP.atom.Selection(hier,molecule="TssK",residue_indexes=range(1,315+1)).get_selected_particles() fixedxyz,fixedrbs=dof.disable_movers(particles,[IMP.core.RigidBodyMover]) for xyz in fixedxyz: IMP.core.XYZ(xyz).set_coordinates_are_optimized(False) for rb in fixedrbs: IMP.core.RigidBody(rb).set_coordinates_are_optimized(False) particles=IMP.atom.Selection(hier,molecule="TssF",copy_index=0).get_selected_particles() for p in particles: rad=IMP.core.XYZR(p).get_radius() IMP.core.XYZR(p).set_radius(rad*0.75) p.set_value(IMP.FloatKey(4),296) p.set_value(IMP.FloatKey(5),216) p.set_value(IMP.FloatKey(6),262)
def test_mc_super_rigid_body_disable(self): """test disable super rigid bodies, floppy bodies and rigid bodies""" mdl = IMP.Model() s,mols = self.init_topology3(mdl) dof = IMP.pmi.dof.DegreesOfFreedom(mdl) rb1_mov,rb1 = dof.create_rigid_body(mols[0], nonrigid_parts = mols[0].get_non_atomic_residues()) rb2_mov,rb2 = dof.create_rigid_body(mols[1], nonrigid_parts = mols[1].get_non_atomic_residues()) rb3_mov,rb3 = dof.create_rigid_body(mols[2], nonrigid_parts = mols[2].get_non_atomic_residues()) srb_mover = dof.create_super_rigid_body(mols,chain_min_length=2, chain_max_length=2) ### rbX = dof.create_rigid_body([mols[0],mols[1]]) should fail # rb1:4, rb2:1, rb3:4, srbs:2 mvs = dof.get_movers() self.assertEqual(len(mvs),11) #fixing all particles particles=IMP.atom.Selection(s.hier).get_selected_particles() xyzs,rbs=dof.disable_movers(particles) self.assertEqual(len(xyzs),6) self.assertEqual(len(rbs),3) mvs = dof.get_movers() self.assertEqual(len(mvs),0) #enabling everything dof.enable_all_movers() mvs = dof.get_movers() self.assertEqual(len(mvs),11) #fixing prot1 particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles) self.assertEqual(len(xyzs),3) self.assertEqual(len(rbs),1) mvs = dof.get_movers() self.assertEqual(len(mvs),6) #fixing prot1 rb dof.enable_all_movers() particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles,mover_types=[IMP.core.RigidBodyMover]) self.assertEqual(len(xyzs),0) self.assertEqual(len(rbs),1) mvs = dof.get_movers() self.assertEqual(len(mvs),10) #fixing prot1 fbs dof.enable_all_movers() particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles,mover_types=[IMP.core.BallMover]) self.assertEqual(len(xyzs),3) self.assertEqual(len(rbs),0) mvs = dof.get_movers() self.assertEqual(len(mvs),8) #removing super rigid body dof.enable_all_movers() particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles,mover_types=[IMP.pmi.TransformMover]) self.assertEqual(len(xyzs),0) self.assertEqual(len(rbs),0) mvs = dof.get_movers() self.assertEqual(len(mvs),10) #removing rbmv, ballmovers and super rigid movers involving prot1 dof.enable_all_movers() particles=IMP.atom.Selection(s.hier,molecule="Prot1").get_selected_particles() xyzs,rbs=dof.disable_movers(particles,mover_types=[IMP.core.RigidBodyMover,IMP.core.BallMover,IMP.pmi.TransformMover]) self.assertEqual(len(xyzs),3) self.assertEqual(len(rbs),1) mvs = dof.get_movers() self.assertEqual(len(mvs),6) #removing rbmv, ballmovers and super rigid movers involving prot2 dof.enable_all_movers() particles=IMP.atom.Selection(s.hier,molecule="Prot2").get_selected_particles() xyzs,rbs=dof.disable_movers(particles,mover_types=[IMP.core.RigidBodyMover,IMP.core.BallMover,IMP.pmi.TransformMover]) self.assertEqual(len(xyzs),0) self.assertEqual(len(rbs),1) mvs = dof.get_movers() self.assertEqual(len(mvs),8)
fixed_particles=[] for prot in [ "Rpb1","Rpb2","Rpb3","Rpb4","Rpb5","Rpb6","Rpb7","Rpb8","Rpb9","Rpb10","Rpb11","Rpb12", "Med6","Med8","Med11","Med17","Med18","Med20","Med22", "Med4","Med7","Med9","Med10","Med14","Med19","Med21","Med31", "Spt15","Toa1","Toa2","Sua7","Tfg1","Tfg2","Tfa1","Tfa2", "Rad3","Tfb1","Tfb2","Tfb4","Tfb5","Ssl1","Ssl2", "NDNA","TDNA" ]: fixed_particles+=IMP.atom.Selection(representation,molecule=prot).get_selected_particles() fixed_particles+=IMP.atom.Selection(representation, molecule="Tfb3", residue_indexes=range(8,145)).get_selected_particles() # Fix corresponding movers using dof fixed_beads,fixed_rbs=dof.disable_movers(fixed_particles, [IMP.core.RigidBodyMover, IMP.pmi.TransformMover]) # Shuffling for random initial conformations IMP.pmi.tools.shuffle_configuration(representation, excluded_rigid_bodies=fixed_rbs, max_translation=20, verbose=False, cutoff=5.0, niterations=100) # Add default mover parameters to simulation outputobjects = [] # reporter objects (for stat files) sampleobjects = [] # sampling objects