Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RamachandranEnergy2B.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/methods/RamachandranEnergy.cc
11 /// @brief Ramachandran energy method class implementation
12 /// @author Phil Bradley
13 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
14 
15 // Unit Headers
18 
19 // Package Headers
22 
23 // Project headers
25 #include <core/id/TorsionID.hh>
26 #include <core/pose/Pose.hh>
28 #include <basic/options/option.hh>
29 
30 // Utility headers
31 #include <numeric/conversions.hh>
32 
33 // option key includes
34 
35 #include <basic/options/keys/score.OptionKeys.gen.hh>
36 
37 #include <utility/vector1.hh>
38 
39 
40 
41 
42 // C++
43 
44 
45 namespace core {
46 namespace scoring {
47 namespace methods {
48 
49 
50 /// @details This must return a fresh instance of the RamachandranEnergy2B class,
51 /// never an instance already in use
55 ) const {
56  return new RamachandranEnergy2B;
57 }
58 
61  ScoreTypes sts;
62  sts.push_back( rama2b );
63  return sts;
64 }
65 
66 
67 /// ctor
70  potential_( ScoringManager::get_instance()->get_Ramachandran2B() )
71 {}
72 
73 /// clone
76 {
77  return new RamachandranEnergy2B;
78 }
79 
80 /////////////////////////////////////////////////////////////////////////////
81 // methods for ContextIndependentOneBodyEnergies
82 /////////////////////////////////////////////////////////////////////////////
83 
84 void
86  conformation::Residue const & rsd1,
87  conformation::Residue const & rsd2,
88  pose::Pose const &, // unnneeded
89  ScoreFunction const &, // unneeded
90  EnergyMap & emap
91 ) const
92 {
93  using namespace basic::options;
94  using namespace basic::options::OptionKeys;
95 
96  if ( ! option[ score::ramaneighbors ] ) return;
97 
98  /// This is called for all nearby residue pairs, so first check to make sure that we've got an i, i+1 pair
99  if ( rsd1.seqpos() + 1 != rsd2.seqpos() || rsd1.seqpos() != rsd2.seqpos() + 1 ) return;
100  if ( rsd1.chain() != rsd2.chain() ) return;
101  if ( ! rsd1.is_protein() || ! rsd2.is_protein() ) return;
102 
103  conformation::Residue const & lower_residue( rsd1.seqpos() < rsd2.seqpos() ? rsd1 : rsd2 );
104  conformation::Residue const & upper_residue( rsd1.seqpos() < rsd2.seqpos() ? rsd2 : rsd1 );
105 
106  //// also need to treat cutpoints correctly.
107 
108  if ( ! lower_residue.is_lower_terminus() ) {
109  emap[ rama2b ] += potential_.RamaE_Upper( lower_residue, upper_residue.aa() );
110  }
111 
112  if ( ! upper_residue.is_upper_terminus() ) {
113  emap[ rama2b ] += potential_.RamaE_Lower( upper_residue, lower_residue.aa() );
114  }
115 }
116 
117 bool
119  return true;
120 }
121 
122 /// @details fictional Cprev-Nnext distance + fudge.
123 Real
125 {
126  return 2.0;
127 }
128 
129 void
131  conformation::Residue const & rsd,
132  pose::Pose const &, // unused,
133  ScoreFunction const &, // unused,
134  EnergyMap & emap
135 ) const
136 {
137  using namespace basic::options;
138  using namespace basic::options::OptionKeys;
139 
140  if ( ! rsd.is_protein() ) return;
141 
142  if ( rsd.is_terminus() ) {
143  /// -- no op -- Rama does not have a defined score for termini
144  /// emap[ rama ] += potential_.Rama_E( rsd ); // add in neighbor-independent rama scores for termini
145  } else if ( option[ score::ramaneighbors ] ) {
146  emap[ rama2b ] -= potential_.RamaE( rsd ); // subtract double-counted neighbor-independent rama scores for mid residues
147  } else {
148  emap[ rama2b ] += potential_.RamaE( rsd ); // add the neighbor-independent rama score, since there's no double counting.
149  }
150 }
151 
152 ///
153 Real
155  id::DOF_ID const &,// dof_id,
156  id::TorsionID const & tor_id,
157  pose::Pose const & pose,
158  ScoreFunction const &,// sfxn,
159  EnergyMap const & weights
160 ) const
161 {
162  using namespace basic::options;
163  using namespace basic::options::OptionKeys;
164 
165  Real deriv(0.0);
166  if ( tor_id.valid() && tor_id.type() == id::BB ) {
167  conformation::Residue const & rsd( pose.residue( tor_id.rsd() ) );
168  if ( rsd.is_protein() && tor_id.torsion() <= 2 && ! rsd.is_terminus() ) {
169  Real rama_score, drama_dphi, drama_dpsi;
170  if ( option[ score::ramaneighbors ] ) {
171  // Neighbor dependent rama score + derivatives.
172  Size const seqpos( rsd.seqpos() );
174  pose.residue_type( seqpos - 1 ).aa(),
175  pose.residue_type( seqpos + 1 ).aa(),
176  rama_score, drama_dphi, drama_dpsi );
177  } else {
178  /// Neighbor independent rama score + derivatives
180  rama_score, drama_dphi, drama_dpsi );
181  }
182  deriv = ( tor_id.torsion() == 1 ? drama_dphi : drama_dpsi );
183  }
184  }
185  // note that the atomtree PHI dofs are in radians
186  // use degrees since dE/dangle has angle in denominator
187  return numeric::conversions::degrees( weights[ rama ] * deriv );
188 }
189 
190 /// @brief Ramachandran Energy is context independent and thus indicates that no context graphs need to
191 /// be maintained by class Energies
192 void
194  utility::vector1< bool > & /*context_graphs_required*/
195 )
196 const
197 {}
200 {
201  return 1; // Initial versioning
202 }
203 
204 
205 } // methods
206 } // scoring
207 } // core
208