Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RotamerRecoveryFeatures.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/features/RotamerRecoveryFeatures.cc
11 /// @brief report rotamer recover features and scores to features Statistics Scientific Benchmark
12 /// @author Matthew O'Meara
13 
14 // Unit Headers
16 
17 // Package Headers
22 #include <core/pose/Pose.hh>
23 #include <protocols/moves/Mover.hh>
31 
32 
33 // Project Headers
34 #include <basic/Tracer.hh>
35 #include <core/types.hh>
37 #include <utility/sql_database/DatabaseSessionManager.hh>
38 #include <utility/tag/Tag.hh>
39 #include <utility/vector1.hh>
40 
41 // External Headers
42 #include <cppdb/frontend.h>
43 
44 // C++ Headers
45 #include <string>
46 #include <sstream>
47 
48 #include <utility/vector0.hh>
49 
50 //Auto Headers
52 #include <utility/excn/Exceptions.hh>
54 
55 
56 
57 namespace protocols{
58 namespace features{
59 
60 using std::string;
61 using std::stringstream;
62 using std::endl;
63 using basic::Tracer;
64 using core::Size;
65 using core::Real;
69 using core::pose::Pose;
89 using utility::sql_database::sessionOP;
91 using utility::vector1;
92 using cppdb::statement;
93 
94 static Tracer TR("protocols.features.RotamerRecoveryFeatures");
95 
97  scfxn_(getScoreFunction()),
98  protocol_(),
99  comparer_(),
100  task_factory_()
101 {}
102 
104  ScoreFunctionOP scfxn) :
105  scfxn_(scfxn),
106  protocol_(),
107  comparer_(),
108  task_factory_()
109 {}
110 
112  RotamerRecoveryFeatures const & src) :
114  scfxn_(src.scfxn_),
115  protocol_(src.protocol_),
116  comparer_(src.comparer_),
117  task_factory_(src.task_factory_)
118 {}
119 
121 
122 string
123 RotamerRecoveryFeatures::type_name() const { return "RotamerRecoveryFeatures"; }
124 
125 
126 void
128  sessionOP db_session
129 ) const {
130  RRReporterSQLite reporter;
132 }
133 
136  vector1<string> dependencies;
137  dependencies.push_back("ResidueFeatures");
138  return dependencies;
139 }
140 
141 void
144 ) {
145  task_factory_ = task_factory;
146 }
147 
148 void
150  TagPtr const tag,
151  DataMap & data,
152  Filters_map const & /*filters*/,
153  Movers_map const & movers,
154  Pose const & /*pose*/
155 ) {
156  string scorefxn_name = tag->getOption<string>("scorefxn", "score12");
157  scfxn_ = data.get<ScoreFunction*>("scorefxns", scorefxn_name);
158 
160 
161  if(tag->hasOption("mover") || tag->hasOption("mover_name")){
162  if(tag->hasOption("reference_name")){
163  throw utility::excn::EXCN_RosettaScriptsOption(
164  "Both 'mover_name' and 'reference_name' were supplied. "
165  "Please specify at most one to indicate which protocols should "
166  "be used to run RotamerRecovery.");
167  }
168 
169  MoverOP mover = parse_mover(tag->hasOption("mover") ?
170  tag->getOption<string>("mover") :
171  tag->getOption<string>("mover_name"), movers);
172  protocol_ = new RRProtocolMover(mover);
173  } else if(tag->hasOption("reference_name")){
174  if(tag->hasOption("mover")){
175  throw utility::excn::EXCN_RosettaScriptsOption(
176  "Both 'mover' and 'reference_name' were supplied. "
177  "Please specify at most one to indicate which protocols "
178  "should be used to run RotamerRecovery.");
179  }
180 
181  if(tag->hasOption("mover_name")){
182  throw utility::excn::EXCN_RosettaScriptsOption(
183  "Both 'mover_name' and 'reference_name' were supplied. "
184  "Please specify at most one to indicate which protocols "
185  "should be used to run RotamerRecovery.");
186  }
187 
188  if(tag->hasOption("protocol") &&
189  !tag->getOption<string>("protocol").compare(
190  "RRProtocolReferenceStructure")){
191  throw utility::excn::EXCN_RosettaScriptsOption(
192  "Specifying 'reference_name' is only compatible with the "
193  "'RRProtocolReferenceStructure' protocol.");
194  }
195 
196  // Use with SavePoseMover
197  // WARNING! reference_pose is not initialized until apply time
198  PoseCOP reference_pose(saved_reference_pose(tag, data));
199  protocol_ = new RRProtocolReferenceStructure(reference_pose);
200  } else {
201  string const & protocol_name(tag->getOption<string>(
202  "protocol", "RRProtocolMinPack"));
203  if(!protocol_name.compare("RRProtocolMover")){
204  throw utility::excn::EXCN_RosettaScriptsOption(
205  "Please specify 'mover_name' with the 'RRProtocolMover' "
206  "rotamer recovery protocol.");
207  } else if(!protocol_name.compare("RRProtocolReferenceStructure")){
208  throw utility::excn::EXCN_RosettaScriptsOption(
209  "Please specify 'reference_name' with 'RRProtocolReferenceStructure' "
210  "rotamer recovery protocol.");
211  } else {
212  protocol_ = factory->get_rotamer_recovery_protocol(protocol_name);
213  }
214  }
215 
216  //mjo if there are many options to be passed to the components,
217  //consider passing the tag to the components themselves to do their
218  //own tag parsing
219  if(protocol_->get_name() == "RRProtocolRTMin"){
220  if(tag->hasOption("nonideal")){
221  static_cast<rotamer_recovery::RRProtocolRTMin &>(*protocol_).set_nonideal(tag->getOption<bool>("nonideal"));
222  }
223  if(tag->hasOption("cartesian")){
224  static_cast<rotamer_recovery::RRProtocolRTMin &>(*protocol_).set_cartesian(tag->getOption<bool>("cartesian"));
225  }
226  }
227 
228  string const & comparer_name(tag->getOption<string>(
229  "comparer", "RRComparerAutomorphicRMSD"));
230  comparer_ = factory->get_rotamer_recovery_comparer(comparer_name);
231 
232  if(tag->hasOption("recovery_threshold")){
233  comparer_->set_recovery_threshold(tag->getOption<Real>("recovery_threshold"));
234  }
235 
237 
238 }
239 
240 
241 
242 Size
244  Pose const & pose_in,
245  vector1< bool > const & relevant_residues,
246  boost::uuids::uuid const struct_id,
247  sessionOP db_session
248 ){
249  RRReporterSQLiteOP reporter(
251 
252  reporter->set_struct_id1(struct_id);
253  RotamerRecovery rotamer_recovery(protocol_, comparer_, reporter);
254 
255  Pose pose=pose_in;
256  (*scfxn_)(pose);
257  //scfxn_->setup_for_scoring(pose);
258 
259  if(task_factory_ == 0){
260  task_factory_ = new TaskFactory();
261  }
262 
263  PackerTaskOP packer_task(task_factory_->create_task_and_apply_taskoperations(pose));
264  packer_task->restrict_to_repacking();
265  packer_task->restrict_to_residues(relevant_residues);
266  packer_task->initialize_from_command_line();
267 
268  rotamer_recovery.run(pose, *scfxn_, *packer_task);
269 
270  return 0;
271 }
272 
273 
274 } // namesapce
275 } // namespace