37 number_of_sampling_attempts = 1
38 number_of_mc_steps = 10000
43 def add_protein_from_length(model, name, residues, parent, restraints,
44 excluded_volume_particles, optimized_particles):
51 optimized_particles.extend(leaves)
52 excluded_volume_particles.extend(leaves)
56 for c
in h.get_children()], k,
62 r.set_maximum_score(k)
67 def add_protein_from_pdb(model, name, file, parent, restraints,
68 excluded_volume_particles, optimized_particles):
73 IMP.get_example_path(os.path.join(
"data", file)), model,
85 rb.set_coordinates_are_optimized(
True)
86 optimized_particles.append(rb)
87 excluded_volume_particles.extend(s.get_children())
92 def add_protein_from_pdbs(model, name, files, parent, restraints,
93 excluded_volume_particles, optimized_particles):
95 for i, f
in enumerate(files):
96 add_protein_from_pdb(model, name + str(i), f, h, restraints,
97 excluded_volume_particles, optimized_particles)
99 for c
in h.get_children()],
100 k,
"connect " + name)
103 r.set_maximum_score(k)
108 def create_representation(model):
110 optimized_particles = []
111 excluded_volume_particles = []
115 add_protein_from_length(model,
"Nup85", 570, universe, restraints,
116 excluded_volume_particles, optimized_particles)
120 hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
121 terminus=IMP.atom.Selection.C)
124 d.set_coordinates_are_optimized(
False)
126 add_protein_from_length(model,
"Nup84", 460, universe, restraints,
127 excluded_volume_particles, optimized_particles)
128 add_protein_from_length(model,
"Nup145C", 442, universe, restraints,
129 excluded_volume_particles, optimized_particles)
130 add_protein_from_length(
131 model,
"Nup120", [0, 500, 761], universe, restraints,
132 excluded_volume_particles, optimized_particles)
133 add_protein_from_length(
134 model,
"Nup133", [0, 450, 778, 1160], universe, restraints,
135 excluded_volume_particles, optimized_particles)
136 add_protein_from_pdb(model,
"Seh1",
"seh1.pdb", universe, restraints,
137 excluded_volume_particles, optimized_particles)
138 add_protein_from_pdb(model,
"Sec13",
"sec13.pdb", universe, restraints,
139 excluded_volume_particles, optimized_particles)
140 return universe, restraints, excluded_volume_particles, optimized_particles
143 def add_distance_restraint(selection0, selection1, name, restraints):
145 r.set_maximum_score(k)
149 def encode_data_as_restraints(universe, restraints):
151 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
152 molecule=
"Nup145C", residue_indexes=[(0, 423)])
154 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
157 hierarchy=universe, hierarchy_types=[IMP.atom.FRAGMENT_TYPE],
160 [s0, s1, s2], k,
"Nup145C Nup84 Sec13")
161 r.set_maximum_score(k)
164 add_distance_restraint(
166 residue_indexes=[(0, 423)],
168 IMP.atom.FRAGMENT_TYPE]),
170 hierarchy=universe, molecule=
"Nup85",
172 IMP.atom.FRAGMENT_TYPE]),
173 "Num145C, Nup85", restraints)
174 add_distance_restraint(
176 residue_indexes=[(0, 423)],
178 IMP.atom.FRAGMENT_TYPE]),
180 hierarchy=universe, molecule=
"Nup120",
181 residue_indexes=[(500, 762)],
183 IMP.atom.FRAGMENT_TYPE]),
184 "Nup145C Nup120", restraints)
185 add_distance_restraint(
188 IMP.atom.FRAGMENT_TYPE]),
190 hierarchy=universe, molecule=
"Nup133",
191 residue_indexes=[(778, 1160)],
193 IMP.atom.FRAGMENT_TYPE]),
194 "Nup84 Nup133", restraints)
195 add_distance_restraint(
198 IMP.atom.FRAGMENT_TYPE]),
200 hierarchy=universe, molecule=
"Seh1",
202 IMP.atom.FRAGMENT_TYPE]),
203 "Nup85 Seh1", restraints)
204 add_distance_restraint(
206 residue_indexes=[(0, 423)],
208 IMP.atom.FRAGMENT_TYPE]),
210 hierarchy=universe, molecule=
"Sec13",
212 IMP.atom.FRAGMENT_TYPE]),
213 "Nup145C Sec13", restraints)
217 def get_configurations(model, restraints, excluded_volume_particles, optimized_particles):
224 for p
in optimized_particles:
235 mc.add_mover(serial_mover)
237 optimized_particles, restraints)
239 excluded_volume_particles)
244 for i
in range(number_of_sampling_attempts):
245 for p
in optimized_particles:
248 mc.optimize(number_of_mc_steps)
249 if scoring_function.get_had_good_score():
250 configuration_set.save()
251 return configuration_set
255 universe, restraints, excluded_volume_particles, optimized_particles = create_representation(
257 encode_data_as_restraints(universe, restraints)
259 configuration_set = get_configurations(model, restraints,
260 excluded_volume_particles,
263 print "Found", configuration_set.get_number_of_configurations(),
"good configurations"
267 rmf = RMF.create_rmf_file(rmf_file_name)
274 for i
in range(0, configuration_set.get_number_of_configurations()):
275 configuration_set.load_configuration(i)
280 for p
in optimized_particles]
282 tr = IMP.algebra.get_transform_taking_first_to_second(
283 optimized_particles, base_coords)
289 print "You can now open", rmf_file_name,
"in chimera"
A class to store a set of configurations of a model.
Hierarchy create_protein(kernel::Model *m, std::string name, double resolution, const Ints domain_boundaries)
void add_restraints(RMF::NodeHandle fh, const kernel::Restraints &hs)
See IMP.container for more information.
bool get_bool_flag(std::string name)
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
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.
See IMP.statistics for more information.
void save_frame(RMF::FileHandle file, int frame, std::string name="frame")
Select all non-alternative ATOM records.
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%")
A decorator for a particle with x,y,z coordinates.
Class to handle individual model particles.
void destroy(Hierarchy d)
Delete the Hierarchy.
See IMP.example for more information.
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)
See IMP.display for more information.
See IMP.atom for more information.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Hierarchies get_leaves(const Selection &h)
Apply 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.