Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnergyEval.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/fragment/picking_old/vall/eval/EnergyEval.cc
11 /// @brief scores a fragment by inserting its backbone angles into a Pose
12 /// and evaluating its energy using a given ScoreFunction
13 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
14 
15 // unit headers
17 
18 // project headers
19 #include <basic/Tracer.hh>
20 
21 // numeric headers
22 #include <numeric/random/random.hh>
23 
24 //Auto Headers
26 #include <utility/vector1.hh>
27 
28 
29 
30 namespace core {
31 namespace fragment {
32 namespace picking_old {
33 namespace vall {
34 namespace eval {
35 
36 
37 // static initialization
38 static numeric::random::RandomGenerator RG( 167872 ); // magic number, don't change
39 
40 static basic::Tracer TR( "core.fragment.picking_old.vall.eval.EnergyEval" );
41 
42 
43 /// @brief default constructor
45  Super(),
46  insert_position_( 0 ),
47  randomize_( false )
48 {}
49 
50 
51 /// @brief constructor
52 /// @param[in] pose insert backbone angles using a copy of this Pose
53 /// @param[in] insert_position insert backbone angles starting from this
54 /// position in the Pose
55 /// @param[in] score_function evaluate the Pose using a copy of this
56 /// ScoreFunction
57 /// @param[in] randomize flags that indicates whether a small amount
58 /// of noise between [0, 0.000001) will be added to the energy
60  Pose const & pose,
61  Size const insert_position,
62  ScoreFunction const & score_function,
63  bool const randomize
64 ) :
65  Super(),
66  pose_( pose ),
67  insert_position_( insert_position ),
68  score_function_( score_function ),
69  randomize_( randomize )
70 {}
71 
72 
73 /// @brief default copy constructor
75  Super( rval ),
76  pose_( rval.pose_ ),
77  insert_position_( rval.insert_position_ ),
78  score_function_( rval.score_function_ ),
79  randomize_( rval.randomize_ )
80 {}
81 
82 
83 /// @brief default destructor
85 
86 
87 /// @brief copy assignment
89  if ( this != &rval ) {
90  Super::operator =( rval );
91 
92  pose_ = rval.pose_;
95  randomize_ = rval.randomize_;
96  }
97  return *this;
98 }
99 
100 
101 /// @brief clone this object
103  return new EnergyEval( *this );
104 }
105 
106 
107 /// @brief for a fragment extent, evaluate and store results in a VallFragmentScore
108 /// @return true, so score is always stored during VallLibrarian::catalog()
110  Extent const & extent,
111  VallFragmentScore & fs
112 )
113 {
114  // insert backbone angles
115  Size position = insert_position_;
116  for ( VallResidueConstIterator i = extent.begin; i != extent.end; ++i, ++position ) {
117  pose_.set_phi( position, i->phi() );
118  pose_.set_psi( position, i->psi() );
119  pose_.set_omega( position, i->omega() );
120  }
121 
122  // evaluate the energy
123  fs.score += score_function_( pose_ );
124 
125  if ( randomize_ ) {
126  fs.score += ( RG.uniform() * 0.000001 );
127  }
128 
129  return true;
130 }
131 
132 
133 /// @brief operation to be perform before catalog() starts
136  TR << std::endl;
137 }
138 
139 
140 } // namespace eval
141 } // namespace vall
142 } // namespace picking_old
143 } // namespace fragment
144 } // namespace core
145