Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RotamerRecoveryMover.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 src/protocols/rotamer_recovery/RotamerRecoveryMover.cc
11 /// @brief A wrapper that measures how similar the rotamers are between before and after running the child mover
12 /// @author Matthew O'Meara (mattjomeara@gmail.com)
13 /// Adapted from:
14 /// protocols::optimize_weights::IterativeOptEDriver::measure_rotamer_recovery()
15 /// and apps::pilot::doug::rotamer_prediction_benchmark()
16 
18 #include <string>
19 
20 
21 // Setup Mover
23 namespace protocols{
24 namespace rotamer_recovery{
25 
28 {
30 }
31 
34  return new RotamerRecoveryMover;
35 }
36 
39 {
40  return "RotamerRecoveryMover";
41 }
42 
43 }
44 }
45 
46 
47 // Unit Headers
48 #include <protocols/moves/Mover.hh>
51 
52 // Project Headers
53 #include <basic/Tracer.hh>
55 // AUTO-REMOVED #include <core/graph/Graph.hh>
60 // AUTO-REMOVED #include <core/pack/task/operation/TaskOperationFactory.hh>
61 // AUTO-REMOVED #include <core/pose/Pose.hh>
62 // AUTO-REMOVED #include <core/pose/PDBInfo.hh>
63 // AUTO-REMOVED #include <core/pose/util.hh>
64 // AUTO-REMOVED #include <core/pack/dunbrack/DunbrackRotamer.hh>
65 // AUTO-REMOVED #include <core/pack/dunbrack/RotamerLibrary.hh>
66 // AUTO-REMOVED #include <core/scoring/Energies.hh>
69 // AUTO-REMOVED #include <core/scoring/TenANeighborGraph.hh>
70 #include <core/types.hh>
71 // AUTO-REMOVED #include <protocols/simple_moves/PackRotamersMover.hh>
77 
78 // Option System Headers
79 #include <basic/options/option.hh>
80 #include <basic/options/keys/in.OptionKeys.gen.hh>
81 #include <basic/options/keys/out.OptionKeys.gen.hh>
82 #include <basic/options/keys/corrections.OptionKeys.gen.hh>
83 
84 // Utility Headers
85 #include <utility/vector1.hh>
86 #include <utility/exit.hh>
87 #include <utility/file/FileName.hh>
88 #include <utility/tag/Tag.hh>
89 
90 // Numeric Headers
91 // AUTO-REMOVED #include <numeric/angle.functions.hh>
92 
93 // C++ Headers
94 #include <algorithm>
95 #include <iostream>
96 // AUTO-REMOVED #include <fstream>
97 
98 //Auto Headers
99 #include <core/kinematics/Jump.hh>
101 #include <utility/excn/Exceptions.hh>
102 #include <utility/vector0.hh>
103 
104 //using std::ios::app;
105 using std::endl;
106 using std::max;
107 using std::ostream;
108 using std::string;
109 using core::Real;
110 using core::Size;
112 using core::pose::PoseOP;
121 using basic::Tracer;
122 using utility::vector1;
132 
133 namespace protocols {
134 namespace rotamer_recovery {
135 
136 static Tracer TR("protocol.rotamer_recovery.RotamerRecoveryMover");
137 
139  rotamer_recovery_( NULL ),
140  scfxn_(NULL),
141  task_factory_(new TaskFactory)
142 {
143  task_factory_->push_back( new InitializeFromCommandline );
144  task_factory_->push_back( new RestrictToRepacking );
145 }
146 
148  RotamerRecoveryOP rotamer_recovery,
149  ScoreFunctionOP scfxn,
150  TaskFactoryOP task_factory) :
151  rotamer_recovery_(rotamer_recovery),
152  scfxn_( scfxn ),
153  task_factory_( task_factory )
154 {}
155 
157 
159  //utility::pointer::ReferenceCount(),
160  Mover( src ),
161  rotamer_recovery_( src.rotamer_recovery_ ),
162  scfxn_( src.scfxn_ ),
163  task_factory_( src.task_factory_ )
164 {}
165 
166 
167 void
169  using basic::options::option;
170  using namespace basic::options::OptionKeys;
171 
172  // Use RotamerRecovery to test new score functions eg. all the corrections
173  option.add_relevant( corrections::correct );
174 
175  // Use full atom binary silent files for best io-performance
176  option.add_relevant( in::file::fullatom );
177  option.add_relevant( in::file::silent_struct_type );
178  option.add_relevant( in::file::silent );
179 
180  // If using an outputter that writes to a database improve
181  // io-performace by not writing out structures
182  option.add_relevant( out::nooutput );
183 
184  rotamer_recovery_->register_options();
185 
186 }
187 
188 bool
190  return false;
191 }
192 
193 bool
195  return false;
196 }
197 
198 void
200 ) {
201  runtime_assert( rotamer_recovery_ );
203  scfxn->setup_for_scoring(pose);
204  PackerTaskOP packer_task( task_factory_->create_task_and_apply_taskoperations( pose ));
205  rotamer_recovery_->run(pose, *scfxn, *packer_task);
206 }
207 
208 string
210  return "RotamerRecoveryMover";
211 }
212 
213 MoverOP
215  return new RotamerRecoveryMover;
216 }
217 
218 
219 MoverOP
221  return new RotamerRecoveryMover( *this );
222 }
223 
224 void
226  utility::tag::TagPtr const tag,
227  moves::DataMap & datamap,
228  Filters_map const & /*filters*/,
229  moves::Movers_map const & movers,
230  Pose const & /*pose*/ )
231 {
232  string const & scorefxn_key( tag->getOption<std::string>("scorefxn", "score12" ));
233  score_function( datamap.get< ScoreFunction * >("scorefxns", scorefxn_key) );
234 
235  if( rotamer_recovery_ ){
236  TR << "WARNING: Attempting to redefine rotamer_recovery_ object from Parser Script" << endl;
237  throw utility::excn::EXCN_RosettaScriptsOption("");
238  }
239 
240  if(tag->hasOption("protocol") && (tag->hasOption("mover") || tag->hasOption("mover_name"))){
241  throw utility::excn::EXCN_RosettaScriptsOption("Please either the 'protocol' field or the 'mover' field but not both.");
242  }
243 
245 
246  RRProtocolOP protocol;
247  if(tag->hasOption("mover") || tag->hasOption("mover_name")){
248  MoverOP mover = parse_mover(tag->hasOption("mover") ?
249  tag->getOption<string>("mover") : tag->getOption<string>("mover_name"), movers);
250  protocol = new RRProtocolMover(mover);
251  } else {
252  protocol = factory->get_rotamer_recovery_protocol(tag->getOption<string>("protocol", "RRProtocolMinPack"));
253  }
254  RRComparerOP comparer(
256  tag->getOption<string>("comparer", "RRComparerAutomorphicRMSD")));
257 
258  RRReporterOP reporter(
260  tag->getOption<string>("reporter", "RRReporterSimple")));
261 
262  rotamer_recovery_ = new RotamerRecovery(protocol, comparer, reporter);
263 }
264 
267  if ( !scfxn_ )
269 
270  return scfxn_;
271 }
272 
273 void
275  ScoreFunctionOP scorefunction
276 ) {
277  scfxn_ = scorefunction;
278 }
279 
280 void
282  rotamer_recovery_->show();
283 }
284 
285 void
287  ostream & out
288 ) {
289  rotamer_recovery_->show( out );
290 }
291 
292 } // namespace rotamer_recovery
293 } // namespace protocols