Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PcsDataCenter.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  //////////////////////////////////////////////
11  /// @begin
12  ///
13  /// @file protocols/scoring/methods/pcs2/PcsDataCenter.cc
14  ///
15  /// @brief
16  ///
17  /// @detailed
18  ///
19  /// @param
20  ///
21  /// @return
22  ///
23  /// @remarks
24  ///
25  /// @references
26  ///
27  /// @authorsv Christophe Schmitz
28  ///
29  /// @last_modified February 2010
30  ////////////////////////////////////////////////
31 
32 
33 // Unit headers
35 
36 // Package headers
39 
40 // Project headers
42 #include <core/pose/Pose.hh>
43 #include <basic/Tracer.hh>
44 
45 // Utility headers
46 #include <utility/exit.hh>
47 
48 // Numeric headers
49 //#include <numeric/constants.hh>
50 
51 // Objexx headers
52 
53 // C++ headers
54 #include <iostream>
55 
56 #include <utility/vector1.hh>
57 
58 
59 namespace protocols{
60 namespace scoring{
61 namespace methods{
62 namespace pcs2{
63 
64 basic::Tracer TR_PcsDataCenter("protocols.scoring.methods.pcs.PcsDataCenter");
65 
67  utility_exit_with_message( "You shouldn't call the empty constructor for PcsDataCenter class" );
68 }
69 
71 }
72 
75 {
76  // TR_PcsDataCenter << " = called" << std::endl;
77  if ( this != &other ) {
79  n_pcs_spin_ = other.n_pcs_spin_;
82  A_all_ = other.A_all_;
83  X_all_ = other.X_all_;
84  Z_all_ = other.Z_all_;
85  Y_all_ = other.Y_all_;
86  }
87  return *this;
88 }
89 
91  ReferenceCount()
92 {
93  // TR_PcsDataCenter << " () called" << std::endl;
95  n_pcs_spin_ = other.n_pcs_spin_;
98  A_all_ = other.A_all_;
99  X_all_ = other.X_all_;
100  Y_all_ = other.Y_all_;
101  Z_all_ = other.Z_all_;
102 }
103 
106  core::Real const xM,
107  core::Real const yM,
108  core::Real const zM,
109  core::Real const x,
110  core::Real const y,
111  core::Real const z){
112 
113 
114  core::Real r2;
115  core::Real r;
116  core::Real r5;
117  core::Real x2, y2, z2;
118  core::Real v_x, v_y, v_z;
119 
120  v_x = x - xM;
121  v_y = y - yM;
122  v_z = z - zM;
123  x2 = v_x * v_x;
124  y2 = v_y * v_y;
125  z2 = v_z * v_z;
126 
127  r2 = x2 + y2 + z2;
128  r = sqrt(r2);
129  r5 = r2 * r2 * r;
130 
131  A_line[1] = (x2 - z2);
132  A_line[2] = (2.0 * v_x * v_y);
133  A_line[3] = (2.0 * v_x * v_z);
134  A_line[4] = (y2 - z2);
135  A_line[5] = (2.0 * v_y * v_z);
136 
137  return(r5);
138 }
139 
140 void
142  core::Real const xM,
143  core::Real const yM,
144  core::Real const zM,
145  core::Real const x,
146  core::Real const y,
147  core::Real const z){
148 
149 
150  // static const core::Real FACT_USI_PRECALC_FOR_A_3( (10000.0/12.0/ core::Real( numeric::constants::d::pi ) ) * 3.0 );
151 
152  core::Real v_x ( x - xM);
153  core::Real v_y ( y - yM);
154  core::Real v_z ( z - zM);
155  core::Real x2 ( v_x * v_x);
156  core::Real y2 ( v_y * v_y);
157  core::Real z2 ( v_z * v_z);
158 
159  core::Real r2 (x2 + y2 + z2);
160  core::Real r (sqrt(r2));
161  core::Real r5 (r2 * r2 * r);
162 
163  core::Real value_1_4_PI_r5 (OTHER_FACT_USI_PRECALC_FOR_A_3 / r5);
164 
165  v_x *= 2.0;
166 
167  A_line[1] = value_1_4_PI_r5 * (x2 - z2);
168  A_line[2] = value_1_4_PI_r5 * (v_x * v_y);
169  A_line[3] = value_1_4_PI_r5 * (v_x * v_z);
170  A_line[4] = value_1_4_PI_r5 * (y2 - z2);
171  A_line[5] = value_1_4_PI_r5 * (2.0 * v_y * v_z);
172 }
173 
174 
175 
179 }
180 
183  return (PCS_data_line_all_spin_);
184 }
185 
189 }
190 
191 void
193  core::Size i;
194  for( i = 1; i <= PCS_data_per_lanthanides_all_.size(); ++i){
195  PCS_data_per_lanthanides_all_[i].update_my_A_matrix_for_svd(A_all_);
196  }
197 }
198 
199 void
201  core::Size i;
202  for( i = 1; i <= PCS_data_per_lanthanides_all_.size(); ++i){
203  PCS_data_per_lanthanides_all_[i].update_my_A_matrix_for_cstyle(A_all_);
204  }
205 }
206 
207 
208 void
210  core::Real const Y,
211  core::Real const Z){
212  core::Size i;
213 
214  for( i = 1; i <= n_pcs_spin_; ++i){
215  fill_A_line_slow(A_all_[i], X, Y, Z, X_all_[i], Y_all_[i], Z_all_[i]);
216  }
217 }
218 
219 void
221  core::Real const Y,
222  core::Real const Z){
223  core::Size i;
224  core::Real x, y, z;
225 
226  for( i = 1; i <= n_pcs_spin_; ++i){
227  x = X_all_[i];
228  y = Y_all_[i];
229  z = Z_all_[i];
230  fill_A_line_slow(A_all_[i], X, Y, Z, x, y, z);
231  }
232  update_matrix_A();
233 }
234 
235 void
237  core::Real const Y,
238  core::Real const Z){
239  core::Size i;
240  core::Real x, y, z;
241 
242  for( i = 1; i <= n_pcs_spin_; ++i){
243  x = X_all_[i];
244  y = Y_all_[i];
245  z = Z_all_[i];
246  fill_A_line_slow(A_all_[i], X, Y, Z, x, y, z);
247  }
249 }
250 
251 
252 
253 
254 
255 
256 
257 //To be called each time the pose is changed
258 void
260  core::Size i, res;
261  std::string at;
263 
264  for( i = 1; i <= PCS_data_line_all_spin_.size(); ++i){
265  res = PCS_data_line_all_spin_[i].get_residue_num();
266  if(res > pose.total_residue()){
267  std::cerr << "Error: Couldn't find residue " << res << std::endl;
268  std::cerr << "Numbering residue within Rosetta match the sequence provided as input" << std::endl;
269  std::cerr << "Make sure the numbering between the sequence and the PseudocontactShift (npc) input file match" << std::endl;
270  utility_exit_with_message("Check your pdb and PseudocontactShift (npc) input file");
271  }
272 
273  at = PCS_data_line_all_spin_[i].get_atom_name();
274  if( ! pose.residue(res).has(at)){
275  std::cerr << "Error: Couldn't find the atom " << at << " in residue " << res << std::endl;
276  std::cerr << "Numbering residue within Rosetta match the sequence provided as input" << std::endl;
277  std::cerr << "Make sure the numbering between the sequence and the PseudocontactShift (npc) input file match" << std::endl;
278  std::cerr << "Use only PCS for the backbone for abinitio." << std::endl;
279  std::cerr << "only N, CA, C, O, CB, H and CEN" << std::endl;
280 
281  utility_exit_with_message("Check your pdb and PseudocontactShift (npc) input file");
282  }
283  coo = pose.residue(res).atom(at).xyz();
284  X_all_[i] = coo.x();
285  Y_all_[i] = coo.y();
286  Z_all_[i] = coo.z();
287  }
288 }
289 
293  core::Size index;
294  index = 1;
295  for ( it = PCS_data_line_all_spin_.begin(); it != PCS_data_line_all_spin_.end(); ++it ) {
296  if ((*it).get_residue_num() == pcs_i_l.get_residue_num()){
297  if ((*it).get_atom_name() == pcs_i_l.get_atom_name()){
298  return(index);
299  }
300  }
301  index = index + 1;
302  }
303  return (0);
304 }
305 
307 
308  // TR_PcsDataCenter << " constructor called" << std::endl;
309 
310  std::map< std::string, PcsInputFile >::iterator it;
311 
313  PcsInputLine * pcs_i_l_temp;
314  core::Size index, i, j;
315 
316  n_pcs_spin_ = 0;
317  n_lanthanides_ = 0;
318 
319  std::map< std::string, PcsInputFile > & pcs_i_f_all = pcs_i_c.get_PcsInputFile_all();
320 
321  for ( it = pcs_i_f_all.begin(); it != pcs_i_f_all.end(); ++it ) {
322  filename = it->first;
323 
324  PcsInputFile & pcs_i_f = (it->second);
326  // TR_PcsDataCenter << "Filename " << filename <<std::endl;
327  core::Real weight(pcs_i_f.get_weight());
328 
330  utility::vector1<PcsInputLine> & pcs_i_l_all = pcs_i_f.get_PcsInputLine_all();
331 
332  PcsDataLanthanide pcs_d_l = PcsDataLanthanide(filename, weight, pcs_i_l_all, start, end, individual_scale);
333 
334  j = 1;
335  for ( it2 = pcs_i_l_all.begin(); it2 != pcs_i_l_all.end(); ++it2 ){
336 
337  pcs_i_l_temp = &(*it2);
338  if(do_I_skip(*pcs_i_l_temp, start, end)){
339  continue;
340  }
341 
342  index = where_is_line(*pcs_i_l_temp);
343  if(index == 0){
344  PCS_data_line_all_spin_.push_back(*it2);
345  n_pcs_spin_ = n_pcs_spin_ + 1;
346  pcs_d_l.set_A_index(j, n_pcs_spin_);
347  }
348  else{
349  pcs_d_l.set_A_index(j, index);
350  }
351  j = j + 1;
352  }
353  PCS_data_per_lanthanides_all_.push_back(pcs_d_l);
354  }
355  // TR_PcsDataCenter << "Total spin independent: " << n_pcs_spin_ << std::endl;
356 
357  A_all_.resize(n_pcs_spin_);
358  for(i = 1; i <= n_pcs_spin_; i++){
359  (A_all_[i]).resize(5);
360  }
361  X_all_.resize(n_pcs_spin_);
362  Y_all_.resize(n_pcs_spin_);
363  Z_all_.resize(n_pcs_spin_);
364 }
365 
366 
369  return (n_lanthanides_);
370 }
371 
372 
375  return(A_all_);
376 }
377 
380  return(X_all_);
381 }
382 
385  return(Y_all_);
386 }
387 
390  return(Z_all_);
391 }
392 
393 std::ostream &
394 operator<<(std::ostream& out, const PcsDataCenter & me){
395  core::Size i;
396  out << "n lanthanides experiment: " << me.get_n_lanthanides() << std::endl;
397  out << "n independent spins in total: " << me.n_pcs_spin_ << std::endl;
398  for (i = 1 ; i <= me.n_lanthanides_; ++i){
399  out << me.PCS_data_per_lanthanides_all_[i] << std::endl;
400  }
401 
402  return out;
403 }
404 
405 }//namespcacs PCS
406 }//namespace methods
407 }//namespace scoring
408 }//namespace protocols