Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JCouplingIO.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file protocols/frag_picker/CSTalosIO.cc
10 /// @brief
11 /// @author Nikolas Sgourakis sgourn@u.w.edu
12 
13 // unit headers
15 
16 // project headers
17 #include <core/types.hh>
18 
19 #include <basic/Tracer.hh>
20 
21 // utility headers
22 #include <utility/io/izstream.hh>
23 #include <utility/vector1.hh>
24 
25 #include <string>
26 #include <map>
27 #include <utility/exit.hh>
28 
29 // boost headers
30 // AUTO-REMOVED #include <boost/tuple/tuple.hpp>
31 #include <basic/options/keys/frags.OptionKeys.gen.hh>
32 #include <basic/options/option.hh>
33 
34 namespace protocols {
35 namespace frag_picker {
36 
37 using namespace basic::options;
38 using namespace basic::options::OptionKeys;
39 using namespace core;
40 
41 static basic::Tracer trJCouplingIO("protocols.frag_picker.TalosReader");
42 
43 
44 void JCouplingIO::read(std::string const & file_name) {
45 
46  utility::io::izstream data(file_name.c_str());
47  trJCouplingIO.Info << "read Jcoupling data from " << file_name << std::endl;
48  if (!data)
49  utility_exit_with_message("[ERROR] Unable to open Jcoupling file: "
50  + file_name);
51 
52  std::string line;
53  Size len;
54  Real a, b, c, theta;
55 
56  getline(data, line);
57  std::istringstream line_stream(line);
58  line_stream >> len >> a >> b >> c >> theta;
59 
60  utility::vector1< Real > tmpv(len);
61  utility::vector1< utility::vector1< Real > > temp_data( 1, tmpv );
62 
63  while (!data.eof()) {
64  getline(data, line);
65  std::istringstream line_stream(line);
66  Real val, dev;
67  Size res;
68  line_stream >> res >> val >> dev;
69 
70  if (!(option[frags::filter_JC].user() && (val >4) && (val<6) )) {
71  temp_data[res].push_back(val);
72  temp_data[res].push_back(dev);
73 // std::cout << "DATA " << res << " " << val << " " << dev << std::endl;
74  }
75  //std::cout << "DATA " << res << " " << val << " " << dev << std::endl;
76 
77  }
78 
79  //Space for error checking and asserts
80 
81  data_ = temp_data;
82  A_ = a;
83  B_ = b;
84  C_ = c;
85  THETA_ = theta;
86  sequence_length_ = len;
87 }
88 
89 std::pair< Real, Real > JCouplingIO::get_data( Size const res_num, bool & has_data ){
90 
91  has_data = false;
92 
93  std::pair< Real, Real > temp;
94 
95  //std::cout << "GETTING " << res_num << " " << data_[res_num].size() << std::endl;
96 
97  if (data_[res_num].size() == 2) {
98  temp.first = data_[res_num][1];
99  temp.second = data_[res_num][2];
100  has_data = true;
101  }
102  return temp;
103 }
104 
106 
107  utility::vector1<Real> params;
108 
109  params.push_back(A_);
110  params.push_back(B_);
111  params.push_back(C_);
112  params.push_back(THETA_);
113 
114  return params;
115 }
116 
117 
118 } // frag_picker
119 } // protocols