IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
automatic.py
1 ## \example pmi/automatic.py
2 """This script shows how to use the BuildSystem macro to construct large
3  systems with minimal code
4 """
5 
6 from __future__ import print_function
7 import IMP
8 import IMP.atom
9 import IMP.rmf
10 import IMP.pmi
11 import IMP.pmi.topology
12 import IMP.pmi.dof
13 import IMP.pmi.macros
14 import IMP.pmi.restraints
16 import tempfile
17 import os
18 import sys
19 
20 IMP.setup_from_argv(sys.argv, "Automatic setup of a large system")
22  print("This example is too slow to test in debug mode - run without")
23  print("internal tests enabled, or without the --run-quick-test flag")
24  sys.exit(0)
25 
26 # This is the topology table format.
27 # It allows you to create many components in a simple way
28 # By default it sets up each molecule as a rigid body, filling in missing
29 # pieces with beads
30 # You can create multiple domains by specifying different segments, as
31 # in Rpb1 below
32 # You can also create copies of molecules by appending '.X' to the name,
33 # as in Rpb4 below
34 topology = '''
35 |molecule_name|color|fasta_fn|fasta_id|pdb_fn|chain|residue_range|pdb_offset|bead_size|em_residues_per_gaussian|rigid_body|super_rigid_body|chain_of_super_rigid_bodies|
36 |Rpb1 |blue |1WCM.fasta|1WCM:A|1WCM_fitted.pdb|A|1,100 |0 |5|0 |1|1,2| |
37 |Rpb1 |cyan |1WCM.fasta|1WCM:A|BEADS |A|101,150|0 |5|0 |2|1,2| |
38 |Rpb2 |red |1WCM.fasta|1WCM:B|1WCM_fitted.pdb|B|1,END |0 |5|0 |3|1 | |
39 |Rpb3 |green |1WCM.fasta|1WCM:C|1WCM_fitted.pdb|C|1,END |0 |5|0 |4|1 | |
40 |Rpb4 |orange |1WCM.fasta|1WCM:D|1WCM_fitted.pdb|D|1,END |0 |5|0 |5|1,3| |
41 |Rpb4.1|yellow |1WCM.fasta|1WCM:D|1WCM_fitted.pdb|D|1,END |0 |5|0 |6|1,3| |
42 |Rpb4.2|salmon |1WCM.fasta|1WCM:D|1WCM_fitted.pdb|D|1,END |0 |5|0 |7|1,3| |
43 |Rpb5 |gold |1WCM.fasta|1WCM:E|BEADS | |1,50 | |5|0 |8|1 | |
44 |Rpb5 |pink |1WCM.fasta|1WCM:E|IDEAL_HELIX | |51,100 | |5|0 |8|1 | |
45 '''
46 
47 # Normally the topology table is kept in a text file but here we just write
48 # it to a temporary one
49 tf = tempfile.NamedTemporaryFile(delete=False, mode='w')
50 tf.write(topology)
51 tf.close()
52 
53 # The TopologyReader reads the text file, and the BuildSystem macro
54 # constructs it
55 mdl = IMP.Model()
57  tf.name, pdb_dir=IMP.pmi.get_example_path('data/'),
58  fasta_dir=IMP.pmi.get_example_path('data/'),
59  gmm_dir=IMP.pmi.get_example_path('data/'))
61 # note you can call this multiple times to create a multi-state system
62 bs.add_state(reader)
63 hier, dof = bs.execute_macro()
64 
65 # ##################### RESTRAINTS #####################
66 output_objects = [] # keep a list of functions that need to be reported
67 
68 # Connectivity keeps things connected along the backbone (ignores if inside
69 # same rigid body)
70 crs = []
71 moldict = bs.get_molecules()[0]
72 mols = []
73 for molname in moldict:
74  for mol in moldict[molname]:
76  cr.add_to_model()
77  output_objects.append(cr)
78  crs.append(cr)
79  mols.append(mol)
80 
81 # Excluded volume - automatically more efficient due to rigid bodies
83  included_objects=mols)
84 evr.add_to_model()
85 output_objects.append(evr)
86 
87 
88 # ##################### SAMPLING #####################
89 
90 
91 # mix it up so it looks cool
93 
94 # Quickly move all flexible beads into place
95 dof.optimize_flexible_beads(100)
96 
98  mdl, root_hier=hier, monte_carlo_sample_objects=dof.get_movers(),
99  global_output_directory='auto_output/', output_objects=output_objects,
100  monte_carlo_steps=10, number_of_best_scoring_models=0, number_of_frames=5)
101 rex.execute_macro()
102 
103 os.remove(tf.name)
Restraints for keeping correct stereochemistry.
bool get_is_quick_test()
Definition: flags.h:183
def shuffle_configuration
Shuffle particles.
Definition: tools.py:1258
A macro to help setup and run replica exchange.
Definition: macros.py:68
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)
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
A macro to build a IMP::pmi::topology::System based on a TopologyReader object.
Definition: macros.py:583
Protocols for sampling structures and analyzing them.
Definition: macros.py:1
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Classes to handle different kinds of restraints.
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.
Python classes to represent, score, sample and analyze models.
Functionality for loading, creating, manipulating and scoring atomic structures.
Support for the RMF file format for storing hierarchical molecular data and markup.