7 from __future__
import print_function
20 import ihm.cross_linkers
34 dat_dir = IMP.nestor.get_example_path(
"input")
36 if not os.path.exists(os.path.join(dat_dir,
'gmm/emd_22904.mrc')):
37 print(
"To run this example, first download the EM map from EMD22094,")
38 print(
"extract it, rename it as `emd_22904.mrc` and place it in")
39 print(
"the `input/gmm/` directory.")
42 run_output_dir =
"run_" +
"0"
43 topology_file = os.path.join(dat_dir,
"topology50.txt")
44 h_param_file = os.path.join(dat_dir,
"nestor_params_optrep.yaml")
51 sampling_adh_xl_data = os.path.join(dat_dir,
"xlms/sampling_filtered_adh.dat")
52 sampling_bs3dss_xl_data = os.path.join(dat_dir,
"xlms/sampling_filtered_bs3dss.dat")
53 sampling_dmtmm_xl_data = os.path.join(dat_dir,
"xlms/sampling_filtered_dmtmm.dat")
55 evi_adh_xl_data = os.path.join(dat_dir,
"xlms/evicalc_filtered_adh.dat")
56 evi_bs3dss_xl_data = os.path.join(dat_dir,
"xlms/evicalc_filtered_adh.dat")
57 evi_dmtmm_xl_data = os.path.join(dat_dir,
"xlms/evicalc_filtered_adh.dat")
59 gmm_data = os.path.join(dat_dir,
"gmm/emd_22904.gmm.40.txt")
62 inter_xl_weight = 10.0
67 def modeling(output_dir, topology_file, h_param_file):
71 pdb_dir=os.path.join(dat_dir,
'pdb'),
72 fasta_dir=os.path.join(dat_dir,
'fasta'),
73 gmm_dir=os.path.join(dat_dir,
'gmm'))
77 root_hier, dof = bs.execute_macro(
90 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(165, 334)
91 ).get_selected_particles()
92 for prot
in [
"HDAC1"]:
95 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(8, 377)
96 ).get_selected_particles()
102 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(1, 165)
103 ).get_selected_particles()
104 for prot
in [
"MTA1"]:
107 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(334, 432)
108 ).get_selected_particles()
109 for prot
in [
"HDAC1"]:
112 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(1, 8)
113 ).get_selected_particles()
114 for prot
in [
"HDAC1"]:
117 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(377, 483)
118 ).get_selected_particles()
119 for prot
in [
"MBD3"]:
121 root_hier, molecule=prot, copy_index=0, residue_indexes=range(1, 296)
122 ).get_selected_particles()
123 for prot
in [
"P66A"]:
125 root_hier, molecule=prot, copy_index=0, residue_indexes=range(136, 179)
126 ).get_selected_particles()
127 for prot
in [
"RBBP4"]:
128 for cp
in [0, 1, 2, 3]:
130 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(1, 425)
131 ).get_selected_particles()
133 fixed_set1_core_beads, fixed_set1_core = dof.disable_movers(
137 fixed_set2_beads, fixed_set2 = dof.disable_movers(
140 molecules = t.get_components()
147 nestor_restraints = []
152 for m
in root_hier.get_children()[0].get_children():
155 output_objects.append(cr)
157 print(
"Connectivity restraint applied")
163 included_objects=[root_hier], resolution=1000
165 output_objects.append(evr)
167 print(
"Excluded volume restraint applied")
174 xldbkc.set_standard_keys()
177 xldb_adh_sampling.create_set_from_file(
178 file_name=sampling_adh_xl_data, converter=xldbkc
183 database=xldb_adh_sampling,
189 linker=ihm.cross_linkers.edc,
194 xldb_bs3dss_sampling.create_set_from_file(
195 file_name=sampling_bs3dss_xl_data, converter=xldbkc
197 xlr_bs3dss_sampling = (
200 database=xldb_bs3dss_sampling,
206 linker=ihm.cross_linkers.bs3,
211 xldb_dmtmm_sampling.create_set_from_file(
212 file_name=sampling_dmtmm_xl_data, converter=xldbkc
214 xlr_dmtmm_sampling = (
217 database=xldb_dmtmm_sampling,
223 linker=ihm.cross_linkers.dsso,
227 output_objects.append(xlr_adh_sampling)
228 output_objects.append(xlr_bs3dss_sampling)
229 output_objects.append(xlr_dmtmm_sampling)
235 xldbkc.set_standard_keys()
238 xldb_adh_evicalc.create_set_from_file(file_name=evi_adh_xl_data, converter=xldbkc)
242 database=xldb_adh_evicalc,
248 linker=ihm.cross_linkers.edc,
253 xldb_bs3dss_evicalc.create_set_from_file(
254 file_name=evi_bs3dss_xl_data, converter=xldbkc
256 xlr_bs3dss_evicalc = (
259 database=xldb_bs3dss_evicalc,
265 linker=ihm.cross_linkers.bs3,
270 xldb_dmtmm_evicalc.create_set_from_file(
271 file_name=evi_dmtmm_xl_data, converter=xldbkc
273 xlr_dmtmm_evicalc = (
276 database=xldb_dmtmm_evicalc,
282 linker=ihm.cross_linkers.dsso,
286 output_objects.append(xlr_adh_evicalc)
287 output_objects.append(xlr_bs3dss_evicalc)
288 output_objects.append(xlr_dmtmm_evicalc)
290 nestor_restraints.append(xlr_adh_evicalc)
291 nestor_restraints.append(xlr_bs3dss_evicalc)
292 nestor_restraints.append(xlr_dmtmm_evicalc)
294 print(
"Cross-linking restraint applied")
298 root_hier, representation_type=IMP.atom.DENSITIES
299 ).get_selected_particles()
305 scale_target_to_mass=
True,
309 output_objects.append(emr)
310 nestor_restraints.append(emr)
311 print(
"EM Restraint Applied")
321 max_translation=max_shuffle_set2,
322 excluded_rigid_bodies=fixed_set1_core,
327 max_translation=max_shuffle_core,
328 excluded_rigid_bodies=fixed_set2,
333 with open(
"shuffle_config.err",
"w")
as shufferr:
334 shufferr.write(str(11))
337 print(f
"{'-'*50}\nExit code: {exit_code}\n{'-'*50}")
338 dof.optimize_flexible_beads(50)
345 xlr_adh_sampling.add_to_model()
346 xlr_bs3dss_sampling.add_to_model()
347 xlr_dmtmm_sampling.add_to_model()
348 xlr_adh_evicalc.add_to_model()
349 xlr_bs3dss_evicalc.add_to_model()
350 xlr_dmtmm_evicalc.add_to_model()
352 print(
"Replica Exchange Maximum Temperature : " + str(rex_max_temp))
358 monte_carlo_temperature=1.0,
359 replica_exchange_minimum_temperature=1.0,
360 replica_exchange_maximum_temperature=rex_max_temp,
361 monte_carlo_sample_objects=dof.get_movers(),
362 global_output_directory=run_output_dir,
363 output_objects=output_objects,
364 monte_carlo_steps=10,
365 number_of_best_scoring_models=0,
372 nestor_restraints=nestor_restraints,
373 h_param_file=h_param_file,
377 ns_return, ns_exit_code = ns.execute_nested_sampling2()
378 return ns_return, ns_exit_code
381 with open(
"errors.log",
"w")
as errf:
382 with contextlib.redirect_stdout(
None):
383 with contextlib.redirect_stderr(errf):
384 nested_sampling_output, nested_sampling_exitcode = modeling(
385 run_output_dir, topology_file, h_param_file
389 if nested_sampling_output
is not None:
390 print(f
"////{nested_sampling_output}")
392 sys.exit(nested_sampling_exitcode)
Setup cross-link distance restraints from mass spectrometry data.
Restraints for keeping correct stereochemistry.
Fit Gaussian-decorated particles to an EM map (also represented with a set of Gaussians) ...
A macro to help setup and run replica exchange.
Set of Python classes to create a multi-state, multi-resolution IMP hierarchy.
Strings setup_from_argv(const Strings &argv, std::string description, std::string positional_description, int num_positional)
Some miscellaneous simple restraints.
Utility classes and functions for reading and storing PMI files.
def enable_all_movers
Re-enable all movers: previously fixed particles will be released.
Modify the transformation of a rigid body.
Handles cross-link data sets.
A macro to build a IMP::pmi::topology::System based on a TopologyReader object.
Protocols for sampling structures and analyzing them.
This class is needed to convert the keywords from a generic database to the standard ones...
Class for storing model, its restraints, constraints, and particles.
Classes to handle different kinds of restraints.
Restraints for handling electron microscopy maps.
Nested sampling-based optimization of representation.
Create a restraint between consecutive TempResidue objects or an entire PMI Molecule object...
Create movers and set up constraints for PMI objects.
A class to create an excluded volume restraint for a set of particles at a given resolution.
Automatically setup System and Degrees of Freedom with a formatted text file.
Restraints for handling cross-linking data.
Python classes to represent, score, sample and analyze models.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
this class handles a cross-link dataset and do filtering operations, adding cross-links, merge datasets...
Support for the RMF file format for storing hierarchical molecular data and markup.