Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MutateResidue.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 sw=2 noet:
3 //
4 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file
10 /// @author Spencer Bliven <blivens@u.washington.edu>
11 /// @date 6/26/2009
12 
13 // Unit headers
16 
17 // Project Headers
18 #include <core/types.hh>
19 #include <core/pose/Pose.hh>
20 
22 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
25 #include <core/chemical/AA.hh>
27 //parsing
28 #include <utility/tag/Tag.hh>
29 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
30 #include <protocols/moves/Mover.fwd.hh> //Movers_map
31 #include <protocols/filters/Filter.fwd.hh> //Filters_map
33 #include <core/pose/selection.hh>
34 #include <basic/Tracer.hh>
35 #include <core/kinematics/Jump.hh>
36 #include <utility/vector0.hh>
37 #include <utility/excn/Exceptions.hh>
38 #include <utility/vector1.hh>
39 
40 
41 // Utility Headers
42 
43 // Unit Headers
44 
45 // C++ headers
46 
47 namespace protocols {
48 namespace simple_moves {
49 
50 using namespace core;
51 using namespace core::chemical;
52 using namespace std;
53 
54 using core::pose::Pose;
56 
57 static basic::Tracer TR( "protocols.simple_moves.MutateResidue" );
58 
61 {
63 }
64 
67  return new MutateResidue;
68 }
69 
72 {
73  return "MutateResidue";
74 }
75 
76 ///@brief default ctor
78  parent(),
79  rb_jump_(1),
80  target_(0)
81 {}
82 
83 ///@brief copy ctor
85  //utility::pointer::ReferenceCount(),
86  parent( dm ),
87  rb_jump_(dm.rb_jump_),
88  target_(dm.target_),
89  res_name_(dm.res_name_)
90 {}
91 
92 ///@brief Mutate a single residue to a new amino acid
93 ///@param target The residue index to mutate
94 ///@param new_res The name of the replacement residue
95 MutateResidue::MutateResidue( Size const target, string const new_res ) :
96  parent(),
97  rb_jump_(1),
98  target_(target),
99  res_name_(new_res)
100 {}
101 
102 MutateResidue::MutateResidue( Size const target, char const new_res ) :
103  parent(),
104  rb_jump_(1),
105  target_(target),
106  res_name_( name_from_aa( aa_from_oneletter_code( new_res ) ) )
107 {}
108 
109 
110 void MutateResidue::apply( Pose & pose ) {
111 
112  if( target_ < 1 ) {
113  // Do nothing for 0
114  return;
115  }
116  if( target_ > pose.total_residue() ) {
117  TR.Error << "Error: Residue "<<target_<<" is out of bounds." << std::endl;
118  utility_exit();
119  }
120 
121  TR.Debug << "Mutating residue " << target_ << " from "
122  << pose.residue(target_).name3() << " to " << res_name_ <<" ." << std::endl;
123 
124  chemical::ResidueTypeSet const& restype_set( pose.residue(target_).residue_type_set() );
125 
126  // Create the new residue and replace it
127  conformation::ResidueOP new_res = conformation::ResidueFactory::create_residue(
128  restype_set.name_map(res_name_), pose.residue(target_),
129  pose.conformation());
130  // Make sure we retain as much info from the previous res as possible
132  *new_res, pose.conformation() );
133  pose.replace_residue(target_, *new_res, false );
134 
135 }
136 
140 }
141 
142 
143 /**
144  * @brief Reinitialize this protocols::moves::Mover with parameters from the specified tags.
145  * @details Parameters recognized:
146  * - target_pdb_num or target_res_num. A single target residue to form disulfides to
147  * - target_pdb_nums or target_res_nums. A list of possible target residues
148  */
153  Pose const & pose)
154 {
155 
156  // Set target to the residue specified by "target_pdb_num" or "target_res_num"
157  if( !tag->hasOption("target") ){
158  TR.Error << "Error: no 'target' parameter specified." << std::endl;
159  throw utility::excn::EXCN_RosettaScriptsOption("");
160  }
162  tag->getOption<string>("target"),pose);
163 
164  if( !tag->hasOption("new_res") ){
165  TR.Error << "Error: no 'new_res' parameter specified." << std::endl;
166  throw utility::excn::EXCN_RosettaScriptsOption("");
167  }
168  res_name_ = tag->getOption<string>("new_res");
169 }
170 
171 void MutateResidue::parse_def( utility::lua::LuaObject const & def,
172  utility::lua::LuaObject const & /*score_fxns*/,
173  utility::lua::LuaObject const & /*tasks*/,
174  protocols::moves::MoverCacheSP /*cache*/ ) {
175  // Set target to the residue specified by "target_pdb_num" or "target_res_num"
176  if( !def["target"] ) {
177  TR.Error << "Error: no 'target' parameter specified." << std::endl;
178  utility_exit();
179  }
180  target_ = def["target"].to<core::Size>();
181 
182  if( !def["target"] ) {
183  TR.Error << "Error: no 'new_res' parameter specified." << std::endl;
184  utility_exit();
185  }
186  res_name_ = def["new_res"].to<std::string>();
187 }
188 
189 } // moves
190 } // protocols