19 #include <basic/Tracer.hh>
22 #include <utility/exit.hh>
24 #include <utility/io/izstream.hh>
32 #include <boost/tuple/tuple.hpp>
35 #include <utility/vector1.hh>
39 namespace frag_picker {
42 tr(
"protocols.frag_picker.PhiPsiTalosIO");
46 utility::io::izstream data(file_name.c_str());
47 tr.Info <<
"read talos data from " << file_name << std::endl;
49 utility_exit_with_message(
"[ERROR] Unable to open talos file: "
55 bool first_not_found =
true;
57 while ( getline(data, line) ) {
58 std::istringstream line_stream(line);
61 while ( line_stream >> token ) {
62 strs.push_back(token);
64 if ( strs.size()==0 )
continue;
65 tr.Trace <<
"token: " << strs.size() <<
" in line " << line << std::endl;
66 if (strs[1] ==
"DATA") {
67 if (strs[2] ==
"SEQUENCE") {
68 for (
Size i = 3; i <= strs.size(); ++i) {
71 }
else if (strs[2] ==
"FIRST_RESID") {
72 first_not_found =
false;
74 tr.Info <<
"FIRST_RESID entry in TALOS file. Setting first-residue to " << first_residue_index_ << std::endl;
76 tr.Warning <<
"Unrecognized DATA entry:" << line
80 if (strs[1] ==
"VARS") {
81 for (
Size i = 2; i <= strs.size(); ++i) {
82 vars.push_back(strs[i]);
84 if ( ( vars.size()!=10 && vars.size()!=11 ) || vars[1]!=
"RESID" || vars[2]!=
"RESNAME" || vars[9]!=
"COUNT" || vars.back()!=
"CLASS" ) {
85 tr.Warning <<
"incompatible format in TALOS+ file "+file_name
86 +
".\n Expected VARS RESID RESNAME PHI PSI DPHI DPSI DIST S2 COUNT CS_COUNT CLASS\n "
87 +
" or VARS RESID RESNAME PHI PSI DPHI DPSI DIST S2 COUNT CLASS\n "
89 tr.Warning << vars.size() <<
" VARS: ";
90 for (
Size i=1; i<=vars.size(); ++i) {
91 tr.Warning << vars[i] <<
" ";
93 tr.Warning <<
" LAST VAR: ->" << vars.back() <<
":";
94 tr.Warning << std::endl;
97 if (strs[1] ==
"FORMAT") {
101 if ((strs.size() == vars.size()) && (strs[1] !=
"REMARK")) {
103 std::istringstream line_stream(line);
107 if ( vars.size()==10 ) {
108 line_stream >> res_id >> aa >> phi >> psi >> d_phi >> d_psi >> dist
109 >> s2 >> count >> cls;
112 line_stream >> res_id >> aa >> phi >> psi >> d_phi >> d_psi >> dist
113 >> s2 >> count >> cs_count >> cls;
115 data_format_ =
" %4d %s %8.3f %8.3f %8.3f %8.3f %8.3f %5.3f %2d %s";
117 typedef boost::tuple<Size, char, Real,Real, Real, Real, Real, Real, Size, std::string> PhiPsiTalosLineEntry;
118 PhiPsiTalosLineEntry
t(res_id, aa, phi, psi, d_phi, d_psi, dist,
120 entries_.insert(std::pair<Size, PhiPsiTalosLineEntry > ( res_id, t) );
126 if (first_not_found) {
128 <<
"FIRST_RESID keyword didn't show up in a file header\n\tAssuming the first residue id is 1"
139 tr.Warning <<
"Could not find DATA SEQUENCE in file "<<file_name << std::endl
140 <<
"Sequence based on entires is:" << std::endl
149 out <<
"DATA SEQUENCE " <<
sequence_ <<
"\n";
153 out <<
"\n" <<
"FORMAT " <<
data_format_ << std::endl <<
"\n";
164 out << buffer <<
"\n";