Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PeakFileFormat_Sparky.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
23 
24 // Package Headers
25 // AUTO-REMOVED #include <protocols/noesy_assign/Exceptions.hh>
26 
27 // Project Headers
28 #include <core/types.hh>
29 #include <core/chemical/AA.hh>
30 
31 // Utility headers
32 #include <ObjexxFCL/format.hh>
33 #include <ObjexxFCL/string.functions.hh>
34 
35 // AUTO-REMOVED #include <utility/string_util.hh>
36 // #include <utility/excn/Exceptions.hh>
37 // #include <utility/vector1.fwd.hh>
38 // #include <utility/pointer/ReferenceCount.hh>
39 // #include <numeric/numeric.functions.hh>
40 // #include <basic/prof.hh>
41 #include <basic/Tracer.hh>
42 // #include <basic/options/option.hh>
43 // #include <basic/options/keys/abinitio.OptionKeys.gen.hh>
44 // #include <basic/options/keys/run.OptionKeys.gen.hh>
45 //#include <basic/options/keys/templates.OptionKeys.gen.hh>
46 
47 //// C++ headers
48 // AUTO-REMOVED #include <cstdlib>
49 #include <string>
50 
51 // AUTO-REMOVED #include <basic/options/option_macros.hh>
52 
54 #include <utility/vector1.hh>
55 
56 
57 static basic::Tracer tr("protocols.noesy_assign.io");
58 
59 namespace protocols {
60 namespace noesy_assign {
61 
62 using namespace core;
63 
65  PeakFileFormat( res )
66 {}
67 
68 void PeakFileFormat_Sparky::write_peak( std::ostream& os, Size ct, CrossPeak const& cp ) const {
69  std::ostringstream line_end;
70  line_end << " #d " << ObjexxFCL::fmt::F( 6, 3, cp.distance_bound() );
71  if ( cp.eliminated( false /*recompute*/, true /*do_not_compute*/) ) line_end << " #eliminated: " << cp.elimination_reason();
72 
73 
74  // cp.write_to_stream( os );
75  write_assignments( os, cp, "" );
76  write_resonances( os, cp );
77  os << "# Peak " << ObjexxFCL::fmt::RJ( 6, ct ) << " ";
78  // write_strength( os, cp );
79 
80  os << line_end.str();
81 
82 
83 }
84 
86  info1_ = new CrossPeakInfo( cp.info( 1 ) );
87  info2_ = new CrossPeakInfo( cp.info( 2 ) );
88  col2proton_.clear();
89  col2islabel_.clear();
90 
91  //dimension 2 - label
92  if ( info2_->has_label() ) {
93  col2proton_.push_back( 2 );
94  col2islabel_.push_back( true );
95  }
96 
97  //dimension 2
98  col2proton_.push_back( 2 );
99  col2islabel_.push_back( false );
100 
101  //dimension 1 - label
102  if ( info1_->has_label() ) {
103  col2proton_.push_back( 1 );
104  col2islabel_.push_back( true );
105  }
106 
107  //dimension 1
108  col2proton_.push_back( 1 );
109  col2islabel_.push_back( false );
110 
111 }
112 
113 void PeakFileFormat_Sparky::write_header( std::ostream& ) {}
114 
115 // void PeakFileFormat_Sparky::write_resonances( std::ostream& os, CrossPeak const& cp ) const {
116 // // cp.write_to_stream( os );
117 // Size const ncol( col2proton_.size() );
118 // runtime_assert( col2islabel_.size() == ncol );
119 
120 // for ( Size icol=1; icol<=ncol; ++icol ) {
121 // Real val;
122 // Size iproton( col2proton_[ icol ] );
123 // bool is_label( col2islabel_[ icol ] );
124 // if ( !is_label ) val = cp.proton( iproton ).freq();
125 // else {
126 // runtime_assert( cp.has_label( iproton ) );
127 // val = cp.label( iproton ).freq();
128 // }
129 // os << ObjexxFCL::fmt::F( 8, 3, val ) << " ";
130 // }
131 // }
132 
133 
134 // void PeakFileFormat_Sparky::write_strength( std::ostream& os, CrossPeak const& cp ) const {
135 // os << ObjexxFCL::fmt::E( 10, 3, cp.volume() ) << " " << ObjexxFCL::fmt::E( 10, 3, 0.0 ) << " ";
136 // }
137 
138 void PeakFileFormat_Sparky::write_assignment_indent( std::ostream& os, CrossPeak const&) const {
139  os << std::endl;// << " ";
140  // if ( cp.has_label( 1 ) && cp.has_label( 2 ) ) os << " ";
141 }
142 
143 void PeakFileFormat_Sparky::write_nil_assignment( std::ostream& os ) const {
144  os << ObjexxFCL::fmt::RJ( 25, "?-?-?" ) << " ";
145 }
146 
147 void PeakFileFormat_Sparky::write_assignment( std::ostream& os, PeakAssignment const& pa ) const {
148  Size resid( 0 );
149  std::ostringstream buf;
150  for ( Size icol=1; icol<=ncol(); ++icol ) {
151  Size val;
152  Size iproton( col2proton_[ icol ] );
153  bool is_label( col2islabel_[ icol ] );
154  if ( write_atom_names() ) {
156  if ( !is_label ) atom = pa.atom( iproton );
157  else atom = pa.label_atom( iproton );
158  if ( resid != atom.rsd() ) {
159  resid = atom.rsd();
160  core::chemical::AA aa( resonances().aa_from_resid( atom.rsd() ));
161  buf << oneletter_code_from_aa(aa) << resid;
162  }
163  buf << atom.atom();
164  } else {
165  if ( !is_label ) val = pa.resonance_id( iproton );
166  else {
167  val = pa.label_resonance_id( iproton );
168  }
169  buf << ObjexxFCL::fmt::RJ( 6, val );
170  }
171  if ( icol < ncol() ) buf << "-";
172  }
173  os << ObjexxFCL::fmt::RJ( 25, buf.str() ) << " ";
174 }
175 
176 
177 }
178 }