Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AACompositionEnergy.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/fldsgn/potentials/AACompositionEnergy.cc
11 /// @brief
12 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
13 
14 // Unit headers
17 
18 // Package headers
20 
21 // Project headers
22 #include <core/pose/Pose.hh>
26 // AUTO-REMOVED #include <core/scoring/ScoreFunction.hh>
27 
28 #include <utility/vector1.hh>
29 
30 
31 
32 namespace protocols {
33 namespace fldsgn {
34 namespace potentials {
35 
38 {
39  return new AACompositionEnergy;
40 }
41 
44 {
45  ScoreTypes sts;
46  sts.push_back( core::scoring::aa_cmp );
47  return sts;
48 }
49 
50 
51 /// @brief default constructor
54 {}
55 
56 
57 /// @brief default constructor
58  AACompositionEnergy::AACompositionEnergy( std::map< AA, std::pair< Real, Real > > const & comp_constraint_aas ) :
60  comp_constraint_aas_( comp_constraint_aas )
61 {
62  initialize();
63 }
64 
65 
66 /// @brief copy constructor
68  parent( src ),
69  comp_constraint_aas_( src.comp_constraint_aas_ )
70 {}
71 
72 
73 /// @brief
75 
76 
77 /// @brief clone
80 {
81  return new AACompositionEnergy( *this );
82 }
83 
84 
85 /// @brief use GoPotential
86 void
87 AACompositionEnergy::set_comp_constraint_aa( std::map< AA, std::pair< Real, Real > > const & comp_constraint_aas )
88 {
89  comp_constraint_aas_ = comp_constraint_aas;
90  initialize();
91 }
92 
93 
94 /// @brief
95 void
97 {}
98 
99 
100 /// @brief
101 void
103  Residue const & rsd,
104  Pose const & pose,
105  EnergyMap & emap
106 ) const
107 {
108  std::map< AA, Size > hist;
109  Size total_types( core::chemical::num_aa_types );
110  for( Size i=1; i<=total_types; i++ ) {
111  AA aa = AA( i );
112  hist.insert( std::map< AA, Size >::value_type( aa, 0 ) );
113  }
114  for( Size i=1; i<=pose.total_residue(); i++ ) {
115  hist[ pose.aa( i ) ] ++;
116  }
117 
118  //
119  std::map< AA, std::pair< Real, Real > >::const_iterator itr( comp_constraint_aas_.find( rsd.aa() ) );
120  if( itr != comp_constraint_aas_.end() ) {
121  // histgoram if the residue at rsd.seqpos() is mutated to rsd.aa()
122  hist[ itr->first ] ++;
123  hist[ pose.aa( rsd.seqpos() ) ] --;
124  }
125 
126  // basic energy
127  Real e( 0.0 );
128  itr = comp_constraint_aas_.begin();
129  while( itr != comp_constraint_aas_.end() ) {
130 
131  std::pair< Real, Real > thresholds( itr->second );
132  #ifndef WIN32
133  Size const lower = (Size)round( thresholds.first * pose.total_residue() );
134  Size const upper = (Size)round( thresholds.second * pose.total_residue() );
135  #else
136  Size const lower = (Size)double( thresholds.first * pose.total_residue() + 0.5 );
137  Size const upper = (Size)double( thresholds.second * pose.total_residue() + 0.5 );
138  #endif
139 
140  if( hist[ itr->first ] < lower ) {
141  e += numeric::square( hist[ itr->first ] - lower );
142  } else if( hist[ itr->first ] > upper ) {
143  e += numeric::square( hist[ itr->first ] - upper );
144  }
145 
146  //std::cout << core::chemical::name_from_aa( itr->first ) << " " << hist[ itr->first ] <<
147  // " " << thresholds.first << " " << thresholds.second << " " << lower << " " << upper << std::endl;
148  ++itr;
149 
150  }
151  emap[ core::scoring::aa_cmp ] = e;
152 
153  //std::cout << rsd.seqpos() << " " << core::chemical::name_from_aa( pose.aa( rsd.seqpos() ) ) << " "
154  //<< core::chemical::name_from_aa( rsd.aa() ) << " " << hist[ rsd.aa() ] << " " << e << std::endl;
155 
156 }
157 
158 
159 /// @brief ReferenceEnergy is context independent; indicates that no
160 /// context graphs are required
161 void
163 {}
164 
165 
166 } // potentials
167 } // fldsgn
168 } // protocols