Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OrbitalsScore.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 #include <core/pose/Pose.hh>
10 
13 
18 #include <map>
19 #include <numeric/deriv/angle_deriv.hh>
20 #include <numeric/deriv/distance_deriv.hh>
21 
23 
25 
30 
32 #include <basic/Tracer.hh>
33 
34 #include <utility/vector1.hh>
35 
36 #include <numeric/xyzVector.hh>
37 #include <numeric/conversions.hh>
38 
39 #include <core/id/types.hh>
40 #include <core/kinematics/Jump.hh>
41 
42 #include <basic/options/keys/OptionKeys.hh>
43 #include <basic/options/keys/in.OptionKeys.gen.hh>
44 #include <basic/options/option.hh>
45 
46 namespace core{
47 namespace scoring{
48 namespace orbitals{
49 
52  methods::EnergyMethodOptions const & options
53 ) const
54 {
55  return new OrbitalsScore(options);
56 }
57 
60 {
61  ScoreTypes sts;
62  sts.push_back( orbitals_hpol );
63  sts.push_back( orbitals_haro );
64  sts.push_back(orbitals_hpol_bb);
65  sts.push_back(orbitals_orbitals);
66  return sts;
67 }
68 
69 static basic::Tracer TR("core.scoring.orbitals_hpol");
70 
73  lookup_table_(core::scoring::ScoringManager::get_instance()->get_OrbitalsLookupTable()),
74  max_orbital_dist_squared_(9),
75  max_dist_squared_(36)
76 
77 {
78  if(basic::options::option[ basic::options::OptionKeys::in::add_orbitals] != 1){
79  utility_exit_with_message( "Trying to run features test without orbitals! Pass the flag -add_orbitals!" );
80  }
81 }
82 
85 {
86  return new OrbitalsScore(*this);
87 }
88 
89 void OrbitalsScore::setup_for_scoring(pose::Pose & pose, ScoreFunction const & weights) const
90 {
93 }
94 
96 {
97  for(core::Size resid=1; resid <= pose.n_residue(); ++resid){
98  pose.update_orbital_coords(resid);
99  }
100 
101 }
102 void
104  for(core::Size resid=1; resid <= pose.n_residue(); ++resid){
105  pose.update_orbital_coords(resid);
106  }
107 }
108 
109 
110 void
112  pose::Pose & pose,
113  ScoreFunction const &,
114  EnergyMap &
115 ) const{
116  for(core::Size resid=1; resid <= pose.n_residue(); ++resid){
117  pose.update_orbital_coords(resid);
118  }
119 }
120 
121 
122 void
124  pose::Pose & pose,
125  ScoreFunction const & ,
127 ) const{
128  for(core::Size resid=1; resid <= pose.n_residue(); ++resid){
129  pose.update_orbital_coords(resid);
130  }
131 }
132 
134  return false;
135 }
136 
137 
138 
139 
142  core::pose::Pose const &,
145 ) const {}
146 
147 /// This is very wrong.
149  return 7.0;
150 }
151 
152 
154 {}
155 
156 
157 void
159  pose::Pose const & /*pose*/,
161 ) const
162 {
163  for ( Size ii = 1; ii <= set.num_rotamers(); ++ii ) {
164  set.nonconst_rotamer( ii )->update_orbital_coords(); // the Rotamer set does not take responsibility for this; why not? -- maybe Residue could?
165  }
166 }
167 
168 void
170  pose::Pose & pose,
171  Size resid
172 ) const
173 {
174  pose.update_orbital_coords( resid );
175 }
176 
177 
178 
179 
182 {
183  return 2; // Initial versioning
184 }
185 
186 /////////////////////////////////
187 //////////////////////////////////////////////////////////////////
188 //////////////////////////////////////////////////////////////////
189 //////////////////////////////////////////////////////////////////
190 //////////////////////////////////////////////////////////////////
191 //////////////////////////////////////////////////////////////////
192 //////////////////////////////////////////////////////////////////
193 //////////////////////////////////////////////////////////////////
194 //////////////////////////////////////////////////////////////////
195 //////////////////////////////////////////////////////////////////
196 //////////////////////////////////////////////////////////////////
197 //////////////////////////////////////////////////////////////////
198 //////////////////////////////////////////////////////////////////
199 //////////////////////////////////////////////////////////////////
200 //////////////////////////////////////////////////////////////////
201 //////////////////////////////////////////////////////////////////
202 //////////////////////////////////////////////////////////////////
203 //////////////////////////////////////////////////////////////////
204 //////////////////////////////////////////////////////////////////
205 //////////////////////////////////////////////////////////////////
206 //////////////////////////////////////////////////////////////////
207 //////////////////////////////////////////////////////////////////
208 //////////////////////////////////////////////////////////////////
209 /////////////////////////////////
210 
212  const core::Size orb_type_name1,
213  const core::Size orb_type_name2
214 )const
215 {
216 
217  if(orb_type_name1==static_cast <core::Size>(core::chemical::orbitals::C_pi_sp2)){
218  if(
219  orb_type_name2==static_cast <core::Size>(core::chemical::orbitals::N_pi_sp2) ||
220  orb_type_name2==static_cast <core::Size>(core::chemical::orbitals::O_pi_sp2) ||
221  orb_type_name2==static_cast <core::Size>(core::chemical::orbitals::C_pi_sp2)
222  )
223  {
224  return true;
225  }else {return false;}
226  }
227  if(orb_type_name1==static_cast <core::Size>(core::chemical::orbitals::N_pi_sp2) && static_cast <core::Size>(orb_type_name2==core::chemical::orbitals::C_pi_sp2)){
228  return true;
229 
230  }
231  if(orb_type_name1==static_cast <core::Size>(core::chemical::orbitals::O_pi_sp2) && static_cast <core::Size>(orb_type_name2==core::chemical::orbitals::C_pi_sp2)){
232  return true;
233  }
234  return false;
235 }
236 
237 
238 void
240  core::conformation::Residue const & res1,
241  core::conformation::Residue const & res2,
242  core::pose::Pose const &,
244  EnergyMap & emap
245 ) const
246 {
247  if(res1.is_aromatic()) {//scOrb scHaro energy calculation 1
248  core::Real HARO_scHscOrb_E(0.0);
249  get_E_haro_one_way(res2, res1, HARO_scHscOrb_E);
250  emap[orbitals_haro] += HARO_scHscOrb_E;
251  }
252  if(res2.is_aromatic()){//scOrb scHaro energy calculation 2
253  core::Real HARO_scHscOrb_E(0.0);
254  get_E_haro_one_way(res1, res2, HARO_scHscOrb_E);
255  emap[orbitals_haro] += HARO_scHscOrb_E;
256  }
257 
258  {//scOrb scHpol energy calculation 1
259  core::Real HPOL_scHscOrb_E(0.0);
260  core::Real HPOL_bb_E(0.0);
261  get_E_hpol_one_way(res1, res2, HPOL_scHscOrb_E, HPOL_bb_E);
262  emap[orbitals_hpol] += HPOL_scHscOrb_E;
263  emap[orbitals_hpol_bb] += HPOL_bb_E;
264  }
265  {//scOrb scHpol energy calculation 2
266  core::Real HPOL_scHscOrb_E(0.0);
267  core::Real HPOL_bb_E(0.0);
268  get_E_hpol_one_way(res2, res1, HPOL_scHscOrb_E, HPOL_bb_E);
269  emap[orbitals_hpol] += HPOL_scHscOrb_E;
270  emap[orbitals_hpol_bb] += HPOL_bb_E;
271  }
272  {//orbital orbital energy calculation
273  //for now cation-pi interactions, maybe pi-pi interactions later. only the future knows!
274  core::Real orb_orb_E(0.0);
275  get_orb_orb_E(res1, res2, orb_orb_E);
276  emap[orbitals_orbitals] += orb_orb_E;
277  }
278 
279  {//orbital orbital energy calculation
280  //for now cation-pi interactions, maybe pi-pi interactions later. only the future knows!
281  core::Real orb_orb_E(0.0);
282  get_orb_orb_E(res2, res1, orb_orb_E);
283  emap[orbitals_orbitals] += orb_orb_E;
284  }
285 
286 
287 }
288 
290  core::conformation::Residue const & res1,
291  core::conformation::Residue const & res2,
292  core::Real & orb_orb_E
293 )const{
294  core::Real add_orb_orb_E(0.0);
295  for (
296  chemical::AtomIndices::const_iterator
297  Aindex = res1.atoms_with_orb_index().begin(),
298  Aindex_end = res1.atoms_with_orb_index().end();
299  Aindex != Aindex_end; ++Aindex
300  ){
301  if ( !res1.atom_is_backbone(*Aindex) ) {
302  for (
303  chemical::AtomIndices::const_iterator
304  Dindex = res2.atoms_with_orb_index().begin(),
305  Dindex_end = res2.atoms_with_orb_index().end();
306  Dindex != Dindex_end; ++Dindex
307  )
308  {
309  if(!res2.atom_is_backbone(*Dindex)){
310  utility::vector1< core::Size > const & res1_orbs(res1.bonded_orbitals(*Aindex));
311  for(
313  res1_orb = res1_orbs.begin(),
314  res1_orb_end = res1_orbs.end();
315  res1_orb != res1_orb_end; ++res1_orb
316  ){
317 
318  utility::vector1< core::Size > const & res2_orbs(res2.bonded_orbitals(*Dindex));
319  for(
321  res2_orb = res2_orbs.begin(),
322  res2_orb_end = res2_orbs.end();
323  res2_orb != res2_orb_end; ++res2_orb
324  ){
325  core::Size const & orbital_type1(res1.orbital_type_index(*res1_orb));
326  core::Size const & orbital_type2(res2.orbital_type_index(*res2_orb));
327  if(orb_orb_rules(orbital_type1,orbital_type2 )){
328  numeric::xyzVector< core::Real > const & res1_Orbxyz(res1.orbital_xyz(*res1_orb) );
329  numeric::xyzVector< core::Real > const & res2_Orbxyz(res2.orbital_xyz(*res2_orb) );
330  core::Real const orb1_orb2_dist= res1_Orbxyz.distance_squared(res2_Orbxyz);
331  if(orb1_orb2_dist < 16){
332  core::Real const dist(std::sqrt(orb1_orb2_dist));
333  numeric::xyzVector< core::Real > const & Axyz(res1.xyz(*Aindex));
334  numeric::xyzVector< core::Real > const & Dxyz(res2.xyz(*Dindex));
335  core::Real const cosAOD(cos_of(Axyz, res1_Orbxyz, Dxyz));
336  core::Real const cosDOA(cos_of(Dxyz, res2_Orbxyz, Axyz));
337  core::Real d_deriv(0.0);
338  core::Real a_deriv(0.0);
339  lookup_table_.OrbOrbDist_cosAOD_energy(orbital_type1, orbital_type2, dist, cosAOD, orb_orb_E, d_deriv, a_deriv, false);
340  add_orb_orb_E +=orb_orb_E;
341  orb_orb_E=0.0;
342  lookup_table_.OrbOrbDist_cosDOA_energy(orbital_type1, orbital_type2, dist, cosDOA, orb_orb_E, d_deriv, a_deriv, false);
343  add_orb_orb_E +=orb_orb_E;
344  orb_orb_E=0.0;
345  }
346  }
347 
348  }
349  }
350  }
351  }
352  }
353  }
354  orb_orb_E=add_orb_orb_E;
355 }
356 
358  core::conformation::Residue const & res1,
359  core::conformation::Residue const & res2,
360  core::Real & HARO_scHscOrb_E
361 ) const
362 {
363  core::Real dummy_E1(0.0);//needed for generalized function get_orb_H_distance_and_energy
364  core::Real max_dist_squared(max_dist_squared_);
365  for (
366  chemical::AtomIndices::const_iterator
367  atoms_with_orb_index = res1.atoms_with_orb_index().begin(),
368  atoms_with_orb_index_end = res1.atoms_with_orb_index().end();
369  atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
370  )
371  {
372  numeric::xyzVector<core::Real> const & Axyz = res1.atom(*atoms_with_orb_index).xyz();//acceptor xyz
373  if ( !res1.atom_is_backbone(*atoms_with_orb_index) ) {
374  for (
375  chemical::AtomIndices::const_iterator
376  haro_index = res2.Haro_index().begin(),
377  haro_end = res2.Haro_index().end();
378  haro_index != haro_end; ++haro_index
379  )
380  {
381  numeric::xyzVector<core::Real> const & Hxyz = res2.atom(*haro_index).xyz(); //hydrogen xyz
382  core::Real temp_dist = Axyz.distance_squared(Hxyz);
383  if ( temp_dist < max_dist_squared ) {
384  core::Size Aindex(*atoms_with_orb_index); //acceptor index
385  core::Size donor_index(res2.bonded_neighbor(*haro_index)[1]);
386  numeric::xyzVector<core::Real> const & Dxyz(res2.xyz(donor_index)); //donor xyz
387  get_orb_H_distance_and_energy(res1, Aindex, Axyz, Hxyz, Dxyz, HARO_scHscOrb_E, dummy_E1, lookup_table_.Haro_scOrbH, false);
388  }
389  }
390  }
391  }
392 }
393 
394 
396  core::conformation::Residue const & res1,
397  core::conformation::Residue const & res2,
398  core::Real & HPOL_sc_H_sc_orb_E,
399  core::Real & HPOL_bb_H_sc_orb_energy
400 ) const
401 {
402  core::Real max_dist_squared(max_dist_squared_);
403  for (
404  chemical::AtomIndices::const_iterator
405  atoms_with_orb_index = res1.atoms_with_orb_index().begin(),
406  atoms_with_orb_index_end = res1.atoms_with_orb_index().end();
407  atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
408  )
409  {
410  numeric::xyzVector<core::Real> const & Axyz = res1.atom(*atoms_with_orb_index).xyz(); //acceptor xyz
411  for (
412  chemical::AtomIndices::const_iterator
413  hpol_index = res2.Hpol_index().begin(),
414  hpol_end = res2.Hpol_index().end();
415  hpol_index != hpol_end; ++hpol_index
416  )
417  {
418  //this check is to look at bb orbital bb hydrogen. This potential does not calculate it.
419  //The hbond_lr_bb and hbond_sr_bb scoring terms look into this.
420  core::Size donor_index(res2.bonded_neighbor(*hpol_index)[1]);
421  if(res1.atom_is_backbone(*atoms_with_orb_index) && res2.atom_is_backbone(donor_index)){
422  continue;
423  }
424  numeric::xyzVector<core::Real> const & Hxyz = res2.atom(*hpol_index).xyz(); //hydrogen xyz
425  //core::Size donor_id(res2.bonded_neighbor(*hpol_index)[1]);
426  core::Real temp_dist = Axyz.distance_squared(Hxyz);
427  if ( temp_dist < max_dist_squared ) {
428  core::Size Aindex(*atoms_with_orb_index);
429  numeric::xyzVector<core::Real> const & Dxyz(res2.xyz(donor_index)); //donor xyz
430  if(res2.atom_is_backbone(donor_index) || res1.atom_is_backbone(Aindex)){
431  get_orb_H_distance_and_energy(res1, Aindex, Axyz, Hxyz, Dxyz, HPOL_sc_H_sc_orb_E, HPOL_bb_H_sc_orb_energy, lookup_table_.Hpol_bbOrbH, true);
432  }else{
433  get_orb_H_distance_and_energy(res1, Aindex, Axyz, Hxyz, Dxyz, HPOL_sc_H_sc_orb_E, HPOL_bb_H_sc_orb_energy, lookup_table_.Hpol_scOrbH, false);
434  }
435  }
436  }
437  }
438 }
439 
441  core::conformation::Residue const & res1,
442  core::Size const & Aindex,
443  numeric::xyzVector<core::Real> const & Axyz, //acceptor xyz
444  numeric::xyzVector<core::Real> const & Hxyz,//hydrogen xyz
445  numeric::xyzVector<core::Real> const & Dxyz, //donor xyz
446  core::Real & sc_energy,
447  core::Real & bb_h_energy,
449  bool bb_h_flag
450 ) const
451 {
452  core::Real d_deriv(0.0);
453  core::Real a_deriv(0.0);
454  utility::vector1< core::Size > const & orbital_indices(res1.bonded_orbitals(Aindex));
455  core::Real added_sc_energy(sc_energy);
456  core::Real added_bb_h_energy(bb_h_energy);
457  for(
459  orbital_index = orbital_indices.begin(),
460  orbital_index_end = orbital_indices.end();
461  orbital_index != orbital_index_end; ++orbital_index
462  )
463  {
464  numeric::xyzVector< core::Real > const & Orbxyz(res1.orbital_xyz(*orbital_index) );
465  core::Real temp_dist_squared = Orbxyz.distance_squared( Hxyz );
466  if(temp_dist_squared < max_orbital_dist_squared_){
467  core::Size orbital_type= res1.orbital_type_index(*orbital_index);
468  if(orbital_type==static_cast<core::Size>(core::chemical::orbitals::O_pi_sp2_bb)){
469  orbital_type=static_cast<core::Size>(core::chemical::orbitals::O_pi_sp2);
470  }
471  if(orbital_type==static_cast<core::Size>(core::chemical::orbitals::O_p_sp2_bb)){
472  orbital_type=static_cast<core::Size>(core::chemical::orbitals::O_p_sp2);
473  }
474  core::Real cosDHO(cos_of(Dxyz, Hxyz, Orbxyz));//Donor - Hydrogen - Orbital angle
475  core::Real cosAOH(cos_of(Axyz, Orbxyz, Hxyz));
476  core::Real dist(std::sqrt(temp_dist_squared));
477  if(bb_h_flag){
478  lookup_table_.OrbHdist_cosDHO_energy(htype, orbital_type, dist, cosDHO, bb_h_energy, d_deriv, a_deriv, false);
479  added_bb_h_energy += bb_h_energy;
480  bb_h_energy=0;
481  lookup_table_.OrbHdist_cosAOH_energy(htype, orbital_type, dist, cosAOH, bb_h_energy, d_deriv, a_deriv, false, false);
482  added_bb_h_energy += bb_h_energy;
483  }else{
484  lookup_table_.OrbHdist_cosDHO_energy(htype, orbital_type, dist, cosDHO, sc_energy, d_deriv, a_deriv, false);
485  added_sc_energy += sc_energy;
486  sc_energy=0;
487  //a little confusing without context. This checks to see if the residue is an aromatic residue. If it is an aromatic residue
488  //then we need to check if the orbital we are looking at is the action center orbital. If it is, then we use a separate
489  //energy than if it were. This is done because the action center orbital has a different angle associated with the acceptor
490  //orbital hydrogen angle. why? because there is no index for action centers, thefore the Acceptor is the first action center atom
491  if(res1.aa() == chemical::aa_tyr || res1.aa() == chemical::aa_phe || res1.aa() == chemical::aa_tyr){
492  if(*orbital_index<=2){
493  lookup_table_.OrbHdist_cosAOH_energy(htype, orbital_type, dist, cosAOH, sc_energy, d_deriv, a_deriv, false, true);
494  added_sc_energy += sc_energy;
495 
496  }else{
497  lookup_table_.OrbHdist_cosAOH_energy(htype, orbital_type, dist, cosAOH, sc_energy, d_deriv, a_deriv, false, false);
498  added_sc_energy += sc_energy;
499  }
500  }else{
501  lookup_table_.OrbHdist_cosAOH_energy(htype, orbital_type, dist, cosAOH, sc_energy, d_deriv, a_deriv, false, false);
502  added_sc_energy += sc_energy;
503  }
504  }
505  }
506  }
507  bb_h_energy = added_bb_h_energy;
508  sc_energy = added_sc_energy;
509 }
510 
511 
512 
513 
514 
515 
516 
517 void
519  conformation::Residue const & res1,
520  conformation::Residue const & res2,
523  ResPairMinimizationData const &,
524  pose::Pose const &, // provides context
525  EnergyMap const & weights,
526  utility::vector1< DerivVectorPair > & r1_atom_derivs,
527  utility::vector1< DerivVectorPair > & r2_atom_derivs
528 ) const {
529 
530  if(res1.is_aromatic()) {
531  assign_haro_derivs_one_way(res2, res1, weights, r2_atom_derivs, r1_atom_derivs);
532  }
533  if(res2.is_aromatic()){
534  assign_haro_derivs_one_way(res1, res2, weights, r1_atom_derivs, r2_atom_derivs);
535  }
536  assign_hpol_derivs_one_way(res1, res2, weights, r1_atom_derivs, r2_atom_derivs);
537  assign_hpol_derivs_one_way(res2, res1, weights, r2_atom_derivs, r1_atom_derivs);
538  assign_orb_orb_derivs(res1, res2, weights, r1_atom_derivs, r2_atom_derivs);
539  assign_orb_orb_derivs(res2, res1, weights, r2_atom_derivs, r1_atom_derivs);
540 
541 }
542 
543 
544 
545 
547  core::conformation::Residue const & res1,
548  core::conformation::Residue const & res2,
549  EnergyMap const & weights,
550  utility::vector1< DerivVectorPair > & r1_atom_derivs,
551  utility::vector1< DerivVectorPair > & r2_atom_derivs
552 ) const
553 {
554  core::Real max_dist_squared(max_dist_squared_);
555  for (
556  chemical::AtomIndices::const_iterator
557  atoms_with_orb_index = res1.atoms_with_orb_index().begin(),
558  atoms_with_orb_index_end = res1.atoms_with_orb_index().end();
559  atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
560  )
561  {
562  if ( !res1.atom_is_backbone(*atoms_with_orb_index) ) {
563  for (
564  chemical::AtomIndices::const_iterator
565  haro_index = res2.Haro_index().begin(),
566  haro_end = res2.Haro_index().end();
567  haro_index != haro_end; ++haro_index
568  )
569  {
570  numeric::xyzVector<core::Real> const & Axyz = res1.atom(*atoms_with_orb_index).xyz();
571  numeric::xyzVector<core::Real> const & Hxyz = res2.atom(*haro_index).xyz();
572  core::Real temp_dist = Axyz.distance_squared(Hxyz);
573  if ( temp_dist < max_dist_squared ) {
574  core::Size atom_index(*atoms_with_orb_index);
575  core::Size H_index(*haro_index);
577  res1, res2, atom_index, Axyz, H_index, Hxyz,
578  lookup_table_.Haro_scOrbH, weights, r1_atom_derivs, r2_atom_derivs
579  );
580  }
581  }
582  }
583  }
584 }
585 
587  core::conformation::Residue const & res1,
588  core::conformation::Residue const & res2,
589  EnergyMap const & weights,
590  utility::vector1< DerivVectorPair > & r1_atom_derivs,
591  utility::vector1< DerivVectorPair > & r2_atom_derivs
592 
593 ) const
594 {
595  core::Real max_dist_squared(max_dist_squared_);
596  for (
597  chemical::AtomIndices::const_iterator
598  atoms_with_orb_index = res1.atoms_with_orb_index().begin(),
599  atoms_with_orb_index_end = res1.atoms_with_orb_index().end();
600  atoms_with_orb_index != atoms_with_orb_index_end; ++atoms_with_orb_index
601  )
602  {
603  for (
604  chemical::AtomIndices::const_iterator
605  hpol_index = res2.Hpol_index().begin(),
606  hpol_end = res2.Hpol_index().end();
607  hpol_index != hpol_end; ++hpol_index
608  )
609  {
610  core::Size donor_index(res2.bonded_neighbor(*hpol_index)[1]);
611  if(res1.atom_is_backbone(*atoms_with_orb_index) && res2.atom_is_backbone(donor_index)){
612  continue;
613  }
614 
615  numeric::xyzVector<core::Real> const & Axyz = res1.atom(*atoms_with_orb_index).xyz();
616  numeric::xyzVector<core::Real> const & Hxyz = res2.atom(*hpol_index).xyz();
617  core::Real temp_dist = Axyz.distance_squared(Hxyz);
618  if ( temp_dist < max_dist_squared ) {
619  core::Size atom_index(*atoms_with_orb_index);
620  core::Size H_index(*hpol_index);
621  if(res2.atom_is_backbone(donor_index) || res1.atom_is_backbone(atom_index)){
623  res1, res2, atom_index, Axyz, H_index, Hxyz,
624  lookup_table_.Hpol_bbOrbH, weights, r1_atom_derivs, r2_atom_derivs
625  );
626  }else{
628  res1, res2, atom_index, Axyz, H_index, Hxyz,
629  lookup_table_.Hpol_scOrbH, weights, r1_atom_derivs, r2_atom_derivs
630  );
631  }
632  }
633  }
634  }
635 }
636 
637 
638 void
640  core::conformation::Residue const & res1,
641  core::conformation::Residue const & res2,
642  EnergyMap const & weights,
643  utility::vector1< DerivVectorPair > & r1_atom_derivs,
644  utility::vector1< DerivVectorPair > & r2_atom_derivs
645 )const {
646  //core::Real add_orb_orb_E(0.0);
647  for (
648  chemical::AtomIndices::const_iterator
649  Aindex = res1.atoms_with_orb_index().begin(),
650  Aindex_end = res1.atoms_with_orb_index().end();
651  Aindex != Aindex_end; ++Aindex
652  ){
653  if ( !res1.atom_is_backbone(*Aindex) ) {
654  for (
655  chemical::AtomIndices::const_iterator
656  Dindex = res2.atoms_with_orb_index().begin(),
657  Dindex_end = res2.atoms_with_orb_index().end();
658  Dindex != Dindex_end; ++Dindex
659  )
660  {
661  if(!res2.atom_is_backbone(*Dindex)){
662 
663  utility::vector1< core::Size > const & res1_orbs(res1.bonded_orbitals(*Aindex));
664  for(
666  res1_orb = res1_orbs.begin(),
667  res1_orb_end = res1_orbs.end();
668  res1_orb != res1_orb_end; ++res1_orb
669  ){
670  numeric::xyzVector< core::Real > const res1_Orbxyz(res1.orbital_xyz(*res1_orb) );
671  utility::vector1< core::Size > const & res2_orbs(res2.bonded_orbitals(*Dindex));
672  for(
674  res2_orb = res2_orbs.begin(),
675  res2_orb_end = res2_orbs.end();
676  res2_orb != res2_orb_end; ++res2_orb
677  ){
678  core::Size orbital_type1 = res1.orbital_type_index(*res1_orb);
679  core::Size orbital_type2 = res2.orbital_type_index(*res2_orb);
680  if(orb_orb_rules(orbital_type1,orbital_type2 )){
681  numeric::xyzVector< core::Real > const res2_Orbxyz(res2.orbital_xyz(*res2_orb) );
682  core::Real orb1_orb2_dist= res1_Orbxyz.distance_squared(res2_Orbxyz);
683  if(orb1_orb2_dist < 16){
684  core::Real dist(std::sqrt(orb1_orb2_dist));
685  numeric::xyzVector< core::Real > const Axyz(res1.xyz(*Aindex));
686  numeric::xyzVector< core::Real > const Dxyz(res2.xyz(*Dindex));
687  core::Real cosAOD(cos_of(Axyz, res1_Orbxyz, Dxyz));
688  core::Real cosDOA(cos_of(Dxyz, res2_Orbxyz, Axyz));
689  core::Real d_deriv(0.0);
690  core::Real a_deriv(0.0);
691  core::Real orb_orb_E(0.0);
692  lookup_table_.OrbOrbDist_cosDOA_energy(orbital_type1, orbital_type2, dist, cosDOA, orb_orb_E, d_deriv, a_deriv, true);
693  core::Real weight = weights[orbitals_orbitals];
694 
695 
696 
697  Vector pD(Dxyz);
698  Vector pDH(res2_Orbxyz);
699  Vector pO(Axyz);
700 
701 
702 
703 
704  Vector f1ab,f2ab;
705  Vector f1ao,f2ao;
706  Vector f1h,f2h;
707  core::Real tau(0.0);
708 
709  numeric::deriv::angle_p1_deriv( pD, pDH, pO, tau, f1ab, f2ab );
710  numeric::deriv::angle_p2_deriv( pD, pDH, pO, tau, f1ao, f2ao );
711  numeric::deriv::angle_p1_deriv( pO, pDH, pD, tau, f1h, f2h );
712 
713 
714  Real neg_sine_tau = -sin( tau ); // d cos(theta) / d theta;
715 
716 
717  r2_atom_derivs[ *Dindex ].f1() += weight * neg_sine_tau * a_deriv * f1ab;
718  r2_atom_derivs[ *Dindex ].f2() += weight * neg_sine_tau * a_deriv * f2ab;
719 
720  r2_atom_derivs[ *Dindex ].f1() += weight * neg_sine_tau * a_deriv * f1ao;
721  r2_atom_derivs[ *Dindex ].f2() += weight * neg_sine_tau * a_deriv * f2ao;
722 
723  r1_atom_derivs[ *Aindex ].f1() += weight * neg_sine_tau * a_deriv * f1h;
724  r1_atom_derivs[ *Aindex ].f2() += weight * neg_sine_tau * a_deriv * f2h;
725 
726 
727  f1ao = f2ao = 0;
728  Real dis(0.0);
729  numeric::deriv::distance_f1_f2_deriv( pDH, res1_Orbxyz, dis, f1ao, f2ao );
730 
731  r2_atom_derivs[ *Dindex ].f1() += weight * d_deriv * f1ao;
732  r2_atom_derivs[ *Dindex ].f2() += weight * d_deriv * f2ao;
733 
734  r1_atom_derivs[ *Aindex ].f1() -= weight * d_deriv * f1ao;
735  r1_atom_derivs[ *Aindex ].f2() -= weight * d_deriv * f2ao;
736 
737 
738  /////////
739  //this starts the AOH derivative calculation
740 
741  lookup_table_.OrbOrbDist_cosAOD_energy(orbital_type1, orbital_type2, dist, cosAOD, orb_orb_E, d_deriv, a_deriv, true);
742 
743 
744 
745  Vector pAB(Axyz);
746  Vector pAO(res1_Orbxyz);
747  Vector pH(Dxyz);
748 
749  f1ab=f2ab=f1ao=f2ao=f1h=f2h=0;
750  tau=0;
751 
752 
753 
754  numeric::deriv::angle_p1_deriv( pAB, pAO, pH, tau, f1ab, f2ab );
755  numeric::deriv::angle_p2_deriv( pAB, pAO, pH, tau, f1ao, f2ao );
756  numeric::deriv::angle_p1_deriv( pH, pAO, pAB, tau, f1h, f2h );
757 
758  neg_sine_tau = -sin( tau ); // d cos(theta) / d theta;core::Size orbital_surrogate_atom_index = atom_index;
759 
760 
761  r1_atom_derivs[ *Aindex ].f1() += weight * neg_sine_tau * a_deriv * f1ab;
762  r1_atom_derivs[ *Aindex ].f2() += weight * neg_sine_tau * a_deriv * f2ab;
763 
764  r1_atom_derivs[ *Aindex ].f1() += weight * neg_sine_tau * a_deriv * f1ao;
765  r1_atom_derivs[ *Aindex ].f2() += weight * neg_sine_tau * a_deriv * f2ao;
766 
767  r2_atom_derivs[ *Dindex ].f1() += weight * neg_sine_tau * a_deriv * f1h;
768  r2_atom_derivs[ *Dindex ].f2() += weight * neg_sine_tau * a_deriv * f2h;
769 
770  f1ao = f2ao = 0;
771  dis= 0.0;
772  numeric::deriv::distance_f1_f2_deriv( pAO, res2_Orbxyz, dis, f1ao, f2ao );
773 
774  r1_atom_derivs[ *Aindex ].f1() += weight * d_deriv * f1ao;
775  r1_atom_derivs[ *Aindex ].f2() += weight * d_deriv * f2ao;
776 
777  r2_atom_derivs[ *Dindex ].f1() -= weight * d_deriv * f1ao;
778  r2_atom_derivs[ *Dindex ].f2() -= weight * d_deriv * f2ao;
779 
780 
781  }
782  }
783 
784  }
785  }
786 
787 
788  }
789  }
790  }
791  }
792 }
793 
794 
795 
796 
798  core::conformation::Residue const & res1,
799  core::conformation::Residue const & res2,
800  core::Size & atom_index,
801  numeric::xyzVector<core::Real> const & Axyz,
802  core::Size const & H_index,
803  numeric::xyzVector<core::Real> const & Hxyz,
805  EnergyMap const & weights,
806  utility::vector1< DerivVectorPair > & r1_atom_derivs,
807  utility::vector1< DerivVectorPair > & r2_atom_derivs
808 )const
809 {
810  core::Real energy(0.0);
811  core::Real d_deriv(0.0); //distance derivative
812  core::Real a_deriv(0.0); //angle derivative
813 
814  Real weight(0.0);
815  if (htype == lookup_table_.Haro_scOrbH) {
816  weight = weights[orbitals_haro];
817  }else if(htype== lookup_table_.Hpol_bbOrbH ){
818  weight = weights[orbitals_hpol_bb];
819  }else if (htype == lookup_table_.Hpol_scOrbH) {
820  weight = weights[orbitals_hpol];
821  }
822 
823  utility::vector1< core::Size > const & orbital_indices(res1.bonded_orbitals(atom_index));
824  for(
826  orbital_index = orbital_indices.begin(),
827  orbital_index_end = orbital_indices.end();
828  orbital_index != orbital_index_end; ++orbital_index
829  )
830  {
831  numeric::xyzVector< core::Real > const Orbxyz(res1.orbital_xyz(*orbital_index) );
832  core::Real temp_dist_squared = Orbxyz.distance_squared( Hxyz );
833  if(temp_dist_squared < max_orbital_dist_squared_){
834  core::Size orbital_type = res1.orbital_type_index(*orbital_index);
835 
836  if(orbital_type==static_cast<core::Size>(core::chemical::orbitals::O_pi_sp2_bb)){
837  orbital_type=static_cast<core::Size>(core::chemical::orbitals::O_pi_sp2);
838  }
839  if(orbital_type==static_cast<core::Size>(core::chemical::orbitals::O_p_sp2_bb)){
840  orbital_type=static_cast<core::Size>(core::chemical::orbitals::O_p_sp2);
841  }
842 
843 
844 
845  //This starts the DHO derivative calculation.
846  core::Size donor_index(res2.bonded_neighbor(H_index)[1]);
847  numeric::xyzVector<core::Real> const & Dxyz(res2.xyz(donor_index));
848  core::Real cosDHO(cos_of(Dxyz, Hxyz, Orbxyz ));
849  core::Real OrbHdist(std::sqrt(temp_dist_squared));
850 
851  lookup_table_.OrbHdist_cosDHO_energy(htype, orbital_type, OrbHdist, cosDHO, energy, d_deriv, a_deriv, true);
852 
853 
854  Vector pD(Dxyz);
855  Vector pDH(Hxyz);
856  Vector pO(Orbxyz);
857 
858 
859  Vector f1ab,f2ab;
860  Vector f1ao,f2ao;
861  Vector f1h,f2h;
862  core::Real tau(0.0);
863 
864 
865  core::Size orbital_surrogate_atom_index = atom_index;
866 
867  numeric::deriv::angle_p1_deriv( pD, pDH, pO, tau, f1ab, f2ab );
868  numeric::deriv::angle_p2_deriv( pD, pDH, pO, tau, f1ao, f2ao );
869  numeric::deriv::angle_p1_deriv( pO, pDH, pD, tau, f1h, f2h );
870 
871 
872  Real neg_sine_tau = -sin( tau ); // d cos(theta) / d theta;
873 
874 
875  r2_atom_derivs[ H_index ].f1() += weight * neg_sine_tau * a_deriv * f1ab;
876  r2_atom_derivs[ H_index ].f2() += weight * neg_sine_tau * a_deriv * f2ab;
877 
878  r2_atom_derivs[ donor_index ].f1() += weight * neg_sine_tau * a_deriv * f1ao;
879  r2_atom_derivs[ donor_index ].f2() += weight * neg_sine_tau * a_deriv * f2ao;
880 
881  r1_atom_derivs[ atom_index ].f1() += weight * neg_sine_tau * a_deriv * f1h;
882  r1_atom_derivs[ atom_index ].f2() += weight * neg_sine_tau * a_deriv * f2h;
883 
884 
885  f1ao = f2ao = 0;
886  Real dis(0.0);
887  numeric::deriv::distance_f1_f2_deriv( pDH, pO, dis, f1ao, f2ao );
888 
889  r2_atom_derivs[ donor_index ].f1() += weight * d_deriv * f1ao;
890  r2_atom_derivs[ donor_index ].f2() += weight * d_deriv * f2ao;
891 
892  r1_atom_derivs[ atom_index ].f1() -= weight * d_deriv * f1ao;
893  r1_atom_derivs[ atom_index ].f2() -= weight * d_deriv * f2ao;
894 
895 
896  /////////
897  //this starts the AOH derivative calculation
898 
899  core::Real cosAOH(cos_of(Axyz, Orbxyz, Hxyz));
900  //a little confusing without context. This checks to see if the residue is an aromatic residue. If it is an aromatic residue
901  //then we need to check if the orbital we are looking at is the action center orbital. If it is, then we use a separate
902  //energy than if it were. This is done because the action center orbital has a different angle associated with the acceptor
903  //orbital hydrogen angle. why? because there is no index for action centers, thefore the Acceptor is the first action center atom
904 
905  if(res1.aa() == chemical::aa_tyr || res1.aa() == chemical::aa_phe || res1.aa() == chemical::aa_tyr){
906  if(*orbital_index<=2){
907  lookup_table_.OrbHdist_cosAOH_energy(htype, orbital_type, OrbHdist, cosAOH, energy, d_deriv, a_deriv, true, true);
908  }else{
909  lookup_table_.OrbHdist_cosAOH_energy(htype, orbital_type, OrbHdist, cosAOH, energy, d_deriv, a_deriv, true, false);
910  }
911  }else{
912  lookup_table_.OrbHdist_cosAOH_energy(htype, orbital_type, OrbHdist, cosAOH, energy, d_deriv, a_deriv, true, false);
913  }
914 
915 
916 
917 
918 
919  Vector pAB(Axyz);
920  Vector pAO(Orbxyz);
921  Vector pH(Hxyz);
922 
923  f1ab=f2ab=f1ao=f2ao=f1h=f2h=0;
924  tau=0;
925 
926 
927 
928  numeric::deriv::angle_p1_deriv( pAB, pAO, pH, tau, f1ab, f2ab );
929  numeric::deriv::angle_p2_deriv( pAB, pAO, pH, tau, f1ao, f2ao );
930  numeric::deriv::angle_p1_deriv( pH, pAO, pAB, tau, f1h, f2h );
931 
932  neg_sine_tau = -sin( tau ); // d cos(theta) / d theta;core::Size orbital_surrogate_atom_index = atom_index;
933 
934 
935  r1_atom_derivs[ atom_index ].f1() += weight * neg_sine_tau * a_deriv * f1ab;
936  r1_atom_derivs[ atom_index ].f2() += weight * neg_sine_tau * a_deriv * f2ab;
937 
938  r1_atom_derivs[ orbital_surrogate_atom_index ].f1() += weight * neg_sine_tau * a_deriv * f1ao;
939  r1_atom_derivs[ orbital_surrogate_atom_index ].f2() += weight * neg_sine_tau * a_deriv * f2ao;
940 
941  r2_atom_derivs[ H_index ].f1() += weight * neg_sine_tau * a_deriv * f1h;
942  r2_atom_derivs[ H_index ].f2() += weight * neg_sine_tau * a_deriv * f2h;
943 
944  f1ao = f2ao = 0;
945  dis= 0.0;
946  numeric::deriv::distance_f1_f2_deriv( pAO, pH, dis, f1ao, f2ao );
947 
948  r1_atom_derivs[ orbital_surrogate_atom_index ].f1() += weight * d_deriv * f1ao;
949  r1_atom_derivs[ orbital_surrogate_atom_index ].f2() += weight * d_deriv * f2ao;
950 
951  r2_atom_derivs[ H_index ].f1() -= weight * d_deriv * f1ao;
952  r2_atom_derivs[ H_index ].f2() -= weight * d_deriv * f2ao;
953  }
954  }
955 }
956 
957 
958 }
959 }
960 }