Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HotspotStub.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/pose/hotspot_hashing/HotspotStub.cc
11 /// @brief HotspotStub class
12 /// @author John Karanicolas, Jacob Corn (jecorn@u.washington.edu), Sarel Fleishman
13 
14 // Unit headers
16 
17 // Package headers
18 // AUTO-REMOVED #include <protocols/hotspot_hashing/HotspotStubSet.hh>
19 
20 //Project Headers
21 // AUTO-REMOVED #include <core/chemical/VariantType.hh>
22 
25 #include <core/pose/Pose.hh>
27 
28 
29 // Utility headers
30 #include <basic/Tracer.hh>
31 #include <utility/exit.hh>
32 #include <core/types.hh>
33 //
34 
35 // C++ Headers
36 #include <map>
37 
38 
39 #include <core/pose/util.hh>
40 #include <utility/vector1.hh>
41 
42 using basic::T;
43 using basic::Error;
44 using basic::Warning;
45 
46 namespace protocols {
47 namespace hotspot_hashing {
48 
50  core::conformation::ResidueCOP const & residue,
51  core::Real const bonus_value,
52  core::pose::PoseOP pose,
53  core::Size chain_to_design,
55 ) :
56  utility::pointer::ReferenceCount(),
57  residue_(new core::conformation::Residue(*residue)), // jk note: deep copy
58  bonus_value_(bonus_value),
59  pose_( pose ),
60  filter_( filter ),
61  chain_to_design_( chain_to_design )
62 // my_set_( parent_set )
63 { }
64 
66  utility::pointer::ReferenceCount( src ),
67  residue_( src.residue_ ), // jk note: this is NOT a deep copy, since residue_ is effectively const
68  // (no member functions to move it). This must be a deep copy if residue_ can change.
69  bonus_value_( src.bonus_value_ ),
70  pose_( src.pose_ ),
71  filter_( src.filter_ ), // How should we deal with the reference to the containing set, since the new stub might be associ with a diff set?
72  chain_to_design_( src.chain_to_design_ ),
73 // my_set_( src.my_set_ ),
74  scaffold_status_( src.scaffold_status_ )
75 {}
76 
78 
79 #ifndef BOINC // gives build error
80 #ifndef WIN32 // gives build error
81 
83 {
84  residue_ = src.residue_; // jk note: this is NOT a deep copy, since residue_ is effectively const
85  // (no member functions to move it). This must be a deep copy if residue_ can change.
87 
88  // How should we deal with the reference to the containing set, since the new stub might be associ with a diff set? my_set_ = src.my_set_ ;
89 // my_set_ = src.my_set_;
91  pose_ = src.pose_;
93  filter_ = src.filter_;
94  return *this;
95 }
96 
97 bool HotspotStub::operator< ( HotspotStub const & right ) const {
98  return ( bonus_value_ < right.bonus_value_ );
99 }
100 
101 #endif
102 #endif
103 
106 
107 /// @brief create scaffold_status_ appropriate for given scaffold and set it all to unchecked
108 void
110 // runtime_assert( my_set_ );
111  core::Size const design_begin( pose_->conformation().chain_begin( chain_to_design_ ) );
112  core::Size const design_end( pose_->conformation().chain_end( chain_to_design_ ) );
113  scaffold_status_.clear();
114  for (core::Size i = design_begin; i <= design_end; ++i ) {
115  scaffold_status_.push_back( unchecked );
116  }
117 }
118 
119 void
121 {
122  pose_ = pose;
123  filter_ = filter;
124  chain_to_design_ = chain_to_design;
125 
126  core::Size const design_begin( pose_->conformation().chain_begin( chain_to_design_ ) );
127  core::Size const design_end( pose_->conformation().chain_end( chain_to_design_ ) );
128  scaffold_status_.clear();
129  for (core::Size i = design_begin; i <= design_end; ++i ) {
130  scaffold_status_.push_back( unchecked );
131  }
132 }
133 
134 /// @brief Check whether stub matches a given position on the scaffold (must be within max_distance)
135 bool
137 {
138  Size const host_chain_begin( pose_->conformation().chain_begin( chain_to_design_) );
139  Size const host_chain_end( pose_->conformation().chain_end( chain_to_design_) );
140  runtime_assert( seqpos <= host_chain_end );
141  runtime_assert( seqpos >= host_chain_begin );
142  core::Size const scaffold_position = seqpos - host_chain_begin;
143  if ( scaffold_status_[ scaffold_position ] == unchecked ) {
144  using namespace core::conformation;
145  ResidueCOP saved_res = new Residue( pose_->residue( seqpos ) );
146  ResidueCOP stub( residue_ );
147  using namespace core::chemical;
148 
149  pose_->replace_residue( seqpos, *stub, true );
150  if( seqpos > host_chain_begin )
152  if( seqpos < host_chain_end )
154  pose_->conformation().update_polymeric_connection( seqpos ); //o/w residue connections mess up
155  if( scaffold_position > 0 )
156  pose_->conformation().update_polymeric_connection( seqpos - 1 );
157  pose_->update_residue_neighbors();
158  if( filter_->apply( *pose_ ) )
159  scaffold_status_[ scaffold_position ] = accept;
160  else
161  scaffold_status_[ scaffold_position ] = reject;
162 // SJF IMPORTANT! Next step is crucial b/c in current setup ALL stubs feed off the SAME POSE. Woe to those who forget
163 // to revert the pose to its original state!
164  pose_->replace_residue( seqpos, *saved_res, true ); // SJF to revert the pose_ to its original state
165  pose_->update_residue_neighbors();
166  }
167  return( scaffold_status_[ scaffold_position ] == accept );
168 }
169 
170 /// @brief Get status, setting if unchecked
171 bool
173 {
174  runtime_assert( seqpos <= pose_->conformation().chain_end( chain_to_design_) );
175  runtime_assert( seqpos >= pose_->conformation().chain_begin( chain_to_design_) );
176  core::Size const scaffold_position = seqpos - pose_->conformation().chain_begin( chain_to_design_ );
177  if( scaffold_status_[ scaffold_position ] != unchecked )
178  return( scaffold_status_[ scaffold_position ] == accept );
179  else
180  {
181  bool const status = scaffold_match( seqpos );
182  return status;
183  }
184 }
185 
186 /// @brief manually set scaffold status
187 void
189 {
190  runtime_assert( seqpos <= pose_->conformation().chain_end( chain_to_design_) );
191  runtime_assert( seqpos >= pose_->conformation().chain_begin( chain_to_design_) );
192  core::Size const scaffold_position = seqpos - pose_->conformation().chain_begin( chain_to_design_ );
193  scaffold_status_[ scaffold_position ] = status;
194 }
195 
197  filter_ = filter;
198 }
199 
202 {
203  core::Size const chain_begin( pose.conformation().chain_begin( chain_to_design_ ) );
204  core::Size const chain_end ( pose.conformation().chain_end ( chain_to_design_ ) );
205 
206  core::Real nearest_distance( 100000 );
207  core::Size nearest_residue( 0 );
208  for( core::Size resi( chain_begin ); resi<=chain_end; ++resi ){
209  core::Real const distance( pose.residue( resi ).xyz( "CB" ).distance( residue()->xyz( "CB" ) ) );
210  if( distance<=nearest_distance ){
211  nearest_distance = distance;
212  nearest_residue = resi;
213  }
214  }
215  runtime_assert( nearest_residue );
216  return( nearest_residue );
217 }
218 
219 } // hotspot_hashing
220 } // protocols