Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CrossPeak.hh
Go to the documentation of this file.
1 // (c) This file is part of the Rosetta software suite and is made available under license.
2 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
3 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
4 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
5 
6 /// @file CrossPeakList.hh
7 /// @author Oliver Lange
8 
9 #ifndef INCLUDED_protocols_noesy_assign_CrossPeak_HH
10 #define INCLUDED_protocols_noesy_assign_CrossPeak_HH
11 
12 
13 // Unit Header
15 
16 // Package Headers
18 // AUTO-REMOVED #include <protocols/noesy_assign/PeakAssignment.hh>
21 
22 // Project Headers
23 #include <core/types.hh>
25 #include <core/chemical/AA.hh>
26 // AUTO-REMOVED #include <core/scoring/constraints/AmbiguousNMRConstraint.fwd.hh>
28 #include <core/pose/Pose.fwd.hh>
29 
30 // Utility headers
31 #include <utility/exit.hh>
32 #include <utility/vector1.hh>
33 #include <utility/pointer/ReferenceCount.hh>
34 
35 //// C++ headers
36 // AUTO-REMOVED #include <cstdlib>
37 #include <string>
38 //#include <list>
39 //#include <map>
40 #include <set>
41 
43 
44 #ifdef WIN32
46 #endif
47 
48 
49 namespace protocols {
50 namespace noesy_assign {
51 
53 public:
54  ///@brief a single dimension of a multidimensional peak, stores putative assignments as indices into Resonance table
55  class Spin {
56  public:
57  Spin( core::Real freq );
58  Spin();
59  ~Spin();
60 
61  ///@brief resonance frequency of peak
62  core::Real freq() const { return freq_; }
63  void set_freq( core::Real freq ) { freq_ = freq; }
64 
65  ///@brief add index-pointer into Resonance table to assign peak to putative spin
67  assignments_.push_back( assignment );
68  }
69 
70  ///@brief return index-pointer into Resonance table
72  return assignments_[ nr ];
73  }
74 
76  return assignments_.size();
77  }
78 
79  core::Size assignment_index( core::Size assignment ) const; //return 0 if not found
80 
81  private:
84  SpinAssignments assignments_; //index into resonance table...
85  };
86 
87 public:
89  typedef PeakAssignments::const_iterator const_iterator;
90  typedef PeakAssignments::iterator iterator;
97  };
98 
99  enum QualityClass {
107  };
108 
109  CrossPeak( Spin const&, Spin const&, core::Real strength );
110  CrossPeak();
111  virtual ~CrossPeak();
113  return new CrossPeak;
114  }
115 
116  virtual bool has_label( core::Size ) const { return false; }
117  virtual Spin& label( core::Size ) { runtime_assert( false ); return proton1_; }
118  virtual Spin const& label( core::Size ) const { runtime_assert( false ); return proton2_; }
119 
120  Spin const& proton( core::Size i ) const { return i>=2 ? proton2_ : proton1_ ; }
121  Spin& proton( core::Size i ) { return i>=2 ? proton2_ : proton1_ ; }
122  bool has_proton( core::Size ) const;
123 
124  ///@brief flat access to spins in [ a, b, h(a), h(b) ] order
125  Spin const& spin( core::Size i ) const { return i>2 ? label( i-2 ) : proton( i ); }
126  Spin& spin( core::Size i ) { return i>2 ? label( i-2 ) : proton( i ); }
127 
128  core::Size dimension() const { return has_label( 1 ) ? ( has_label( 2 ) ? 4 : 3 ) : 2; }
129  ///@brief expect res_ids in order: spin1, spin2, label1, label2
130  virtual void add_full_assignment( core::Size res_ids[] );
131 
133  if ( i==1 ) {
134  return info1_->fold_proton_resonance();
135  } else if ( i==2 ) {
136  return info2_->fold_proton_resonance();
137  } else if ( i==3 ) {
138  return info1_->fold_label_resonance();
139  } else if ( i==4 ) {
140  return info2_->fold_label_resonance();
141  };
142  runtime_assert( false );
143  return UNFOLDED_; //to make compiler happy
144  }
145 
147  // dim = 1, 2 are the protons
148  // dim = 3, 4 are the labels
149 
150  /// for now only labels can be folded
151  if ( i==1 ) {
152  return info1_->fold_proton_resonance()( freq );
153  } else if ( i==2 ) {
154  return info2_->fold_proton_resonance()( freq );
155  } else if ( i==3 ) {
156  return info1_->fold_label_resonance()( freq );
157  } else if ( i==4 ) {
158  return info2_->fold_label_resonance()( freq );
159  };
160  runtime_assert( false ); //should never get here...
161  return 0.0; //to make compiler happy
162  }
163 // virtual void read_from_stream( std::istream& );
164 // virtual void add_assignment_from_stream( std::istream& );
165 // virtual void write_to_stream( std::ostream& ) const;
166 
167  virtual void find_assignments();
168  virtual void assign_spin( core::Size spin_id );
169 
170  //provide array with spin 1 spin 2 label 1 label 2 -- returns index in assignment list
171  virtual core::Size assign_spin( core::Size spin_id, core::Size res_ids[] );
172 
173  ///@brief the measured integral of the peak
174  core::Real volume() const { return volume_; }
175  void set_volume( core::Real val ) { volume_ = val; }
176 
178  resonances_=res_in;
179  }
180 
181  ResonanceList const& resonances() const { return *resonances_; }
182 
183  ///@brief the cumulative cyana-type weights for all assignments Vk
186  }
187 
189  cumulative_peak_volume_ = setting;
190  }
191 
192  ///@brief the largest volume contribution (normalized) any of the assignments has
194 
195  core::Real probability() const;
196 
198  if ( eliminated_due_to_dist_violations_ && !setting ) eliminated_ = NOT_ELIMINATED; //remove elimination if this is not longer violated
200  eliminated_ = ( setting ) ? EL_DISTVIOL : eliminated_;
201  }
202 
203  void set_elimination_candidate( bool setting = true ) {
204  elimination_candidate_ = setting;
205  }
206 
209  }
210 
212  return elimination_candidate_;
213  }
214 
215  ///@brief returns true if this peak is to be ignored due to points (i)-(iv) on p215 of JMB 2002, 319,209-227
216  /// do_not_compute ... for outputter that does not want to change state...
217  bool eliminated( bool recompute = false, bool do_not_compute = false ) const;
219 
221 
222  void
226  core::pose::Pose const& pose,
227  core::pose::Pose const& centroid_pose,
228  core::Size normalization,
229  core::Real padding = 0.0,
230  bool fa_only = false
231  ) const;
232 
233 #if 0
235  create_constraint(
236  core::pose::Pose const& pose,
237  core::Size normalization = 1
238  ) const;
239 
241  create_centroid_constraint(
242  core::pose::Pose const& pose,
243  core::pose::Pose const& centroid_pose,
244  core::Size normalization = 1
245  ) const;
246 #endif
247 // ///@brief number of assigned protons
248 // core::Size n_assigned() const { runtime_assert( proton1_.n_assigned() == proton2_.n_assigned() ); return proton1_.n_assigned(); }
249 
250 // ///@brief number of valid assignments
251 // core::Size n_valid_assigned() const { return proton1_.n_valid_assigned(); }
252 
253 // ///@brief return the index for the next valid assigned spin. -- return 0 for last
254 // core::Size next_assigned( core::Size last = 0 ) const {
255 // return proton1_.next_assigned( last );
256 // }
257 
258  bool assigned() const { return assignments_.size(); }
259  bool ambiguous() const { return assignments_.size() > 1; }
260  core::Size n_assigned() const { return assignments_.size(); }
261 
262  ///@brief number of assignments with peak volume higher than params.min_volume_
264 
265  //void invalidate_assignment( Size assignment );
266 
267  PeakAssignments const& assignments() const { return assignments_; }
268  const_iterator begin() const { return assignments_.begin(); }
269  iterator begin() { return assignments_.begin(); }
270  const_iterator end() const { return assignments_.end(); }
271 
273  void nudge_distance_bound( core::Real offset );
274  core::Size peak_id() const { return peak_id_; };
275 
276  std::string const& filename() const { return info1_->filename(); }
277  size_t exp_hash() const { return info1_->exp_hash(); }
278 
279  bool same_peak( CrossPeak const & other ) const {
280  return peak_id() == other.peak_id() && exp_hash() == other.exp_hash();
281  }
282 
283  void set_peak_id( core::Size val ) {
284  peak_id_ = val;
285  }
286 
287  // CrossPeakInfo const& info_struct( core::Size i ) const { return i>=2 ? *info2_ : *info1_; }
288  CrossPeakInfo const& info( core::Size i ) const { return i>=2 ? *info2_ : *info1_; }
289 
290  void set_info( core::Size i, CrossPeakInfoCOP info ) { if ( i<2 ) info1_=info; else info2_=info; }
291 
292  void calibrate( PeakCalibrator const&, CalibrationTypeCumulator& calibration_types );
293 
295  runtime_assert( info1_ && info2_ );
296  if ( d == 1 ) {
297  return info1_->proton_tolerance();
298  } else if ( d == 2 ) {
299  return info2_->proton_tolerance();
300  } else if ( d == 3 ) {
301  return info1_->label_tolerance();
302  } else if ( d == 4 ) {
303  return info1_->label_tolerance();
304  }
305  runtime_assert( false );
306  return 0.0;
307  }
308 
309  bool is4D() const {
310  return has_label( 1 ) && has_label( 2 ) && (info1_->label_tolerance() < 10) && (info1_->proton_tolerance() <10)
311  && (info2_->label_tolerance() <10) && (info2_->proton_tolerance() <10);
312  }
313 
314  void print_peak_info( std::ostream& ) const;
315  // core::Size assignment( core::Size nr ) const;
316  QualityClass quality_class() const;
319 private:
320 
321  FoldResonance UNFOLDED_; //dummy folder
327  core::Real volume_; //exp intensity
330  core::Real distance_bound_; //b -- computed after calibration...
335 
336 protected:
337  static std::set< core::id::NamedAtomID > unknown_resonances_;
338 };
339 
340 inline std::ostream& operator<< ( std::ostream& os, CrossPeak const& peak ) {
341  peak.print_peak_info( os );
342  return os;
343 }
344 
345 class CrossPeak3D : public CrossPeak {
346 public:
347  CrossPeak3D( Spin const& sp1, Spin const& sp2, Spin const& label1, core::Real strength );
348  CrossPeak3D();
349  ~CrossPeak3D();
351  return new CrossPeak3D;
352  }
353  virtual void assign_spin( Size spin_id );
354  virtual core::Size assign_spin( core::Size spin_id, core::Size res_ids[] ); //provide array with spin 1 spin 2 label 1 label 2
355  virtual void assign_labelled_spin( Size proton );
356  virtual bool has_label( core::Size i ) const { return i==1; }
357  virtual Spin& label( core::Size ) { return label1_; }
358  virtual Spin const& label( core::Size ) const { return label1_; }
359 private:
361 };
362 
363 class CrossPeak4D : public CrossPeak3D {
364 public:
365  CrossPeak4D( Spin const& sp1, Spin const& sp2, Spin const& label1, Spin const& label2, core::Real strength );
366  CrossPeak4D();
367  ~CrossPeak4D();
369  return new CrossPeak4D;
370  }
371  virtual void assign_spin( Size proton );
372  virtual core::Size assign_spin( core::Size spin_id, core::Size res_ids[] ); //provide array with spin 1 spin 2 label 1 label 2
373  virtual bool has_label( core::Size ) const { return true; }
374  Spin& label( core::Size i ) { return i==1 ? CrossPeak3D::label( 1 ) : label2_; }
375  Spin const& label( core::Size i ) const { return i==1 ? CrossPeak3D::label( 1 ) : label2_; }
376 private:
378 };
379 
380 }
381 }
382 
383 #endif