Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TaskAwareMinMover.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/simple_moves/TaskAwareMinMover.cc
11 /// @brief TaskAwareMinMover methods implemented
12 /// @author Steven Lewis
13 
14 
15 // Unit Headers
18 
19 // Package Headers
20 
21 // Project Headers
23 
24 // AUTO-REMOVED #include <core/pose/Pose.hh>
25 
28 // AUTO-REMOVED #include <core/pack/task/operation/TaskOperation.hh>
29 
31 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
35 
36 // Utility Headers
37 #include <basic/Tracer.hh>
38 #include <core/types.hh>
39 #include <utility/exit.hh>
40 // AUTO-REMOVED #include <utility/string_util.hh>
41 #include <utility/tag/Tag.hh>
42 
43 #include <utility/vector0.hh>
44 #include <utility/vector1.hh>
45 
46 
47 // C++ Headers
48 
49 using basic::T;
50 using basic::Error;
51 using basic::Warning;
52 
53 
54 static basic::Tracer TR( "protocols.simple_moves.TaskAwareMinMover" );
55 
56 namespace protocols {
57 namespace simple_moves {
58 
61 {
63 }
64 
67  return new TaskAwareMinMover;
68 }
69 
72 {
73  return "TaskAwareMinMover";
74 }
75 
77  : protocols::moves::Mover("TaskAwareMinMover"),
78  minmover_(0),
79  factory_(0),
80  chi_(true),
81  bb_(false)
82 {}
83 
84 ///@brief constructor with TaskFactory
88 ) : protocols::moves::Mover("TaskAwareMinMover"),
89  minmover_(minmover_in),
90  factory_(factory_in),
91  chi_(true),
92  bb_(false),
93  jump_(false)
94 {
95  protocols::moves::Mover::type( "TaskAwareMinMover" );
96 }
97 
99 
100 ///@details apply will extract the movemap from your minmover, modify it to include sidechain DOFs that are packable according to some TaskFactory, run the minmover with this movemap, and revert the minmover to its original movemap.
102  runtime_assert( minmover_ );
103  runtime_assert( factory_ );
104 
107 
108  // non-initialization failsafe
109  if ( ! minmover_->movemap() ) minmover_->movemap( new MoveMap );
110 
111  //clone the MinMover's MoveMap
112  MoveMapOP mm = new MoveMap( *( minmover_->movemap() ) );
113  MoveMapOP mm_copy = new MoveMap( *( minmover_->movemap() ) );
114 
115  //generate task
117  PackerTaskOP task( factory_->create_task_and_apply_taskoperations( pose ) );
118 
119  //modify movemap by task
120 // core::kinematics::modify_movemap_from_packertask( *mm, *task );
121  Size const nres( task->total_residue() );
122 
123  mm->set_jump( jump_ );
124  for ( Size i(1); i <= nres; ++i ) {
125  if ( task->design_residue( i ) ) {
126  // the MoveMap initializes to false for all degrees of freedom
127  // this class only turns on minimization at packable dofs, it does not turn them off
128  if ( chi_ ) mm->set_chi( i, chi_ );
129  if ( bb_ ) mm->set_bb( i, bb_ );
130  }
131  else if( task->pack_residue( i ) ) {
132  if( chi_ ) mm->set_chi( i, chi_ );
133  }
134  }
135 
136  //pass the modified map into the MinMover
137  minmover_->movemap( mm );
138 
139  //now run MinMover
140  minmover_->apply( pose );
141 
142  //restore MinMover's original movemap to prevent accumulation of state
143  minmover_->movemap( mm_copy );
144 
145 
146 }//apply
147 
151 }
152 
155 
156 ///@brief parse XML (specifically in the context of the parser/scripting scheme)
157 void
159  TagPtr const tag,
160  protocols::moves::DataMap & datamap,
161  Filters_map const & filters,
162  protocols::moves::Movers_map const & movers,
163  Pose const & pose
164 )
165 {
166  if ( tag->getName() != "TaskAwareMinMover" ) {
167  TR << " received incompatible Tag " << tag << std::endl;
168  assert(false);
169  return;
170  }
171  if ( tag->hasOption("chi") ) chi_ = tag->getOption<bool>("chi");
172  if ( tag->hasOption("bb") ) bb_ = tag->getOption<bool>("bb");
173  if( tag->hasOption( "jump" ) ){
174  std::string const jump( tag->getOption< std::string >( "jump" ) );
175  if( jump != "0" && jump != "1" )
176  utility_exit_with_message( "TaskAwareMinMover only knows how to interpret jump=1(all jumps true) or jump=0 (false). I got jump = "+jump );
177  }
178  jump_ = tag->getOption< bool >( "jump", false );
179  minmover_ = new MinMover;
180  // call to MinMover::parse_my_tag avoided here to prevent collision of chi and bb tag options
181  minmover_->parse_opts( tag, datamap, filters, movers, pose );
182  parse_task_operations( tag, datamap, filters, movers, pose );
183  minmover_->score_function( protocols::rosetta_scripts::parse_score_function( tag, datamap, "score12" ) );
184 }
185 
186 void TaskAwareMinMover::parse_def( utility::lua::LuaObject const & def,
187  utility::lua::LuaObject const & score_fxns,
188  utility::lua::LuaObject const & tasks,
190  if( def["chi"] )
191  chi_ = def["chi"].to<bool>();
192  if( def["bb"] )
193  bb_ = def["bb"].to<bool>();
194  jump_ = def["jump"] ? def["jump"].to<bool>() : false;
195  minmover_ = new MinMover;
196 // interesting how this doesn't read a movemap....
197  minmover_->parse_def_opts( def, score_fxns, tasks, cache );
198  if( def["tasks"] ) {
199  core::pack::task::TaskFactoryOP new_task_factory( protocols::elscripts::parse_taskdef( def["tasks"], tasks ));
200  if ( new_task_factory == 0) return;
201  factory_ = new_task_factory;
202  }
203  if( def["scorefxn"] ) {
204  minmover_->score_function( protocols::elscripts::parse_scoredef( def["scorefxn"], score_fxns ) );
205  } else {
206  minmover_->score_function( score_fxns["score12"].to<core::scoring::ScoreFunctionSP>()->clone() );
207  }
208 }
209 
210 ///@brief parse "task_operations" XML option (can be employed virtually by derived Packing movers)
211 void
213  TagPtr const tag,
214  protocols::moves::DataMap const & datamap,
215  Filters_map const &,
217  Pose const &
218 )
219 {
220  using namespace core::pack::task;
221  TaskFactoryOP new_task_factory( protocols::rosetta_scripts::parse_task_operations( tag, datamap ) );
222  if ( new_task_factory == 0) return;
223  factory_ = new_task_factory;
224 }
225 
226 }//moves
227 }//protocols
228