Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RestrictNativeResiduesOperation.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/toolbox/task_operations/RestrictNativeResiduesOperation.cc
11 /// @brief Restrict every residue in the current pose that is native to repacking. ie, only allow mutated positions to be designed.
12 /// @author Jacob Bale, balej@u.washington.edu
13 
14 
15 // Unit Headers
18 
19 // Project Headers
20 #include <basic/options/option.hh>
21 #include <basic/options/keys/in.OptionKeys.gen.hh>
22 #include <basic/Tracer.hh>
23 
25 #include <core/pose/Pose.hh>
26 #include <core/pose/PDBInfo.hh>
31 
32 // Utility Headers
33 #include <utility/tag/Tag.hh>
34 #include <utility/vector1.hh>
35 #include <string>
36 #include <ObjexxFCL/format.hh>
37 #include <utility/vector0.hh>
38 
39 
40 static basic::Tracer TR("protocols.toolbox.task_operations.RestrictNativeResiduesOperation");
41 
42 namespace protocols{
43 namespace toolbox{
44 namespace task_operations{
45 
48 {
50 }
51 
52 /// @brief default constructor
54  TaskOperation(),
55  reference_pose_( NULL ),
56  verbose_( false ),
57  prevent_repacking_( 0 )
58 {
59 }
60 
61 /// @brief destructor
63 
64 /// @brief clone
67  return new RestrictNativeResiduesOperation( *this );
68 }
69 
72 {
73  return reference_pose_;
74 }
75 
76 void
78 {
79  reference_pose_ = pose;
80 }
81 
82 void
84 {
85  reference_pose_ = new core::pose::Pose( pose );
86 }
87 
88 bool
90 {
91  return( verbose_ );
92 }
93 
94 void
96 {
97  verbose_ = verb;
98 }
99 
100 bool
102 {
103  return( prevent_repacking_ );
104 }
105 
106 void
108 {
109  prevent_repacking_ = prev;
110 }
111 
112 /// @brief Loop over the residues in the current pose and restrict those that match the
113 /// reference pose (ie, native residues) to repacking.
114 void
116 {
117  runtime_assert( reference_pose() );
118  core::Size total_residue_ref;
119  core::pose::Pose asym_ref_pose;
122  for (core::Size i = 1; i <= asym_ref_pose.total_residue(); ++i) {
123  if (asym_ref_pose.residue_type(i).name() == "VRT") {
124  asym_ref_pose.conformation().delete_residue_slow(asym_ref_pose.total_residue());
125  }
126  }
127  total_residue_ref = asym_ref_pose.total_residue();
128  } else {
129  total_residue_ref = reference_pose()->total_residue();
130  asym_ref_pose = *reference_pose();
131  }
132  core::Size total_residue;
133  core::pose::Pose asym_pose;
134  if (core::pose::symmetry::is_symmetric( pose )) {
136  for (core::Size i = 1; i <= asym_pose.total_residue(); ++i) {
137  if (asym_pose.residue_type(i).name() == "VRT") {
138  asym_pose.conformation().delete_residue_slow(asym_pose.total_residue());
139  }
140  }
141  total_residue = asym_pose.total_residue();
142  } else {
143  total_residue = pose.total_residue();
144  asym_pose = pose;
145  }
146  if( total_residue_ref != total_residue )
147  utility_exit_with_message( "Reference pose and current pose have a different number of residues" );
148  std::string select_non_native_resis("select non_native_resis, resi ");
149  core::Size designable_resis = 0;
150  for( core::Size resi=1; resi<=total_residue; ++resi ) {
151  if ( asym_ref_pose.residue(resi).name3() == asym_pose.residue(resi).name3() ) {
154  } else {
155  if ( verbose_ ) {
156  select_non_native_resis.append(ObjexxFCL::string_of(resi) + "+");
157  }
158  designable_resis++;
159  }
160  }
161  if( designable_resis == 0 ) {
162  TR<<"Warning: No designable residues identified in pose."<<std::endl;
163  } else {
164  TR<<designable_resis<<" non-native, designable residues found in pose"<<std::endl;
165  }
166  if ( verbose_ ) {
167  TR<<select_non_native_resis<<std::endl;
168  }
169 } // apply
170 
171 void
173 {
174  verbose( tag->getOption< bool >( "verbose", 0 ) );
175  prevent_repacking( tag->getOption< bool >( "prevent_repacking", 0 ) );
176 
177  using namespace basic::options;
178  using namespace basic::options::OptionKeys;
179  std::string reference_pdb = "";
180 
181  if( option[ in::file::native ].user() ){
182  reference_pdb = option[ in::file::native ]();
183  } else if ( tag->hasOption("pdbname") ) {
184  reference_pdb = tag->getOption< std::string >("pdbname");
185  }
186  if ( reference_pdb != "" ) {
187  core::pose::PoseOP temp_pose( new core::pose::Pose );
188  core::import_pose::pose_from_pdb( *temp_pose, reference_pdb );
189  reference_pose( temp_pose );
190  TR<<"Using pdb "<<reference_pdb<<" as reference.";
191  } else {
192  throw utility::excn::EXCN_RosettaScriptsOption( "Native PDB not specified." );
193  }
194 }
195 
196 } // TaskOperations
197 } // toolbox
198 } // protocols
199