22 #include <ObjexxFCL/format.hh>
28 #include <basic/Tracer.hh>
29 #include <utility/io/izstream.hh>
30 #include <utility/string_util.hh>
32 #include <utility/exit.hh>
35 #include <basic/options/option.hh>
36 #include <basic/options/keys/abinitio.OptionKeys.gen.hh>
37 #include <basic/options/keys/OptionKeys.hh>
43 #include <utility/vector1.hh>
46 #include <numeric/random/random.fwd.hh>
61 range_pair_ = std::make_pair( std::make_pair( s1_1, s1_2 ), std::make_pair( s2_1, s2_2 ) );
93 using ObjexxFCL::fmt::I;
94 out <<
"Hairpin - Strand1: " << I(5,s.
s1_start()) <<
"-" << I(5,s.
s1_end()) <<
" Strand2: "
108 ) : hairpin_list_( s.hairpin_list_ )
128 Hairpin new_hairpin(s1_1, s1_2, s2_1, s2_2);
154 using ObjexxFCL::fmt::I;
160 ite= temp_list.end(); it != ite; ++it ) {
168 kill_parallel_( false ),
169 kill_antiparallel_( true )
175 kill_parallel_( src.kill_parallel_ ),
176 kill_antiparallel_( src.kill_antiparallel_ ),
177 hairpins_ ( src.hairpins_ )
203 while (!input_file.eof()) {
204 getline(input_file, line);
205 if (line.length() > 5) {
206 std::istringstream line_stream(line);
212 line_stream >> res >> aa >> ss >> L_freq >> H_freq >> E_freq;
214 strand_prob.push_back(E_freq);
215 helix_prob.push_back(H_freq);
216 loop_prob.push_back(L_freq);
218 if ((strand_prob.size() != res) || (strand_prob.size() != helix_prob.size())
219 || (loop_prob.size() != helix_prob.size())) {
220 utility_exit_with_message(
"[ERROR] -kill_hairpins can't parse psipred_ss2 file");
238 bool has_helix(
false), on_strand(
false), has_strand(
false);
239 std::pair< core::Size, core::Size > working_strand;
240 std::pair< core::Size, core::Size > last_strand;
241 for (
core::Size i=1; i <= strand_prob.size(); ++i) {
245 if ( i <= strand_prob.size() - 2 ) {
247 if (( strand_prob[i] >= 0.5 ) &&
248 ( strand_prob[i+1] >= 0.5 ) &&
249 ( strand_prob[i+2] >= 0.5) ){
253 working_strand.first = i;
266 helix_prob_sum = 0.0;
270 helix_prob_sum += helix_prob[i];
272 if ( helix_prob_sum >= 3.0 ) {
279 if (( strand_prob[i] < 0.5 ) || ( i == strand_prob.size())) {
280 working_strand.second = i-1;
282 if ( ( has_strand ==
true ) && ( last_strand.first != last_strand.second ) ) {
283 runtime_assert( last_strand != working_strand );
285 runtime_assert( (last_strand.first<=last_strand.second)
286 && (last_strand.second<=working_strand.first)
287 && (working_strand.first<=working_strand.second));
289 Hairpin new_hairpin( last_strand.first, last_strand.second,
290 working_strand.first, working_strand.second );
291 all_hairpins.push_back( new_hairpin );
294 last_strand = working_strand;
295 working_strand.first = 0;
296 working_strand.second = 0;
303 core::Real freq_limit( basic::options::option[ basic::options::OptionKeys::abinitio::kill_hairpins_frequency ] );
305 for (
core::Size i=1; i<= all_hairpins.size(); ++i) {
307 core::Real freq_attempt(numeric::random::uniform());
309 trKillHairpinsIO.Info <<
"KHP: Hairpin Detected in Psipred File: " << all_hairpins[i].s1_start() <<
"-" << all_hairpins[i].s1_end() <<
" " << all_hairpins[i].s2_start() <<
"-" << all_hairpins[i].s2_end();
310 if ( freq_attempt <= freq_limit ) {
312 all_hairpins[i].s1_end(),
313 all_hairpins[i].s2_start(),
314 all_hairpins[i].s2_end());
327 while (!input_file.eof()) {
328 getline(input_file, line);
330 if (line.length() > 5) {
331 std::istringstream line_stream(line);
336 line_stream >> frequency >> res1 >> res2 >> res3 >> res4;
338 runtime_assert((res1<=res2) && (res2<=res3) && (res3<=res4));
340 core::Real freq_attempt(numeric::random::uniform());
342 trKillHairpinsIO.Info <<
"KHP: Hairpin Read from Kill Hairpins File: " << res1 <<
"-" << res2 <<
" " << res3 <<
"-" << res4;
344 if (freq_attempt <= frequency) {
358 if ( basic::options::option[ basic::options::OptionKeys::abinitio::kill_hairpins ].user() ) {
359 utility::io::izstream input_file( basic::options::option[ basic::options::OptionKeys::abinitio::kill_hairpins ] );
362 utility_exit_with_message(
"[ERROR] Unable to open kill_hairpins file");
366 getline(input_file, line);
368 if ( tokens.size() == 4 ) {
371 }
else if ( tokens.size() == 3 ) {
373 }
else if ( tokens.size() == 2 ) {
375 utility_exit_with_message(
"[ERROR] invalid header input for kill_hairpins file. ");
378 if( a !=
"ANTI" && a !=
"PARA" && a !=
"" ) {
379 utility_exit_with_message(
"[ERROR] invalid kill type for kill_hairpins. ANTI or PARA, is required. ");
381 if( b !=
"ANTI" && b !=
"PARA" && b !=
"" ) {
382 utility_exit_with_message(
"[ERROR] invalid kill type for kill_hairpins. ANTI or PARA, is required. ");
385 if ( a ==
"ANTI" || b ==
"ANTI" ) {
388 if ( a ==
"PARA" || b ==
"PARA" ) {
393 if ( keyword ==
"PSIPRED" ) {
396 if ( keyword ==
"KILL" ) {
399 utility_exit_with_message(
"[ERROR] Unknown file type for kill_hairpins file (need psipred_ss2 or kill). File type is autodetected by file header; check your header.");