Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ReturnSidechainMover.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/ReturnSidechainMover.cc
11 /// @brief ReturnSidechainMover methods implemented
12 /// @author Steven Lewis
13 
14 
15 // Unit Headers
17 
18 // Package Headers
19 
20 // Project Headers
21 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
22 #include <core/pose/Pose.hh>
23 
24 #include <core/scoring/Energies.hh>
25 
26 // AUTO-REMOVED #include <core/chemical/VariantType.hh>
27 
29 
30 // Utility Headers
31 #include <basic/Tracer.hh>
32 #include <core/types.hh>
33 #include <utility/exit.hh>
34 
35 // C++ Headers
36 #include <string> //making sure that residue_type.name() comparison works
37 
39 #include <core/pose/util.hh>
40 #include <utility/vector1.hh>
41 
45 
46 using basic::T;
47 using basic::Error;
48 using basic::Warning;
49 
50 
51 static basic::Tracer TR( "protocols.simple_moves.ReturnSidechainMover" );
52 
53 
54 namespace protocols {
55 namespace simple_moves {
56 
57 ///@details this code was copied from protocols/loops/loops_main.cc:187-204, revision 21282
59 
60  core::pose::Pose saved_input_pose(remembered_pose_);
61  core::Size nres( end_res_ - start_res_ + 1 );
62 
63  //symmetry
67  dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( pose.conformation()) );
68  symm_info = SymmConf.Symmetry_Info();
69  }
70 
71  if( nres != saved_input_pose.total_residue() )
72  utility_exit_with_message("ReturnSidechainMover used with poses of different length; aborting");
73 
74  for (Size i=start_res_, j=1; i<= end_res_; ++i, ++j ) {
75  bool copy_this_residue( false );
76 
77  if( copy_all_chi_ )
78  copy_this_residue = true;
79  else {
80  if( allow_chi_copy_[i] )
81  copy_this_residue = true;
82  }
83 
84  if (symm_info && !symm_info->bb_is_independent( i )) continue;
85  if (pose.residue_type(i).aa() == core::chemical::aa_vrt) continue;
86 
87  if( copy_this_residue ) {
88  core::chemical::ResidueType const & rsd_type ( pose.residue(i).type() );
89  core::chemical::ResidueType const & saved_rsd_type( saved_input_pose.residue(j).type() );
90 
91  //ensure that there is no sequence change
92  if( rsd_type.name3() != saved_rsd_type.name3() )
93  utility_exit_with_message("ReturnSidechainMover used with poses of different sequence; aborting");
94 
95  //we need to check variant types in case there are cutpoints for loop modeling or whatever
96  if ( ! rsd_type.variants_match( saved_rsd_type) ) {
97  utility::vector1<core::chemical::VariantType> const & variant_types ( rsd_type.variant_types() );
99 
100  for ( utility::vector1<core::chemical::VariantType>::const_iterator it = variant_types.begin(),
101  it_end=variant_types.end(); it != it_end; ++it ) {
102  if ( !saved_rsd_type.has_variant_type( *it ) ) missing_variant_types.push_back( *it );
103  }
104 
105  for ( utility::vector1<core::chemical::VariantType>::const_iterator it = missing_variant_types.begin(),
106  it_end=missing_variant_types.end(); it != it_end; ++it ) {
107  core::pose::add_variant_type_to_pose_residue( saved_input_pose, *it, i);
108  }
109  }//checking variants
110 
111  pose.replace_residue(i, saved_input_pose.residue(j), true );
112  }
113  } // residue i
114 
115  pose.energies().clear();
116  return;
117 }//apply
118 
121  return "ReturnSidechainMover";
122 }
123 
124 ///@brief default constructor
126 {
127  protocols::moves::Mover::type( "ReturnSidechainMover" );
128  copy_all_chi_ = true;
129 }
130 
131 ///@brief constructor with pose
133  core::pose::Pose const & pose_in,
134  core::Size start_res,
135  core::Size end_res ) :
136  protocols::moves::Mover(), remembered_pose_(pose_in)
137 {
138  protocols::moves::Mover::type( "ReturnSidechainMover" );
139  copy_all_chi_ = true;
140  if ( start_res == 0 ) start_res_ = 1;
141  else start_res_ = start_res;
142  if ( end_res == 0 ) end_res_ = pose_in.total_residue();
143  else end_res_ = end_res;
144 }
145 
146 ///@brief constructor with pose
148  core::pose::Pose const & pose_in,
149  utility::vector1<bool> allow_chi_in,
150  core::Size start_res,
151  core::Size end_res ) :
152  protocols::moves::Mover(),
153  allow_chi_copy_( allow_chi_in ),
154  remembered_pose_(pose_in)
155 {
156  protocols::moves::Mover::type( "ReturnSidechainMover" );
157  copy_all_chi_ = false;
158  if ( start_res == 0 ) start_res_ = 1;
159  else start_res_ = start_res;
160  if ( end_res == 0 ) end_res_ = pose_in.total_residue();
161  else end_res_ = end_res;
162 }
163 
165 
167  return start_res_;
168 }
169 
171  return end_res_;
172 }
173 
174 std::ostream &operator<< (std::ostream &os, ReturnSidechainMover const &mover)
175 {
176  moves::operator<<(os, mover);
177  os << " start\tend" << std::endl;
178  os << "Range of residues: " << mover.get_start_res() << "\t\t" << mover.get_end_res() << std::endl;
179 
180  return os;
181 }
182 
183 }//moves
184 }//protocols