Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IterativeBase.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 ///
10 /// @author Oliver Lange
11 
12 
13 #ifndef INCLUDED_protocols_abinitio_IterativeBase_hh
14 #define INCLUDED_protocols_abinitio_IterativeBase_hh
15 
16 // Unit Headers
17 //#include <protocols/abinitio/IterativeAbrelax.fwd.hh>
18 
19 // Package Headers
23 
24 // Project Headers
26 #include <protocols/loops/Loops.hh>
27 
28 #include <core/types.hh>
29 #include <core/pose/Pose.fwd.hh>
30 // AUTO-REMOVED #include <core/io/silent/SilentStruct.fwd.hh>
31 // AUTO-REMOVED #include <core/io/silent/SilentFileData.hh>
33 
34 
35 #include <utility/options/OptionCollection.hh>
36 
37 
38 // Utility headers
39 //for dynamic patching
40 #include <utility/options/keys/FileVectorOptionKey.hh>
41 #include <utility/io/ozstream.fwd.hh>
42 
43 // Third-party Headers
44 #include <boost/functional/hash.hpp>
45 
46 
47 //// C++ headers
48 #include <string>
49 
51 #include <utility/vector1.hh>
52 
53 
54 namespace protocols {
55 namespace abinitio {
56 
60 public:
69  // CEN2FULLATOM_NON_POOL_DECOYS,
71  // FLEX_CORE_RESAMPLING,
73  FINISHED //keep last
74  };
75 
78 
79  ///@brief archive is finished when at last stage
80  virtual bool finished() const { return stage_ >= finish_stage_; };
81 
82  ///@brief do initializing work that requires fully setup object here
83  virtual void initialize();
84 
85  ///@brief where to stop ?
86  void set_finish_stage( IterationStage setting ) {
87  finish_stage_ = setting;
88  }
89 
90  ///@brief calls increment_stage() if appropriate
91  void test_for_stage_end();
92 
93  ///@brief overloaded to make input decoys appear the same as decoys coming from batches
94  virtual void init_from_decoy_set( core::io::silent::SilentFileData const& sfd );
95 
96  ///@brief we are always ready to generate a new batch
97  virtual bool ready_for_batch() const { return true; };
98 
99  ///@brief we are not interested in batches that were generated in old stages
100  virtual bool still_interested( jd2::archive::Batch const& batch ) const;
101 
102  ///@brief generate a new batch, use different recipe according to current stage
103 
104  ///@brief generate a new batch, use different recipe according to current stage
105  virtual void generate_batch();
106 
107  ///@brief while waiting for jobs to finish
108  virtual void idle();
109  virtual void rescore();
110  virtual void save_status( std::ostream& ) const;
111  virtual void restore_status( std::istream& );
112 
113  ///@brief overloaded to handel special convergence check 'pool_converged_rmsd'
115 
116  ///@brief setup JumpNrEvaluator
118 
119  ///@brief overloaded so we can test for end of IterationStage after reading
120  virtual void read_structures( core::io::silent::SilentFileData& returned_decoys, jd2::archive::Batch const& batch );
121 
122  ///@brief generate flags and stuff for the out-sourced evaluation ---> such that score_final column is returned for each decoy
123  /// note needs to be public, since IterativeCentroid calls this from IterativeFullatom to prepare evaluation for soon to be full-atom decoys
124  // cen2fullatom-stage ( stage5 )
125  virtual void gen_evaluation_output( jd2::archive::Batch& batch, bool fullatom = false );
126 
127  // overload by IterativeCentroid for rerouting to fullatom archive
128  virtual void gen_diversity_pool( jd2::archive::Batch&, bool fullatom = false );
129 
130  // cen2fullatom-stage ( stage5 )
131  virtual void gen_dynamic_patches( jd2::archive::Batch& batch );
132 
133  virtual void update_noesy_filter_files(
134  std::string const& current,
135  bool fullatom
136  );
137 
138  // ///@brief need to get these from the IterativeCentroid to IterativeFullatom at end of stage5 ;
139 // std::string const& first_noesy_fa_cst_file() const { return first_noesy_fa_cst_file_; }
140 protected:
141  //void set_first_noesy_fa_cst_file( std::string setting ) { first_noesy_fa_cst_file_ = setting; }
142 
143 // core::Real noesy_assign_float_cycle() const { return noesy_assign_float_cycle_; }
147 
149  /// ------------- helper functions to be used from generate_batch() --------------------
150 
156  void gen_cen2fullatom( jd2::archive::Batch& batch );
159  jd2::archive::Batch const& batch,
160  core::io::silent::SilentStructOPs& start_decoys,
161  core::Real score_cut_per_batch
162  );
164 
165  /// actually run the assignment machinery (only after batch is started to keep archive from hogging the queue... )
167 
168  /// generate cst-input from current assigned noesy data
170 
171  /// some helpers for the helpers
174  core::fragment::FragSet const& frags,
175  std::string const& out_pairings_file,
176  std::string const& out_frag_ss_file
177  ) const;
178  void compute_cores();
179 
180  ///these are set by the cmd-line options iterative::fa_score and iterative::fa_score_patch
181  std::string const& fa_score() const {
182  return fa_score_;
183  }
184  std::string const& fa_score_patch() const {
185  return fa_score_patch_;
186  }
187 
188  ///these are set by the cmd-line options iterative::cen_score and iterative::cen_score_patch
189  std::string const& cen_score() const {
190  return cen_score_;
191  }
192  std::string const& cen_score_patch() const {
193  return cen_score_patch_;
194  }
195 
196  ///@brief this is set from score::atom_pair_constraint of the pool-scorefunction
199  }
200 
201  ///@brief this is set from score::atom_pair_constraint of the pool-scorefunction
203  overall_cstfilter_weight_ = setting;
204  }
205 
206  ///OBSOLET cores are computed by compute_cores() in idle()
208  if ( i == 1 ) { return core15_; };
209  if ( i == 2 ) { return core2_; };
210  if ( i == 3 ) { return core3_; };
211  if ( i == 4 ) { return core4_; };
212  runtime_assert( false );
213  return core2_; //happy compiler
214  }
215 
216  ///@brief current stage?
218  return stage_;
219  }
220 
221  ///@brief needed for writing of psi-pred fiels (guess_pairings_from_secondary_structure)
222  std::string const& target_sequence() const {
223  return target_sequence_;
224  }
225 
226  void set_stage( IterationStage setting ) {
227  stage_ = setting;
228  }
229 
230 
231  ///@brief cluster structures with min_diversity_list_[ stage_ ] as cluster:radius
232  void cluster();
233 
234  std::string const& chemshift_column() const {
235  return chemshift_column_;
236  }
237 
238  void test_broker_settings( jd2::archive::Batch const& batch );
239  void setup_filter_cst( core::Real weight );
240 
241 private:
242 
244  ///@brief score a pose with Pool-Scoring function (adds necessary data to pose (RDC, constraints, etc ) )
245  virtual void score( core::pose::Pose& pose ) const;
246 
247  void collect_alternative_decoys( SilentStructs primary_decoys, std::string alternative_decoy_file, SilentStructVector& output_decoys );
248 
249  ///@brief what is the expected lowest acceptance ratio at the current stage ?
251 
252  ///@brief [OBSOLET] add score_coreX and rms_coreX evaluators (and columns) with 0.0 weight
253  void add_core_evaluator( loops::Loops const& core, std::string const& core_tag );
254 
255  ///@brief necessary steps to go to next stage... e.g., saving snapshot of archive
256  void increment_stage();
257 
258  // void read_noisy_assign_data_from_last_batch();
259 
262 
263  void setup_autoNOE();
264  void do_dynamic_patching(
265  jd2::archive::Batch& batch,
266  utility::io::ozstream& flags,
268  utility::options::FileVectorOptionKey const& key
269  ) const;
270 private:
271  /// ----------------- -- private data members -- --------------------
272 
273  /// ------------------------------ stage - control --------------------------
274  ///@brief current stage
276 
277  ///@brief end-condition
279 
280  ///@brief indices of prominent batches ( STATUS file )
283 
284  /// --------------------------------- other ------------------------------------
285  ///@brief toggle to keep track of the enumerate-pairings mode .. want to run this only every 2nd batch
287 
288  ///@brief [OBSOLET?] keep track when idle() has been run ...
290 
291  ///core-regions --- used in IterativeFullatom for the "rigid-core" sampling step...
296 
297  /// ----------- some cmd-line controlled settings -----------------
298 
299  ///@brief how many structures are maximally produced in stage X
300  utility::vector1< int > max_nstruct_list_; //-1 --> skip stage, 0 infinite, N>0 make a maximum of N structures.
301 
302  ///@brief cluster:radius for minimum diversity in stage X
304 
305  ///@brief minimum acceptance ratio .. current_accept_ratio < target_accept_ratio[ stage_ ] --> increment_stage
307 
308  ///@brief for RMSD ... e.g., in:file:native
310 
311  ///@brief from cmd-line cen-score and patch names
314 
315  ///@brief from cmd-line fa-score and patch names
318 
319  ///@brief this is set from score::atom_pair_constraint of the pool-scorefunction
321 
322  std::string target_sequence_; //read from in:file:fasta in c'stor
323 
326 
329 
332 
333 
334  //hash value to see if decoys for noesy assign have changed
336  boost::hash<std::string> hasher;
337 
338  ///@brief even in centroid mode the end of abinitio will have a fast relax... enables cs-score and noe-assignment
340 
343 
344  ///@brief even in centroid mode the end of abinitio will have a fast relax... enables cs-score and noe-assignment
346 
347 
348  ///@brief use the score_variations from EvaluatedArchive to determine new sampling weights
350 
352 
354  ///@brief cache some of the experimental data so we don't reload from file for each evaluation
355  mutable core::scoring::ResidualDipolarCouplingOP rdc_data_; //need to cache this to avoid reading RDC file each time...
358  /// ------------------ register cmdline options ---------------------------
359 
360  utility::options::OptionCollection const vanilla_options_; //options before stage-dpd auto-noe-options were added
361 
362 
363 private:
364  static bool options_registered_;
365 public:
366  static void register_options();
367 
368 };
369 
370 
371 }
372 }
373 
374 #endif