Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SaveAndRetrieveSidechains.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/protein_interface_design/movers/SaveAndRetrieveSidechains.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu), Jacob Corn (jecorn@u.washington.edu)
13 
14 // Unit headers
17 
18 // Project headers
19 #include <utility/tag/Tag.hh>
20 #include <core/pose/Pose.hh>
21 #include <basic/Tracer.hh>
23 #include <core/kinematics/Jump.hh>
27 //for putting back right variants
28 
29 //Auto Headers
30 #include <core/pose/util.hh>
32 #include <utility/vector0.hh>
33 #include <utility/vector1.hh>
34 
39 
40 namespace protocols {
41 namespace protein_interface_design {
42 namespace movers {
43 
44 using namespace core;
45 using namespace std;
46 using namespace core::scoring;
47 using namespace protocols::moves;
48 
49 static basic::Tracer TR( "protocols.protein_interface_design.movers.SaveAndRetrieveSidechains" );
50 
53 {
55 }
56 
59  return new SaveAndRetrieveSidechains;
60 }
61 
64 {
65  return "SaveAndRetrieveSidechains";
66 }
67 
69  simple_moves::DesignRepackMover( SaveAndRetrieveSidechainsCreator::mover_name() )
70 {
71  allsc_ = false; // default
72  jumpid_ = 1; //default
73  ensure_variant_matching_ = false; //default
74 }
75 
77  core::pose::Pose const & pose,
78  bool const allsc /*=false*/,
79  bool const ensure_variant_matching /*=false*/,
80  core::Size const jumpid /*=1*/
81 ) :
82  simple_moves::DesignRepackMover( SaveAndRetrieveSidechainsCreator::mover_name() ),
83  allsc_( allsc ),
84  ensure_variant_matching_(ensure_variant_matching),
85  jumpid_( jumpid )
86 {
87  init_pose_ = new core::pose::Pose( pose );
88 }
89 
91 
92 void
94 {
96  TR << "Retrieving sidechains...\n";
97  Size nres = pose.total_residue();
98  if (nres != init_pose_->total_residue() && core::pose::symmetry::is_symmetric(pose)) {
100  dynamic_cast<conformation::symmetry::SymmetricConformation &> ( pose.conformation()) );
101  nres = symm_conf.Symmetry_Info()->num_independent_residues();
102  }
103  runtime_assert( nres == init_pose_->total_residue() );
104  kinematics::Jump new_jump;
105  core::Size const rb_jump( jumpid_ );
106  new_jump = pose.jump( rb_jump );
107  for( core::Size res=1; res<=nres; ++res ) {
108  if( allsc_ ) { // replace all sidechains
109  pose.replace_residue( res, init_pose_->residue( res ), true/*orient_backbone*/ );
110  continue;
111  }
112  else {
113  if( pose.residue( res ).name3() == "ALA" ) // only replace Ala positions
114  pose.replace_residue( res, init_pose_->residue( res ), true/*orient_backbone*/ );
115  }
116  }
118  //make sure variants match, if not put back the initial variants
119  using namespace core;
120  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
121 
122  if( !(pose.residue_type( i ).variants_match( init_pose_->residue_type( i ) ) ) ){
123 
124  utility::vector1< std::string > const new_var_types( pose.residue_type( i ).variant_types() );
125  utility::vector1< std::string > const old_var_types( init_pose_->residue_type( i ).variant_types() );
126  for( utility::vector1< std::string >::const_iterator newvars = new_var_types.begin(); newvars != new_var_types.end(); ++newvars ){
127  if( ! (init_pose_->residue_type( i ).has_variant_type( *newvars ) ) ) core::pose::remove_variant_type_from_pose_residue( pose, *newvars, i );
128  }
129 
130  for( utility::vector1< std::string >::const_iterator oldvars = old_var_types.begin(); oldvars != old_var_types.end(); ++oldvars ){
131  if( !pose.residue_type( i ).has_variant_type( *oldvars ) ) core::pose::add_variant_type_to_pose_residue( pose, *oldvars, i );
132  }
133  } //if variants don't match
134  }
135  }
136  pose.set_jump( rb_jump, new_jump );
137  TR.flush();
138 }
139 
143 }
144 
145 void
147 {
148  init_pose_ = new core::pose::Pose( pose );
149  allsc_ = tag->getOption<bool>( "allsc", 0 );
150 }
151 
155 }
156 
157 } //movers
158 } //protein_interface_design
159 } //protocols