Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WorkUnit_BatchRelax.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 // (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 protocols/wum/WorkUnitBase.cc
11 /// @brief
12 /// @author Mike Tyka
13 
17 
18 // AUTO-REMOVED #include <core/io/silent/SilentFileData.hh>
19 // AUTO-REMOVED #include <core/io/silent/SilentStructFactory.hh>
21 // AUTO-REMOVED #include <core/io/silent/ProteinSilentStruct.hh>
22 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
24 // AUTO-REMOVED #include <core/pose/util.hh>
25 // AUTO-REMOVED #include <core/scoring/rms_util.hh>
26 #include <basic/options/option.hh>
27 #include <basic/options/keys/relax.OptionKeys.gen.hh>
28 #include <basic/options/keys/wum.OptionKeys.gen.hh>
29 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
30 // AUTO-REMOVED #include <basic/options/keys/symmetry.OptionKeys.gen.hh>
31 #include <basic/options/keys/edensity.OptionKeys.gen.hh>
34 // AUTO-REMOVED #include <core/id/AtomID_Map.hh>
35 #include <core/pose/Pose.hh>
36 // AUTO-REMOVED #include <core/chemical/util.hh>
40 #include <basic/Tracer.hh>
42 // AUTO-REMOVED #include <protocols/simple_moves/symmetry/SetupForSymmetryMover.hh>
44 // AUTO-REMOVED #include <core/scoring/symmetry/SymmetricScoreFunction.hh>
45 // AUTO-REMOVED #include <protocols/electron_density/util.hh>
46 
50 #include <utility/vector1.hh>
51 
52 //Auto Headers
53 #include <core/kinematics/Jump.hh>
54 
55 
56 #if defined(WIN32) || defined(__CYGWIN__)
57  #include <ctime>
58 #endif
59 
60 namespace protocols {
61 namespace relax {
62 
63 
64 static basic::Tracer TR("WorkUnit_BatchRelax");
65 
66 
67 /// WorkUnit_BatchRelax
68 
69 WorkUnit_BatchRelax::WorkUnit_BatchRelax(): protocols::wum::WorkUnit_SilentStructStore() {}
70 
72 
75  return new WorkUnit_BatchRelax( *this );
76 }
77 
78 
79 void
81  using namespace basic::options;
82  using namespace basic::options::OptionKeys;
83 
84  // scorefxn and sequence file are controllable from commandline - unfortunately that means
85  // there can only be one setting. The batch solution handles this better but is also much more
86  // restricted in a way.
87  if( !scorefxn_ ) {
90  }
91  protocols::relax::FastRelax relax( scorefxn_, option[ OptionKeys::relax::sequence_file ]() );
92  if( native_pose_ ){
94  }
95 
96  TR << "Pre Processing: " << std::endl;
97  pre_process();
98 
99  // relax handles all the silent structures in situ
100  if ( option[ OptionKeys::constraints::cst_fa_file ].user() ) {
101  core::pose::Pose pose;
103  ss->fill_pose( pose );
105  relax.batch_apply( decoys().store(), cstset );
106  } else {
107  relax.batch_apply( decoys().store() );
108  }
109 
110  TR << "Post Processing: " << std::endl;
111 
112  post_process();
113 
114  TR << "NRELAXED: " << decoys().size() << std::endl;
115 }
116 
117 
118 void
120  native_pose_ = native_pose;
121 }
122 
123 
124 // @brief Hook for post processing such as rescoring etc.
125 void
127  TR << "WorkUnit_BatchRelax::pre_process()" << std::endl;
128 }
129 
130 
131 // @brief Hook for post processing such as rescoring etc.
132 void
134  TR << "WorkUnit_BatchRelax::post_process()" << std::endl;
135 }
136 
137 
138 // -----------------------------------------------------------------------
139 //
140 // WorkUnit_BatchRelax_and_PostRescore
141 //
142 
143 
144 
145 
148 {
149  set_defaults();
150 }
151 
152 
153 void
155  using namespace basic::options;
156  using namespace basic::options::OptionKeys;
157  trim_proportion_ = option[ OptionKeys::wum::trim_proportion ]();
158 
159  if( option[ OptionKeys::wum::extra_scorefxn_ref_structure ].user() ){
160  core::import_pose::pose_from_pdb( ref_pose_, option[ OptionKeys::wum::extra_scorefxn_ref_structure ]() );
161  // We do the following to save memory, since we dont actually need anything but the backbone coordiantes from this pose.
162  //core::util::switch_to_residue_type_set( ref_pose_, core::chemical::CENTROID);
163  if( !ref_pose_.is_fullatom() ){
165  }
166  }
167 }
168 
169 
171 
174 {
175  return new WorkUnit_BatchRelax_and_PostRescore( *this );
176 }
177 
178 
179 // Here the pre_process routing will take each structure in turn and apply a new score function including, potentially,
180 // the electron density score. THen it will remove the worst n percent of the structures
181 void
183  // if trimming is to occur rescore all the input decoys and trim on combined score
184  if( trim_proportion_ > 0.0 ){
186  trim();
187  }
188 }
189 
190 // Here the post_process routing will take each structure in turn and apply a new score function including, potentially,
191 // the electron density score.
192 
193 void
196 }
197 
198 
199 void
201  using basic::options::option;
202  using namespace basic::options;
203  using namespace core;
204  //bool superimpose_to_ref = true;
205 
206  TR << "rescore_all_decoys" << std::endl;
207 
208  if ( !basic::options::option[ OptionKeys::wum::extra_scorefxn ].user() ) return;
209 
210  core::Size starttime = time(NULL);
211 
212  core::scoring::ScoreFunctionOP extra_scorefxn;
213  std::string weight_set = option[ OptionKeys::wum::extra_scorefxn];
214  TR << "weights_set " << weight_set << std::endl;
215  extra_scorefxn = core::scoring::ScoreFunctionFactory::create_score_function( weight_set );
216 
217  core::scoring::ScoreFunctionOP combined_scorefxn;
218  combined_scorefxn = core::scoring::ScoreFunctionFactory::create_score_function( weight_set );
219  combined_scorefxn->merge( *scorefxn_ );
220 
221  for( protocols::wum::SilentStructStore::iterator struc = decoys().begin(); struc != decoys().end(); ++ struc ){
222  core::pose::Pose pose;
223  (*struc)->fill_pose( pose );
224 
225  if( !pose.is_fullatom() ){
226  TR.Debug << "Switching struct to fullatom" << std::endl;
228  }
229 
230 
231  if( ref_pose_.total_residue() > 0 ){
234  sm.apply( pose );
235  }
236 
237 
238  if ( option[ OptionKeys::edensity::mapfile ].user() ) {
240  setup_for_density.apply( pose );
241  }
242 
243  core::Real the_extra_score = (*extra_scorefxn)(pose);
244 
245 
246  if( option[ OptionKeys::wum::extra_scorefxn_relax]() > 0 ){
247  // combine the score functions into one
248 
249 
250  //
251  core::Size pre_relax_time = time(NULL);
252  relax::FastRelax final_relax( combined_scorefxn, option[ OptionKeys::wum::extra_scorefxn_relax]() );
253  final_relax.apply( pose );
254 
255  // make sure the total score reflects the normal score, not the combined score. (that is saved seperately)
256  core::Real normal_score = (*scorefxn_)( pose );
257  (*struc)->fill_struct( pose );
258  core::Size post_relax_time = time(NULL);
259 
260  TR << "extra_scorefxn_relax time: " << (post_relax_time - pre_relax_time ) << " " << normal_score << std::endl;
261 
262 
263  }
264 
265 
266  (*struc)->add_energy( "extra_score", the_extra_score );
267  (*struc)->add_energy( "combined_score", the_extra_score + (*struc)->get_energy("score") );
268  TR << "ExtraScore: " << the_extra_score << " " << the_extra_score + (*struc)->get_energy("score") << std::endl;
269  }
270 
271  core::Size endtime = time(NULL);
272 
273  TR << "rescore_all_decoys.end " << (endtime - starttime) << std::endl;
274 
275 }
276 
277 
278 void
280  decoys().sort_by("combined_score");
281  decoys().limit( (core::Size)( core::Real(decoys().size() * (1.0 - trim_proportion_)) ));
282 }
283 
284 
285 }
286 }
287