Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MinPackMover.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/simple_moves/MinPackMover.cc
11 /// @brief Implementation of the MinPackMover class; a wrapper class for invoking core::pack::min_pack
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 // Unit headers
17 
18 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
20 
22 #include <core/pack/min_pack.hh>
25 // AUTO-REMOVED #include <core/pack/task/operation/TaskOperation.hh>
26 #include <core/pose/Pose.hh>
27 // AUTO-REMOVED #include <core/pose/PDBInfo.hh>
30 #include <basic/Tracer.hh>
31 
32 // Utility Headers
33 #include <utility/exit.hh>
34 #include <utility/tag/Tag.hh>
35 // AUTO-REMOVED #include <utility/string_util.hh>
36 
37 // option key includes
38 
39 #include <utility/vector0.hh>
40 #include <utility/vector1.hh>
41 #include <basic/options/option.hh>
42 #include <basic/options/keys/OptionKeys.hh>
43 #include <basic/options/keys/optimization.OptionKeys.gen.hh>
44 
45 
46 namespace protocols {
47 namespace simple_moves {
48 
49 using namespace core;
50  using namespace basic::options;
51  using namespace pack;
52  using namespace task;
53  using namespace operation;
54  using namespace scoring;
55 
56 using basic::Warning;
57 using basic::t_warning;
58 static basic::Tracer TR("protocols.simple_moves.MinPackMover");
59 
60 
63 {
65 }
66 
69  return new MinPackMover;
70 }
71 
74 {
75  return "MinPackMover";
76 }
77 
79  protocols::moves::Mover("MinPackMover"),
80  scorefxn_(0),
81  task_(0),
82  task_factory_(0),
83  stochastic_pack_( false )
84 {
85  init();
86 }
87 
89  protocols::moves::Mover( type_name ),
90  scorefxn_(0),
91  task_(0),
92  task_factory_(0),
93  stochastic_pack_( false )
94 {
95  init();
96 }
97 
98  // constructors with arguments
100  ScoreFunctionCOP scorefxn
101 ) :
102  protocols::moves::Mover("MinPackMover"),
103  scorefxn_( scorefxn ),
104  task_( 0 ),
105  task_factory_(0),
106  stochastic_pack_( false )
107 {
108  init();
109 }
110 
111 
113  ScoreFunctionCOP scorefxn,
114  PackerTaskCOP task
115 ) :
116  protocols::moves::Mover("MinPackMover"),
117  scorefxn_( scorefxn ),
118  task_( task ),
119  task_factory_(0),
120  stochastic_pack_( false )
121 {
122  init();
123 }
124 
126 
127 void
129 {
130  nonideal_ = basic::options::option[ basic::options::OptionKeys::optimization::scmin_nonideal ]();
131  cartesian_ = basic::options::option[ basic::options::OptionKeys::optimization::scmin_cartesian ]();
132 }
133 
135  //utility::pointer::ReferenceCount(),
136  protocols::moves::Mover( other ),
137  stochastic_pack_( other.stochastic_pack_ )
138 {
139  scorefxn_ = other.score_function();
140  task_ = other.task();
141  task_factory_ = other.task_factory();
142  nonideal_ = other.nonideal_;
143  cartesian_ = other.cartesian_;
144 }
145 
146 void
148 {
149  if ( scorefxn_ == 0 ) {
150  Warning() << "undefined ScoreFunction -- creating a default one" << std::endl;
152  }
153 
155  if ( task_factory_ ) {
156  task = task_factory_->create_task_and_apply_taskoperations( pose );
157  } else {
158  runtime_assert( task_ );
159  runtime_assert( task_is_valid( pose ) );
160  task = task_;
161  //core::pack::min_pack( pose, *scorefxn_, task_ );
163  }
164 
165  if ( stochastic_pack_ ) {
166  core::pack::stochastic_pack( pose, *scorefxn_, task );
167  } else {
169  }
170 
171 }
172 
176 }
177 
178 ///@brief when the PackerTask was not generated locally, verify compatibility with pose
179 ///@details the pose residue types must be equivalent to the ones used to generate the ResidueLevelTasks, because of the way that prevent_repacking and its associated flags work
180 bool
181 MinPackMover::task_is_valid( Pose const & pose ) const
182 {
183  if ( task_->total_residue() != pose.total_residue() ) return false;
184  for ( Size i(1); i <= pose.total_residue(); ++i ) {
185  if ( ! task_->residue_task(i).is_original_type( &pose.residue_type(i) ) ) return false;
186  }
187  return true;
188 }
189 
190 ///@brief parse XML (specifically in the context of the parser/scripting scheme)
191 void
193  TagPtr const tag,
194  protocols::moves::DataMap & datamap,
195  Filters_map const & filters,
196  protocols::moves::Movers_map const & movers,
197  Pose const & pose
198 )
199 {
200  if ( tag->getName() != "MinPackMover" ) {
201  TR(t_warning) << " received incompatible Tag " << tag << std::endl;
202  assert(false);
203  return;
204  }
205  parse_score_function( tag, datamap, filters, movers, pose );
206  parse_task_operations( tag, datamap, filters, movers, pose );
207 
208  if (tag->hasOption( "nonideal" )) {
209  nonideal_ = tag->getOption<bool>( "nonideal" );
210  }
211  if (tag->hasOption( "cartesian" )) {
212  cartesian_ = tag->getOption<bool>( "cartesian" );
213  }
214 }
215 
216 ///@brief parse "scorefxn" XML option (can be employed virtually by derived Packing movers)
217 void
219  TagPtr const tag,
220  protocols::moves::DataMap const & datamap,
221  Filters_map const &,
223  Pose const &
224 )
225 {
226  ScoreFunctionOP new_score_function( protocols::rosetta_scripts::parse_score_function( tag, datamap ) );
227  if ( new_score_function == 0 ) return;
228  score_function( new_score_function );
229 }
230 
231 ///@brief parse "task_operations" XML option (can be employed virtually by derived Packing movers)
232 void
234  TagPtr const tag,
235  protocols::moves::DataMap const & datamap,
236  Filters_map const &,
238  Pose const &
239 )
240 {
241  TaskFactoryOP new_task_factory( protocols::rosetta_scripts::parse_task_operations( tag, datamap ) );
242  if ( new_task_factory == 0) return;
243  task_factory( new_task_factory );
244 }
245 
246 ///@brief required in the context of the parser/scripting scheme
249 {
250  return new MinPackMover;
251 }
252 
253 ///@brief required in the context of the parser/scripting scheme
256 {
257  return new protocols::simple_moves::MinPackMover( *this );
258 }
259 
260 
261 // setters
263 {
264  runtime_assert( sf );
265  scorefxn_ = sf;
266 }
267 
269 
271 {
272  runtime_assert( tf );
273  task_factory_ = tf;
274 }
275 
276 // accessors
280 
281 void MinPackMover::stochastic_pack( bool setting ) { stochastic_pack_ = setting; }
283 
284 } // moves
285 } // protocols
286