Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SurfaceEnergies.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 core/scoring/solid_surface/SurfaceEnergies.cc
11 /// @brief SurfaceEnergies class avoids calculating energies between surface residues, and detecting their
12 /// neighbor relationships
13 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
14 /// @author Mike Pacella (mpacella@gmail.com)
15 
16 // Unit Headers
18 
19 #include <basic/Tracer.hh>
20 
21 // Project Headers
24 
25 #include <core/pose/Pose.hh>
26 #include <core/pose/util.hh>
27 
29 
30 // Numeric headers
31 #include <numeric/numeric.functions.hh>
32 
33 // Utility headers
34 #include <utility/exit.hh>
35 #include <utility/string_util.hh>
36 
37 static basic::Tracer tr("core.scoring.solid_surface.SurfaceEnergies");
38 
39 namespace core {
40 namespace scoring {
41 namespace solid_surface {
42 
44  parent(),
45  total_residue_( 0 ),
46  neighbor_cutoff_( -1 )
47 {}
48 
49 
50 /// copy ctor -- deep copy
52  parent( other ),
53  total_residue_( other.total_residue_ ),
54  non_surface_ranges_( other.non_surface_ranges_ ),
55  is_surface_( other.is_surface_ ),
56  neighbor_cutoff_( other.neighbor_cutoff_ )
57  //surface_grid_( other.surface_grid_ ),
58  //surf_bb_( other.surf_bb_ ),
59  //surf_dim_( other.surf_dim_ )
60 {}
61 
62 /// assignment operator -- deep copy
63 Energies const &
65 {
66  assert( dynamic_cast< SurfaceEnergies const * > ( & rhs ) );
67  if ( this == &rhs ) return *this;
68 
69  SurfaceEnergies const & surf_rhs( static_cast< SurfaceEnergies const & > ( rhs ) );
70  total_residue_ = surf_rhs.total_residue_;
72  is_surface_ = surf_rhs.is_surface_;
73 
75  //surface_grid_ = surf_rhs.surface_grid_;
76  //surf_bb_ = surf_rhs.surf_bb_;
77  //surf_dim_ = surf_rhs.surf_dim_;
78 
79  parent::operator = ( rhs );
80 
81  return *this;
82 }
83 
84 ///@details If recurse is true, then this is the first call to same_type_as_me;
85 // determine if the other object is also a SurfaceEnergies object. If recurse is false
86 // then the other object is also of type SurfaceEnergies, so return true, otherwise,
87 // ask the other objec to make sure it's the same type as me
88 bool
89 SurfaceEnergies::same_type_as_me( Energies const & other, bool recurse /* = true */ ) const
90 {
91  if ( dynamic_cast< SurfaceEnergies const * > (&other) ) {
92  if ( ! recurse ) {
93  return true;
94  } else {
95  return other.same_type_as_me( *this, false );
96  }
97  } else {
98  return false;
99  }
100 }
101 
103 
104 ///@details make a copy of this Energies( allocate actual memory for it )
107 {
108  return new SurfaceEnergies( *this );
109 }
110 
111 
112 /// @brief The SurfaceEnergies object needs to know how many residues are in its pose;
113 /// it also has to be told which residues are considered part of the surface and which
114 /// residues are not part of the surface.
115 void
117  total_residue_ = total_residue;
119 }
120 
121 /// @brief Wipe away all the information in the SurfacEnergies object describing which
122 /// residues are considered part of the surface and which residues are not part of the
123 /// surface. (Afterwards, all residues are going to be considered part of the surface).
124 void
126  non_surface_ranges_.clear();
127  is_surface_.resize( total_residue_ );
128  std::fill( is_surface_.begin(), is_surface_.end(), true );
129 }
130 
131 /// @brief Tell the SurfacEnergies that the following residues are considered not
132 /// part of the surface.
133 void
135  // 1. make sure the input is valid:
136  assert( seqpos_begin <= seqpos_end );
137  assert( seqpos_begin <= total_residue_ );
138  assert( seqpos_end <= total_residue_ );
139  for ( Size ii = 1; ii <= non_surface_ranges_.size(); ++ii ) {
140  assert( non_surface_ranges_[ ii ].first < seqpos_end || non_surface_ranges_[ ii ].second > seqpos_begin );
141  }
142  non_surface_ranges_.push_back( std::make_pair( seqpos_begin, seqpos_end ));
143  for ( Size ii = seqpos_begin; ii <= seqpos_end; ++ii ) {
144  assert( is_surface_[ ii ] );
145  is_surface_[ ii ] = false;
146  }
147 }
148 
149 /// @brief Does the SurfaceEnergies object consider a particular residue to be part of the surface?
150 bool
152  return is_surface_[ seqpos ];
153 }
154 
155 /// @brief determine distance cutoff threshold based on scorefxn_info_ and
156 /// then add edges to the PointGraph class
157 void
159 
161 
162  Distance const max_pair_radius = pose::pose_max_nbr_radius( pose );
163  Distance const energy_neighbor_cutoff = 2 * max_pair_radius + get_scorefxn_info().max_atomic_interaction_distance();
164 
165  Distance const context_cutoff = max_context_neighbor_cutoff();
166 
167  Distance const neighbor_cutoff = numeric::max( energy_neighbor_cutoff, context_cutoff );
168 
169  //if ( neighbor_cutoff != neighbor_cutoff_ ) { // the surface grid is out of date!
170  // prepare_surface_grid( pg, neighbor_cutoff );
171  //}
172 
173  core::conformation::find_neighbors_naive_surface<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>( pg, neighbor_cutoff, non_surface_ranges_, is_surface_ );
174 
175 
176  //core::conformation::find_neighbors_octree_surface<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>(
177  //pg, neighbor_cutoff, non_surface_ranges_, is_surface_, surface_grid_, surf_bb_, surf_dim_ );
178 }
179 
180 /// @brief Create a new surface grid, bounding box and dimension for the surface residues.
181 /// This might get called if the range on the score function changes or if the surface
182 /// moves. (NOTE: currently not prepared to handle the case where the surface moves!)
183 /*void
184 SurfaceEnergies::prepare_surface_grid( conformation::PointGraphOP pg, Real neighbor_cutoff ) const
185 {
186  neighbor_cutoff_ = neighbor_cutoff;
187 
188  core::Size const n_points( pg->num_vertices() );
189 
190  //local copy
191  utility::vector1< PointPosition > points( n_points );
192  for ( core::Size ii = 1; ii <= n_points; ++ii ) { points[ ii ] = pg->get_vertex( ii ).data().xyz(); }
193 
194  bool first_surface_residue_found = false;
195  for ( Size ii = 1; ii <= total_residue_; ++ii ) {
196  if ( ! is_surface_[ ii ] ) continue;
197  if ( first_surface_residue_found ) {
198  surf_bb_.add( points[ ii ] );
199  } else {
200  surf_bb_.set_lower( points[ ii ] );
201  surf_bb_.set_upper( points[ ii ] );
202  first_surface_residue_found = true;
203  }
204  }
205 
206  core::Size const epsilon_multiplier( 10 ); // Increase this if assert failures hit in finding a point's cube
207  core::Real const epsilon( epsilon_multiplier * std::numeric_limits< core::Real >::epsilon() );
208  surf_bb_.set_lower( surf_bb_.lower() - epsilon ); // Expand bounding box to assure all points get assigned cubes in it
209  surf_bb_.set_upper( surf_bb_.upper() + epsilon );
210 
211  // Set cube size and dimensions within bounding box
212  core::Size const side_factor( 1 ); // 1 factor => Check <= 27 adjacent cubes // 2 factor => Check <= 8 adjacent cubes
213  // Might gain some speed by replacing max_residue_pair_cutoff below with the max cutoff for pairs present
214  core::Real const side( side_factor * neighbor_cutoff );
215  assert( side > core::Real( 0 ) );
216  core::Real const side_inv( core::Real( 1 ) / side );
217  surf_dim_ = core::conformation::CubeKey(
218  core::Size( std::ceil( ( surf_bb_.upper().x() - surf_bb_.lower().x() ) * side_inv ) ),
219  core::Size( std::ceil( ( surf_bb_.upper().y() - surf_bb_.lower().y() ) * side_inv ) ),
220  core::Size( std::ceil( ( surf_bb_.upper().z() - surf_bb_.lower().z() ) * side_inv ) ));
221  surface_grid_.clear();
222  for ( Size ii = 1; ii <= total_residue_; ++ii ) {
223  if ( ! is_surface_[ ii ] ) continue;
224  PointPosition const pp( points[ ii ]);
225 
226  // Find the residue's cube: Cube coords are indexed from 0 to cube_dim -1
227  core::conformation::CubeKey const cube_key(
228  core::Size( ( pp.x() - surf_bb_.lower().x() ) * side_inv ),
229  core::Size( ( pp.y() - surf_bb_.lower().y() ) * side_inv ),
230  core::Size( ( pp.z() - surf_bb_.lower().z() ) * side_inv )
231  );
232 
233  // Check that it is within the expanded bounding box
234  assert( cube_key.x() < surf_dim_.x() );
235  assert( cube_key.y() < surf_dim_.y() );
236  assert( cube_key.z() < surf_dim_.z() );
237 
238  // Add the point's position to the cube's collection
239  surface_grid_[ cube_key ].push_back( ii ); // Creates the cube if it doesn't exist yet
240  }
241 
242 }
243 
244 /// @brief Wipe everything held in the surface grid, ensuring that in the next score function
245 /// evaluation, a new grid will be computed.
246 void
247 SurfaceEnergies::reset_surface_grid() const
248 {
249 
250 } */
251 
252 
253 
254 } // solid_surface
255 } // scoring
256 } // core
257