Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConsensusDesignMover.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/ConsensusDesignMover.cc
11 /// @brief cc file for ConsensusDesignMover
12 /// @author Florian Richter (floric@u.washington.edu), april 2011
13 
14 // Unit headers
17 
18 // Project Headers
19 #include <basic/options/option.hh>
20 
22 #include <core/id/AtomID_Map.hh>
27 #include <core/pose/Pose.hh>
30 #include <core/scoring/sasa.hh>
33 
40 
41 //option key includes
42 #include <basic/options/keys/pose_metrics.OptionKeys.gen.hh>
43 
44 //utility includes
45 #include <utility/string_util.hh>
46 #include <utility/tag/Tag.hh>
47 
48 // AUTO-REMOVED #include <basic/basic.hh>
49 #include <basic/Tracer.hh>
50 
51 static basic::Tracer TR( "protocols.simple_moves.ConsensusDesignMover" );
52 
53 // c++ headerss
54 #include <string>
55 
56 #include <utility/vector0.hh>
57 #include <utility/vector1.hh>
58 
59 
60 namespace protocols {
61 namespace simple_moves {
62 
65 {
67 }
68 
71  return new ConsensusDesignMover;
72 }
73 
76 {
77  return "ConsensusDesignMover";
78 }
79 
80 
82 : ptask_(NULL), task_factory_(NULL),
83  sfxn_(NULL), invert_task_(false),
84  use_seqprof_constraints_(false), sasa_cutoff_(0.0),
85  seqprof_(NULL), ignore_pose_profile_length_mismatch_(false)
86 {}
87 
91 )
92  : ptask_(ptask), task_factory_(NULL),
93  sfxn_(sfxn), invert_task_(false),
94  use_seqprof_constraints_(false), sasa_cutoff_(0.0),
95  seqprof_(NULL), ignore_pose_profile_length_mismatch_(false)
96 {}
97 
99 
102 {
103  return new ConsensusDesignMover( *this );
104 }
105 
108 {
109  return new ConsensusDesignMover();
110 }
111 
112 /// @details this mover is allowed to touch all residues specified
113 /// as designable in the passed in task, resp. if the invert_task_
114 /// variable is set to true, all residues specified as non-packable
115 /// in the task
116 /// if no task is passed in, all residues will be considered legit
117 void
119 {
120  //first two safeguards
123  core::scoring::ScoreFunctionOP newsfxn = sfxn_->clone();
124  newsfxn->set_weight( core::scoring::res_type_constraint, 1.0 );
125  sfxn_ = newsfxn;
126  }
127 
129 
130  core::scoring::constraints::ConstraintCOPs seqprof_constraints;
131 
133  seqprof_constraints = pose.add_constraints( create_sequence_profile_constraints( pose, *task ) );
134  }
135 
138  packer.apply( pose );
139  }
140  else{
142  packer.apply( pose );
143  }
144 
146  if( !pose.remove_constraints( seqprof_constraints ) ) utility_exit_with_message("Couldn't remove sequence profile constraints after ConsensusDesignMover packing step.");
147  }
148 
149  (*sfxn_)(pose);
150 
151 } //apply
152 
153 /// @details
154 /// at every position that this mover is allowed to touch,
155 /// the task will be modified according to task operation SeqprofConsensusOperation
158  core::pose::Pose const & pose
159 )
160 {
161 
162  if( !ptask_ ){
163  if( task_factory_ ) ptask_ = task_factory_->create_task_and_apply_taskoperations( pose );
164  else{
166  if( invert_task_) utility_exit_with_message("invert_task_ set to true even though no task or task_factory was passed in. something probably unclean somewhere.");
167  }
168  }
169 
171  consensus_task->initialize_from_command_line();
174  seqprof_to.apply( pose, *consensus_task );
175  if( use_seqprof_constraints_ ) seqprof_ = seqprof_to.seqprof();
176 
178  consensus_task = core::pack::make_new_symmetric_PackerTask_by_requested_method( pose, consensus_task );
180  }
181 
182  utility::vector1< core::Real > residue_sasa;
183  bool use_sasa( sasa_cutoff_ > 0.0 );
184  if( use_sasa ){
186  core::scoring::calc_per_atom_sasa( pose, dummy, residue_sasa, basic::options::option[ basic::options::OptionKeys::pose_metrics::sasa_calculator_probe_radius]);
187  }
188 
189  std::string touched_residues;
190  core::Size num_design_residues(0);
191 
192  for( core::Size i = 1; i <= pose.total_residue(); ++i){
193 
194  bool this_residue_allowed( invert_task_ ? !ptask_->residue_task(i).being_packed() : ptask_->residue_task(i).being_designed() );
195  if( !pose.residue_type( i ).is_protein() ) this_residue_allowed = false;
196  if( use_sasa && (residue_sasa[i] < sasa_cutoff_ ) ) this_residue_allowed = false;
197 
198  if( !this_residue_allowed ) consensus_task->nonconst_residue_task(i).restrict_to_repacking();
199  else{
200  if( consensus_task->residue_task( i ).being_designed() ){
201  touched_residues = touched_residues + utility::to_string( i ) + "+";
202  num_design_residues++;
203  }
204  }
205 
206  } // loop over pose residues
207  TR << num_design_residues << "residues (out of a total of " << pose.total_residue() << ") for consensus design are " << touched_residues << std::endl;
208 
209  return consensus_task;
210 }
211 
214  core::pose::Pose const & pose,
215  core::pack::task::PackerTask const & task
216 ) const
217 {
219  core::sequence::SequenceProfileOP temp_sp = new core::sequence::SequenceProfile(*seqprof_); //dumb nonconstness of seqprofile in SequenceProfileConstraint makes this necessary :(
220  for( core::Size i = 1; i <= pose.total_residue(); ++i){
221  if( pose.residue_type(i).is_protein() && task.residue_task(i).being_designed() )
222  csts.push_back( new core::scoring::constraints::SequenceProfileConstraint( pose, i, temp_sp ) );
223  }
224  return csts;
225 }
226 
229  return "ConsensusDesignMover";
230 }
231 
232 void
234 {
236  if( tag->hasOption("invert_task") ) invert_task_ = tag->getOption< bool >("invert_task",1);
237  if( tag->hasOption("use_seqprof_constraints") ) use_seqprof_constraints_ = tag->getOption< bool >("use_seqprof_constraints",1);
238  if( tag->hasOption("sasa_cutoff") ) sasa_cutoff_ = tag->getOption< core::Real >("sasa_cutoff",1.0);
239  //if( tag->hasOption("scorefxn") ) sfxn_ = new core::scoring::ScoreFunction( *data_map.get< core::scoring::ScoreFunction * >("scorefxns", tag->getOption< std::string >("scorefxn")) );
240  if( tag->hasOption("scorefxn") ) sfxn_ = protocols::rosetta_scripts::parse_score_function( tag, data_map );
241 
242  if( tag->hasOption("ignore_pose_profile_length_mismatch") ) ignore_pose_profile_length_mismatch_ = tag->getOption< bool >("ignore_pose_profile_length_mismatch");
243 }
244 
245 } // namespace simple_moves
246 } // namespace protocols