8 from __future__
import print_function
38 number_of_sampling_attempts = 1
39 number_of_mc_steps = 10000
44 def add_protein_from_length(model, name, residues, parent, restraints,
45 excluded_volume_particles, optimized_particles):
52 optimized_particles.extend(leaves)
53 excluded_volume_particles.extend(leaves)
57 for c
in h.get_children()], k,
63 r.set_maximum_score(k)
68 def add_protein_from_pdb(model, name, file, parent, restraints,
69 excluded_volume_particles, optimized_particles):
77 c =
IMP.atom.Chain(IMP.atom.get_by_type(t, IMP.atom.CHAIN_TYPE)[0])
86 rb.set_coordinates_are_optimized(
True)
87 optimized_particles.append(rb)
88 excluded_volume_particles.extend(s.get_children())
93 def add_protein_from_pdbs(model, name, files, parent, restraints,
94 excluded_volume_particles, optimized_particles):
96 for i, f
in enumerate(files):
97 add_protein_from_pdb(model, name + str(i), f, h, restraints,
98 excluded_volume_particles, optimized_particles)
100 for c
in h.get_children()],
101 k,
"connect " + name)
104 r.set_maximum_score(k)
109 def create_representation(model):
111 optimized_particles = []
112 excluded_volume_particles = []
116 add_protein_from_length(model,
"Nup85", 570, universe, restraints,
117 excluded_volume_particles, optimized_particles)
121 hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
122 terminus=IMP.atom.Selection.C)
125 d.set_coordinates_are_optimized(
False)
127 add_protein_from_length(model,
"Nup84", 460, universe, restraints,
128 excluded_volume_particles, optimized_particles)
129 add_protein_from_length(model,
"Nup145C", 442, universe, restraints,
130 excluded_volume_particles, optimized_particles)
131 add_protein_from_length(
132 model,
"Nup120", [0, 500, 761], universe, restraints,
133 excluded_volume_particles, optimized_particles)
134 add_protein_from_length(
135 model,
"Nup133", [0, 450, 778, 1160], universe, restraints,
136 excluded_volume_particles, optimized_particles)
137 add_protein_from_pdb(model,
"Seh1",
"seh1.pdb", universe, restraints,
138 excluded_volume_particles, optimized_particles)
139 add_protein_from_pdb(model,
"Sec13",
"sec13.pdb", universe, restraints,
140 excluded_volume_particles, optimized_particles)
141 return universe, restraints, excluded_volume_particles, optimized_particles
144 def add_distance_restraint(selection0, selection1, name, restraints):
146 r.set_maximum_score(k)
150 def encode_data_as_restraints(universe, restraints):
152 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
153 molecule=
"Nup145C", residue_indexes=[(0, 423)])
155 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
158 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
161 [s0, s1, s2], k,
"Nup145C Nup84 Sec13")
162 r.set_maximum_score(k)
165 add_distance_restraint(
167 residue_indexes=[(0, 423)],
169 IMP.atom.FRAGMENT_TYPE]),
171 hierarchy=universe, molecule=
"Nup85",
173 IMP.atom.FRAGMENT_TYPE]),
174 "Num145C, Nup85", restraints)
175 add_distance_restraint(
177 residue_indexes=[(0, 423)],
179 IMP.atom.FRAGMENT_TYPE]),
181 hierarchy=universe, molecule=
"Nup120",
182 residue_indexes=[(500, 762)],
184 IMP.atom.FRAGMENT_TYPE]),
185 "Nup145C Nup120", restraints)
186 add_distance_restraint(
189 IMP.atom.FRAGMENT_TYPE]),
191 hierarchy=universe, molecule=
"Nup133",
192 residue_indexes=[(778, 1160)],
194 IMP.atom.FRAGMENT_TYPE]),
195 "Nup84 Nup133", restraints)
196 add_distance_restraint(
199 IMP.atom.FRAGMENT_TYPE]),
201 hierarchy=universe, molecule=
"Seh1",
203 IMP.atom.FRAGMENT_TYPE]),
204 "Nup85 Seh1", restraints)
205 add_distance_restraint(
207 residue_indexes=[(0, 423)],
209 IMP.atom.FRAGMENT_TYPE]),
211 hierarchy=universe, molecule=
"Sec13",
213 IMP.atom.FRAGMENT_TYPE]),
214 "Nup145C Sec13", restraints)
218 def get_configurations(
221 excluded_volume_particles,
222 optimized_particles):
229 for p
in optimized_particles:
240 mc.add_mover(serial_mover)
242 optimized_particles, restraints)
244 excluded_volume_particles)
249 for i
in range(number_of_sampling_attempts):
250 for p
in optimized_particles:
253 mc.optimize(number_of_mc_steps)
254 if scoring_function.get_had_good_score():
255 configuration_set.save()
256 return configuration_set
260 universe, restraints, excluded_volume_particles, optimized_particles = create_representation(
262 encode_data_as_restraints(universe, restraints)
264 configuration_set = get_configurations(model, restraints,
265 excluded_volume_particles,
268 print(
"Found", configuration_set.get_number_of_configurations(),
"good configurations")
272 rmf = RMF.create_rmf_file(rmf_file_name)
279 for i
in range(0, configuration_set.get_number_of_configurations()):
280 configuration_set.load_configuration(i)
285 for p
in optimized_particles]
287 tr = IMP.algebra.get_transform_taking_first_to_second(
288 optimized_particles, base_coords)
294 print(
"You can now open", rmf_file_name,
"in chimera")
RMF::FrameID save_frame(RMF::FileHandle file, std::string name="")
Save the current state of the linked objects as a new RMF frame.
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Various classes to hold sets of particles.
bool get_bool_flag(std::string name)
Modify the transformation of a rigid body.
Modify a set of continuous variables by perturbing them within a ball.
void read_pdb(TextInput input, int model, Hierarchy h)
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
Code to compute statistical measures.
Class for storing model, its restraints, constraints, and particles.
Hierarchy create_protein(Model *m, std::string name, double target_radius, const Ints domain_boundaries)
Select all non-alternative ATOM records.
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
void add_hierarchy(RMF::FileHandle fh, atom::Hierarchy hs)
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
A class to store a set of configurations of a model.
A decorator for a particle with x,y,z coordinates.
void add_restraints(RMF::NodeHandle fh, const Restraints &hs)
static bool get_is_setup(const IMP::ParticleAdaptor &p)
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Hierarchy create_simplified_along_backbone(Chain input, const IntRanges &residue_segments, bool keep_detailed=false)
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Class to handle individual model particles.
Restraint * create_distance_restraint(const Selection &n0, const Selection &n1, double x0, double k, std::string name="Distance%1%")
Store info for a chain of a protein.
Restraint * create_connectivity_restraint(const Selections &s, double x0, double k, std::string name="Connectivity%1%")
Create a restraint connecting the selections.
Score the model efficiently when a small number of particles are changed.
Output IMP model data in various file formats.
Functionality for loading, creating, manipulating and scoring atomic structures.
void add_bool_flag(std::string name, std::string description)
Hierarchies get_leaves(const Selection &h)
Select hierarchy particles identified by the biological name.
Applies a list of movers one at a time.
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.
A decorator for a particle with x,y,z coordinates and a radius.