Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResidualDipolarCouplingRigidSegments.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/ResidualDipolarCouplingRigidSegments.cc
11 /// @brief Uses NMR RDC for scoring
12 /// @author Nikolas Sgourakis
13 /// @author Oliver Lange
14 /// @author Srivatsan Raman
15 
16 //Unit headers
17 
19 
20 // Package headers
21 
22 // Project headers
23 #include <protocols/loops/Loop.hh>
25 // AUTO-REMOVED #include <core/conformation/Residue.hh>
26 // AUTO-REMOVED #include <core/kinematics/FoldTree.hh>
27 
28 // AUTO-REMOVED #include <basic/options/after_opts.hh>
29 #include <basic/options/option.hh>
30 
31 #include <basic/datacache/BasicDataCache.hh>
33 #include <core/pose/Pose.hh>
34 
35 #include <basic/Tracer.hh>
36 
37 
38 
39 // ObjexxFCL headers
40 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
41 
42 //C++ headers
43 #include <iostream>
44 // AUTO-REMOVED #include <fstream>
45 #include <string>
46 //#include <iostream.h>
47 
48 /// Utility headers
49 // AUTO-REMOVED #include <utility/excn/Exceptions.hh>
50 // AUTO-REMOVED #include <utility/io/izstream.hh>
51 #include <utility/vector1.hh>
52 // AUTO-REMOVED #include <basic/options/option_macros.hh>
53 
54 // option key includes
55 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
56 #include <basic/options/keys/rdc.OptionKeys.gen.hh>
57 
58 static basic::Tracer tr("core.scoring.ResidualDipolarCouplingRigidSegments");
59 
60 namespace protocols {
61 namespace scoring {
62  using namespace core;
63  using namespace scoring;
64 
67  typedef core::Real Tensor[3][3];
68  typedef core::Real rvec[3];
69 
70 
72  core::pose::Pose& pose) {
73  //using core::pose::datacache::CacheableDataType::RESIDUAL_DIPOLAR_COUPLING_SEGMENTS_DATA;
75 }
76 
78  core::pose::Pose const& pose) {
79  //using core::pose::datacache::CacheableDataType::RESIDUAL_DIPOLAR_COUPLING_SEGMENTS_DATA;
81  return static_cast<ResidualDipolarCouplingRigidSegments const *> (pose.data().get_const_ptr(
83  };
84  return NULL;
85 }
86 
88  //using core::pose::datacache::CacheableDataType::RESIDUAL_DIPOLAR_COUPLING_SEGMENTS_DATA;
90  return static_cast<ResidualDipolarCouplingRigidSegments*> (pose.data().get_ptr(
92  };
93  return NULL;
94 }
95 
96 
97 
99  Real score(0);
100  using namespace basic::options;
101  using namespace basic::options::OptionKeys;
102  if ( !option[ OptionKeys::rdc::segment_scoring_mode ].user() ) {
103  tr.Warning << "no al.tensor scoring method specified" << std::endl;
104  return score;
105  }
106 
107  if ( option[ OptionKeys::rdc::segment_scoring_mode ]() == "pairwise" ) {
108  core::Size n_of_exps = rdc_segments_[1]->get_n_alignments();
109  //Loop over all experiments caution: indexing starts at 0
110  for (Size exp=0; exp < n_of_exps; ++exp){
111  for (RDC_Segments::const_iterator it1=rdc_segments_.begin(); it1 != rdc_segments_.end(); ++it1){
112  for (RDC_Segments::const_iterator it2=it1; (it2+1) != rdc_segments_.end(); ++it2){
113  Tensor* S1 = (*it1)->tensor();
114  Tensor* S2 = (*it2)->tensor();
115  Real dot = (S1[exp][0][0] * S2[exp][0][0]) + (S1[exp][0][1] * S2[exp][0][1]) +
116  (S1[exp][0][2] * S2[exp][0][2]) + (S1[exp][1][1] * S2[exp][1][1]) + (S1[exp][1][2] * S2[exp][1][2]);
117  score += dot;
118 
119  /*Real Delta_FA(0);
120  Delta_FA = std::abs ( (*it1)->get_fractional_anisotropy(exp) - (*it2)->get_fractional_anisotropy(exp) );
121  score += Delta_FA;*/
122  }
123  }
124  }
125  return score;
126  }
127 
128  if ( option[ OptionKeys::rdc::segment_scoring_mode ]() == "fixed_sum" ) {
129 
130  core::Size n_of_exps = rdc_segments_[1]->get_n_alignments();
131  core::Size ndata_segment (0), ndata(0);
132  core::Real score_temp;
133  core::Size id;
134 
135  for (Size exp=0; exp < n_of_exps; ++exp){
136  ndata = 0;
137  score_temp = 0;
138  for (RDC_Segments::const_iterator it1=rdc_segments_.begin(); it1 != rdc_segments_.end(); ++it1){
139  Real trace(0);
140  ndata_segment = 0;
141  //loop over RDCs in segment and find number of data points for this experiment
142  RDC_lines myrdcs = (*it1)->get_RDC_data();
143  for (RDC_lines::const_iterator it = myrdcs.begin();it!=myrdcs.end(); ++it){
144  id = it->expid();
145  if (id == exp) { ++ndata_segment; }
146  }
147 
148  trace = (*it1)->get_al_tensor_trace(exp);
149  score_temp += ( 3 - trace ) * ndata_segment;
150  ndata += ndata_segment;
151  }
152 
153  score += score_temp / ndata;
154  } //close loop over exps
155 
156 
157  return score;
158  }
159 
160  if ( option[ OptionKeys::rdc::segment_scoring_mode ]() == "fixed_axis_z" ) {
161 
162  core::Size n_of_exps = rdc_segments_[1]->get_n_alignments();
163  core::Size ndata_segment (0), ndata(0);
164  core::Real score_temp;
165  core::Size id;
166 
167  for (Size exp=0; exp < n_of_exps; ++exp){
168  ndata = 0;
169  score_temp = 0;
170  for (RDC_Segments::const_iterator it1=rdc_segments_.begin(); it1 != rdc_segments_.end(); ++it1){
171  Real maxz(0);
172  ndata_segment = 0;
173  //loop over RDCs in segment and find number of data points for this experiment
174  RDC_lines myrdcs = (*it1)->get_RDC_data();
175  for (RDC_lines::const_iterator it = myrdcs.begin();it!=myrdcs.end(); ++it){
176  id = it->expid();
177  if (id == exp) { ++ndata_segment; }
178  }
179 
180  maxz = (*it1)->get_al_tensor_max_z(exp);
181  score_temp += ( 1 - maxz ) * ndata_segment;
182  ndata += ndata_segment;
183  }
184 
185  score += score_temp / ndata;
186  } //close loop over exps
187 
188 
189  return score;
190  }
191  return 0;
192  }
193 
195  Real score(0);
196  Real n_rdcs(0);
197  Real total_lines(0);
198  for (RDC_Segments::const_iterator it=rdc_segments_.begin();it!=rdc_segments_.end();++it){
199  n_rdcs = (*it)->get_RDC_data().size();
200  total_lines += n_rdcs;
201  score += ( (*it)->compute_dipscore(pos) ) * n_rdcs;
202  }
203  return score / total_lines;
204  }
205 
207  return line.res1() > line.res2() ? line.res1() : line.res2();
208  }
209 
211  Size eff_plane(find_effective_plane(line));
212  Size segid (segment_definitions_.loop_index_of_residue(eff_plane));
213  // cout <<segid << std::endl;
214  return segid;
215  }
216 
218  read_RDC_segment_file( basic::options::option[ basic::options::OptionKeys::rdc::segment_file ]() );
219  }
220 
221 
223  //make an ifstream
224  std::ifstream is( filename.c_str() );
225 
226  if (!is.good()) {
227  utility_exit_with_message( "[ERROR] Error opening RBSeg file '" + filename + "'" );
228  }
229 
233  is, filename, false /*no strict checking */ );
234  segment_definitions_ = loops::Loops( loops );
235  }
236 
239  return all_rdcs.get_RDC_data();
240  }
241 
243  // std::cout <<"calling sorter" <<std::endl;
244  RDC_lines_collection rdc_segm_data( segment_definitions_.num_loop() );
245 
246  //process all lines and assign into segments
247 
248  for (RDC_lines::iterator line_it=all_rdcs.begin(); line_it!=all_rdcs.end(); ++line_it) {
249  // std::cout << line_it->res1() <<std::endl;
250  Size segid( find_segid_from_RDC_line( *line_it ) );
251  if(segid >0){
252  rdc_segm_data[ segid ].push_back( *line_it );}
253  }
254 
255 
256  //create new RDC objects for all Segments
257  for ( RDC_lines_collection::iterator it=rdc_segm_data.begin(); it!=rdc_segm_data.end(); ++it ) {
258  rdc_segments_.push_back( new core::scoring::ResidualDipolarCoupling( *it ) );
259  }
260  }
261 
262  void ResidualDipolarCouplingRigidSegments::show(std::ostream& out) const {
263  Size ct (0);
264  for (RDC_Segments::const_iterator it=rdc_segments_.begin();it!=rdc_segments_.end();++it){
265  out <<"SEGMENT " << ++ct <<std::endl;
266  (*it)->show(out);
267  out << std::endl;
268  }
269 }
270 
271 std::ostream& operator<<(std::ostream& out, ResidualDipolarCouplingRigidSegments const& rdcrs) {
272  rdcrs.show(out);
273  return out;
274 }
275 } //namespace protocol
276 } //namespace core