Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_CS_RingCurrent.cc
Go to the documentation of this file.
1 // (c) Copyright Rosetta Commons Member Institutions.
2 // (c) This file is part of the Rosetta software suite and is made available under license.
3 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
4 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
5 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
6 
7 
8 /// @file core/scoring/rna/chemical_shift/RNA_CS_RingCurrent.cc
9 /// @brief
10 /// @author Parin Sripakdeevong (sripakpa@stanford.edu)
11 
12 
13 
16 #include <ObjexxFCL/format.hh>
17 #include <numeric/xyzMatrix.hh>
18 //////////////////////////////////////////////////////////////////////////////////
19 //////////////////////////////////////////////////////////////////////////////////
20 //////////////////////////////////////////////////////////////////////////////////
21 
22 namespace core {
23 namespace scoring {
24 namespace rna {
25 namespace chemical_shift {
26 
27 ///////////////////////////////////////////////////////////////
29 ring_pos(conformation::Residue const & rsd, RNA_CS_residue_parameters const & rna_cs_rsd_params, Size const ring_ID) //NOTE: ONLY INCLUDE HEAVY ATOMS (no hydrogens!)
30 {
31 
32  numeric::xyzVector<core::Real> ring_center(0.0, 0.0, 0.0);
33 
34  Size atom_count=0;
35 
36  if( rsd.aa()!= rna_cs_rsd_params.aa() ) utility_exit_with_message("rsd.aa()!= rna_cs_rsd_params.aa()!");
37 
38  Size const maxatoms=rna_cs_rsd_params.get_atomnames_size();
39 
40  for (Size count = 1; count < maxatoms; count++){
41 
42  if(ring_ID==1){
43 
44  if(dround(rna_cs_rsd_params.atom_data(count, rcl1)!=1)) continue;
45 
46  }else if(ring_ID==2){
47 
48  if(dround(rna_cs_rsd_params.atom_data(count, rcl2)!=1)) continue;
49 
50  }else{
51  utility_exit_with_message("(ring_ID!=1) && (ring_ID!=2), ring_ID=("+ ObjexxFCL::string_of(ring_ID)+")!");
52  }
53 
54  Size const atom_index=rsd.atom_index( rna_cs_rsd_params.get_atomname(count) );
55 
56  ring_center+=rsd.xyz(atom_index);
57  atom_count++;
58 
59  }
60 
61  if(atom_count==0) utility_exit_with_message("atom_count==0!");
62 
63  ring_center=ring_center/atom_count;
64 
65  return ring_center;
66 }
67 
68 ///////////////////////////////////////////////////////////////
69 /* derivative of ellintk. expects 0 <= m < 1 as input.
70 */
71 static
73 {
74  Real const ak0 = 1.38629436112;
75  Real const ak1 = 0.09666344259;
76  Real const ak2 = 0.03590092383;
77  Real const ak3 = 0.03742563713;
78  Real const ak4 = 0.01451196212;
79  Real const bk0 = 0.5 ;
80  Real const bk1 = 0.12498593597;
81  Real const bk2 = 0.06880248576;
82  Real const bk3 = 0.03328355346;
83  Real const bk4 = 0.00441787012;
84  Real const mr = 1.0 - m;
85  Real const mr2 = mr * mr;
86  Real const mr3 = mr * mr * mr;
87  Real const mr4 = mr * mr * mr * mr;
88 
89  Real const bd = bk0 + (bk1 * mr) + (bk2 * mr2) + (bk3 * mr3) + (bk4 * mr4);
90  Real const cd = std::log (1.0 / mr);
91 
92  //DEFINITION: ellintk = ad + (bd * cd)
93  // dellinte_dm = dad_dm + (bd * dcd_dm + dbd_dm * cd)
94 
95  Real const dad_dm = -1.0 * ( ( ak1 + (2 * ak2 * mr) + (3 * ak3 * mr2) + (4 * ak4 * mr3) ) );
96  Real const dbd_dm = -1.0 * ( ( bk1 + (2 * bk2 * mr) + (3 * bk3 * mr2) + (4 * bk4 * mr3) ) );
97  Real const dcd_dm = +1.0 * ( 1.0 / mr );
98 
99  return ( dad_dm + (bd * dcd_dm + dbd_dm * cd) );
100 }
101 
102 ///////////////////////////////////////////////////////////////
103 /* derivative of ellinte. expects 0<=m<1 as input.
104 */
105 static
107 {
108  Real const ae0 = 1.0 ;
109  Real const ae1 = 0.44325141463;
110  Real const ae2 = 0.06260601220;
111  Real const ae3 = 0.04757383546;
112  Real const ae4 = 0.01736506451;
113  Real const be0 = 0.0 ;
114  Real const be1 = 0.24998368310;
115  Real const be2 = 0.09200180037;
116  Real const be3 = 0.04069697526;
117  Real const be4 = 0.00526449639;
118  Real const mr = 1.0 - m;
119  Real const mr2 = mr * mr;
120  Real const mr3 = mr * mr * mr;
121  Real const mr4 = mr * mr * mr * mr;
122 
123  Real const bd = be0 + (be1 * mr) + (be2 * mr2) + (be3 * mr3) + (be4 * mr4);
124  Real const cd = std::log(1.0 / mr);
125 
126  //DEFINITION: ellinte = ad + (bd * cd)
127  // dellinte_dm = dad_dm + (bd * dcd_dm + dbd_dm * cd)
128 
129  Real const dad_dm = -1.0 * ( ( ae1 + (2 * ae2 * mr) + (3 * ae3 * mr2 ) + (4 * ae4 * mr3) ) );
130  Real const dbd_dm = -1.0 * ( ( be1 + (2 * be2 * mr) + (3 * be3 * mr2 ) + (4 * be4 * mr3) ) );
131  Real const dcd_dm = +1.0 * ( 1.0 / mr );
132 
133  return ( dad_dm + (bd * dcd_dm + dbd_dm * cd) );
134 }
135 
136 ///////////////////////////////////////////////////////////////
137 /* ellintk, calculates the K factor of the elliptical integral
138  expects 0 <= m < 1 as input. This function was difined from formula 17.3.34
139  Abramowitz and Segun, Handbook of Mathematical Functions,
140  Dover publications 1965
141 */
142 static
143 Real ellintk(Real const m) //ellintk( m = 0 ) = PI/2
144 {
145  Real const ak0 = 1.38629436112;
146  Real const ak1 = 0.09666344259;
147  Real const ak2 = 0.03590092383;
148  Real const ak3 = 0.03742563713;
149  Real const ak4 = 0.01451196212;
150  Real const bk0 = 0.5 ;
151  Real const bk1 = 0.12498593597;
152  Real const bk2 = 0.06880248576;
153  Real const bk3 = 0.03328355346;
154  Real const bk4 = 0.00441787012;
155  Real const mr = 1.0 - m;
156  Real const mr2 = mr * mr;
157  Real const mr3 = mr * mr * mr;
158  Real const mr4 = mr * mr * mr * mr;
159 
160  Real const ad = ak0 + (ak1 * mr) + (ak2 * mr2) + (ak3 * mr3) + (ak4 * mr4);
161  Real const bd = bk0 + (bk1 * mr) + (bk2 * mr2) + (bk3 * mr3) + (bk4 * mr4);
162  Real const cd = std::log (1.0 / mr);
163 
164  return ( ad + (bd * cd) );
165 }
166 
167 
168 ///////////////////////////////////////////////////////////////
169 /* ellinte, calculates the E factor of the elliptical integral
170  expects 0<=m<1 as input. This function was defined from formula 17.3.36
171  Abramowitz and Segun, Handbook of Mathematical Functions,
172  Dover publications 1965
173 */
174 static
175 Real ellinte(Real const m) //ellinte( m = 0 ) = PI/2
176 {
177  Real const ae0 = 1.0 ;
178  Real const ae1 = 0.44325141463;
179  Real const ae2 = 0.06260601220;
180  Real const ae3 = 0.04757383546;
181  Real const ae4 = 0.01736506451;
182  Real const be0 = 0.0 ;
183  Real const be1 = 0.24998368310;
184  Real const be2 = 0.09200180037;
185  Real const be3 = 0.04069697526;
186  Real const be4 = 0.00526449639;
187  Real const mr = 1.0 - m;
188  Real const mr2 = mr * mr;
189  Real const mr3 = mr * mr * mr;
190  Real const mr4 = mr * mr * mr * mr;
191 
192  Real const ad = ae0 + (ae1 * mr) + (ae2 * mr2) + (ae3 * mr3) + (ae4 * mr4);
193  Real const bd = be0 + (be1 * mr) + (be2 * mr2) + (be3 * mr3) + (be4 * mr4);
194  Real const cd = std::log (1.0 / mr);
195 
196  return ( ad + (bd * cd) );
197 }
198 
199 ///////////////////////////////////////////////////////////////
200 /*calculates the cylindrical coordinates for atom_xyz with the origin located ring_center and z-direction equal to base_z_axis */
201 void
202 get_rho_and_z(numeric::xyzVector<core::Real> const & atom_xyz, numeric::xyzVector<core::Real> const & ring_center, numeric::xyzVector<core::Real> const & base_z_axis, Real & rho, Real & z)
203 {
204 
205  numeric::xyzVector<core::Real> const r_vector = atom_xyz - ring_center;
206 
207  Real const r_length = r_vector.length();
208 
209  if(std::abs(base_z_axis.length() - 1.0) > 0.00001) utility_exit_with_message("std::abs(base_z_axis.length() - 1.0) > 0.00001 !!");
210 
211  Real const dot_product = dot(r_vector, base_z_axis) / (r_length); //i.e cos( angle )
212 
213  Real const angle = acos(dot_product);
214 
215  rho = sin (angle) * r_length;
216  z = dot_product * r_length;
217 
218 }
219 
220 ///////////////////////////////////////////////////////////////
221 Real
222 delta_ring_current_term( Real const rho, Real const z, Real const ring_radius, Real const ring_z_offset)
223 {
224 
225 
226  Real const d = rho / ring_radius;
227  Real const hp = (z - ring_z_offset) / ring_radius;
228 
229  Real const hp2 = hp * hp;
230 
231  Real const rp = ( (1.0 + d) * (1.0 + d) ) + hp2;
232  Real const sp = ( (1.0 - d) * (1.0 - d) ) + hp2;
233  Real const tp = (1.0 - (d * d) - hp2);
234 
235 
236  Real const mp = (4.0 * d) / rp;
237 
238  Real const Fp =( 2.0 / std::sqrt (rp) );
239  Real const Gp =( tp / sp );
240  Real const Hp =( ellintk(mp) + ( Gp * ellinte(mp) ) );
241 
242  Real const term = ( Fp ) * ( Hp );
243 
244  return term;
245 
246 }
247 
248 ///////////////////////////////////////////////////////////////
249 void
250 get_ring_current_term_derivatives(Real const rho, Real const z, Real const ring_radius, Real const ring_z_offset, Real & dterm_drho, Real & dterm_dz )
251 {
252 
253  Real const d = rho / ring_radius;
254  Real const hp = (z - ring_z_offset) / ring_radius;
255 
256  Real const hp2 = hp * hp;
257 
258  Real const rp = ( (1.0 + d) * (1.0 + d) ) + hp2;
259  Real const sp = ( (1.0 - d) * (1.0 - d) ) + hp2;
260  Real const tp = (1.0 - (d * d) - hp2);
261 
262  Real const rp2 = rp * rp;
263  Real const rp3 = rp * rp * rp;
264 
265  Real const sp2 = sp * sp;
266 
267  Real const mp = (4.0 * d) / rp;
268 
269  Real const Fp =( 2.0 / std::sqrt (rp) );
270  Real const Gp =( tp / sp );
271  Real const Hp =( ellintk(mp) + ( Gp * ellinte(mp) ) );
272 
273  //Definition: term = ( Fp ) * ( Hp );
274 
275  /////////////////////////////////
276  //dterm_drho
277  /////////////////////////////////
278 
279  //dpterm_drho = (dFp_drho * Hp) + (Fp * dHp_drho) //Chain rule.
280 
281  Real const dFp_drho = ( 1.0 / ring_radius ) * (-2.0 * (1.0 + d) ) * ( 1 / ( sqrt ( rp3 ) ) );
282 
283  //EQ: dHp_drho = d_ellintk_drho + (dGp_drho * ellinte(mp) ) + ( Gp * d_ellinte_drho )
284  //EQ: dHp_drho = (d_ellintk_dmp * dmp_drho ) + (dGp_drho * ellinte(mp) ) + ( Gp * dellinte_dmp * dmp_drho )
285 
286  Real const dmp_drho = ( 1.0 / ring_radius ) * ( ( rp * 4.0 ) - ( ( 4.0 * d ) * ( 2.0 * (1.0 + d) ) ) ) * ( 1.0 / (rp2) ); //Quotient Rule.
287 
288  Real const dGp_drho = ( 1.0 / ring_radius ) * ( ( sp * ( -2.0 * d ) ) - ( tp * (-2.0 * (1.0 - d) ) ) ) * ( 1.0 / (sp2) ); //Quotient Rule.
289 
290  Real const dHp_drho= (dellintk_dm(mp) * dmp_drho ) + (dGp_drho * ellinte(mp) ) + ( Gp * dellinte_dm(mp) * dmp_drho );
291 
292  dterm_drho=(dFp_drho * Hp) + (Fp * dHp_drho);
293 
294 
295  /////////////////////////////////
296  //dterm_dz
297  /////////////////////////////////
298 
299  //dpterm_dz = (dFp_dz * Hp) + (Fp * dHp_dz) //Chain rule.
300 
301  Real const dFp_dz = ( 1.0 / ring_radius ) * (-2.0 * ( hp ) ) * ( 1 / ( sqrt ( rp3 ) ) );
302 
303  //EQ: dHp_dz = d_ellintk_dz + (dGp_dz * ellinte(mp) ) + ( Gp * d_ellinte_dz )
304  //EQ: dHp_dz = (d_ellintk_dmp * dmp_dz ) + (dGp_dz * ellinte(mp) ) + ( Gp * dellinte_dmp * dmp_dz )
305 
306  Real const dmp_dz = ( 1.0 / ring_radius ) * ( (rp * 0.0 ) - ( ( 4.0 * d ) * ( 2.0 * hp ) ) ) * ( 1.0 / (rp2) ); //Quotient Rule.
307 
308  Real const dGp_dz = ( 1.0 / ring_radius ) * ( ( sp * ( -2.0 * hp ) ) - ( tp * (2.0 * hp ) ) ) * ( 1.0 / (sp2) ); //Quotient Rule.
309 
310  Real const dHp_dz= (dellintk_dm(mp) * dmp_dz ) + (dGp_dz * ellinte(mp) ) + ( Gp * dellinte_dm(mp) * dmp_dz );
311 
312  dterm_dz=(dFp_dz * Hp) + (Fp * dHp_dz);
313 
314 }
315 
316 ///////////////////////////////////////////////////////////////
317 
318 //atom_xyz,: the place where it should be calculated for
319 //molecular_ring_center : the middle of the plane where the atoms reside which carry the ring current
320 //base_z_axis: a vector perpendicular to the plane of the ring (perpendicular to the plane plane)
321 
322 Real
324  numeric::xyzVector<core::Real> const & molecular_ring_center,
325  numeric::xyzVector<core::Real> const & base_z_axis,
326  RNA_CS_residue_parameters const & source_rsd_CS_params,
327  Size const ring_ID)
328 {
329 
330  Real const rci=source_rsd_CS_params.ring_intensity(ring_ID);
331  Real const rca=source_rsd_CS_params.ring_radius(ring_ID);
332  Real const rch=source_rsd_CS_params.ring_height(ring_ID);
333 
334  Real rho=0.0; //rho component of cylindrical coordinate
335  Real z=0.0; //z component of cylindrical coordinate
336 
337  get_rho_and_z(atom_xyz, molecular_ring_center, base_z_axis, rho, z);
338 
339  //Note definition of mterm and pterm is switched compared to NUCHEMIC!
340  Real const mterm = delta_ring_current_term(rho, z, rca, (-1.0) * rch ); //This is contribution of the ring located at -rca below the molecular_plane
341  Real const pterm = delta_ring_current_term(rho, z, rca, (+1.0) * rch ); //This is contribution of the ring located at +rca above the molecular_plane
342 
343  return ( -1.0 * source_rsd_CS_params.ring_current_coeff() * (rci / rca) * (mterm + pterm) ); //Definition uses opposite sign compare to NUCHEMICS!
344 }
345 
346 ///////////////////////////////////////////////////////////////
347 ///The ring_current contribution of source_rsd to the chemical_shift at atom_xyz
348 Real
349 ring_current_effect(numeric::xyzVector<core::Real> const & atom_xyz, conformation::Residue const & source_rsd, RNA_CS_residue_parameters const & rna_cs_rsd_params){
350 
351  Real chem_shift = 0.0;
352 
353  //RNA_CS_residue_parameters const & rna_cs_rsd_params=rna_cs_params.get_RNA_CS_residue_parameters(source_rsd.aa());
354 
355  if( source_rsd.aa()!= rna_cs_rsd_params.aa() ) utility_exit_with_message("rsd.aa()!= rna_cs_rsd_params.aa()!");
356 
357  numeric::xyzMatrix< core::Real > const coordinate_matrix =get_rna_base_coordinate_system_from_CS_params(source_rsd, rna_cs_rsd_params);
358 
359  numeric::xyzVector<core::Real> const & base_z_axis=coordinate_matrix.col_z();
360 
361  for (Size ring_ID = 1; ring_ID <= rna_cs_rsd_params.num_rings(); ring_ID++){
362 
363  chem_shift += delta_ring_current(atom_xyz, ring_pos(source_rsd, rna_cs_rsd_params, ring_ID), base_z_axis, rna_cs_rsd_params, ring_ID);
364 
365  }
366 
367  return chem_shift;
368 }
369 
370 
371 ///////////////////////////////////////////////////////////////
372 //ONLY USE FOR TESTING PURPOSES!
373 Real
374 ring_current_effect_individual_ring(numeric::xyzVector<core::Real> const & atom_xyz, conformation::Residue const & source_rsd, RNA_CS_residue_parameters const & rna_cs_rsd_params, Size const source_ring_ID){
375 
376  //RNA_CS_residue_parameters const & rna_cs_rsd_params=rna_cs_params.get_RNA_CS_residue_parameters(source_rsd.aa());
377 
378  if( source_rsd.aa()!= rna_cs_rsd_params.aa() ) utility_exit_with_message("rsd.aa()!= rna_cs_rsd_params.aa()!");
379 
380  numeric::xyzMatrix< core::Real > const coordinate_matrix =get_rna_base_coordinate_system_from_CS_params(source_rsd, rna_cs_rsd_params);
381 
382  numeric::xyzVector<core::Real> const & base_z_axis=coordinate_matrix.col_z();
383 
384  Real const chem_shift = delta_ring_current(atom_xyz, ring_pos(source_rsd, rna_cs_rsd_params, source_ring_ID), base_z_axis, rna_cs_rsd_params, source_ring_ID);
385 
386  return chem_shift;
387 }
388 ///////////////////////////////////////////////////////////////
389 //The gradient of ring_current_effect() with respect to r_vector (r_vector = CS_data_atom_xyz - molecular_ring_center)
390 //Between the source_ring_ID ring_current center of source_rsd and CS_data_atom_xyz.
391 //OK RIGHT NOW CONCERN WITH GETTING THIS FUNCTION RIGHT. OPTIMIZE LATER!
392 
395  conformation::Residue const & source_rsd,
396  core::Size const source_ring_ID,
397  RNA_CS_residue_parameters const & source_rsd_CS_params){
398 
399 
400  //Use cylindrical coordinates, ring_effect is a function of z and rho.
401  //RC =( -1.0 * source_rsd_CS_params.ring_current_coeff() * (rci / rca) * (pterm(z, rho) + mterm(z, rho) ) );
402  //Gradient = dRC/drho * rho_norm + dRC/dz * z_norm
403 
404  Real const rci=source_rsd_CS_params.ring_intensity(source_ring_ID);
405  Real const rca=source_rsd_CS_params.ring_radius(source_ring_ID);
406  Real const rch=source_rsd_CS_params.ring_height(source_ring_ID);
407 
408  if( source_rsd.aa()!= source_rsd_CS_params.aa() ) utility_exit_with_message("rsd.aa()!= source_rsd_CS_params.aa()!");
409 
410  numeric::xyzMatrix< core::Real > const coordinate_matrix =get_rna_base_coordinate_system_from_CS_params(source_rsd, source_rsd_CS_params);
411 
412 
413  numeric::xyzVector<core::Real> const & base_z_axis=coordinate_matrix.col_z();
414 
415  numeric::xyzVector<core::Real> const & molecular_ring_center=ring_pos(source_rsd, source_rsd_CS_params, source_ring_ID);
416 
417  Real rho=0.0; //rho component of cylindrical coordinate
418  Real z=0.0; //z component of cylindrical coordinate
419 
420  get_rho_and_z(CS_data_atom_xyz, molecular_ring_center, base_z_axis, rho, z);
421 
422  numeric::xyzVector<core::Real> const r_vector = CS_data_atom_xyz - molecular_ring_center;
423 
424  numeric::xyzVector<core::Real> const z_vector = (base_z_axis * z);
425 
426  numeric::xyzVector<core::Real> const rho_vector = r_vector - (base_z_axis * z);
427 
428  Real const r_length = r_vector.length();
429 
430  numeric::xyzVector<core::Real> const z_norm = z_vector/z; //This gives back base_z_axis!;
431 
432  numeric::xyzVector<core::Real> const rho_norm = rho_vector/rho;
433 
434  /////////////////////////////////////////////////////////////////////
435 
436  Real dmterm_drho=0.0;
437  Real dmterm_dz =0.0;
438  Real dpterm_drho=0.0;
439  Real dpterm_dz =0.0;
440 
441  get_ring_current_term_derivatives( rho, z, rca, (-1.0) * rch, dmterm_drho, dmterm_dz); //This is contribution of the ring located at -rca below the molecular_plane
442 
443  get_ring_current_term_derivatives( rho, z, rca, (+1.0) * rch, dpterm_drho, dpterm_dz); //This is contribution of the ring located at +rca above the molecular_plane
444 
445  Real const dRC_drho = -1.0 * source_rsd_CS_params.ring_current_coeff() * (rci / rca) * (dmterm_drho + dpterm_drho);
446 
447  Real const dRC_dz = -1.0 * source_rsd_CS_params.ring_current_coeff() * (rci / rca) * (dmterm_dz + dpterm_dz);
448 
449  /////////////////////////////////////////////////////////////////////
450 
451  numeric::xyzVector<core::Real> const analytical_gradient=(dRC_drho * rho_norm) + (dRC_dz * z_norm);
452 
453  return analytical_gradient;
454 
455  /////////////////////////////////////////////////////////////////////
456  /*
457  bool numerical_check=true;
458 
459  if(numerical_check){
460 
461  bool use_numerical_deriv=false;
462 
463  Real const increment = 0.000005;
464 
465  ///Numerical dRC_drho
466 
467  numeric::xyzVector<core::Real> const RC_rho_plus_xyz= CS_data_atom_xyz + (rho_norm * increment);
468  numeric::xyzVector<core::Real> const RC_rho_minus_xyz= CS_data_atom_xyz - (rho_norm * increment);
469 
470  Real const RC_rho_plus_effect= ring_current_effect_individual_ring(RC_rho_plus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
471  Real const RC_rho_minus_effect= ring_current_effect_individual_ring(RC_rho_minus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
472 
473  Real const dRC_drho_numerical = ( RC_rho_plus_effect - RC_rho_minus_effect ) / ( 2 * increment );
474 
475 
476  numeric::xyzVector<core::Real> const RC_z_plus_xyz= CS_data_atom_xyz + (z_norm * increment);
477  numeric::xyzVector<core::Real> const RC_z_minus_xyz= CS_data_atom_xyz - (z_norm * increment);
478 
479  Real const RC_z_plus_effect= ring_current_effect_individual_ring(RC_z_plus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
480  Real const RC_z_minus_effect= ring_current_effect_individual_ring(RC_z_minus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
481 
482  Real const dRC_dz_numerical = ( RC_z_plus_effect - RC_z_minus_effect ) / ( 2 * increment );
483 
484  std::cout << "---------------------------------------------------------------------" << std::endl;
485  std::cout << "rho_norm=(" << rho_norm.x() << ", " << rho_norm.y() << ", " << rho_norm.z() << ") rho_norm.length()=" << rho_norm.length();
486  std::cout << " | z_norm =(" << z_norm.x() << ", " << z_norm.y() << ", " << z_norm.z() << ") dRC_drho.length()=" << z_norm.length();
487  std::cout << " | dot(rho_norm, z_norm)= " << dot(rho_norm, z_norm) << std::endl;
488  std::cout << "ring_current_deriv_numerical_check dRC_drho_analytical= " << dRC_drho << " | dRC_drho_numerical= " << dRC_drho_numerical;
489  std::cout << " | dRC_dz_analytical= " << dRC_dz << " | dRC_dz_numerical= " << dRC_dz_numerical << std::endl;
490 
491 
492  numeric::xyzVector<core::Real> const numerical_gradient_one=(dRC_drho_numerical * rho_norm) + (dRC_dz_numerical * z_norm);
493 
494 
495  numeric::xyzVector<core::Real> const rosetta_frame_x_vector(1.0, 0.0, 0.0);
496  numeric::xyzVector<core::Real> const rosetta_frame_y_vector(0.0, 1.0, 0.0);
497  numeric::xyzVector<core::Real> const rosetta_frame_z_vector(0.0, 0.0, 1.0);
498 
499  numeric::xyzVector<core::Real> const RC_rosetta_frame_x_plus_xyz= CS_data_atom_xyz + (rosetta_frame_x_vector*increment);
500  numeric::xyzVector<core::Real> const RC_rosetta_frame_x_minus_xyz= CS_data_atom_xyz - (rosetta_frame_x_vector*increment);
501 
502  Real const RC_rosetta_frame_x_plus_effect = ring_current_effect_individual_ring(RC_rosetta_frame_x_plus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
503  Real const RC_rosetta_frame_x_minus_effect = ring_current_effect_individual_ring(RC_rosetta_frame_x_minus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
504 
505  Real const dRC_drosettax_numerical = (RC_rosetta_frame_x_plus_effect - RC_rosetta_frame_x_minus_effect ) / ( 2 * increment );
506 
507  /////////////
508  numeric::xyzVector<core::Real> const RC_rosetta_frame_y_plus_xyz= CS_data_atom_xyz + (rosetta_frame_y_vector*increment);
509  numeric::xyzVector<core::Real> const RC_rosetta_frame_y_minus_xyz= CS_data_atom_xyz - (rosetta_frame_y_vector*increment);
510 
511  Real const RC_rosetta_frame_y_plus_effect = ring_current_effect_individual_ring(RC_rosetta_frame_y_plus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
512  Real const RC_rosetta_frame_y_minus_effect = ring_current_effect_individual_ring(RC_rosetta_frame_y_minus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
513 
514  Real const dRC_drosettay_numerical = (RC_rosetta_frame_y_plus_effect - RC_rosetta_frame_y_minus_effect ) / ( 2 * increment );
515 
516  /////////////
517  numeric::xyzVector<core::Real> const RC_rosetta_frame_z_plus_xyz= CS_data_atom_xyz + (rosetta_frame_z_vector*increment);
518  numeric::xyzVector<core::Real> const RC_rosetta_frame_z_minus_xyz= CS_data_atom_xyz - (rosetta_frame_z_vector*increment);
519 
520  Real const RC_rosetta_frame_z_plus_effect = ring_current_effect_individual_ring(RC_rosetta_frame_z_plus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
521  Real const RC_rosetta_frame_z_minus_effect = ring_current_effect_individual_ring(RC_rosetta_frame_z_minus_xyz, source_rsd, source_rsd_CS_params, source_ring_ID);
522 
523  Real const dRC_drosettaz_numerical = (RC_rosetta_frame_z_plus_effect - RC_rosetta_frame_z_minus_effect ) / ( 2 * increment );
524  /////////////
525 
526  numeric::xyzVector<core::Real> const numerical_gradient_two=(dRC_drosettax_numerical * rosetta_frame_x_vector) + (dRC_drosettay_numerical * rosetta_frame_y_vector) + (dRC_drosettaz_numerical * rosetta_frame_z_vector);
527 
528  std::cout << "analytical_gradient=( " << analytical_gradient.x() << " , " << analytical_gradient.y() << " , " << analytical_gradient.z() << " )";
529  std::cout << " | numerical_gradient_one=( " << numerical_gradient_one.x() << " , " << numerical_gradient_one.y() << " , " << numerical_gradient_one.z() << " )";
530  std::cout << " | numerical_gradient_two=( " << numerical_gradient_two.x() << " , " << numerical_gradient_two.y() << " , " << numerical_gradient_two.z() << " )" << std::endl;
531  std::cout << "---------------------------------------------------------------------" << std::endl;
532 
533  if(use_numerical_deriv) return numerical_gradient_two;
534  }
535 
536 
537  /////////////////////////////////////////////////////////////////////
538  */
539 
540 }
541 
542 
543 } // chemical_shift
544 } // rna
545 } // scoring
546 } // core
547 
548