7 from __future__
import print_function
20 import ihm.cross_linkers
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.")
44 "Command-line arguments needed to run this script. See the readme for more details"
48 run_output_dir =
"run_" + sys.argv[1]
49 topology_file = os.path.join(dat_dir, sys.argv[2])
50 h_param_file = os.path.join(dat_dir, sys.argv[3])
57 sampling_adh_xl_data = os.path.join(dat_dir,
"xlms/sampling_filtered_adh.dat")
58 sampling_bs3dss_xl_data = os.path.join(dat_dir,
"xlms/sampling_filtered_bs3dss.dat")
59 sampling_dmtmm_xl_data = os.path.join(dat_dir,
"xlms/sampling_filtered_dmtmm.dat")
61 evi_adh_xl_data = os.path.join(dat_dir,
"xlms/evicalc_filtered_adh.dat")
62 evi_bs3dss_xl_data = os.path.join(dat_dir,
"xlms/evicalc_filtered_adh.dat")
63 evi_dmtmm_xl_data = os.path.join(dat_dir,
"xlms/evicalc_filtered_adh.dat")
65 gmm_data = os.path.join(dat_dir,
"gmm/emd_22904.gmm.40.txt")
68 inter_xl_weight = 10.0
73 def modeling(output_dir, topology_file, h_param_file):
77 pdb_dir=os.path.join(dat_dir,
"pdb"),
78 fasta_dir=os.path.join(dat_dir,
"fasta"),
79 gmm_dir=os.path.join(dat_dir,
"gmm"),
84 root_hier, dof = bs.execute_macro(
97 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(165, 334)
98 ).get_selected_particles()
99 for prot
in [
"HDAC1"]:
102 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(8, 377)
103 ).get_selected_particles()
106 for prot
in [
"MTA1"]:
109 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(1, 165)
110 ).get_selected_particles()
111 for prot
in [
"MTA1"]:
114 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(334, 432)
115 ).get_selected_particles()
116 for prot
in [
"HDAC1"]:
119 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(1, 8)
120 ).get_selected_particles()
121 for prot
in [
"HDAC1"]:
124 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(377, 483)
125 ).get_selected_particles()
126 for prot
in [
"MBD3"]:
128 root_hier, molecule=prot, copy_index=0, residue_indexes=range(1, 296)
129 ).get_selected_particles()
130 for prot
in [
"P66A"]:
132 root_hier, molecule=prot, copy_index=0, residue_indexes=range(136, 179)
133 ).get_selected_particles()
134 for prot
in [
"RBBP4"]:
135 for cp
in [0, 1, 2, 3]:
137 root_hier, molecule=prot, copy_index=cp, residue_indexes=range(1, 425)
138 ).get_selected_particles()
140 fixed_set1_core_beads, fixed_set1_core = dof.disable_movers(
144 fixed_set2_beads, fixed_set2 = dof.disable_movers(
147 molecules = t.get_components()
154 nestor_restraints = []
159 for m
in root_hier.get_children()[0].get_children():
162 output_objects.append(cr)
164 print(
"Connectivity restraint applied")
170 included_objects=[root_hier], resolution=1000
172 output_objects.append(evr)
174 print(
"Excluded volume restraint applied")
181 xldbkc.set_standard_keys()
184 xldb_adh_sampling.create_set_from_file(
185 file_name=sampling_adh_xl_data, converter=xldbkc
190 database=xldb_adh_sampling,
196 linker=ihm.cross_linkers.edc,
201 xldb_bs3dss_sampling.create_set_from_file(
202 file_name=sampling_bs3dss_xl_data, converter=xldbkc
204 xlr_bs3dss_sampling = (
207 database=xldb_bs3dss_sampling,
213 linker=ihm.cross_linkers.bs3,
218 xldb_dmtmm_sampling.create_set_from_file(
219 file_name=sampling_dmtmm_xl_data, converter=xldbkc
221 xlr_dmtmm_sampling = (
224 database=xldb_dmtmm_sampling,
230 linker=ihm.cross_linkers.dsso,
234 output_objects.append(xlr_adh_sampling)
235 output_objects.append(xlr_bs3dss_sampling)
236 output_objects.append(xlr_dmtmm_sampling)
242 xldbkc.set_standard_keys()
245 xldb_adh_evicalc.create_set_from_file(file_name=evi_adh_xl_data, converter=xldbkc)
249 database=xldb_adh_evicalc,
255 linker=ihm.cross_linkers.edc,
260 xldb_bs3dss_evicalc.create_set_from_file(
261 file_name=evi_bs3dss_xl_data, converter=xldbkc
263 xlr_bs3dss_evicalc = (
266 database=xldb_bs3dss_evicalc,
272 linker=ihm.cross_linkers.bs3,
277 xldb_dmtmm_evicalc.create_set_from_file(
278 file_name=evi_dmtmm_xl_data, converter=xldbkc
280 xlr_dmtmm_evicalc = (
283 database=xldb_dmtmm_evicalc,
289 linker=ihm.cross_linkers.dsso,
293 output_objects.append(xlr_adh_evicalc)
294 output_objects.append(xlr_bs3dss_evicalc)
295 output_objects.append(xlr_dmtmm_evicalc)
297 nestor_restraints.append(xlr_adh_evicalc)
298 nestor_restraints.append(xlr_bs3dss_evicalc)
299 nestor_restraints.append(xlr_dmtmm_evicalc)
301 print(
"Cross-linking restraint applied")
305 root_hier, representation_type=IMP.atom.DENSITIES
306 ).get_selected_particles()
312 scale_target_to_mass=
True,
316 output_objects.append(emr)
317 nestor_restraints.append(emr)
318 print(
"EM Restraint Applied")
328 max_translation=max_shuffle_set2,
329 excluded_rigid_bodies=fixed_set1_core,
334 max_translation=max_shuffle_core,
335 excluded_rigid_bodies=fixed_set2,
340 with open(
"shuffle_config.err",
"w")
as shufferr:
341 shufferr.write(str(11))
344 print(f
"{'-'*50}\nExit code: {exit_code}\n{'-'*50}")
345 dof.optimize_flexible_beads(50)
352 xlr_adh_sampling.add_to_model()
353 xlr_bs3dss_sampling.add_to_model()
354 xlr_dmtmm_sampling.add_to_model()
355 xlr_adh_evicalc.add_to_model()
356 xlr_bs3dss_evicalc.add_to_model()
357 xlr_dmtmm_evicalc.add_to_model()
359 print(
"Replica Exchange Maximum Temperature : " + str(rex_max_temp))
364 monte_carlo_temperature=1.0,
365 replica_exchange_minimum_temperature=1.0,
366 replica_exchange_maximum_temperature=rex_max_temp,
367 monte_carlo_sample_objects=dof.get_movers(),
368 global_output_directory=run_output_dir,
369 output_objects=output_objects,
370 monte_carlo_steps=10,
371 number_of_best_scoring_models=0,
378 nestor_restraints=nestor_restraints,
379 h_param_file=h_param_file,
383 ns_return, ns_exit_code = ns.execute_nested_sampling2()
384 return ns_return, ns_exit_code
387 with open(
"errors.log",
"w")
as errf:
388 with contextlib.redirect_stdout(
None):
389 with contextlib.redirect_stderr(errf):
390 nested_sampling_output, nested_sampling_exitcode = modeling(
391 run_output_dir, topology_file, h_param_file
395 if nested_sampling_output
is not None:
396 print(f
"////{nested_sampling_output}")
398 sys.exit(nested_sampling_exitcode)
def get_example_path
Return the full path to one of this module's example files.
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.