Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Fa_MbenvEnergy.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file core/scoring/methods/Fa_MbenvEnergy.cc
10 /// @author Patrick Barth
11 
12 
13 // Unit headers
16 
17 // Package headers
24 // AUTO-REMOVED #include <core/scoring/Energies.hh> //pba
29 
30 // Project headers
31 #include <core/pose/Pose.hh>
33 // AUTO-REMOVED #include <core/chemical/AtomType.hh>
34 #include <core/id/AtomID.hh>
36 #include <basic/datacache/BasicDataCache.hh> //pba
37 
38 //#include <ObjexxFCL/formatted.o.hh>
39 #include <ObjexxFCL/FArray1.fwd.hh>
40 
41 #include <utility/vector1.hh>
42 
43 
44 namespace core {
45 namespace scoring {
46 namespace methods {
47 
48 
49 /// that created object reads in the three database files: p_aa, p_aa_pp, and p_aa_n. That object is returned and then stored as
50 /// a private member variable here.
51 /// @details This must return a fresh instance of the Fa_MbsolvEnergy class,
52 /// never an instance already in use
55  methods::EnergyMethodOptions const & options
56 ) const {
57  return new Fa_MbenvEnergy(*( ScoringManager::get_instance()->memb_etable( options.etable_type() )) );
58 }
59 
62  ScoreTypes sts;
63  sts.push_back( fa_mbenv );
64  return sts;
65 }
66 
67 
70  memb_etable_(memb_etable_in),
71  lk_dgrefce_(memb_etable_in.lk_dgrefce()),
72  memb_lk_dgrefce_(memb_etable_in.memb_lk_dgrefce()),
73  potential_( ScoringManager::get_instance()->get_Membrane_FAPotential() )
74 {}
75 
76 
79  return new Fa_MbenvEnergy( *this );
80 }
81 
82 
83 /////////////////////////////////////////////////////////////////////////////
84 // methods for ContextDependentOneBodyEnergies
85 /////////////////////////////////////////////////////////////////////////////
86 
87 ///
88 void
90 {
92 }
93 
94 void
96  conformation::Residue const & rsd,
97  pose::Pose const & pose,
98  EnergyMap & emap ) const {
99 
100  for ( Size i = 1, i_end = rsd.nheavyatoms(); i <= i_end; ++i ) {
101  emap[ fa_mbenv ] += eval_fa_mbenv( rsd.atom(i), Membrane_FAEmbed_from_pose( pose ).fa_proj(rsd.seqpos(),i));
102  }
103 }
104 
105 ////////////////////////////////////////////////
106 Real
108  conformation::Atom const & atom1,
109  Real const & f1 ) const
110 {
111 
112  Real temp_score( 0.0 );
113  //Make this an input option for efficiency
114  //bool const eval_deriv( true );
115 
116  // l1 and l2 are FArray LINEAR INDICES for fast lookup:
117  // [ l1 ] == (disbin ,attype2,attype1)
118  // [ l2 ] == (disbin+1,attype2,attype1)
119 
120  temp_score = (1 - f1) * (memb_lk_dgrefce_(atom1.type()) - lk_dgrefce_(atom1.type()));
121  return temp_score;
122 
123 }
124 
125 /////////////////////////////////////////////////////////////////////////////
126 // derivatives
127 /////////////////////////////////////////////////////////////////////////////
128 void
130  pose::Pose & pose,
131  ScoreFunction const & scfxn
132 ) const
133 {
135  fa_mbenv_weight_ = scfxn.weights()[ fa_mbenv ];
136 }
137 
138 //////////////////////////////////////////////////////////////////////////////////////
139 void
141  id::AtomID const & atom_id,
142  pose::Pose const & pose,
143  kinematics::DomainMap const & /*domain_map*/,
144  ScoreFunction const &,// sfxn,
145  EnergyMap const & /*weights*/,
146  Vector & F1,
147  Vector & F2
148 ) const
149 {
150 
151  Size const i( atom_id.rsd() );
152  Size const m( atom_id.atomno() );
153  conformation::Residue const & rsd1( pose.residue( i ) );
154 
155  if ( m > rsd1.nheavyatoms() ) return;
156 
157  Vector const heavy_atom_i( rsd1.xyz( m ) );
158  // bool const pos1_fixed( domain_map( i ) != 0 );
159 
160  Real cp_weight = 1.0;
161 
162  Vector const center(MembraneEmbed_from_pose( pose ).center());
163 
164  Vector f1( 0.0 ), f2( 0.0 );
165 
166  Real const deriv = memb_lk_dgrefce_(rsd1.atom(m).type()) - lk_dgrefce_(rsd1.atom(m).type());
167  Real dE_dZ_over_r = fa_mbenv_weight_ * deriv * Membrane_FAEmbed_from_pose( pose ).fa_proj_deriv(rsd1.seqpos(),m);
168 
169  Vector const d_ij = Membrane_FAEmbed_from_pose( pose ).fa_proj_coord(rsd1.seqpos(),m) - heavy_atom_i;
170  Real const d_ij_norm = d_ij.length();
171  if ( d_ij_norm == Real(0.0) ) return;
172 
173  Real const invd = 1.0 / d_ij_norm;
174  f2 = d_ij * invd;
175  f1 = Membrane_FAEmbed_from_pose( pose ).fa_proj_coord(rsd1.seqpos(),m).cross(heavy_atom_i);
176  f1 *= invd;
177 
178  if ( dE_dZ_over_r != 0.0 ) {
179  F1 += dE_dZ_over_r * cp_weight * f1;
180  F2 += dE_dZ_over_r * cp_weight * f2;
181  }
182 }
183 
184 ////////////////////////////////////////////////
185 void
187  pose::Pose & /*pose*/,
188  ScoreFunction const &,
189  EnergyMap & emap
190 ) const
191 {
192  //std::cout << "BEFORE emap[ fa_mbenv ] " << emap[ fa_mbenv ] << std::endl;
193  //emap[ fa_mbenv ] += Membrane_FAEmbed_from_pose( pose ).fa_penalty();
194  emap[ fa_mbenv ] += 0.0;
195  //std::cout << "AFTER emap[ fa_mbenv ] " << emap[ fa_mbenv ] << std::endl;
196 }
197 
198 /// @brief Fa_MbenvEnergy is context independent; indicates that no context graphs are required
199 void
201 
202 /// @details Pose must already contain a cenlist object or this method will fail.
203 Membrane_FAEmbed const &
205 {
206  //using core::pose::datacache::CacheableDataType::MEMBRANE_FAEMBED;
207  return *( static_cast< Membrane_FAEmbed const * >( pose.data().get_const_ptr( core::pose::datacache::CacheableDataType::MEMBRANE_FAEMBED )() ));
208 }
209 
210 MembraneEmbed const &
212 {
213  //using core::pose::datacache::CacheableDataType::MEMBRANE_EMBED;
215  return *( static_cast< MembraneEmbed const * >( pose.data().get_const_ptr( core::pose::datacache::CacheableDataType::MEMBRANE_EMBED )() ));
216 }
217 
218 MembraneTopology const &
220 {
221  //using core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY;
222  return *( static_cast< MembraneTopology const * >( pose.data().get_const_ptr( core::pose::datacache::CacheableDataType::MEMBRANE_TOPOLOGY )() ));
223 }
226 {
227  return 1; // Initial versioning
228 }
229 
230 
231 } // methods
232 } // scoring
233 } // core
234