Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DesignAroundOperation.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/DesignAroundOperation.cc
11 /// @brief
12 /// @author Sarelf Fleishman sarelf@uw.edu
13 
14 // Unit Headers
18 #include <core/pose/selection.hh>
19 
20 // Project Headers
21 #include <core/pose/Pose.hh>
22 
23 // AUTO-REMOVED #include <core/pack/task/PackerTask.hh>
24 // AUTO-REMOVED #include <core/pack/task/operation/TaskOperations.hh>
25 
26 // Utility Headers
27 #include <core/types.hh>
28 #include <basic/Tracer.hh>
29 #include <utility/exit.hh>
30 #include <utility/vector1.hh>
32 #include <utility/tag/Tag.hh>
34 // AUTO-REMOVED #include <basic/options/keys/pose_metrics.OptionKeys.gen.hh>
35 // AUTO-REMOVED #include <basic/options/option.hh>
37 // AUTO-REMOVED #include <core/pack/task/operation/NoRepackDisulfides.hh>
38 // AUTO-REMOVED #include <protocols/toolbox/task_operations/RestrictToInterface.hh>
39 // AUTO-REMOVED #include <protocols/toolbox/task_operations/RestrictChainToRepackingOperation.hh>
40 // AUTO-REMOVED #include <protocols/toolbox/task_operations/PreventChainFromRepackingOperation.hh>
41 // Auto-header: duplicate removed #include <core/pack/task/operation/TaskOperations.hh>
42 
43 #include <boost/foreach.hpp>
44 #define foreach BOOST_FOREACH
45 
46 // C++ Headers
47 #include <set>
48 
49 #include <utility/vector0.hh>
50 
51 
52 using basic::Error;
53 using basic::Warning;
54 static basic::Tracer TR( "protocols.toolbox.TaskOperations.DesignAroundOperation" );
55 
56 namespace protocols {
57 namespace toolbox {
58 namespace task_operations {
59 
60 using namespace core::pack::task::operation;
61 using namespace std;
62 
64  design_shell_( 8.0 ),
65  repack_shell_( 8.0 ),
66  allow_design_( true ),
67  string_resnums_( "" )
68 {
69  resid_.clear();
70 }
71 
73 
76 {
77  return new DesignAroundOperation;
78 }
79 
81 {
82  return new DesignAroundOperation( *this );
83 }
84 
85 ///@brief restricts to repacking all residues outside of design_shell_ around each residue
86 void
88 {
89  using namespace core::pack::task::operation;
90 
91 
92  runtime_assert( repack_shell() >= design_shell() );
93  set< core::Size > focus_residues;// all of the residues that were input (notice that the method is const, so I can't change resid_)
94  focus_residues.clear();
95  focus_residues.insert( resid_.begin(), resid_.end() );
96  set< core::Size > const res_vec( core::pose::get_resnum_list( string_resnums_, pose ) );
97  focus_residues.insert( res_vec.begin(), res_vec.end() );
98 
99  utility::vector1< core::Size > packing_residues, prevent_repacking_residues;
100  packing_residues.clear(); prevent_repacking_residues.clear();
101  for( core::Size i=1; i<=pose.total_residue(); ++i ){
102  bool allow_design_res( false );
103  bool allow_packing( false );
104  foreach( core::Size const res, focus_residues ){ // don't change anything for focus residues
105  if( i == res ){
106  allow_design_res = true;
107  break;
108  }
109  }
110  if( allow_design() && !allow_design_res ){
111  foreach( core::Size const res, focus_residues ){
112  core::Real const distance( pose.residue( i ).xyz( pose.residue( i ).nbr_atom() ).distance( pose.residue( res ).xyz( pose.residue( res ).nbr_atom() )) );
113  if( distance <= design_shell() || distance <= 0.0001 /*if design_shell is specified as 0 ensure that focus residues are allowed to design*/){
114  allow_design_res = true;
115  break;
116  }// fi distance
117  } //foreach res
118  }
119  if( allow_design_res ) continue;
120  foreach( core::Size const res, focus_residues ){
121  core::Real const distance( pose.residue( i ).xyz( pose.residue( i ).nbr_atom() ).distance( pose.residue( res ).xyz( pose.residue( res ).nbr_atom() )) );
122  if( distance <= repack_shell() ){
123  allow_packing = true;
124  break;
125  }// fi distance
126  } //foreach res
127  if( allow_packing ) packing_residues.push_back( i );
128  else prevent_repacking_residues.push_back( i );
129  }//for i
130 ///for some unfathomable reason OperateOnCertainResidues defaults to applying to all residues if none are defined, so you have to be careful here...
131  OperateOnCertainResidues oocr_repacking, oocr_prevent_repacking;
132  if( packing_residues.size() ){
133  oocr_repacking.op( new RestrictToRepackingRLT );
134  oocr_repacking.residue_indices( packing_residues );
135  oocr_repacking.apply( pose, task );
136  }
137  if( prevent_repacking_residues.size() ){
138  oocr_prevent_repacking.op( new PreventRepackingRLT );
139  oocr_prevent_repacking.residue_indices( prevent_repacking_residues );
140  oocr_prevent_repacking.apply( pose, task );
141  }
142 }
143 
144 void
146 {
147  design_shell_ = radius;
148  if( radius >= repack_shell() )
149  repack_shell_ = radius;
150 }
151 
152 void
154 {
155  resid_.insert( resid );
156 }
157 
158 void
160 {
161  string_resnums_ = tag->getOption< std::string >( "resnums" );// these are kept in memory until the pose is available (at apply time)
162  design_shell( tag->getOption< core::Real >( "design_shell", 8.0 ) );
163  allow_design( tag->getOption< bool >( "allow_design", 1 ) );
164  repack_shell( tag->getOption< core::Real >( "repack_shell", 8.0 ));
165  runtime_assert( design_shell() <= repack_shell() );
166  TR<<"repack_shell = "<<repack_shell()<<" design shell = "<<design_shell()<<std::endl;
167 }
168 void DesignAroundOperation::parse_def( utility::lua::LuaObject const & def ) {
169  if( def["resnums"] ) {
170  ostringstream oss("");
171  utility::lua::LuaIterator beg = def["resnums"].begin();
172  for (utility::lua::LuaIterator i=beg, end; i != end; ++i) {
173  if( i != beg )
174  oss << ",";
175  oss << (*i).to<core::Size>();
176  }
177  string_resnums_ = oss.str();
178  }
179  design_shell( def["design_shell"] ? def["design_shell"].to<core::Real>() : 8.0 );
180  allow_design( def["allow_design"] ? def["allow_design"].to<bool>() : true );
181  repack_shell( def["repack_shell"] ? def["repack_shell"].to<core::Real>() : 8.0 );
182  runtime_assert( design_shell() <= repack_shell() );
183  TR<<"repack_shell = "<<repack_shell()<<" design shell = "<<design_shell()<<std::endl;
184 }
185 } //namespace protocols
186 } //namespace toolbox
187 } //namespace task_operations