Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HybridVDW_Energy.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/HybridVDW_Energy.cc
11 /// @brief Statistically derived rotamer pair potential class implementation
12 /// @author Phil Bradley
13 /// @author Andrew Leaver-Fay
14 
15 
16 // Unit headers
19 
20 // Package headers
21 #include <core/scoring/AtomVDW.hh>
23 #include <core/scoring/Energies.hh>
25 //#include <core/scoring/etable/count_pair/CountPair1BC4.hh>
26 // AUTO-REMOVED #include <core/scoring/etable/count_pair/CountPairFunction.hh>
27 // AUTO-REMOVED #include <core/scoring/etable/count_pair/CountPairFactory.hh>
28 // AUTO-REMOVED #include <core/scoring/etable/count_pair/types.hh>
29 
30 // Project headers
31 #include <core/pose/Pose.hh>
35 
36 #include <core/id/AtomID.hh>
38 #include <utility/vector1.hh>
39 
40 
41 
42 namespace core {
43 namespace scoring {
44 namespace methods {
45 
46 
47 /// @details This must return a fresh instance of the HybridVDW_Energy class,
48 /// never an instance already in use
52 ) const {
53  return new HybridVDW_Energy;
54 }
55 
58  ScoreTypes sts;
59  sts.push_back( hybrid_vdw );
60  return sts;
61 }
62 
63 
64 Real const vdw_scale_factor( 0.8 );
65 
66 /// @details C-TOR
69  atom_vdw_( ScoringManager::get_instance()->get_AtomVDW( chemical::HYBRID_FA_STANDARD_CENTROID ) )
70 {}
71 
72 
73 /// clone
76 {
77  return new HybridVDW_Energy( *this );
78 }
79 
80 /// @details copy c-tor
82  parent( src ),
83  atom_vdw_( src.atom_vdw_ )
84 {}
85 
86 
87 /////////////////////////////////////////////////////////////////////////////
88 // scoring
89 /////////////////////////////////////////////////////////////////////////////
90 
91 ///
92 void
94 {
95  // is this really necessary?
97 }
98 
99 
100 ///
101 void
103 {
104  // is this really necessary?
106 }
107 
108 
109 ///
110 void
112  conformation::Residue const & rsd1, //_in,
113  conformation::Residue const & rsd2, //_in,
114  pose::Pose const &,
115  ScoreFunction const &,
116  EnergyMap & emap
117 ) const
118 {
119  using namespace etable::count_pair;
120 
121 
122  if ( ( rsd1.is_protein() && ! rsd2.is_protein() ) ||
123  ( rsd2.is_protein() && ! rsd1.is_protein() ) ) {
124  //OK
125  } else {
126  return;
127  }
128 // bool swap( false );
129 // if ( rsd1_in.is_protein() && !rsd2_in.is_protein() ) {
130 // // pass
131 // } else if ( rsd2_in.is_protein() && !rsd1_in.is_protein() ) {
132 // swap = true;
133 // } else {
134 // return;
135 // }
136 
137 // conformation::Residue const & rsd1( swap ? rsd2_in : rsd1_in );
138 // conformation::Residue const & rsd2( swap ? rsd1_in : rsd2_in );
139 // assert( rsd1.is_protein() && !rsd2.is_protein() );
140 
141  Real score(0.0);
142  assert( ! rsd1.is_bonded( rsd2 ) );
143 
144  // no countpair!
145  for ( Size i = 1, i_end = rsd1.natoms(); i <= i_end; ++i ) {
146  Vector const & i_xyz( rsd1.xyz(i) );
147  Size const i_type( rsd1.atom_type_index(i) );
148  Real const i_radius( atom_vdw_.approximate_vdw_radius( i_type ) );
149  for ( Size j = 1, j_end = rsd2.natoms(); j <= j_end; ++j ) {
150  Real const bump_dsq( numeric::square( i_radius + atom_vdw_.approximate_vdw_radius( rsd2.atom_type_index( j ) ) ) );
151  Real const clash( bump_dsq - i_xyz.distance_squared( rsd2.xyz(j) ) );
152  if ( clash > 0.0 ) {
153  score += ( clash * clash ) / bump_dsq;
154  //std::cout << "BUMP: " << I(4,rsd1.seqpos() ) << I(4,rsd2.seqpos() ) <<
155  // ' ' << rsd1.atom_name(i) << ' ' << rsd2.atom_name(j) << ' ' << ( clash * clash ) / bump_dsq << std::endl;
156  }
157  }
158  }
161  emap[ hybrid_vdw ] += score * vdw_scale_factor;
162 
163 }
164 
165 
166 void
168  id::AtomID const & atom_id,
169  pose::Pose const & pose,
170  kinematics::DomainMap const & domain_map,
171  ScoreFunction const &,
172  EnergyMap const & weights,
173  Vector & F1,
174  Vector & F2
175  ) const
176 {
177  using namespace etable::count_pair;
178 
179  // what is my charge?
180  Size const pos1( atom_id.rsd() );
181  Size const i ( atom_id.atomno() );
182  conformation::Residue const & rsd1( pose.residue( pos1 ) );
183 
184  int const pos1_map( domain_map( pos1 ) );
185  bool const pos1_fixed( pos1_map != 0 );
186 
187  Vector const & i_xyz( rsd1.xyz(i) );
188  Size const i_type( rsd1.atom_type_index(i) );
189  Real const i_radius( atom_vdw_.approximate_vdw_radius( i_type ) );
190  //utility::vector1< Real > const & i_atom_vdw( atom_vdw_( i_type ) );
191 
192  // cached energies object
193  Energies const & energies( pose.energies() );
194 
195  // the neighbor/energy links
196  EnergyGraph const & energy_graph( energies.energy_graph() );
197 
198  // loop over *all* nbrs of rsd1 (not just upper or lower)
200  iru = energy_graph.get_node( pos1 )->const_edge_list_begin(),
201  irue = energy_graph.get_node( pos1 )->const_edge_list_end();
202  iru != irue; ++iru ) {
203  //EnergyEdge const * edge( static_cast< EnergyEdge const *> (*iru) );
204  //Size const pos2( edge->get_second_node_ind() );
205  Size const pos2( (*iru)->get_other_ind( pos1 ) );
206 
207  if ( pos1_fixed && pos1_map == domain_map( pos2 ) ) continue; // fixed wrt one another
208 
209  conformation::Residue const & rsd2( pose.residue( pos2 ) );
210 
211  if ( ! ( ( rsd1.is_protein() && ! rsd2.is_protein() ) ||
212  ( rsd2.is_protein() && ! rsd1.is_protein() ) ) ) continue;
213  assert( pos2 != pos1 );
214  assert( ! rsd1.is_bonded( rsd2 ) );
215  // no countpair!
216  for ( Size j=1, j_end = rsd2.natoms(); j<= j_end; ++j ) {
217 
218  Vector const & j_xyz( rsd2.xyz(j) );
219  Vector const f2( i_xyz - j_xyz );
220  Real const dis2( f2.length_squared() );
221  //Real const bump_dsq( i_atom_vdw[ rsd2.atom_type_index(j) ] );
222 
223  Real const bump_dsq( numeric::square( i_radius + atom_vdw_.approximate_vdw_radius( rsd2.atom_type_index( j ) ) ) );
224 
225  if ( dis2 < bump_dsq ) {
226  // E += vdw_scale_factor_ * weights[vdw] * ( ( dis2 - bump_dsq ) **2 ) / bump_dsq
227  Real const dE_dr_over_r = vdw_scale_factor * weights[ hybrid_vdw ] * 4.0 * ( dis2 - bump_dsq ) / bump_dsq;
228  Vector const f1( i_xyz.cross( j_xyz ) );
229  F1 += dE_dr_over_r * f1;
230  F2 += dE_dr_over_r * f2;
231  }
232  }
233 
234  } // loop over nbrs of rsd1
235 
236 }
237 
238 
239 
240 /// @brief HybridVDW_Energy distance cutoff
241 Distance
243 {
244  return 6.0; /// now subtracted off 3.0 from cutoffs in centroid params files
245  //return 0.0; /// since all the cutoffs for centroid mode are rolled into the cendist check
246 }
247 
248 /// @brief HybridVDW_Energy
249 void
251 {
252 }
255 {
256  return 1; // Initial versioning
257 }
258 
259 
260 
261 }
262 }
263 }