Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PeakAssignment.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 FragmentSampler.cc
11 /// @brief ab-initio fragment assembly protocol for proteins
12 /// @detailed
13 /// Contains currently: Classic Abinitio
14 ///
15 ///
16 /// @author Oliver Lange
17 
18 // Unit Headers
21 
23 
24 // Package Headers
26 
27 // Project Headers
31 
32 // Utility headers
33 #include <ObjexxFCL/format.hh>
34 #include <ObjexxFCL/string.functions.hh>
35 #include <basic/prof.hh>
36 #include <basic/Tracer.hh>
37 
38 // Utility headers
39 // AUTO-REMOVED #include <basic/options/option_macros.hh>
40 
41 
42 //// C++ headers
43 #include <cstdlib>
44 #include <string>
45 
46 #include <utility/vector1.hh>
47 
48 
49 static basic::Tracer tr("protocols.noesy_assign.assignments");
50 
51 namespace protocols {
52 namespace noesy_assign {
53 
54 /// @details Auto-generated virtual destructor
56 using namespace core;
57 
58 PeakAssignment::PeakAssignment( CrossPeakAP const& cp, core::Size assign_spin1, core::Size assign_spin2 )
59  : crosspeak_( cp ),
60  spin_assign_index1_( assign_spin1 ),
61  spin_assign_index2_( assign_spin2 ),
62  chemshift_overlap_( 1.0 ),
63  symmetry_compliance_( 0 ),
64  covalent_compliance_( false ),
65  decoy_compatibility_( 1.0 ),
66  network_anchoring_( 1.0 ),
67  network_anchoring_per_residue_( 200 ), //so we are not eliminated by default
68  native_distance_viol_( -1 )
69 {
70  if ( cp ) update_resonances_from_peak();
71 }
72 
74  return crosspeak_->resonances();
75 }
76 
77 void PeakAssignment::dump_weights( std::ostream& os ) const {
79  using namespace ObjexxFCL::fmt;
80  os << F( 5, 2, chemshift_overlap_ ) << " "
81  << F( 5, 2, std::max( symmetry_compliance_*params.symmetry_compliance_weight_, 1.0 ) ) << " "
82  << F( 5, 2, covalent_compliance_ ? params.covalent_compliance_weight_ : 1.0 ) << " "
83  << F( 5, 2, decoy_compatibility_ ) << " "
84  << F( 5, 2, network_anchoring_ ) << " "
85  << F( 5, 2, network_anchoring_per_residue_ ) << " ";
86  os << F( 5, 2, native_distance_viol_ ) << " ";
87 }
88 
91  return chemshift_overlap_
92  * std::min( params.smax_,
97 }
98 
100  if ( crosspeak_->cumulative_peak_volume() > 0.0 ) return peak_volume() / crosspeak_->cumulative_peak_volume();
101  return 0.0;
102 }
103 
105  resonance1_ = crosspeak_->proton( 1 ).assignment( spin_id( 1 ) );
106  resonance2_ = crosspeak_->proton( 2 ).assignment( spin_id( 2 ) );
107 }
108 
111  Real const& weight( params.chemshift_overlap_weight_ );
112  Real sum( 0.0 );
113  for ( Size d=1; d<=crosspeak_->dimension(); d++ ) {
114  CrossPeak::Spin const& spin( crosspeak_->spin( d ) );
115  Resonance const& assigned_resonance( resonances()[ spin.assignment( spin_id( d>2 ? d-2 : d ) ) ] );
116  Real s = 1.0/weight*assigned_resonance.pmatch( spin.freq(), crosspeak_->tolerance( d ), crosspeak_->folder( d ) );
117  // Real diff( spin.freq()-crosspeak_->fold_resonance( assigned_resonance.freq(), d ) );
118  // Real s( diff/weight/std::max( crosspeak_->tolerance( d ), assigned_resonance.tolerance() ) );
119  sum += s*s;
120  }
121  chemshift_overlap_ = exp( -0.5*sum );
122 }
123 
125  core::id::NamedAtomID const& atom1( atom( 1 ) );
126  core::id::NamedAtomID const& atom2( atom( 2 ) );
127  covalent_compliance_ = covalent_compliance( atom1, atom2 );
128 }
129 
131  pose::Pose const& pose,
133 ) const {
134  basic::ProfileThis doit( basic::NOESY_ASSIGN_PA_GEN_CST );
135 
136  bool flip = atom( 1 ).rsd() > atom( 2 ).rsd();
137  core::id::NamedAtomID const& atom1( atom( flip ? 2 : 1 ) );
138  core::id::NamedAtomID const& atom2( atom( flip ? 1 : 2 ) );
139 
140  tr.Debug << "create constraint for atom: " << atom1 << " " << atom2 << " from resonances id: "
141  << resonance_id( 1 ) << " " << resonance_id( 2 ) << std::endl;
142 
143  using namespace core::scoring::constraints;
144  if ( !func )
145  func = new BoundFunc( 1.5,
146  5.5,
147  1.0,
148  "VC "+ObjexxFCL::string_of( normalized_peak_volume(), 3 )
149  );
150  return new NmrConstraint( atom1, atom2, pose, func ); //later figure out what the func should be...
151 }
152 
153 
154  ///@brief return resonance_id, i.e., pointer into Resonance list that will resolve in assigned atom
156  runtime_assert( select == 1 || select == 2 );
157  runtime_assert( crosspeak_ );
158  runtime_assert( crosspeak_->has_label( select ) );
159  return crosspeak_->label( select ).assignment( spin_id( select ) );
160 }
161 
162 PeakAssignment const BOGUS_ASSIGNMENT( NULL, 0, 0 );
163 
165  bool match=true;
166 
167  //because I also allow now the peaks that have not turned around residue numbers we have to exclude assignments with the same peak
168  if ( crosspeak_->same_peak( *other.crosspeak_ ) ) {
169  tr.Debug << " SAME ";
170  return false;
171  }
172  for ( Size select = 1; select <=2 && match; ++select ) {
173  core::Size self = select;
174  core::Size partner = select % 2 + 1;
175  if ( has_label( self ) && other.has_label( partner ) ) {
176  match = match && label_resonance_id( self ) == other.label_resonance_id( partner );
177  }
178  // if ( has_proton( self ) && other.has_proton( partner ) ) {
179  match = match && resonance_id( self ) == other.resonance_id( partner );
180  // } else {
181  // match = match && label_atom_
182  }
183  // return match;
184  //we also have to match 1-1 and 2-2 since this can be the case when comparing
185  // CHH and CCH spectra.
186  if ( crosspeak_->exp_hash() == other.crosspeak().exp_hash() ) return match;
187  if ( match ) return true;
188  match = true;
189  for ( Size select = 1; select <=2 && match; ++select ) {
190  core::Size self = select;
191  core::Size partner = select;
192  if ( has_label( self ) && other.has_label( partner ) ) {
193  match = match && label_resonance_id( self ) == other.label_resonance_id( partner );
194  }
195  // if ( has_proton( self ) && other.has_proton( partner ) ) {
196  match = match && resonance_id( self ) == other.resonance_id( partner );
197  // }
198  }
199  return match;
200  // return resonance_id( 1 ) == other.resonance_id( 2 ) && resonance_id( 2 ) == other.resonance_id( 1 );
201 }
202 
203 void PeakAssignment::show( std::ostream& os ) const {
204  for ( Size select =1; select <= 2; ++select ) {
205  if ( has_proton( select ) ) {
206  os << atom( select ) << " ";
207  } else {
208  os << "[ " << atom( select ) << "] ";
209  }
210  if ( has_label( select ) ) {
211  os << label_atom( select ) << " ";
212  }
213  }
214 }
215 
216 std::ostream& operator<<( std::ostream& os, PeakAssignment const& pa ) {
217  pa.show( os );
218  return os;
219 }
220 
221 // void PeakAssignment::invalidate_assignment() {
222 // if ( crosspeak_ ) crosspeak_->invalidate_assignment( assignment_index_ );
223 // }
224 
225 }
226 }