Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DNA_BaseEnergy.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/DNA_BaseEnergy.cc
11 /// @brief
12 /// @author Phil Bradley
13 /// @author Andrew Leaver-Fay
14 
15 
16 // Unit headers
19 
20 // Package headers
24 #include <core/scoring/dna/setup.hh> // set_base_partner
25 
26 // Project headers
28 #include <core/pose/Pose.hh>
29 #include <basic/datacache/BasicDataCache.hh>
32 
33 #include <core/id/AtomID.hh>
34 #include <utility/vector1.hh>
35 
36 
37 // ObjexxFCL headers
38 
39 namespace core {
40 namespace scoring {
41 namespace methods {
42 
43 
44 /// @details This must return a fresh instance of the DNA_BaseEnergy class,
45 /// never an instance already in use
49 ) const {
50  return new DNA_BaseEnergy;
51 }
52 
55  ScoreTypes sts;
56  sts.push_back( dna_bp );
57  sts.push_back( dna_bs );
58  return sts;
59 }
60 
61 
62 using namespace dna; //////////////////// NOTE NOTE NOTE
63 
64 /// the atom through which the knowledge based potential applies a force
65 
66 std::string const dna_deriv_atom( " C5 " );
67 
70  potential_( ScoringManager::get_instance()->get_DNA_BasePotential() )
71 {}
72 
73 
74 /// clone
77 {
78  return new DNA_BaseEnergy();
79 }
80 
81 /// are these really necessary??????????? move to scheme that doesnt depend on nbr calcn
82 ///
83 void
85 {
86  set_base_partner( pose );
88 }
89 
90 ///
91 void
93 {
94  set_base_partner( pose );
96 }
97 
98 void
100 {
101  set_base_partner( pose );
103 }
104 
105 /////////////////////////////////////////////////////////////////////////////
106 // scoring
107 /////////////////////////////////////////////////////////////////////////////
108 
109 /// ordered!!!! requires pos1<pos2
110 inline
111 bool
113  Size const pos1,
114  Size const pos2,
115  BasePartner const & partner
116 )
117 {
118  return ( pos2 == pos1 + 1 && partner[pos1] && partner[pos2] && partner[pos2] == partner[pos1]-1 &&
119  partner[pos1] != pos2 );
120 }
121 
122 
123 /// same as dna::retrieve_base_partner_from_pose
124 inline
125 BasePartner const &
127 {
128  //using core::pose::datacache::CacheableDataType::BASE_PARTNER;
130  assert( dynamic_cast< BasePartner const *>( &( pose.data().get( core::pose::datacache::CacheableDataType::BASE_PARTNER ))));
131  return ( static_cast< BasePartner const &>( pose.data().get( core::pose::datacache::CacheableDataType::BASE_PARTNER )));
132 }
133 
134 
135 ///
136 void
138  conformation::Residue const & rsd1,
139  conformation::Residue const & rsd2,
140  pose::Pose const & pose,
141  ScoreFunction const &,
142  EnergyMap & emap
143 ) const
144 {
145 
146  if ( !rsd1.is_DNA() || !rsd2.is_DNA() ) return;
147 
148  Real bp_score( 0.0 ), bs_score( 0.0 );
149 
150  // retrieve DNA basepair info from pose
151  BasePartner const & base_partner( retrieve_base_partner_from_pose_inline( pose ) );
152 
153  // base step score:
154  Size const pos1( rsd1.seqpos() ), pos2( rsd2.seqpos() );
155  if ( count_pair_bs( pos1, pos2, base_partner ) ) {
156  bs_score += potential_.base_step_score( rsd1, rsd2 );
157  }
158  if ( count_pair_bs( pos2, pos1, base_partner ) ) {
159  bs_score += potential_.base_step_score( rsd2, rsd1 );
160  }
161 
162 
163  // base pair score
164  if ( pos2 == base_partner[ pos1 ] ) {
165  if ( pos1 < pos2 ) {
166  bp_score += potential_.base_pair_score( rsd1, rsd2 );
167  } else {
168  bp_score += potential_.base_pair_score( rsd2, rsd1 );
169  }
170  }
171 
172  emap[ dna_bs ] += bs_score;
173  emap[ dna_bp ] += bp_score;
174  //std::cout << "DNA_BaseEnergy " << rsd1.seqpos() << " " << rsd2.seqpos() << " " << bs_score << " " << bp_score << std::endl;
175 }
176 
177 
178 
179 void
181  id::AtomID const & atom_id,
182  pose::Pose const & pose,
183  kinematics::DomainMap const &, // domain_map,
184  ScoreFunction const &,
185  EnergyMap const & weights,
186  Vector & F1,
187  Vector & F2
188  ) const
189 {
190  Size const pos1( atom_id.rsd() );
191  Size const atom1( atom_id.atomno() );
192  conformation::Residue const & rsd1( pose.residue( pos1 ) );
193  if ( ( !rsd1.is_DNA() ) || ( rsd1.atom_name( atom1 ) != dna_deriv_atom ) ) return;
194 
195 
196  // retrieve DNA basepair info from pose
197  BasePartner const & base_partner( retrieve_base_partner_from_pose_inline( pose ) );
198 
199  ///////////////////
200  // base step derivs
201  if ( weights[ dna_bs ] != 0.0 ) {
202  // to next residue:
203  if ( pos1 < pose.total_residue() ) {
204  Size const pos2( pos1+1 );
205  conformation::Residue const & rsd2( pose.residue( pos2 ) );
206  if ( rsd2.is_DNA() && count_pair_bs( pos1, pos2, base_partner ) ) {
207  potential_.eval_base_step_derivative( rsd1, rsd2, F1, F2, weights[ dna_bs ] );
208  }
209  }
210 
211  // to previous residue:
212  if ( pos1 > 1 ) {
213  Size const pos2( pos1-1 );
214  conformation::Residue const & rsd2( pose.residue( pos2 ) );
215  if ( rsd2.is_DNA() && count_pair_bs( pos2, pos1, base_partner ) ) {
216  potential_.eval_base_step_derivative( rsd2, rsd1, F1, F2, -1.0 * weights[ dna_bs ] );
217  }
218  }
219  }
220 
221 
222  ///////////////////
223  // base pair derivs
224  if ( weights[ dna_bp ] != 0.0 && base_partner[ pos1 ] ) {
225  Size const pos2( base_partner[ pos1 ] );
226  if ( pos1 < pos2 ) {
227  potential_.eval_base_pair_derivative( rsd1, pose.residue( pos2 ), F1, F2, weights[ dna_bp ] );
228  } else {
229  potential_.eval_base_pair_derivative( pose.residue( pos2 ), rsd1, F1, F2, -1.0 * weights[ dna_bp ] );
230  }
231  }
232 }
233 
234 
235 
236 /// @brief DNA_BaseEnergy distance cutoff
237 Distance
239 {
240  return 5.5; // -- temporary hack to allow us to use the standard neighbor array
241 }
242 
243 /// @brief DNA_BaseEnergy
244 void
246 {
247 }
250 {
251  return 1; // Initial versioning
252 }
253 
254 
255 
256 } // methods
257 } // scoring
258 } // core