Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SingleResidueMultifunc.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/optimization/SingleResidueMultifunc.cc
11 ///
12 /// @brief
13 /// @author Ian W. Davis
14 
16 
17 #include <core/graph/Graph.hh>
22 #include <core/pose/Pose.hh>
23 #include <core/scoring/Energies.hh>
25 // AUTO-REMOVED #include <core/scoring/ScoreFunctionInfo.hh>
29 #include <basic/prof.hh>
30 
32 
33 #include <utility/vector1.hh>
34 
35 
36 
37 namespace core {
38 namespace optimization {
39 
41  pose::Pose & pose_in,
42  Size const rsd_id_in,
43  MinimizerMap & min_map_in,
44  scoring::ScoreFunction const & scorefxn_in,
45  graph::GraphCOP packer_neighbor_graph_in,
46  bool const deriv_check_in,
47  bool const deriv_check_verbose_in
48 ):
49  AtomTreeMultifunc(pose_in, min_map_in, scorefxn_in, deriv_check_in, deriv_check_verbose_in),
50  rsd_id_(rsd_id_in),
51  packer_neighbor_graph_(packer_neighbor_graph_in)
52 {}
53 
55 
56 // func
57 Real
59  using namespace conformation;
60  using namespace scoring;
61 
65 
66  PROF_START( basic::FUNC );
69 
70  // Code adapted from RotamerSet_::compute_onebody_energies()
71  EnergyMap emap;
72  EnergyMap emap2b;
73 
75  // Setup (particularly hbonds) is expensive and so is done once, in RTMIN.
76  //// do any setup necessary
77  //for ( ScoreFunction::AllMethodsIterator it=score_function_.all_energies_begin(),
78  // it_end = score_function_.all_energies_end(); it != it_end; ++it ) {
79  // (*it)->setup_for_scoring( pose_, score_function_ );
80  //}
81 
82  score_function_.eval_ci_1b( rsd, pose_, emap );
83  score_function_.eval_cd_1b( rsd, pose_, emap );
85 
87  ir = packer_neighbor_graph_->get_node( rsd_id_ )->const_edge_list_begin(),
88  ire = packer_neighbor_graph_->get_node( rsd_id_ )->const_edge_list_end();
89  ir != ire; ++ir ) {
90  int const neighbor_id( (*ir)->get_other_ind( rsd_id_ ) );
91  //if ( task.pack_residue( neighbor_id ) ) continue;
92  Residue const & neighbor( pose_.residue( neighbor_id ) );
93 
94  emap2b.zero();
95  score_function_.eval_ci_2b( rsd, neighbor, pose_, emap2b );
96  emap += emap2b;
97 
98  emap2b.zero();
99  score_function_.eval_cd_2b( rsd, neighbor, pose_, emap2b );
100  emap += emap2b;
101  }
102 
103  // long-range energy interactions
104  // Iterate across the long range energy functions and use the iterators generated
105  // by the LRnergy container object
109  lr_iter != lr_end; ++lr_iter ) {
110  LREnergyContainerCOP lrec = pose_.energies().long_range_container( (*lr_iter)->long_range_type() );
111  if ( !lrec || lrec->empty() ) continue; // only score non-emtpy energies.
112 
113  // Potentially O(N) operation leading to O(N^2) behavior
115  rni = lrec->const_neighbor_iterator_begin( rsd_id_ ),
116  rniend = lrec->const_neighbor_iterator_end( rsd_id_ );
117  (*rni) != (*rniend); ++(*rni) ) {
118  Size const neighbor_id = rni->neighbor_id();
119  assert( neighbor_id != rsd_id_ );
120 
121  (*lr_iter)->residue_pair_energy( rsd, pose_.residue( neighbor_id ), pose_, score_function_, emap );
122 
123  } // (potentially) long-range neighbors of rsd
124  } // long-range energy functions
125 
126  // give energyfunctions a chance update/finalize energies
127  // etable nblist calculation is performed here (?)
129  it_end = score_function_.all_energies_end(); it != it_end; ++it ) {
130  (*it)->finalize_total_energy( pose_, score_function_, emap );
131  }
132 
133  //emap.show_weighted(std::cout, score_function_.weights());
134 
135  Real const score = score_function_.weights().dot( emap );
137  PROF_STOP( basic::FUNC );
138  return score;
139 }
140 
141 } // namespace optimization
142 } // namespace core
143