19 #include <basic/Tracer.hh>
22 #include <utility/io/izstream.hh>
26 #include <utility/exit.hh>
29 #include <boost/tuple/tuple.hpp>
30 #include <utility/vector1.hh>
33 namespace frag_picker {
35 static basic::Tracer
tr(
"protocols.frag_picker.TalosReader");
48 data[i].push_back(std::pair<Size, Real>(atom_id, shift));
56 utility::io::izstream data(file_name.c_str());
57 tr.Info <<
"read talos data from " << file_name << std::endl;
59 utility_exit_with_message(
"[ERROR] Unable to open talos file: "
66 bool header_done =
false;
67 bool first_not_found =
false;
68 while (!header_done) {
70 std::istringstream line_stream(line);
71 line_stream >> keyword;
72 if (keyword ==
"DATA") {
73 line_stream >> subkeyword;
74 if (subkeyword ==
"SEQUENCE") {
75 while (line_stream >> entry) {
78 }
else if (subkeyword ==
"FIRST_RESID") {
79 first_not_found =
true;
81 tr.Info <<
"first residue is set to " << first_residue_index_ <<
" by FIRST_RESID entry in chemical shift file." << std::endl;
83 tr.Warning <<
"Unrecognized DATA entry:" << line
87 if (keyword ==
"VARS") {
88 while ( line_stream >> entry ) {
92 if (keyword ==
"FORMAT") {
98 if (!first_not_found) {
100 tr.Debug <<
"FIRST_RESID keyword didn't show up in a file header\n\tAssuming the first residue id is 1"
104 while (getline(data, line)) {
105 if (line.length() > 7) {
106 std::istringstream line_stream(line);
111 line_stream >> ires >> aa >> atom_name >> shift;
113 if (atom_name ==
"H")
118 boost::tuple<Size, char, std::string, Real>
t(ires, aa, atom_name,
133 out <<
"DATA SEQUENCE " <<
sequence_ << std::endl;
137 out << std::endl <<
"FORMAT " <<
data_format_ << std::endl << std::endl;
145 out << buffer << std::endl;
156 while (iter->first == residue_id) {
157 results.push_back(
entries_[iter->second]);
165 std::multimap<Size, Size>::const_iterator iter =
169 while (iter->first == residue_id) {
171 results.push_back(
entries_[iter->second]);
178 std::multimap<Size, Size>::const_iterator iterat =
187 for (
Size i = 1; i <= used_for_searching_.size(); i++) {
192 if ((used_for_searching_[i].get<0>() == residue_id) && (used_for_searching_[i].get<2> () == atom_name)) {
193 used_for_searching_.clear();
197 used_for_searching_.clear();
204 std::multimap<Size, Size>::const_iterator iterat =
213 for (
Size i = 1; i <= used_for_searching_.size(); i++){
218 if ((used_for_searching_[i].get<0>() == residue_id) && (used_for_searching_[i].get<2> () == atom_name)) {
219 Real ret = used_for_searching_[i].get<3> ();
220 used_for_searching_.clear();
225 utility_exit_with_message(
226 "[ERROR] Unable locate chemical shift for an atom " + atom_name
227 +
" within a residue");