Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_VDW_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/rna/RNA_VDW_Energy.cc
11 /// @brief Statistically derived clash check for RNA.
12 /// @author Rhiju Das
13 
14 
15 // Unit headers
18 
19 // Package headers
23 #include <core/scoring/Energies.hh>
25 #include <basic/Tracer.hh>
26 
27 // Project headers
28 #include <core/pose/Pose.hh>
30 
31 
32 #include <core/id/AtomID.hh>
33 #include <utility/vector1.hh>
34 #include <ObjexxFCL/FArray2D.hh>
35 
36 #include <ObjexxFCL/format.hh>
37 
38 using ObjexxFCL::fmt::I;
39 
40 static basic::Tracer tr("core.scoring.rna.RNA_VDW_Energy");
41 
42 namespace core {
43 namespace scoring {
44 namespace rna {
45 
46 
47 /// @details This must return a fresh instance of the RNA_VDW_Energy class,
48 /// never an instance already in use
52 ) const {
53  return new RNA_VDW_Energy;
54 }
55 
58  ScoreTypes sts;
59  sts.push_back( rna_vdw );
60  return sts;
61 }
62 
63 
66  rna_atom_vdw_( ScoringManager::get_instance()->get_RNA_AtomVDW() ), // need to make the table choice configurable
67  vdw_scale_factor_( 0.8 ) // hack from rosetta++
68 {}
69 
70 
71 /// clone
74 {
75  return new RNA_VDW_Energy;
76 }
77 
78 /////////////////////////////////////////////////////////////////////////////
79 // scoring
80 /////////////////////////////////////////////////////////////////////////////
81 
82 //////////////////////////////////////////////////////////////////////////////////////////
83 void
85 {
88 }
89 
90 
91 //////////////////////////////////////////////////////////////////////////////////////////
92 void
94 {
97 }
98 
99 
100 //////////////////////////////////////////////////////////////////////////////////////////
101 void
103 {
106 }
107 
108 
109 
110 //////////////////////////////////////////////////////////////////////////////////////////
111 void
113  conformation::Residue const & rsd1,
114  conformation::Residue const & rsd2,
115  pose::Pose const & pose,
116  ScoreFunction const &,
117  EnergyMap & emap
118 ) const
119 {
120 
121  //std::cout << "Checking out VDW: " << rsd1.seqpos() << " " << rsd2.seqpos() << std::endl;
122 
123  rna::RNA_ScoringInfo const & rna_scoring_info( rna::rna_scoring_info_from_pose( pose ) );
124  utility::vector1< bool > const & is_magnesium = rna_scoring_info.is_magnesium();
125 
126 
127  Size const pos1 = rsd1.seqpos();
128  Size const pos2 = rsd2.seqpos();
129 
130  if ( !rsd1.is_RNA() && !is_magnesium[ pos1 ] ) return;
131  if ( !rsd2.is_RNA() && !is_magnesium[ pos2 ]) return;
132 
133  char const which_nucleotide1 = rsd1.name1(); //a,c,g,u
134  char const which_nucleotide2 = rsd2.name1(); //a,c,g,u
135 
136  Real score(0.0);
137 
138  //Precomputed list of atom numbers... cached inside the pose.
140  atom_numbers_for_vdw_calculation( rna_scoring_info.atom_numbers_for_vdw_calculation() );
141 
142  utility::vector1< Size > const & atom_numbers1 ( atom_numbers_for_vdw_calculation[ pos1 ] );
143 
144  Size const num_vdw_atoms1( atom_numbers1.size() );
145 
146  // no countpair for RNA!
147  // Don't need to loop over all atoms, just some representatives...
148  for ( Size m = 1; m <= num_vdw_atoms1; ++m ) {
149 
150  Size const i = atom_numbers1[ m ];
151  if (rsd1.is_virtual(i) ) continue;
152 
153  Vector const & i_xyz( rsd1.xyz(i) );
154 
155  utility::vector1< Size > const & atom_numbers2 ( atom_numbers_for_vdw_calculation[ pos2 ] );
156  Size const num_vdw_atoms2( atom_numbers2.size() );
157 
158  for ( Size n = 1; n <= num_vdw_atoms2; ++n ) {
159 
160  Size const j = atom_numbers2[ n ];
161  if (rsd2.is_virtual(j) ) continue;
162 
163  Real const bump_dsq( rna_atom_vdw_.bump_parameter( m, n, which_nucleotide1, which_nucleotide2 ) );
164  Real const clash( bump_dsq - i_xyz.distance_squared( rsd2.xyz(j) ) );
165 
166  if ( clash > 0.0 ) {
167 
168  score += ( clash * clash ) / bump_dsq;
169 
170  // tr << "BUMP " << rsd1.name3() << I(4,rsd1.seqpos() ) << ' ' << rsd1.atom_name(i) << " --- " << rsd2.name3() << I(4,rsd2.seqpos() ) << ' ' << rsd2.atom_name(j) << " Penalty: " << ( clash * clash ) / bump_dsq << " sqrt(atomvdw) " << sqrt( bump_dsq ) << " dist " << i_xyz.distance( rsd2.xyz(j)) << " index: " << m << " " << n << std::endl;
171 
172  }
173 
174  }
175  }
176 
177  emap[ rna_vdw ] += score * vdw_scale_factor_; // vdw prefactor!
178 
179 }
180 
181 
182 /////////////////////////////////
183 Size
185  utility::vector1< utility::vector1< Size > > const & atom_numbers_for_vdw_calculation,
186  Size const & pos1,
187  Size const & i ) const
188 {
189  Size m( 0 );
190  bool is_vdw_atom( false );
191 
192  for ( m = 1; m <= atom_numbers_for_vdw_calculation.size(); ++m ) {
193  if ( atom_numbers_for_vdw_calculation[ pos1 ][ m ] == i ){
194  is_vdw_atom = true; break;
195  }
196  }
197 
198  if ( is_vdw_atom ) return m;
199  return 0;
200 }
201 
202 
203 /////////////////////////////////
204 void
206  id::AtomID const & atom_id,
207  pose::Pose const & pose,
208  kinematics::DomainMap const & domain_map,
209  ScoreFunction const &,
210  EnergyMap const & weights,
211  Vector & F1,
212  Vector & F2
213  ) const
214 {
215  //using namespace etable::count_pair;
216 
217  Size const pos1( atom_id.rsd() );
218  Size const i ( atom_id.atomno() );
219  conformation::Residue const & rsd1( pose.residue( pos1 ) );
220 
221  rna::RNA_ScoringInfo const & rna_scoring_info( rna::rna_scoring_info_from_pose( pose ) );
222  utility::vector1< bool > const & is_magnesium = rna_scoring_info.is_magnesium();
223 
224  if ( !rsd1.is_RNA() && !is_magnesium[ pos1 ] ) return;
225 
226  char const which_nucleotide1 = rsd1.name1(); //a,c,g,u
227 
228  int const pos1_map( domain_map( pos1 ) );
229  bool const pos1_fixed( pos1_map != 0 );
230 
231  Vector const & i_xyz( rsd1.xyz(i) );
232 
234  atom_numbers_for_vdw_calculation( rna_scoring_info.atom_numbers_for_vdw_calculation() );
235 
236  Size m = get_vdw_atom_number( atom_numbers_for_vdw_calculation, rsd1.seqpos(), i );
237  if ( m == 0 ) return;
238 
239  // cached energies object
240  Energies const & energies( pose.energies() );
241 
242  // the neighbor/energy links
243  EnergyGraph const & energy_graph( energies.energy_graph() );
244 
245  // loop over *all* nbrs of rsd1 (not just upper or lower)
247  iru = energy_graph.get_node( pos1 )->const_edge_list_begin(),
248  irue = energy_graph.get_node( pos1 )->const_edge_list_end();
249  iru != irue; ++iru ) {
250  Size const pos2( (*iru)->get_other_ind( pos1 ) );
251 
252  if ( pos1_fixed && pos1_map == domain_map( pos2 ) ) continue; // fixed wrt one another
253 
254  conformation::Residue const & rsd2( pose.residue( pos2 ) );
255  char const which_nucleotide2 = rsd2.name1(); //a,c,g,u
256 
257  if ( !rsd2.is_RNA() && !is_magnesium[ pos2 ] ) continue;
258 
259  runtime_assert( pos2 != pos1 );
260 
261  utility::vector1< Size > const & atom_numbers2 ( atom_numbers_for_vdw_calculation[ pos2 ] );
262 
263  for ( Size n = 1; n <= atom_numbers2.size(); ++n ) {
264 
265  Size const j = atom_numbers2[ n ];
266 
267  Vector const & j_xyz( rsd2.xyz(j) );
268  Vector const f2( i_xyz - j_xyz );
269  Real const dis2( f2.length_squared() );
270  Real const bump_dsq( rna_atom_vdw_.bump_parameter( m, n, which_nucleotide1, which_nucleotide2 ) );
271 
272  if ( dis2 < bump_dsq ) {
273  Real const dE_dr_over_r = vdw_scale_factor_ * weights[ rna_vdw ] * 4.0 * ( dis2 - bump_dsq ) / bump_dsq;
274  Vector const f1( i_xyz.cross( j_xyz ) );
275  F1 += dE_dr_over_r * f1;
276  F2 += dE_dr_over_r * f2;
277  }
278  }
279 
280  } // loop over nbrs of rsd1
281 
282 }
283 
284 
285 
286 /// @brief RNA_VDW_Energy distance cutoff
287 Distance
289 {
290  return 5.0; /// now subtracted off 3.0 from cutoffs in centroid params files
291  //return 0.0; /// since all the cutoffs for centroid mode are rolled into the cendist check
292 }
293 
294 /// @brief RNA_VDW_Energy
295 void
297 {
298 }
299 
300 //////////////////////////////////////////////////////////////////////////////////////////
301 //And make atom_numbers_for_vdw_calculation a vector of vectors, and
302 // have a copy available in RNA_Scoring_info for setting (in this funciton) and getting in
303 // the score & derivative functions above.
304 
305 void
307 {
308  //We don't know a priori which atom numbers correspond to which
309  // atom names (e.g., O2* on an adenosine could be different depending
310  // on whether its at a chainbreak, terminus, etc.)
311  //Better to do a quick setup every time to pinpoint atoms that require
312  // monitoring for VDW clashes.
313 
315 
316  if ( rna_scoring_info.vdw_calculation_annotated_sequence() == pose.annotated_sequence() ) return; // should be up to date
318 
320  atom_numbers_for_vdw_calculation( rna_scoring_info.nonconst_atom_numbers_for_vdw_calculation() );
321  utility::vector1< bool > & is_magnesium = rna_scoring_info.nonconst_is_magnesium();
322 
323  Size const total_residue( pose.total_residue() );
324 
325  atom_numbers_for_vdw_calculation.resize( total_residue );
326  is_magnesium.resize( total_residue );
327 
328  for (Size i = 1; i <= total_residue; i++ ) {
329  conformation::Residue const & rsd( pose.residue( i ) );
330 
331  is_magnesium[ i ] = ( rsd.name3() == " MG" );
332  atom_numbers_for_vdw_calculation[ i ].clear();
333 
334  if ( rsd.is_RNA() || is_magnesium[ i ] /*magnesium now OK!*/ ) {
335  //a,c,g, or u?
336  char const which_nucleotide = rsd.name1();
337  //What atom names to look at?
338  utility::vector1< std::string > const vdw_atom_list = rna_atom_vdw_.vdw_atom_list( which_nucleotide );
339  for (Size m = 1; m <= vdw_atom_list.size(); m++ ){
340  Size const vdw_atom_index = rsd.atom_index( vdw_atom_list[ m ] );
341  atom_numbers_for_vdw_calculation[ i ].push_back( vdw_atom_index);
342  //std::cout << i << " " << rsd.name1() << " " << m << " of " << vdw_atom_list.size() << ": " << vdw_atom_list[ m ] << " " << vdw_atom_index << std::endl;
343  }
344 
345  }
346 
347  }
348 }
351 {
352  return 1; // Initial versioning
353 }
354 
355 
356 }
357 }
358 }