Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MMTorsionScore.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/mm/MMTorsionScore.cc
11 /// @brief Molecular mechanics torsion score class
12 /// @author P. Douglas Renfrew (renfrew@unc.edu)
13 
14 // Unit headers
19 
20 // Project headers
22 // AUTO-REMOVED #include <core/chemical/MMAtomTypeSet.hh>
23 
25 
26 // Utility header
27 #include <utility/keys/Key4Tuple.hh>
28 #include <utility/keys/Key3Tuple.hh>
29 #include <utility/pointer/access_ptr.hh>
30 #include <utility/pointer/owning_ptr.hh>
31 #include <utility/pointer/ReferenceCount.hh>
32 
33 // C++ headers
34 #include <iostream>
35 #include <string>
36 #include <map>
37 #include <math.h>
38 
39 #include <utility/vector1.hh>
40 
41 
42 namespace core {
43 namespace scoring {
44 namespace mm {
45 
46 /// @details Auto-generated virtual destructor
48 
50  mm_torsion_library_( scoring::ScoringManager::get_instance()->get_MMTorsionLibrary() )
51 { }
52 
54  mm_torsion_library_( mmtl )
55 { }
56 
57 /// @details Score take a set of 4 mm atom types in the form of an mm_torsion_quad and an angle in radians and returns
58 /// an energy. This is done by first looking up the set(s) of torsional parameters in the library and then calculating
59 /// the score given an angle in radians.
60 Real
61 MMTorsionScore::score( mm_torsion_atom_quad mm_atomtype_set, Real angle ) const
62 {
63  Real score = 0;
64 
65  // lookup
67  mm_atomtype_set.key1(),
68  mm_atomtype_set.key2(),
69  mm_atomtype_set.key3(),
70  mm_atomtype_set.key4() );
71 
72  // calc score
73  for ( mm_torsion_library_citer i = pair.first, e = pair.second; i != e; ++i ) {
74  score += ( (i->second).key1() * ( 1+cos( (i->second).key2() * angle - (i->second).key3() ) ) );
75  }
76 
77  /* Debug virtual atom scores
78  if ( mm_atomtype_set.key1() == 38
79  || mm_atomtype_set.key2() == 38
80  || mm_atomtype_set.key3() == 38
81  || mm_atomtype_set.key4() == 38 ) {
82  std::cout << "MM virtual score: " << score << std::endl;
83  if ( score != 0.0 ) {
84  for ( mm_torsion_library_citer i = pair.first, e = pair.second; i != e; ++i ) {
85  std::cout << "(i->second).key1() " << (i->second).key1();
86  std::cout << " (i->second).key2() " << (i->second).key2();
87  std::cout << " (i->second).key3() " << (i->second).key3() << std::endl;
88  }
89 
90  }
91  }
92  */
93 
94  return score;
95 }
96 
97 /// @details dscore take a set of 4 mm atom types in the form of an mm_torsion_quad and an angle in radians and returns
98 /// an energy derivative. This is done by first looking up the set(s) of torsional parameters in the library and then calculating
99 /// the score derivative given an angle in radians.
100 Real
101 MMTorsionScore::dscore( mm_torsion_atom_quad mm_atomtype_set, Real angle ) const
102 {
103  Real dscore_dang = 0;
104 
105  // lookup
107  mm_atomtype_set.key1(),
108  mm_atomtype_set.key2(),
109  mm_atomtype_set.key3(),
110  mm_atomtype_set.key4() );
111 
112  // calc score
113  //for ( mm_torsion_library_citer i = pair.first, e = pair.second; i != e; ++i ) {
114  // score += ( (i->second).key1() * ( 1+cos( (i->second).key2() * angle - (i->second).key3() ) ) );
115  //}
116 
117  for ( mm_torsion_library_citer i = pair.first, e = pair.second; i != e; ++i ) {
118  /// The math below is entirely Doug's and I'm trusting it.
119  dscore_dang += (-1 * (i->second).key1() * (i->second).key2() * sin( (i->second).key2() * angle - (i->second).key3() ) );
120  }
121 
122  /* Debug virtual atom scores
123  if ( mm_atomtype_set.key1() == 38
124  || mm_atomtype_set.key2() == 38
125  || mm_atomtype_set.key3() == 38
126  || mm_atomtype_set.key4() == 38 ) {
127  std::cout << "MM virtual score: " << dscore_dang << std::endl;
128  if ( score != 0.0 ) {
129  for ( mm_torsion_library_citer i = pair.first, e = pair.second; i != e; ++i ) {
130  std::cout << "(i->second).key1() " << (i->second).key1();
131  std::cout << " (i->second).key2() " << (i->second).key2();
132  std::cout << " (i->second).key3() " << (i->second).key3() << std::endl;
133  }
134 
135  }
136  }
137  */
138 
139  return dscore_dang;
140 }
141 
142 } // namespace mm
143 } // namespace scoring
144 } // namespace core