Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IterativeFullatom.cc
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 /// @file IterativeAbrelax
10 /// @brief iterative protocol starting with abinitio and getting progressively more concerned with full-atom relaxed structures
11 /// @detailed
12 ///
13 ///
14 /// @author Oliver Lange
15 
16 
17 // Unit Headers
20 
21 // Package Headers
22 
23 // Project Headers
24 #include <core/types.hh>
29 
30 // ObjexxFCL Headers
31 
32 // Utility headers
33 #include <utility/io/ozstream.hh>
34 #include <utility/file/FileName.hh>
35 
36 // Option Headers
37 // AUTO-REMOVED #include <basic/options/keys/constraints.OptionKeys.gen.hh>
38 #include <basic/Tracer.hh>
39 #include <basic/MemTracer.hh>
40 
41 //// C++ headers
42 #include <cstdlib>
43 #include <string>
44 
45 // Utility headers
46 #include <basic/options/option_macros.hh>
47 
50 #include <utility/vector1.hh>
51 
52 
53 static basic::Tracer tr("protocols.iterative");
54 using basic::mem_tr;
55 
56 using core::Real;
57 using namespace core;
58 using namespace basic;
59 using namespace basic::options;
60 using namespace basic::options::OptionKeys;
61 
62 OPT_1GRP_KEY( Real, iterative, perturb_fa_resampling )
63 OPT_1GRP_KEY( Real, iterative, fapool_noesy_cst_weight )
64 OPT_1GRP_KEY( Real, iterative, fapool_chemicalshift_weight )
65 OPT_1GRP_KEY( Real, iterative, fapool_first_noesy_cycle_nr )
66 
67 bool protocols::abinitio::IterativeFullatom::options_registered_( false );
68 
69 void protocols::abinitio::IterativeFullatom::register_options() {
71  if ( !options_registered_ ) {
72  NEW_OPT( iterative::perturb_fa_resampling, "perturb resample_stage2 start structures by this amount", 2.0 );
73  NEW_OPT( iterative::fapool_noesy_cst_weight, "weight to apply to fullatom pool for noesy-autoassigned constraints", 5);
74  NEW_OPT( iterative::fapool_chemicalshift_weight, "weight to apply to chemical shifts in centroid pool rescoring", 5 );
75  NEW_OPT( iterative::fapool_first_noesy_cycle_nr, "start noesy assignment with this cycle selector", 6.0);
76  options_registered_ = true;
77  }
78 }
79 
80 namespace protocols {
81 namespace abinitio {
82 using namespace jd2::archive;
83 
84 IterativeFullatom::IterativeFullatom()
85  : IterativeBase( "fullatom_pool" )
86 {
87  perturb_start_structures_ = option[ iterative::perturb_fa_resampling ];
88 }
89 
92  // --- setup scorefxn
96  mem_tr << "before setup fa-score function" << std::endl;
97 
100 
101  // if local evaluation done by cmdline_cst evaluator
102  set_scorefxn( scorefxn );
103 
104  //Base class sets chainbreak scores as convenience if not in patches..
105  // this will go wrong in fullatom mode, since chainbreaks not returned ... remove here
106  if ( !evaluate_local() ) {
107  remove_evaluation( "linear_chainbreak");
108  remove_evaluation( "overlap_chainbreak" );
109 
111  set_weight( "noesy_autoassign_cst", option[ iterative::fapool_noesy_cst_weight ]()*overall_cstfilter_weight());
112  }
113  if ( option[ iterative::fapool_chemicalshift_weight ].user() ) {
114  set_weight( chemshift_column(), option[ iterative::fapool_chemicalshift_weight ]() );
115  }
116  } else { //evaluate local
117  set_weight( "score", 1.0 );
118  set_weight( "atom_pair_constraint", 0 ); //this is now done via FILTER mechanism of ConstraintClaimer only !
119  if ( std::abs( scorefxn->get_weight( scoring::atom_pair_constraint ) - overall_cstfilter_weight() ) > 0.1 ) {
122  }
123  scorefxn->set_weight( scoring::atom_pair_constraint, 0 );
124 
125  set_weight( "rdc", scorefxn->get_weight( scoring::rdc ) );
126  scorefxn->set_weight( scoring::rdc, 0 );
127 
128  set_scorefxn( scorefxn );
129  }
130  set_noesy_assign_float_cycle( option[ iterative::fapool_first_noesy_cycle_nr ]() );
132  set_weight( "score_fa", evaluate_local() ? 0.0 : 1.0 );
133  set_weight( "prefa_centroid_score", 0.0 );
134  set_weight( "prefa_clean_score3", 0.0 );
135  }
136 }
137 
139  return ( stage() > LAST_CENTROID_START );
140  }
141 
142 ///@details generate new batch...
143 /// type of batch depends on stage_. we switch to next stage based on some convergence criteria:
144 /// right now it is how many decoys were accepted from last batch.. if this number drops sufficiently ---> next stage...
145 /// (maybe need to put a safeguard in here: ratio small but at least XXX decoys proposed since last batch... )
146 ///
148 
149  //start new batch
150  Batch& batch( manager().start_new_batch() );
151  tr.Info << "\ngenerate batch from " << name() << " " << batch.batch() << "\n";
152  mem_tr << "IterativeFullatom::generate_batch " << stage() << " " << batch.batch() << std::endl;
153  batch.set_intermediate_structs( false );
154 
155  cluster();
156 
157  gen_noe_assignments( batch );
158  gen_resample_fragments( batch );
159  gen_evaluation_output( batch, true /*fullatom*/ );
160 // if ( stage() == FLEX_CORE_RESAMPLING ) {
161 // gen_resample_core( batch, true /*flex*/ );
162 // }
163  if ( stage() == RIGID_CORE_RESAMPLING ) {
164  gen_resample_core( batch, false /*flex*/ );
165  }
166 
167 
168  tr.Info << std::endl;
169  //finalize
170  manager().finalize_batch( batch );
171  // don't want to reset counters too often... if we run out of steam the QUEUE EMPTY pathway will make sure that we do more runs
172  // if ( proposed_since_last_batch() > 500 ) {
173  // reset_accept_counter();
174  // }
175  mem_tr << "IterativeFullatom::generated_batch " << std::endl;
176  //now it is best time to do this... JobQueue is definitely filled up....
177  reassign_noesy_data( batch );
178 
179 
180 
181 }
182 
183 
184 /// ============================================================================
185 /// ----------- methods to make new batches ------------
186 /// ----- each method should only "append" to broker and flags -----
187 /// ============================================================================
188 
189 
190 void IterativeFullatom::gen_resample_core( Batch& batch, bool flex ) {
191  //copy pool as input decoys
192  batch.set_has_silent_in();
194  for ( SilentStructs::const_iterator it = decoys().begin(); it != decoys().end(); ++it ) {
195  sfd.add_structure( *it ); //only add OP to sfd
196  }
197  sfd.write_all( batch.silent_in() );
198 
199  //take rigid-core definition that has most individual loops --- most jumps
200  Size most_jumps( 0 ), nr_jumps( 0 );
201  for ( Size i = 2; i<=4; ++i ) {
202  if ( core( i ).num_loop() > nr_jumps ) {
203  nr_jumps = core( i ).num_loop();
204  most_jumps = i;
205  }
206  }
207 
208  utility::io::ozstream broker( batch.broker_file(), std::ios::app );
209  broker << "\nUSE_INPUT_POSE" << std::endl;
210 
211  if ( most_jumps ) {
212  core( most_jumps ).write_loops_to_file( batch.dir()+"core.rigid", "RIGID" );
213  broker << "\nCLAIMER RigidChunkClaimer \n"
214  << "REGION_FILE "<< batch.dir() << "core.rigid\n"
215  << ( flex ? "KEEP_FLEXIBLE\n" : "" )
216  << "END_CLAIMER\n\n" << std::endl;
217  }
218 
219  broker << "\nCLAIMER StartStructClaimer\n"
220  << "PERTURB " << perturb_start_structures_ << "\n"
221  << "END_CLAIMER\n\n" << std::endl;
222 
223  broker.close();
224 
225  utility::io::ozstream flags( batch.flag_file(), std::ios::app );
226  flags << "-abinitio::skip_stages 1 2" << std::endl;
227 
228  add_fullatom_flags( batch );
229  batch.nstruct() = std::max( 1, int( 1.0*batch.nstruct() / ( 1.0*decoys().size() ) ) );
230 }
231 
232 } //abinitio
233 } //protocols