Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResidualDipolarCouplingEnergyRigidSegments.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/ResidualDipolarCouplingEnergyRigidSegments.cc
11 /// @brief RDC energy - comparing experimental RDC values to calculated values
12 /// @author Nikos Sgourakis
13 
14 
15 //Unit headers
21 //Package headers
22 
23 // AUTO-REMOVED #include <core/conformation/Residue.hh>
24 //#include <core/scoring/ScoringManager.hh>
25 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
26 // AUTO-REMOVED #include <core/pose/Pose.hh>
27 //#include <core/pose/datacache/CacheableDataType.hh>
28 
29 //numeric headers
30 #include <numeric/numeric.functions.hh>
31 // AUTO-REMOVED #include <numeric/xyzMatrix.hh>
32 #include <numeric/xyzVector.hh>
33 // AUTO-REMOVED #include <numeric/xyz.functions.hh>
34 
35 // AUTO-REMOVED #include <core/id/NamedAtomID.hh>
36 
37 //utility headers
38 #include <utility/vector1.hh>
39 #include <utility/exit.hh>
40 #include <basic/Tracer.hh>
41 
42 //Objexx headers
43 #include <ObjexxFCL/char.functions.hh>
44 #include <ObjexxFCL/string.functions.hh>
45 // AUTO-REMOVED #include <ObjexxFCL/Fmath.hh>
46 
47 // AUTO-REMOVED #include <utility/io/ozstream.hh> //for dump_weights
48 
49 #include <basic/options/option.hh>
50 #include <basic/options/keys/rdc.OptionKeys.gen.hh>
51 
52 //C++ headers
53 #include <iostream>
54 
56 
57 //Auto using namespaces
58 namespace ObjexxFCL { namespace fmt { } } using namespace ObjexxFCL::fmt; // AUTO USING NS
59 //Auto using namespaces end
60 
61 
62 static basic::Tracer tr("core.scoring.ResidualDipolarCouplingRigidSegments");
63 
64 namespace protocols {
65 namespace scoring {
66 namespace methods {
67 
68 using namespace ObjexxFCL::fmt;
69 using namespace core::scoring;
70 
71 /// @details This must return a fresh instance of the ResidualDipolarCouplingEnergyRigidSegments class,
72 /// never an instance already in use
74 ResidualDipolarCouplingEnergyRigidSegmentsCreator::create_energy_method(
76 ) const {
77  return new ResidualDipolarCouplingEnergyRigidSegments;
78 }
79 
81 ResidualDipolarCouplingEnergyRigidSegmentsCreator::score_types_for_method() const {
82  ScoreTypes sts;
83  sts.push_back( rdc_segments );
84  return sts;
85 }
86 
87 
88 
89 //////////////////////////////////////////////////////
90 //@brief
91 //////////////////////////////////////////////////////
92 ResidualDipolarCouplingEnergyRigidSegments::ResidualDipolarCouplingEnergyRigidSegments() :
94 {}
95 
96 
97 //////////////////////////////////////////////////////
98 //@brief
99 //////////////////////////////////////////////////////
102 {
103 
105 
106 }
107 
109  core::pose::Pose & pose,
110  ScoreFunction const &
111 ) const
112 {
113  //ResidualDipolarCoupling& rdc_data( rdc_from_pose( pose ) );
114  dip_score_ = eval_dipolar( pose );
115 }
116 
119  ScoreFunction const &,
120  EnergyMap & totals
121 ) const
122 {
123  totals[ rdc_segments ] = dip_score_; //???????
124 }
125 
126 /*void ResidualDipolarCouplingEnergyRigidSegments::setup_for_minimizing(
127  pose::Pose & pose,
128  ScoreFunction const &,
129  optimization::MinimizerMap const &
130 ) const
131 {
132  ResidualDipolarCoupling const& rdc_data( * retrieve_RDC_segments_from_pose( pose ) );
133  residual_dipolar_coupling::RDC_lines const& All_RDC_lines( rdc_data.get_RDC_data() );
134  residual_dipolar_coupling::RDC_lines::const_iterator it;
135  Size ct = 0;
136  for( it = All_RDC_lines.begin(); it != All_RDC_lines.end(); ++it) {
137  id::AtomID atom1( id::NamedAtomID( it->atom1(), it->res1() ), pose );
138  id::AtomID atom2( id::NamedAtomID( it->atom2(), it->res2() ), pose );
139  tr.Trace << "insert in atom-map " << atom1 << " " << atom2 << std::endl;
140  ++ct;
141  atom2rdc_map_.set( atom1, ct );
142  atom2rdc_map_.set( atom2, ct );
143  }
144 }
145 */
146 
147 
148 //////////////////////////////////////////////////////
149 //@brief
150 //////////////////////////////////////////////////////
153  core::pose::Pose & pose
154 ) const
155 {
156 // //using core::pose::datacache::CacheableDataType::RESIDUAL_DIPOLAR_COUPLING_DATA;
157 
158 // if( pose.data().has( RESIDUAL_DIPOLAR_COUPLING_DATA ) )
159 // return *( static_cast< ResidualDipolarCoupling const * >( pose.data().get_const_ptr( RESIDUAL_DIPOLAR_COUPLING_DATA )() ) );
160 
161 // ResidualDipolarCouplingOP rdc_info = new ResidualDipolarCoupling;
162 // pose.data().set( RESIDUAL_DIPOLAR_COUPLING_DATA, rdc_info );
163 
165  if ( !rdcrs_info ) {
166  rdcrs_info = new ResidualDipolarCouplingRigidSegments;
167  store_RDC_segments_in_pose( rdcrs_info, pose );
168  }
169  return *rdcrs_info;
170 }
171 
172 //////////////////////////////////////////////////////
173 //@brief main computation routine for RDC energy... everything is happening here right now.
174 // this has to be spread out over different routines to make this energy yield derivatives
175 //////////////////////////////////////////////////////
177  core::pose::Pose & pose
178 ) const
179 {
180  using namespace basic::options;
181  using namespace basic::options::OptionKeys;
182 
184  /* utility::vector1< core::scoring::RDC > const& All_RDC_lines( rdc_segment_data.get_RDC_data() );
185  Real score;
186  //Size const nrow( All_RDC_lines.size() ); //number of experimental couplins
187  if ( basic::options::option[ basic::options::OptionKeys::rdc::iterate_weights ].user() ) {
188  Real const sigma2( basic::options::option[ basic::options::OptionKeys::rdc::iterate_weights ] );
189  Real const tol( basic::options::option[ basic::options::OptionKeys::rdc::iterate_tol ] );
190  bool const reset( basic::options::option[ basic::options::OptionKeys::rdc::iterate_reset ] );
191  score = rdc_data.iterate_tensor_weights( pose, sigma2, tol, reset );
192 
193  if ( basic::options::option[ basic::options::OptionKeys::rdc::dump_weight_trajectory ].user() ) {
194  std::string const filename( basic::options::option[ basic::options::OptionKeys::rdc::dump_weight_trajectory ]() );
195  utility::io::ozstream out( filename , std::ios_base::out | std::ios_base::app );
196  utility::vector1< core::scoring::RDC >::const_iterator it;
197  for ( it = All_RDC_lines.begin(); it != All_RDC_lines.end(); ++it) {
198  out << RJ( 4, it->weight()) << " ";
199  }
200  out << std::endl;
201  } //dump_weights
202  } else {*/
203  core::Real score (0);
204  core::Real weight_total(1.0);
205  core::Real weight_pairwise(1.0);
206 
207  if ( option[ OptionKeys::rdc::total_weight ].user() ) {
208  weight_total = option[ OptionKeys::rdc::total_weight ]();
209  }
210 
211  if ( option[ OptionKeys::rdc::tensor_weight ].user() ) {
212  weight_pairwise = option[ OptionKeys::rdc::total_weight ]();
213  }
214 
215 
216  score = weight_total * rdc_segment_data.compute_total_score( pose );
217  score += weight_pairwise * rdc_segment_data.compute_pairwise_score();
218 //}
219  return score;
220 }
221 
222 
223 /*void
224 ResidualDipolarCouplingEnergyRigidSegments::eval_atom_derivative(
225  id::AtomID const & aid,
226  pose::Pose const & pose,
227  kinematics::DomainMap const &,
228  ScoreFunction const &,
229  EnergyMap const & score_weights,
230  Vector & F1,
231  Vector & F2
232 ) const {
233 
234  if ( !atom2rdc_map_.has( aid ) ) return; //damn this "has" isn't correct at all
235  Size const rdc_nr( atom2rdc_map_[ aid ] );
236  if ( rdc_nr == 0 ) {
237  // tr.Trace << "no RDC entry for " << aid << " skipping.. "<< std::endl;
238  return;
239  }
240  ResidualDipolarCoupling const& rdc_cache( *retrieve_RDC_segments_from_pose( pose ) );
241  utility::vector1< core::scoring::RDC > All_RDC_lines( rdc_cache.get_RDC_data() );
242  runtime_assert( rdc_nr <= All_RDC_lines.size() );
243  RDC const& rdc_data( All_RDC_lines[ rdc_nr ] );
244  conformation::Residue const& rsd1( pose.residue( rdc_data.res1() ) );
245  conformation::Residue const& rsd2( pose.residue( rdc_data.res2() ) );
246  Vector fij;
247  if ( aid.rsd() == rdc_data.res1() && utility::trimmed_compare( rsd1.atom_name( aid.atomno() ), rdc_data.atom1() ) ) {
248  fij = rdc_data.fij();
249  } else if ( aid.rsd() == rdc_data.res2() && utility::trimmed_compare( rsd2.atom_name( aid.atomno() ), rdc_data.atom2() ) ){
250  fij = -rdc_data.fij();
251  } else return;
252 
253  // Real fij;
254  //thanks to Will Sheffler:
255  numeric::xyzVector<core::Real> atom_x = pose.xyz(aid);
256  numeric::xyzVector<core::Real> const f2( -fij );
257  numeric::xyzVector<core::Real> const atom_y = atom_x - f2; // a "fake" atom in the direcion of the gradient
258  numeric::xyzVector<core::Real> const f1( atom_x.cross( atom_y ) );
259 
260  F1 += score_weights[ rdc ] * f1;
261  F2 += score_weights[ rdc ] * f2;
262 
263 }
264 
265 */
268 {
269  return 1; // Initial versioning
270 }
271 
272 
273 } // protocols
274 } // scoring
275 } // core