Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TopologyBroker.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file TopologyBroker
11 /// @brief top-class (Organizer) of the TopologyBroker mechanism
12 /// @detailed responsibilities:
13 /// maintains list of ToplogyClaimers
14 /// maintains DofClaims -- exclusive or non-exclusively markedup dofs like BackboneClaim, IntraResClaim, JumpClaim
15 /// generates FoldTree, MoveMap, and collects samplers provided by TopologyClaimers
16 /// @author Oliver Lange
17 
18 #ifndef INCLUDED_protocols_topology_broker_TopologyBroker_hh
19 #define INCLUDED_protocols_topology_broker_TopologyBroker_hh
20 
21 // Unit Headers
23 
24 // Package Headers
27 
28 // Project Headers
34 
35 #ifdef __clang__
37 #endif
38 
39 #include <core/pose/Pose.fwd.hh> /// FIX THIS
42 #include <utility/pointer/ReferenceCount.hh>
43 #include <utility/exit.hh>
44 #include <utility/vector1.hh>
45 
46 // C/C++ headers
47 #include <cassert>
48 #include <string>
49 
51 
52 #ifdef WIN32
54 #endif
55 
56 
57 // option key includes
58 /* Topology Broker is the central class for the broking mechanism. The broker maintains a list of ToplogyClaimers. These Claimers
59 will be asked what kind of things they want to do (i.e., they return a list of DofClaims )
60 then the Broker asks each Claimer if foreign claims are acceptable. A claim can be disallowed. For instance, the RigidChunkClaimer,
61 can't accept any changes within its region of interest, and thus will disallow any claims to move BB-Torsions or to make jumps within its region.
62 The Broking process will be handled in two rounds ( generate_round1 and generate_final_claims ) to give Claimers the possibility to react on
63 the situation presented to them in round1.
64 
65 The Claimer needs to keep track himself what he can move and what was declined. This is not enforced any further. The idea is that the claimer
66 being asked to provide a mover will return a Mover class that moves the dofs it had claimed successfully.
67  -> notify via claim about each change you want to make to the pose
68  -> don't move anything which was declined.
69  --> be aware that multiple movers might move the same dof -- unless your claimer takes care of declining foreign claims.
70 
71 the process is carried out each time the apply is called ( since we might have different choices, e.g., different jumps, different ss-bonds, different chunks)
72 
73 the life of a job goes thru stages:
74 first apply is called, but the state is safed for further consulting during the run of the job:
75 
76 >>>apply
77 
78 broking ( round1 , final_round )
79 
80 setting up the pose --> pose is made from scratch!!
81  whatever you pass into apply will be ignored.(we call pose.clear() )
82  1. ) init_sequence ( make residues from sequence )
83  2. ) init_dofs ( initialize dofs , from fragments (jumps, bbtorsion), from pdb (rigid chunks)
84 
85 add_constraints
86 
87 >>>sampling within the protocol
88  during the run of the samplign protocol the TopologyBroker system can be consulted for
89  movers ( depending on stage )
90  adding chainbreaks ( depending on sequence separation )
91  switch to fullatom ( e.g., rigid chunks provide the full-atom sidechains of their input-pdb if available )
92  final_fold_tree ( which chainbreaks and jumps should the loop-closer remove before relax ? )
93 
94 */
95 
96 namespace protocols {
97 namespace topology_broker {
98 
102 public:
103  typedef TopologyClaimers::const_iterator const_iterator;
104  ///constructor
105  TopologyBroker();
106  virtual ~TopologyBroker();
107  TopologyBroker( TopologyBroker const& );
108  TopologyBroker const& operator = ( TopologyBroker const& );
109 
110  /// ---------------- Application Setup ------------------------------------
111  ///@brief add new Claimers to the broker ---- useful before a job is started
112  void add( TopologyClaimerOP cl );
113 
114  ///@brief use the input pose from the job (i.e., call new_decoy( pose ) )
115  void use_job_pose( bool setting ) {
116  bUseJobPose_ = setting;
117  }
118 
119  /// @brief Returns true if we are using the input pose from the job
120  /// (i.e. new_decoy(pose)), false otherwise.
121  bool use_job_pose() const {
122  return bUseJobPose_;
123  }
124 
125  /// @brief Returns the ith topology claimer if it exists.
127  assert(i >= 1 && i <= claimers_.size());
128  return claimers_[i];
129  }
130 
131  TopologyClaimers::const_iterator begin() const {
132  return claimers_.begin();
133  }
134 
135  TopologyClaimers::const_iterator end() const {
136  return claimers_.end();
137  }
138 
139  /// @brief Returns the number of claimers associated with the broker
141  return claimers_.size();
142  }
143 
144  /// ----------------------- Job Setup ------------------------------------------
145  ///@brief at the start of a job this is called, e.g., by the AbrelaxMover
146  /// it generates a pose with appropriate foldtree and initializes dofs, adds constraints, etc.
147  void apply( core::pose::Pose& );
148 
149  ////---------------------------------- Consulting ----------------------------------------------------
150  /// the following interface is for the Mover to consult the Broker during the course of a simulation
151  /// usually these calls a relayed to the Claimers only some will answer, others will ignore it.
152  /// e.g., ConstraintClaimer will not add a Mover, JumpClaimer and RigidChunkClaimer will add chainbreaks
153  /// a basic FragmentClaimer will not
154 
155  ///@brief return a set of Movers ( RandomMover, i.e. container of movers )
157 
158  ///@brief apply filter (TopologyClaimer::passes_filter() ) and raise exception EXCN_FILTER_FAILED if failed
159  void apply_filter( core::pose::Pose const&, abinitio::StageID, core::Real progress ) const;
160 
161  ///@brief if some claimer wants to influence the movemap for relax he can do it here:
163 
164  ///@brief the SlidingWindowLoopClosure needs pure fragments, because it changes the the residue number in the ShortLoopClosure part
165  /// thus extra hook for this --- > only some Claimers will answer
167 
168  ///@brief do we need to close loops ( unphysical chainbreaks have been introduced? )
169  bool has_chainbreaks_to_close() const;
170 
171  ///@brief add chainbreak variant residue to the unphysical chainbreaks
173  ///@brief check that each chainbreak residue has a chainbreak variant
174  bool check_chainbreak_variants( core::pose::Pose &pose ) const;
175 
176  ///@brief switch to fullatom --- some Claimers might help by providing template based side-chain information
178 
179  ///@brief access for hacky claimers
181  runtime_assert( final_fold_tree_ );
182  return *final_fold_tree_;
183  };
184 
185  ///@brief get the sequence claim that is consistent with the label,
186  /// throws EXCN_Unknown_SequenceLabel if not found
187  SequenceClaim& resolve_sequence_label( std::string const& label ) const;
188 
189  core::Size resolve_residue( std::string const& chain_label, core::Size pos ) const;
190 
191  void relay_message( ClaimerMessage& msg ) const;
192  //// ------------------------------- End Consulting --------------------------------------------
193 
194  bool has_sequence_claimer();
195 
196  core::pose::Pose const & current_pose() const {
197  return *current_pose_;
198  }
199 
200 private:
201  ///@brief first round claims are collected
202  void generate_sequence_claims( DofClaims& all_claims );
203 
204  ///@brief first round claims are collected
205  void generate_round1( DofClaims& all_claims );
206 
207  ///@brief second round claims are collected
208  void generate_final_claims( DofClaims& all_claims );
209 
210  ///@brief notify owner of accepted claims
211  void accept_claims( DofClaims& claims );
212 
213  ///@brief run thru list of claims, ask all claimers if this claims is acceptable --- > returns accepted claims in pre_accepted
214  /// throws EXCN_ExclusiveClaimDeclined if the call to the owners TopologyClaimer::accept_declined_claim( declined_claim ) returns false
215  bool broking( DofClaims const& all_claims, DofClaims& pre_accepted );
216 
217  ///@brief creates a fold-tree from the Jump- and CutClaims
218  /// throws EXCN_InvalidFoldTree at failure
219  void build_fold_tree( DofClaims& claims, Size nres );
220 
221  ///@brief create new pose from SeqClaims
222  void initialize_sequence( DofClaims& claims, core::pose::Pose& new_pose );
223 
224  ///@brief creates the list "to_be_closed_cuts_" from current fold-tree and CutClaims
225  void initialize_cuts( DofClaims& claims, core::pose::Pose& new_pose );
226 
227  ///@brief initialize dofs
228  void initialize_dofs( DofClaims& claims, core::pose::Pose& new_pose );
229 
230  ///@brief add constraints --> referred to Claimers ( e.g., ConstraintClaimer, RigidChunkClaimer )
231  void add_constraints( core::pose::Pose& ) const;
232 
233 private:
234  ///@brief vector of Claimers --- RigidChunkClaimer, FragmentClaimer, ConstraintClaimer, etc.
236 
237  //=============================================================================
238  //all these are derived infos and change each time that we use apply ( generate a new pose with foldtree etc )
239 
240  ///@brief list of dof-claims currently active
242 
243  ///@brief current pose has nres total_residues
245 
246  ///@brief the current fold-tree
248 
249  //// mutable here is hack to make wrong MembraneTopologyClaimer work --- don't want to clean up that guy right now...
250  ///@brief current final-fold-tree --- after removal to_bel_closed_cuts_
252 
253  ///@brief Scorefunction used in switch_to_fullatom
255 
256  ///@brief these cuts are not physical and should be closed ( i.e., chainbreak energy, loop-closing )
257  utility::vector1< Size > to_be_closed_cuts_; //keeps the residue number not the cut-nr --- thats safer.
258 
259  ///@brief these cuts are not physical and should be closed ( i.e., chainbreak energy, loop-closing )
260  utility::vector1< Size > start_pose_cuts_; //keeps the residue number not the cut-nr --- thats safer.
261 
263 
264  ///@brief we restart from the input pose... call steal( pose ) for all claimers
266 
268 }; //class TopologyBroker
269 
270 }
271 }
272 
273 #endif // INCLUDED_protocols_topology_broker_TopologyBroker_hh