4 define rigid bodies and super rigid bodies
5 define symmetries (see representation.py)
6 create nuisances and their parameters
7 generate lists of MC or MD movers
9 def __init__(self,root,
10 maxtrans_rb=
None,maxrot_rb=
None,
11 maxtrans_srb=
None,maxrot_srb=
None):
12 self.rigid_bodies = []
13 self.fixed_rigid_bodies = []
14 self.floppy_bodies = []
15 self.super_rigid_bodies = []
17 self.maxtrans_rb = 2.0
19 self.maxtrans_srb = 2.0
21 self.rigidbodiesarefixed =
False
22 self.maxtrans_fb = 3.0
27 This method allows the construction of a rigid body given a list
28 of hierarchies and or a list of particles.
30 hiers: list of hierarchies
31 particles: (optional, default=None) list of particles to add to the rigid body
37 rigid_parts = set(particles)
40 print "set_rigid_body_from_hierarchies> setting up a new rigid body"
46 print "set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name())
49 name += hier.get_name() +
"-"
50 print "set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name()
52 rb.set_coordinates_are_optimized(
True)
53 rb.set_name(name +
"rigid_body")
54 self.rigid_bodies.append(rb)
59 This method allows the construction of a rigid body given a list
60 of tuples, that identify the residue ranges and the subunit names (the names used
61 to create the component by using create_component.
63 subunits: [(name_1,(first_residue_1,last_residue_1)),(name_2,(first_residue_2,last_residue_2)),.....]
65 [name_1,name_2,(name_3,(first_residue_3,last_residue_3)),.....]
67 example: ["prot1","prot2",("prot3",(1,10))]
69 sometimes, we know about structure of an interaction
70 and here we make such PPIs rigid
75 if type(s) == type(tuple())
and len(s) == 2:
79 residue_indexes=range(s[1][0],
81 if len(sel.get_selected_particles()) == 0:
82 print "set_rigid_bodies: selected particle does not exists"
83 for p
in sel.get_selected_particles():
87 print "set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name())
91 elif type(s) == type(str()):
93 if len(sel.get_selected_particles()) == 0:
94 print "set_rigid_bodies: selected particle does not exists"
95 for p
in sel.get_selected_particles():
99 print "set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name())
104 rb.set_coordinates_are_optimized(
True)
105 rb.set_name(
''.join(str(subunits)) +
"_rigid_body")
106 self.rigid_bodies.append(rb)
109 def set_super_rigid_body_from_hierarchies(
115 super_rigid_xyzs = set()
116 super_rigid_rbs = set()
118 print "set_super_rigid_body_from_hierarchies> setting up a new SUPER rigid body"
125 super_rigid_rbs.add(rb)
127 super_rigid_xyzs.add(p)
128 print "set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name()
129 if len(super_rigid_rbs) < min_size:
132 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
135 self.super_rigid_bodies.append(
136 (super_rigid_xyzs, super_rigid_rbs, axis))
138 def fix_rigid_bodies(self, rigid_bodies):
139 self.fixed_rigid_bodies += rigid_bodies
148 this function takes a linear list of hierarchies (they are supposed
149 to be sequence-contiguous) and
150 produces a chain of super rigid bodies with given length range, specified
151 by min_length and max_length
154 hiers = IMP.pmi.tools.flatten_list(hiers)
158 self.set_super_rigid_body_from_hierarchies(hs, axis, min_length)
160 def set_super_rigid_bodies(self, subunits, coords=None):
161 super_rigid_xyzs = set()
162 super_rigid_rbs = set()
165 if type(s) == type(tuple())
and len(s) == 3:
169 residue_indexes=range(s[0],
171 if len(sel.get_selected_particles()) == 0:
172 print "set_rigid_bodies: selected particle does not exists"
173 for p
in sel.get_selected_particles():
176 super_rigid_rbs.add(rb)
178 super_rigid_xyzs.add(p)
179 elif type(s) == type(str()):
181 if len(sel.get_selected_particles()) == 0:
182 print "set_rigid_bodies: selected particle does not exists"
183 for p
in sel.get_selected_particles():
187 super_rigid_rbs.add(rb)
189 super_rigid_xyzs.add(p)
190 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
194 give a list of hierarchies, get the leaves and remove the corresponding particles
195 from the floppy bodies list. We need this function because sometimes
196 we want to constraint the floppy bodies in a rigid body. For instance
197 when you want to associate a bead with a density particle.
199 for h
in hierarchies:
202 if p
in self.floppy_bodies:
203 print "remove_floppy_bodies: removing %s from floppy body list" % p.get_name()
204 self.floppy_bodies.remove(p)
206 def set_floppy_bodies(self):
207 for p
in self.floppy_bodies:
209 p.set_name(name +
"_floppy_body")
211 print "I'm trying to make this particle flexible although it was assigned to a rigid body", p.get_name()
214 rb.set_is_rigid_member(p.get_index(),
False)
217 rb.set_is_rigid_member(p.get_particle_index(),
False)
218 p.set_name(p.get_name() +
"_rigid_body_member")
220 def set_floppy_bodies_from_hierarchies(self, hiers):
225 self.floppy_bodies.append(p)
227 def get_particles_to_sample(self):
237 if not self.rigidbodiesarefixed:
238 for rb
in self.rigid_bodies:
243 if rb
not in self.fixed_rigid_bodies:
246 for fb
in self.floppy_bodies:
253 for srb
in self.super_rigid_bodies:
256 rigid_bodies = list(srb[1])
257 filtered_rigid_bodies = []
258 for rb
in rigid_bodies:
259 if rb
not in self.fixed_rigid_bodies:
260 filtered_rigid_bodies.append(rb)
261 srbtmp.append((srb[0], filtered_rigid_bodies))
263 self.rigid_bodies = rbtmp
264 self.floppy_bodies = fbtmp
265 self.super_rigid_bodies = srbtmp
267 ps[
"Rigid_Bodies_SimplifiedModel"] = (
271 ps[
"Floppy_Bodies_SimplifiedModel"] = (
274 ps[
"SR_Bodies_SimplifiedModel"] = (
275 self.super_rigid_bodies,
def remove_floppy_bodies
give a list of hierarchies, get the leaves and remove the corresponding particles from the floppy bod...
Add symmetric attribute to a particle.
def set_rigid_bodies
This method allows the construction of a rigid body given a list of tuples, that identify the residue...
def set_rigid_body_from_hierarchies
This method allows the construction of a rigid body given a list of hierarchies and or a list of part...
static bool get_is_setup(Model *m, ParticleIndex pi)
A decorator for a particle with x,y,z coordinates.
def set_chain_of_super_rigid_bodies
this function takes a linear list of hierarchies (they are supposed to be sequence-contiguous) and pr...
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Hierarchies get_leaves(const Selection &h)
Select hierarchy particles identified by the biological name.