Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NeighborList.tmpl.hh
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
11 /// @brief
12 /// @author
13 
14 
15 #ifndef INCLUDED_core_scoring_NeighborList_tmpl_hh
16 #define INCLUDED_core_scoring_NeighborList_tmpl_hh
17 
18 // Unit headers
20 
21 // Package headers
22 //#include <core/scoring/EnergyGraph.hh> // necessary?
23 //#include <core/scoring/etable/EtableEnergy.hh>
26 
27 // Project headers
29 #include <core/pose/Pose.hh>
30 #include <core/pose/util.hh>
31 #include <basic/prof.hh>
34 
35 //Auto Headers
36 #include <platform/types.hh>
37 #include <core/types.hh>
38 #include <core/chemical/AA.hh>
40 #include <core/chemical/Adduct.hh>
57 #include <core/chemical/types.hh>
87 #include <core/id/AtomID.fwd.hh>
88 #include <core/id/AtomID.hh>
90 #include <core/id/AtomID_Map.hh>
92 #include <core/id/DOF_ID.fwd.hh>
93 #include <core/id/DOF_ID.hh>
95 #include <core/id/DOF_ID_Map.hh>
98 #include <core/id/NamedAtomID.hh>
101 #include <core/id/TorsionID.fwd.hh>
102 #include <core/id/types.hh>
109 #include <core/kinematics/Edge.hh>
113 #include <core/kinematics/Jump.hh>
116 #include <core/kinematics/RT.fwd.hh>
117 #include <core/kinematics/RT.hh>
120 #include <core/kinematics/Stub.hh>
123 #include <core/pose/MiniPose.fwd.hh>
124 #include <core/pose/PDBInfo.fwd.hh>
125 #include <core/pose/Pose.fwd.hh>
135 #include <core/scoring/EnergyMap.hh>
141 #include <core/scoring/ScoreType.hh>
157 #include <utility/Bound.fwd.hh>
158 #include <utility/Bound.hh>
159 #include <utility/down_cast.hh>
160 #include <utility/exit.hh>
161 #include <utility/stream_util.hh>
162 #include <utility/string_util.hh>
163 #include <utility/vector0_bool.hh>
164 #include <utility/vector1.fwd.hh>
165 #include <utility/vector1.hh>
166 #include <utility/vector1_bool.hh>
167 #include <utility/vectorL.fwd.hh>
168 #include <utility/vectorL.hh>
169 #include <utility/vectorL_Selector.hh>
170 #include <utility/vectorL_bool.hh>
171 #include <utility/file/FileName.fwd.hh>
172 #include <utility/file/FileName.hh>
173 #include <utility/file/PathName.fwd.hh>
174 #include <utility/file/PathName.hh>
175 #include <utility/keys/AutoKey.fwd.hh>
176 #include <utility/keys/AutoKey.hh>
177 #include <utility/keys/Key.fwd.hh>
178 #include <utility/keys/Key.hh>
179 #include <utility/keys/Key2Tuple.fwd.hh>
180 #include <utility/keys/Key2Tuple.hh>
181 #include <utility/keys/Key3Tuple.fwd.hh>
182 #include <utility/keys/Key3Tuple.hh>
183 #include <utility/keys/Key4Tuple.fwd.hh>
184 #include <utility/keys/Key4Tuple.hh>
185 #include <utility/keys/KeyLess.fwd.hh>
186 #include <utility/keys/KeyLookup.fwd.hh>
187 #include <utility/keys/KeyLookup.hh>
188 #include <utility/keys/NoClient.fwd.hh>
189 #include <utility/keys/NoClient.hh>
190 #include <utility/keys/SmallKeyVector.fwd.hh>
191 #include <utility/keys/SmallKeyVector.hh>
192 #include <utility/keys/UserKey.fwd.hh>
193 #include <utility/keys/VariantKey.fwd.hh>
194 #include <utility/keys/VariantKey.hh>
195 #include <utility/options/AnyOption.fwd.hh>
196 #include <utility/options/AnyOption.hh>
197 #include <utility/options/AnyVectorOption.fwd.hh>
198 #include <utility/options/AnyVectorOption.hh>
199 #include <utility/options/BooleanOption.fwd.hh>
200 #include <utility/options/BooleanOption.hh>
201 #include <utility/options/BooleanVectorOption.fwd.hh>
202 #include <utility/options/BooleanVectorOption.hh>
203 #include <utility/options/FileOption.fwd.hh>
204 #include <utility/options/FileOption.hh>
205 #include <utility/options/FileVectorOption.fwd.hh>
206 #include <utility/options/FileVectorOption.hh>
207 #include <utility/options/IntegerOption.fwd.hh>
208 #include <utility/options/IntegerOption.hh>
209 #include <utility/options/IntegerVectorOption.fwd.hh>
210 #include <utility/options/IntegerVectorOption.hh>
211 #include <utility/options/Option.fwd.hh>
212 #include <utility/options/Option.hh>
213 #include <utility/options/OptionCollection.fwd.hh>
214 #include <utility/options/OptionCollection.hh>
215 #include <utility/options/PathOption.fwd.hh>
216 #include <utility/options/PathOption.hh>
217 #include <utility/options/PathVectorOption.fwd.hh>
218 #include <utility/options/PathVectorOption.hh>
219 #include <utility/options/RealOption.fwd.hh>
220 #include <utility/options/RealOption.hh>
221 #include <utility/options/RealVectorOption.fwd.hh>
222 #include <utility/options/RealVectorOption.hh>
223 #include <utility/options/ScalarOption.fwd.hh>
224 #include <utility/options/ScalarOption.hh>
225 #include <utility/options/ScalarOption_T_.fwd.hh>
226 #include <utility/options/ScalarOption_T_.hh>
227 #include <utility/options/StringOption.fwd.hh>
228 #include <utility/options/StringOption.hh>
229 #include <utility/options/StringVectorOption.fwd.hh>
230 #include <utility/options/StringVectorOption.hh>
231 #include <utility/options/VariantOption.fwd.hh>
232 #include <utility/options/VariantOption.hh>
233 #include <utility/options/VectorOption.fwd.hh>
234 #include <utility/options/VectorOption.hh>
235 #include <utility/options/VectorOption_T_.fwd.hh>
236 #include <utility/options/VectorOption_T_.hh>
237 #include <utility/options/mpi_stderr.hh>
238 #include <utility/options/keys/AnyOptionKey.fwd.hh>
239 #include <utility/options/keys/AnyOptionKey.hh>
240 #include <utility/options/keys/AnyVectorOptionKey.fwd.hh>
241 #include <utility/options/keys/AnyVectorOptionKey.hh>
242 #include <utility/options/keys/BooleanOptionKey.fwd.hh>
243 #include <utility/options/keys/BooleanOptionKey.hh>
244 #include <utility/options/keys/BooleanVectorOptionKey.fwd.hh>
245 #include <utility/options/keys/BooleanVectorOptionKey.hh>
246 #include <utility/options/keys/FileOptionKey.fwd.hh>
247 #include <utility/options/keys/FileOptionKey.hh>
248 #include <utility/options/keys/FileVectorOptionKey.fwd.hh>
249 #include <utility/options/keys/FileVectorOptionKey.hh>
250 #include <utility/options/keys/IntegerOptionKey.fwd.hh>
251 #include <utility/options/keys/IntegerOptionKey.hh>
252 #include <utility/options/keys/IntegerVectorOptionKey.fwd.hh>
253 #include <utility/options/keys/IntegerVectorOptionKey.hh>
254 #include <utility/options/keys/OptionKey.fwd.hh>
255 #include <utility/options/keys/OptionKey.hh>
256 #include <utility/options/keys/OptionKeys.hh>
257 #include <utility/options/keys/PathOptionKey.fwd.hh>
258 #include <utility/options/keys/PathOptionKey.hh>
259 #include <utility/options/keys/PathVectorOptionKey.fwd.hh>
260 #include <utility/options/keys/PathVectorOptionKey.hh>
261 #include <utility/options/keys/RealOptionKey.fwd.hh>
262 #include <utility/options/keys/RealOptionKey.hh>
263 #include <utility/options/keys/RealVectorOptionKey.fwd.hh>
264 #include <utility/options/keys/RealVectorOptionKey.hh>
265 #include <utility/options/keys/ScalarOptionKey.fwd.hh>
266 #include <utility/options/keys/ScalarOptionKey.hh>
267 #include <utility/options/keys/StringOptionKey.fwd.hh>
268 #include <utility/options/keys/StringOptionKey.hh>
269 #include <utility/options/keys/StringVectorOptionKey.fwd.hh>
270 #include <utility/options/keys/StringVectorOptionKey.hh>
271 #include <utility/options/keys/VectorOptionKey.fwd.hh>
272 #include <utility/options/keys/VectorOptionKey.hh>
273 #include <utility/options/keys/all.hh>
274 #include <utility/pointer/ReferenceCount.fwd.hh>
275 #include <utility/pointer/ReferenceCount.hh>
276 #include <utility/pointer/access_ptr.fwd.hh>
277 #include <utility/pointer/access_ptr.hh>
278 #include <utility/pointer/owning_ptr.functions.hh>
279 #include <utility/pointer/owning_ptr.fwd.hh>
280 #include <utility/pointer/owning_ptr.hh>
281 #include <utility/signals/BufferedSignalHub.fwd.hh>
282 #include <utility/signals/BufferedSignalHub.hh>
283 #include <utility/signals/Link.fwd.hh>
284 #include <utility/signals/Link.hh>
285 #include <utility/signals/LinkUnit.fwd.hh>
286 #include <utility/signals/LinkUnit.hh>
287 #include <utility/signals/PausableSignalHub.fwd.hh>
288 #include <utility/signals/PausableSignalHub.hh>
289 #include <utility/signals/SignalHub.fwd.hh>
290 #include <utility/signals/SignalHub.hh>
291 #include <numeric/NumericTraits.hh>
292 #include <numeric/constants.hh>
293 #include <numeric/conversions.hh>
294 #include <numeric/numeric.functions.hh>
295 #include <numeric/sphericalVector.fwd.hh>
296 #include <numeric/sphericalVector.hh>
297 #include <numeric/trig.functions.hh>
298 #include <numeric/types.hh>
299 #include <numeric/xyz.functions.fwd.hh>
300 #include <numeric/xyz.functions.hh>
301 #include <numeric/xyzMatrix.fwd.hh>
302 #include <numeric/xyzMatrix.hh>
303 #include <numeric/xyzTriple.fwd.hh>
304 #include <numeric/xyzTriple.hh>
305 #include <numeric/xyzVector.fwd.hh>
306 #include <numeric/xyzVector.hh>
307 #include <numeric/internal/ColPointers.hh>
308 #include <numeric/internal/ColVectors.hh>
309 #include <numeric/internal/ColsPointer.hh>
310 #include <numeric/internal/RowPointers.hh>
311 #include <numeric/internal/RowVectors.hh>
312 #include <numeric/internal/RowsPointer.hh>
313 #include <ObjexxFCL/Dimension.fwd.hh>
314 #include <ObjexxFCL/Dimension.hh>
315 #include <ObjexxFCL/DimensionExpression.hh>
316 #include <ObjexxFCL/DynamicIndexRange.fwd.hh>
317 #include <ObjexxFCL/DynamicIndexRange.hh>
318 #include <ObjexxFCL/FArray.all.fwd.hh>
319 #include <ObjexxFCL/FArray.fwd.hh>
320 #include <ObjexxFCL/FArray.hh>
321 #include <ObjexxFCL/FArray1.all.fwd.hh>
322 #include <ObjexxFCL/FArray1.fwd.hh>
323 #include <ObjexxFCL/FArray1.hh>
324 #include <ObjexxFCL/FArray1A.fwd.hh>
325 #include <ObjexxFCL/FArray1D.fwd.hh>
326 #include <ObjexxFCL/FArray1D.hh>
327 #include <ObjexxFCL/FArray1P.fwd.hh>
328 #include <ObjexxFCL/FArray2.all.fwd.hh>
329 #include <ObjexxFCL/FArray2.fwd.hh>
330 #include <ObjexxFCL/FArray2.hh>
331 #include <ObjexxFCL/FArray2A.fwd.hh>
332 #include <ObjexxFCL/FArray2D.fwd.hh>
333 #include <ObjexxFCL/FArray2D.hh>
334 #include <ObjexxFCL/FArray2P.fwd.hh>
335 #include <ObjexxFCL/FArray3.all.fwd.hh>
336 #include <ObjexxFCL/FArray3.fwd.hh>
337 #include <ObjexxFCL/FArray3.hh>
338 #include <ObjexxFCL/FArray3A.fwd.hh>
339 #include <ObjexxFCL/FArray3D.fwd.hh>
340 #include <ObjexxFCL/FArray3D.hh>
341 #include <ObjexxFCL/FArray3P.fwd.hh>
342 #include <ObjexxFCL/FArray4.all.fwd.hh>
343 #include <ObjexxFCL/FArray4.fwd.hh>
344 #include <ObjexxFCL/FArray4A.fwd.hh>
345 #include <ObjexxFCL/FArray4D.fwd.hh>
346 #include <ObjexxFCL/FArray4P.fwd.hh>
347 #include <ObjexxFCL/FArray5.all.fwd.hh>
348 #include <ObjexxFCL/FArray5.fwd.hh>
349 #include <ObjexxFCL/FArray5A.fwd.hh>
350 #include <ObjexxFCL/FArray5D.fwd.hh>
351 #include <ObjexxFCL/FArray5P.fwd.hh>
352 #include <ObjexxFCL/FArray6.all.fwd.hh>
353 #include <ObjexxFCL/FArray6.fwd.hh>
354 #include <ObjexxFCL/FArray6A.fwd.hh>
355 #include <ObjexxFCL/FArray6D.fwd.hh>
356 #include <ObjexxFCL/FArray6P.fwd.hh>
357 #include <ObjexxFCL/FArrayInitializer.fwd.hh>
358 #include <ObjexxFCL/FArrayInitializer.hh>
359 #include <ObjexxFCL/FArraySection.fwd.hh>
360 #include <ObjexxFCL/FArraySection.hh>
361 #include <ObjexxFCL/FArrayTraits.fwd.hh>
362 #include <ObjexxFCL/FArrayTraits.hh>
363 #include <ObjexxFCL/IndexRange.fwd.hh>
364 #include <ObjexxFCL/IndexRange.hh>
365 #include <ObjexxFCL/InitializerSentinel.hh>
366 #include <ObjexxFCL/KeyFArray1D.fwd.hh>
367 #include <ObjexxFCL/KeyFArray2D.fwd.hh>
368 #include <ObjexxFCL/KeyFArray3D.fwd.hh>
369 #include <ObjexxFCL/KeyFArray4D.fwd.hh>
370 #include <ObjexxFCL/KeyFArray5D.fwd.hh>
371 #include <ObjexxFCL/KeyFArray6D.fwd.hh>
372 #include <ObjexxFCL/Observer.fwd.hh>
373 #include <ObjexxFCL/Observer.hh>
374 #include <ObjexxFCL/ObserverMulti.hh>
375 #include <ObjexxFCL/ObserverSingle.hh>
376 #include <ObjexxFCL/ProxySentinel.hh>
377 #include <ObjexxFCL/SetWrapper.fwd.hh>
378 #include <ObjexxFCL/Star.fwd.hh>
379 #include <ObjexxFCL/Star.hh>
380 #include <ObjexxFCL/TypeTraits.hh>
381 #include <ObjexxFCL/char.functions.hh>
382 #include <ObjexxFCL/proxy_const_assert.hh>
383 #include <ObjexxFCL/string.functions.hh>
384 #include <algorithm>
385 #include <cassert>
386 #include <cmath>
387 #include <cstddef>
388 #include <cstdio>
389 #include <cstdlib>
390 #include <iomanip>
391 #include <iosfwd>
392 #include <iostream>
393 #include <limits>
394 #include <list>
395 #include <map>
396 #include <ostream>
397 #include <set>
398 #include <sstream>
399 #include <string>
400 #include <time.h>
401 #include <typeinfo>
402 #include <utility>
403 #include <vector>
404 #include <basic/MetricValue.fwd.hh>
405 #include <basic/datacache/BasicDataCache.fwd.hh>
406 #include <basic/datacache/BasicDataCache.hh>
407 #include <basic/datacache/CacheableData.fwd.hh>
408 #include <basic/datacache/CacheableData.hh>
409 #include <basic/datacache/DataCache.fwd.hh>
410 #include <basic/datacache/DataCache.hh>
411 #include <basic/options/keys/OptionKeys.hh>
412 #include <basic/options/keys/run.OptionKeys.gen.hh>
413 #include <basic/options/keys/score.OptionKeys.gen.hh>
414 #include <basic/options/option.hh>
415 #include <boost/algorithm/string/erase.hpp>
416 #include <boost/bind.hpp>
417 #include <boost/function.hpp>
418 #include <boost/functional/hash.hpp>
419 #include <boost/unordered_map.hpp>
420 
421 //Auto Headers
422 #include <core/pose/util.tmpl.hh>
423 
424 namespace core {
425 namespace scoring {
426 
427 ///////////////////////////////////////////////////////////////////////////////
428 /// @details const so that it may be called within setup_for_scoring
429 /// T_Etable class must implement the following functions:
430 /// bool defines_intrares_energy( EnergyMap const & ) const;
431 /// CountPairFunctionCOP get_intrares_countpair(
432 /// conformation::Residue const &,
433 /// pose::Pose const &,
434 /// ScoreFunction const & ) const;
435 /// CountPairFunctionCOP get_count_pair_function(
436 /// Size &,
437 /// Size &,
438 /// pose::Pose const &,
439 /// ScoreFunction const & ) const;
440 
441 template < class T_Etable >
442 void
444  pose::Pose const & pose,
445  ScoreFunction const & sfxn,
446  T_Etable const & etable_method
447 ) const
448 {
449  using namespace etable::count_pair;
450  using namespace graph;
451 
452  PROF_START( basic::SETUP_NBLIST );
453 
454  Size const nres( pose.total_residue() );
455 
456  if ( auto_update_ ) {
457 
458  if ( reference_coords_.size() == 0 ) {
459  reference_coords_.resize( nres );
460  wide_reference_coords_.resize( nres );
461  atom_needs_update_from_wide_.resize( nres );
462  //atom_has_been_updated_from_wide_.resize( nres );
463  for ( Size ii = 1; ii <= nres; ++ii ) {
464  Size const ii_natoms = pose.residue( ii ).natoms();
465  reference_coords_[ ii ].resize( ii_natoms );
466  wide_reference_coords_[ ii ].resize( ii_natoms );
467  atom_needs_update_from_wide_[ ii ].resize( ii_natoms, 0 );
468  //atom_has_been_updated_from_wide_[ ii ].resize( ii_natoms, 0 );
469  }
470  }
471  assert( reference_coords_.size() == nres );
472  for ( Size ii = 1; ii <= nres; ++ii ) {
473  assert( reference_coords_[ ii ].size() == pose.residue( ii ).natoms() );
474  assert( wide_reference_coords_[ ii ].size() == pose.residue( ii ).natoms() );
475  for ( Size jj = 1; jj <= reference_coords_[ ii ].size(); ++jj ) {
476  reference_coords_[ ii ][ jj ] = pose.residue( ii ).xyz( jj );
477  wide_reference_coords_[ ii ][ jj ] = pose.residue( ii ).xyz( jj );
478  /// if these aren't zero, then the logic for updating atom nblists from the wide-nblists has failed
479  assert( atom_needs_update_from_wide_[ ii ][ jj ] == 0 );
480  //assert( atom_has_been_updated_from_wide_[ ii ][ jj ] == 0 );
481  }
482  }
483  }
484 
485  /////////////////////////
486  // dimension the nblists, or on a subsquenct setup, remove the stale data from
487  // the nblists
488  bool const first_time_setup( nblist_.size() == 0 );
489  assert( first_time_setup || nblist_.size() == pose.total_residue() );
490  if ( first_time_setup ) { nblist_.resize( nres ); upper_nblist_.resize( nres ); intrares_upper_nblist_.resize( nres ); }
491  if ( auto_update_ && first_time_setup ) wide_nblist_.resize( nres );
492  for ( Size i=1; i<= nres; ++i ) {
493  Size const natoms( pose.residue(i).natoms() );
494  if ( first_time_setup ) { nblist_[i].resize( natoms ); upper_nblist_[i].resize( natoms ); intrares_upper_nblist_[i].resize( natoms ); }
495  if ( auto_update_ && first_time_setup ) wide_nblist_[i].resize( natoms );;
496  for ( Size j=1; j<= natoms; ++j ) {
497  nblist_[i][j].clear();
498  upper_nblist_[i][j].clear();
499  intrares_upper_nblist_[i][j].clear();
500  if ( auto_update_ ) wide_nblist_[i][j].clear();
501  }
502  }
503 
504  /// Detect residue neighbors
508  core::conformation::find_neighbors_restricted<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>(
509  residue_point_graph,
510  2 * pose::pose_max_nbr_radius( pose ) +
511  XX_cutoff_ +
512  ( auto_update_ ? 2 * wide_nblist_extension_ : 0 ) ,
513  residue_mask
514  );
515 // find_neighbors(
516 // residue_point_graph,
517 // 2 * pose::pose_max_nbr_radius( pose ) +
518 // XX_cutoff_ +
519 // ( auto_update_ ? 2 * wide_nblist_extension_ : 0 )
520 // );
521 
522 
523  ////////////////////
524  // fill the nblist
525  for ( Size i=1; i<= nres; ++i ) {
526  conformation::Residue const & ires( pose.residue( i ) );
527  int const imap( domain_map_(i) );
528 
529  if (!residue_mask[i]) continue;
531 
532  // are we defining intraresidue interactions? if so, add them
533  // Do we only include intraresidue pair energies in the neighborlist if imap == 0?
534  if ( etable_method.defines_intrares_energy( sfxn.weights() ) && imap == 0 ) {
535 
536  CountPairFunctionCOP count_pair( etable_method.get_intrares_countpair( ires, pose, sfxn) );
537 
538  for ( int ii=1, ii_end = ires.natoms(); ii<= ii_end; ++ii ) {
539  conformation::Atom const & iatom( ires.atom(ii) );
540  bool const iatom_is_hydrogen( ires.atom_is_hydrogen( ii ) );
541  for ( int jj=ii+1, jj_end = ires.natoms(); jj<= jj_end; ++jj ) {
542 
543  // this code is duplicated -- a candidate for refactoring...
544  conformation::Atom const & jatom( ires.atom(jj) );
545  bool const jatom_is_hydrogen( ires.atom_is_hydrogen( jj ) );
546 
547  Real weight(1.0);
548  Size path_dist( 0 );
549  if ( count_pair->count( ii, jj, weight, path_dist ) ) {
550  Real const dist_sq( iatom.xyz().distance_squared( jatom.xyz() ));
551  Real const cutoff = atom_pair_cutoff( iatom_is_hydrogen, jatom_is_hydrogen );
552  if ( dist_sq <= cutoff ) {
553  declare_atoms_neighbors( id::AtomID( ii, i ), id::AtomID( jj, i ), path_dist, weight, weight_func );
554  } // distance check
555 
556  if ( auto_update_ ) {
557  Real const wide_cutoff
558  ( ( iatom_is_hydrogen && jatom_is_hydrogen ) ?
559  HH_cutoff_wide_ : ( ( iatom_is_hydrogen || jatom_is_hydrogen ) ?
561  if ( dist_sq <= wide_cutoff ) {
562  wide_nblist_[i][ii].push_back( AtomNeighbor( i, jj, path_dist, weight ) );
563  wide_nblist_[i][jj].push_back( AtomNeighbor( i, ii, path_dist, weight ) );
564  }
565  }
566 
567  } // count_pair check
568 
569  } // jj = ii=1,ires.natoms()
570  } // ii = 1,ires.natoms()
571  }
572 
573  Real const ireach( pose.residue( i ).nbr_radius() + sqrt_XX_cutoff_ + ( auto_update_ ? 2 * wide_nblist_extension_ : 0 ) );
574 
575  // Iterate across the neighbors of residue i
576  //for ( graph::Graph::EdgeListConstIter
577  // iru = pose.energies().energy_graph().get_node(i)->const_upper_edge_list_begin(),
578  // irue = pose.energies().energy_graph().get_node(i)->const_upper_edge_list_end();
579  // iru != irue; ++iru ) {
581  iru = residue_point_graph->get_vertex( i ).upper_edge_list_begin(),
582  irue = residue_point_graph->get_vertex( i ).upper_edge_list_end();
583  iru != irue; ++iru ) {
584 
585  //EnergyEdge const * edge( static_cast< EnergyEdge const *>(*iru));
586  //EnergyEdge const * edge( utility::down_cast< EnergyEdge const * > (*iru) );
587 
588  Size const j( iru->upper_vertex() );
589  Distance const ijsqrdist( iru->data().dsq() );
590  Distance const ijreach( ireach + pose.residue( j ).nbr_radius() );
591  /// ignore residues with either negative nbr_radii, or residue pairs that are sufficiently separated.
592  if ( ijreach < 0 || ijsqrdist > ijreach * ijreach ) continue;
593 
594  //count_pair::CountPairFunctionCOP count_pair( edge->count_pair_function() );
595  if ( imap == domain_map_(j) && imap != 0 ) continue;
596 
597  CountPairFunctionCOP count_pair( etable_method.get_count_pair_function( i, j, pose, sfxn) );
598 
599  conformation::Residue const & jres( pose.residue( j ) );
600  core::Real weight_func = pose.conformation().get_residue_weight(i,j);
601 
602  for ( int ii=1, ii_end = ires.natoms(); ii<= ii_end; ++ii ) {
603  conformation::Atom const & iatom( ires.atom(ii) );
604  bool const iatom_is_hydrogen( ires.atom_is_hydrogen( ii ) );
605  for ( int jj=1, jj_end = jres.natoms(); jj<= jj_end; ++jj ) {
606  conformation::Atom const & jatom( jres.atom(jj) );
607  bool const jatom_is_hydrogen( jres.atom_is_hydrogen( jj ) );
608 
609  Real weight(1.0);
610  Size path_dist( 0 );
611  if ( count_pair->count( ii, jj, weight, path_dist ) ) {
612  Real const dist_sq( iatom.xyz().distance_squared( jatom.xyz() ));
613  Real const cutoff( atom_pair_cutoff( iatom_is_hydrogen, jatom_is_hydrogen ));
614  if ( dist_sq <= cutoff ) {
615  declare_atoms_neighbors( id::AtomID( ii, i ), id::AtomID( jj, j ), path_dist, weight, weight_func );
616  } // distance check
617 
618  if ( auto_update_ ) {
619  Real const wide_cutoff
620  ( ( iatom_is_hydrogen && jatom_is_hydrogen ) ?
621  HH_cutoff_wide_ : ( ( iatom_is_hydrogen || jatom_is_hydrogen ) ?
623  if ( dist_sq <= wide_cutoff ) {
624  wide_nblist_[i][ii].push_back( AtomNeighbor( j, jj, path_dist, weight, weight_func ) );
625  wide_nblist_[j][jj].push_back( AtomNeighbor( i, ii, path_dist, weight, weight_func ) );
626  }
627  }
628 
629  } // count_pair check
630  } // jj = 1,jres.natoms()
631  } // ii = 1,ires.natoms()
632  } // iru = { rsd nbrs of ires }
633  } // i = 1,nres
634  PROF_STOP ( basic::SETUP_NBLIST );
635 }
636 
637 /// @brief If auto_update_, ensure that no atom in the pose has not moved too much
638 /// since the last time the neighborlist was updated. The neighborlist
639 /// tracks the starting coords for all atoms, and then updates
640 template < class T_Etable >
641 void
643  pose::Pose const & pose,
644  ScoreFunction const & sfxn,
645  T_Etable const & etable_method
646 ) const
647 {
648  //std::cout << "prepare_for_scoring: " << auto_update_ << std::endl;
649  if ( !auto_update_ ) return;
650 
652 
653  atoms_to_update_.clear();
654  Size const nres = pose.total_residue();
655 
656  bool update_narrow = false; // true if any atom has moved > sqrt( move_tolerance_sqr_ ) from reference_coords_
657  bool update_wide = false; // true if any atom has moved > sqrt( wide_move_tolerance_sqr_ ) from wide_reference_coords_
658 
659  assert( atom_needs_update_from_wide_.size() == nres );
660  for ( Size ii = 1; ii <= nres; ++ii ) {
661  assert( reference_coords_[ ii ].size() == pose.residue( ii ).natoms() );
662  assert( atom_needs_update_from_wide_[ ii ].size() == pose.residue( ii ).natoms() );
663  for ( Size jj = 1; jj <= reference_coords_[ ii ].size(); ++jj ) {
664  DistanceSquared dsqr_from_ref = reference_coords_[ ii ][ jj ].distance_squared( pose.residue( ii ).xyz( jj ));
665  if ( dsqr_from_ref > move_tolerance_sqr_ ) {
666  DistanceSquared dsqr_from_wide_ref = wide_reference_coords_[ ii ][ jj ].distance_squared( pose.residue( ii ).xyz( jj ));
667  if ( dsqr_from_wide_ref > wide_move_tolerance_sqr_ ) {
668  //std::cout << "Atom " << pose.residue( ii ).atom_name( jj ) << " on residue " << pose.residue( ii ).name() << " ";
669  //std::cout << ii << " moved " << dsqr_from_wide_ref;
670  //std::cout << " which is greater than wide move tolerance " << sqrt( wide_move_tolerance_sqr_ ) << std::endl;
671 
672  update_wide = true;
673  break;
674  }
675  //std::cout << "Atom " << pose.residue( ii ).atom_name( jj ) << " on residue " << pose.residue( ii ).name() << " ";
676  //std::cout << ii << " moved " << reference_coords_[ ii ][ jj ].distance( pose.residue( ii ).xyz( jj ));
677  //std::cout << " which is greater than " << sqrt( move_tolerance_sqr_ ) << std::endl;
678  update_narrow = true;
679  atom_needs_update_from_wide_[ ii ][ jj ] = 1;
680  atoms_to_update_.push_back( id::AtomID( jj, ii ) );
681  }
682  }
683  if ( update_wide ) break;
684  }
685  if ( update_wide ) {
686  /// Any atoms that we thought needed narrow-from-wide updates need to be reset.
687  for ( Size ii = 1; ii <= atoms_to_update_.size(); ++ii ) {
688  id::AtomID ii_atom( atoms_to_update_[ ii ] );
689  atom_needs_update_from_wide_[ ii_atom.rsd() ][ ii_atom.atomno() ] = 0;
690  }
691 
692  //std::cout << "Updating entire neighborlist!" << std::endl;
693  ++n_full_updates_;
694  setup( pose, sfxn, etable_method );
695  } else if ( update_narrow ) {
696  //std::cout << "Updating neighborlist from wide neighborlist" << std::endl;
698  update_from_wide_nblist( pose );
699  }
700 }
701 
702 }
703 }
704 
705 #endif