18 #include <basic/options/option.hh>
19 #include <basic/options/keys/OptionKeys.hh>
20 #include <basic/options/keys/in.OptionKeys.gen.hh>
23 #include <basic/database/open.hh>
26 #include <basic/Tracer.hh>
33 #include <utility/io/izstream.hh>
34 #include <utility/exit.hh>
36 #include <utility/vector1.hh>
40 namespace frag_picker {
42 using namespace basic::options;
43 using namespace basic::options::OptionKeys;
45 static basic::Tracer
tr(
"protocols.frag_picker.SecondaryShiftCalculator");
61 shift_types.push_back(std::make_pair(1,
"N"));
62 shift_types.push_back(std::make_pair(2,
"HA"));
63 shift_types.push_back(std::make_pair(3,
"C"));
64 shift_types.push_back(std::make_pair(4,
"CA"));
65 shift_types.push_back(std::make_pair(5,
"CB"));
66 shift_types.push_back(std::make_pair(6,
"HN"));
71 for (
Size seqpos = 0; seqpos < sequence.length(); seqpos++ ) {
75 for (
Size st_i = 1; st_i <= shift_types.size(); st_i++ ) {
79 std::pair<Size,std::string> shift_type(shift_types[st_i]);
81 std::pair< Size, Real > shift;
88 Real shift_value(9999);
89 bool has_shift(
false);
91 if ((( shift_type.second == HA ) || ( shift_type.second == CB)) && (sequence[seqpos] ==
'G')) {
93 offset = randcoil.find(sequence[seqpos])->second.find(HA)->second
94 +rcadj.find(sequence[seqpos])->second.find(HA)->second;
97 offset = offset + rcprev.find(sequence[seqpos-1])->second.find(HA)->second;
99 if (seqpos != sequence.length()-1) {
100 offset = offset + rcnext.find(sequence[seqpos+1])->second.find(HA)->second;
103 if ( input_data.
has_atom(seqpos+1,HA2) && input_data.
has_atom(seqpos+1,HA3) ) {
107 shift_value = (input_data.
get_shift(seqpos+1,HA2) + input_data.
get_shift(seqpos+1,HA3))/2 - offset;
111 tr.Debug <<
"CALC_SECONDARY_G " << (seqpos+1) <<
" " << sequence[seqpos] <<
" " << input_data.
get_shift(seqpos+1, HA2) + input_data.
get_shift(seqpos+1,HA3) <<
" " << offset <<
" " << shift_type.second <<
" " << shift_value << std::endl;
116 offset = randcoil.find(sequence[seqpos])->second.find(shift_type.second)->second
117 +rcadj.find(sequence[seqpos])->second.find(shift_type.second)->second;
120 offset = offset + rcprev.find(sequence[seqpos-1])->second.find(shift_type.second)->second;
122 if (seqpos != sequence.length()-1) {
123 offset = offset + rcnext.find(sequence[seqpos+1])->second.find(shift_type.second)->second;
126 if ( input_data.
has_atom(seqpos+1,shift_type.second) ) {
131 shift_value = input_data.
get_shift(seqpos+1,shift_type.second) - offset;
135 tr.Debug <<
"CALC_SECONDARY_A " << (seqpos+1) <<
" " << sequence[seqpos] <<
" " << input_data.
get_shift(seqpos+1, shift_type.second) <<
" " << offset <<
" " << shift_type.second <<
" " << shift_value << std::endl;
140 if (has_shift ==
true) {
141 if (sslimit.count(sequence[seqpos]) == 1) {
142 if (sslimit.find(sequence[seqpos])->second.count(shift_type.second) == 1) {
144 Real min( sslimit.find(sequence[seqpos])->second.find(shift_type.second)->second.first );
145 Real max( sslimit.find(sequence[seqpos])->second.find(shift_type.second)->second.second );
148 if ( ((shift_value >= min) && ( shift_value <= max )) || ( !use_sslimit) ) {
149 shift.first = shift_type.first;
150 shift.second = shift_value;
151 res_shifts.push_back( shift );
153 tr.Debug <<
"USING_2ND_SHIFT: " << seqpos+1 <<
" " << sequence[seqpos] <<
"_aa" <<
" " << shift_type.second <<
" " << shift.second << std::endl;
155 if (shift_value < min) {
156 tr.Debug <<
"SHIFT OUTLIER REMOVED: " << seqpos+1 <<
" " << sequence[seqpos] <<
" " << shift.second <<
" " << shift_value <<
" Limit: " << min << std::endl;
158 tr.Debug <<
"SHIFT OUTLIER REMOVED: " << seqpos+1 <<
" " << sequence[seqpos] <<
" " << shift.second <<
" " << shift_value <<
" Limit: " << max << std::endl;
166 secondary_shifts_.push_back( res_shifts );
170 std::map< char, std::map<std::string,Real> >
173 std::map< char, std::map<std::string,Real> > file_data_map;
177 utility::io::izstream data(basic::database::full_name(file_name.c_str()));
178 tr.Info <<
"read CS adjustment data from " << file_name << std::endl;
180 utility_exit_with_message(
"[ERROR] Unable to open talos file: "
188 bool header_done =
false;
189 while (!header_done) {
191 std::istringstream line_stream(line);
192 line_stream >> keyword;
194 if (keyword ==
"VARS") {
195 line_stream >> junk >> junk >> entry;
197 while (!line_stream.eof()) {
201 column_names_.push_back(entry);
202 line_stream >> entry;
208 column_names_.push_back(entry);
211 if (keyword ==
"FORMAT") {
218 while (!data.eof()) {
219 std::istringstream line_stream(line);
223 line_stream >> junk >> aa;
225 std::map< std::string ,Real > linemap;
226 for (
Size i = 1; i <= column_names_.size(); i++ ){
228 line_stream >> offset;
229 linemap.insert(std::make_pair(column_names_[i], offset));
231 file_data_map.insert(std::make_pair(aa,linemap));
236 return file_data_map;
239 std::map<char,std::map<std::string,std::pair< core::Real, core::Real > > >
242 std::map<char,std::map<std::string,std::pair< core::Real, core::Real > > > file_data_map;
247 utility::io::izstream data(basic::database::full_name(file_name.c_str()));
248 tr.Info <<
"read CS sslimit data from " << file_name << std::endl;
250 utility_exit_with_message(
"[ERROR] Unable to open talos file: "
260 bool header_done =
false;
261 while (!header_done) {
263 std::istringstream line_stream(line);
264 line_stream >> keyword;
266 if (keyword ==
"VARS") {
267 line_stream >> junk >> junk >> entry >> junk;
269 while (!line_stream.eof()) {
270 Size mid = entry.find_first_of(
'_');
271 sub_entry = entry.substr(0,mid);
272 column_names_.push_back(sub_entry);
274 line_stream >> entry >> junk;
277 Size mid = entry.find_first_of(
'_');
278 sub_entry = entry.substr(0,mid);
279 column_names_.push_back(sub_entry);
282 if (keyword ==
"FORMAT") {
289 while (!data.eof()) {
290 std::istringstream line_stream(line);
294 line_stream >> junk >> aa;
296 std::map< std::string , std::pair< Real, Real> > linemap;
297 for (
Size i = 1; i <= column_names_.size(); i++ ){
298 Real min(0.0), max(0.0);
299 line_stream >> min >> max;
301 if ( (min < 1000) && (max < 1000) ) {
302 tr.Debug <<
"READ_SSLIST " << column_names_[i] <<
" " << aa <<
" " << min <<
" " << max << std::endl;
303 linemap.insert(std::make_pair(column_names_[i], std::make_pair(min,max)));
306 file_data_map.insert(std::make_pair(aa,linemap));
311 return file_data_map;
317 if (option[in::fix_disulf].user()) {
325 for (
Size i = 1; i <= disulfides_in_file.size(); ++i ) {
327 Size l = disulfides_in_file[i].first;
328 Size u = disulfides_in_file[i].second;
331 utility_exit_with_message(
"[ERROR] Disulfide File Format: res2 must be > res1");
334 if ( !((instring[l-1] ==
'C') || (instring[l-1] ==
'c'))
335 || !((instring[u-1] ==
'C') || (instring[u-1] ==
'c')) ) {
336 utility_exit_with_message(
"[ERROR] -fix_disulf residues do not map to cysteines in talos file");