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):
74 IMP.get_example_path(os.path.join(
"data", file)), model,
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")
A class to store a set of configurations of a model.
void save_frame(RMF::FileHandle file, unsigned int, std::string name="")
void add_restraints(RMF::NodeHandle fh, const kernel::Restraints &hs)
Various classes to hold sets of particles.
bool get_bool_flag(std::string name)
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.
Modify the transformation of a rigid body.
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
kernel::Restraint * create_distance_restraint(const Selection &n0, const Selection &n1, double x0, double k, std::string name="Distance%1%")
Modify a set of continuous variables by perturbing them within a ball.
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
Code to compute statistical measures.
Select all non-alternative ATOM records.
Hierarchy create_protein(kernel::Model *m, std::string name, double target_radius, const Ints domain_boundaries)
void add_hierarchy(RMF::FileHandle fh, atom::Hierarchy hs)
void add_bool_flag(std::string name, std::string description)
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
kernel::Restraint * create_connectivity_restraint(const Selections &s, double x0, double k, std::string name="Connectivity%1%")
Create a restraint connecting the selections.
A decorator for a particle with x,y,z coordinates.
Class to handle individual model particles.
void destroy(Hierarchy d)
Delete the Hierarchy.
Hierarchy create_simplified_along_backbone(Chain input, const IntRanges &residue_segments, bool keep_detailed=false)
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Store info for a chain of a protein.
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Output IMP model data in various file formats.
Functionality for loading, creating, manipulating and scoring atomic structures.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Hierarchies get_leaves(const Selection &h)
Select hierarchy particles identified by the biological name.
Applies a list of movers one at a time.
Class for storing model, its restraints, constraints, and particles.
A decorator for a particle with x,y,z coordinates and a radius.