15 #include <utility/io/izstream.hh>
36 #include <basic/options/option.hh>
40 #include <basic/datacache/BasicDataCache.hh>
41 #include <basic/datacache/CacheableString.hh>
42 #include <basic/datacache/DiagnosticData.hh>
43 #include <basic/Tracer.hh>
50 #include <numeric/random/random_permutation.hh>
51 #include <utility/exit.hh>
52 #include <utility/file/FileName.hh>
53 #include <utility/pointer/owning_ptr.hh>
64 #if defined(WIN32) || defined(__CYGWIN__)
70 #include <basic/options/keys/out.OptionKeys.gen.hh>
71 #include <basic/options/keys/run.OptionKeys.gen.hh>
72 #include <basic/options/keys/in.OptionKeys.gen.hh>
73 #include <basic/options/keys/score.OptionKeys.gen.hh>
83 #include <utility/vector0.hh>
84 #include <utility/vector1.hh>
85 #include <utility/file/file_sys_util.hh>
93 basic::Tracer
TR(
"protocols.jobdist.main");
94 static numeric::random::RandomGenerator
RG(32342524);
101 using basic::options::option;
104 using namespace basic::options::OptionKeys;
108 if ( option[ in::file::s ].active() )
109 pdb_file_names = option[ in::file::s ]().vector();
112 if ( option[ in::file::l ].active() )
113 list_file_names = option[ in::file::l ]().vector();
114 if ( option[ in::file::list ].active() ){
116 better_list_file_names= option[in::file::list ]().vector();
118 list_file_names.push_back(*i);
124 utility::io::izstream data(
filename.c_str() );
125 if ( !data.good() ) {
126 utility_exit_with_message(
"Unable to open file: " +
filename +
'\n' );
129 while( getline(data, line) ) {
130 pdb_file_names.push_back(
FileName(line) );
136 int const nstruct_flag = option[ out::nstruct ];
137 int const nstruct = std::max( 1, nstruct_flag );
141 if ( option[ in::file::native ].user() ) {
142 native_file = option[ in::file::native ]().name();
144 native_file = i->name();
151 jobs.push_back( job );
162 using basic::datacache::CacheableString;
174 using basic::datacache::DiagnosticData;
177 std::map < std::string, core::Real > map;
178 map[
"NO_OUTPUT_TAG_CACHED_SORRY" ] = 0.0;
189 using namespace basic::options;
190 using namespace basic::options::OptionKeys;
191 option.add_relevant( in::file::centroid_input );
192 option.add_relevant( in::file::fullatom );
193 option.add_relevant( in::file::l );
194 option.add_relevant( in::file::native );
195 option.add_relevant( in::file::s );
196 option.add_relevant( in::file::silent );
197 option.add_relevant( in::file::silent_struct_type );
198 option.add_relevant( in::file::silent_list );
199 option.add_relevant( in::file::tags );
200 option.add_relevant( out::file::scorefile );
201 option.add_relevant( out::file::silent );
202 option.add_relevant( out::nooutput );
203 option.add_relevant( out::nstruct );
204 option.add_relevant( out::prefix );
205 option.add_relevant( run::repeat );
213 using namespace protocols;
214 using namespace protocols::jobdist;
215 using namespace protocols::moves;
216 using namespace core::scoring;
217 using namespace basic::options;
218 using namespace basic::options::OptionKeys;
219 using namespace utility::file;
222 using basic::datacache::CacheableString;
226 if (option[ in::file::native ].user()) {
230 #ifdef BOINC_GRAPHICS
232 boinc::Boinc::set_graphics_native_pose( native_pose );
238 if( option[ in::file::silent ].user() || option[ in::file::silent_list ].user() ){
242 if ( option[ in::file::fullatom ]() ) {
244 }
else if ( option[ in::file::residue_type_set ]() ==
"rna" || option[ out::file::residue_type_set ]() ==
"rna" ) {
254 if ( option[ in::file::tags ].user() ) {
255 requested_tags = option[ in::file::tags ]().vector();
259 if ( option[ in::file::user_tags ].user() ) {
260 requested_user_tags = option[ in::file::user_tags ]().vector();
265 if ( option[ in::file::silent ].active() )
266 input_silent_files = option[ in::file::silent ]();
270 if ( option[ in::file::silent_list ].active() )
271 list_file_names = option[ in::file::silent_list ]();
275 utility::io::izstream data(
filename.c_str() );
276 if ( !data.good() ) { utility_exit_with_message(
"Unable to open file: " +
filename +
'\n' ); }
278 while( getline(data, line) ) {
279 input_silent_files.push_back(
FileName(line) );
284 int const nstruct_flag = option[ out::nstruct ];
285 int const nstruct = std::max( 1, nstruct_flag );
291 if( input_silent_files.size() > 1 ){
292 utility_exit_with_message(
"Sorry - extracitng/reading multiple silent files is disabled.");
304 if( input_silent_files.size() > 1 ) outfile = outfile + infile;
311 if(
RG.uniform() < thinout_factor ){
317 if ( option[ in::file::tags ].user() ) {
319 bool foundtag =
false;
321 for ( ; it !=
end; ++it ) {
322 if( iter->decoy_tag() == (*it) ){
323 foundtag =
true;
break;
326 if( foundtag ) requested_tags.erase( it );
327 if( !foundtag )
continue;
331 if ( option[ in::file::user_tags ].user() ) {
333 bool founduser_tag =
false;
335 std::cout << iter->get_comment(
"user_tag") << std::endl;
336 for ( ; it !=
end; ++it ) {
337 if( iter->get_comment(
"user_tag") == (*it) ){
338 std::cerr <<
"FOUND: " << iter->get_comment(
"user_tag") << std::endl;
339 founduser_tag =
true;
break;
342 if( !founduser_tag )
continue;
346 job->set_preserve_whole_input_tag(
true );
347 input_jobs.push_back( job );
350 bool const silent_output = option[ out::file::silent ].user();
351 if ( silent_output ) {
353 std::cerr <<
"Silent Output Mode " << std::endl;
355 TR <<
"Silent Output Mode " << std::endl;
359 std::cerr <<
"PDB Output Mode " << std::endl;
361 TR <<
"PDB Output Mode " << std::endl;
364 if( option[ out::nooutput ]() ){
365 jobdist->disable_output();
366 jobdist->enable_ignorefinished();
375 int curr_nstruct, num_structures_processed = 0;
377 std::cerr <<
"Jobdist startup.." << std::endl;
380 while( jobdist->next_job(curr_job, curr_nstruct) ) {
385 if( iter->decoy_tag() != curr_job->input_tag() )
continue;
387 time_t pdb_start_time = time(NULL);
389 std::string curr_job_tag = curr_job->output_tag(curr_nstruct);
392 std::cerr <<
"Starting work on structure: " << curr_job_tag <<
" <--- " << curr_job->input_tag() << std::endl;
395 iter->fill_pose( input_pose, *rsd_set );
398 std::string user_tag( iter->get_comment(
"user_tag" ) );
399 if ( user_tag ==
"" ) user_tag = iter->get_comment(
"user_ta" );
400 if ( user_tag ==
"" ) user_tag = iter->get_comment(
"user_t" );
402 std::string alignment_id( iter->get_comment(
"alignment_id" ) );
404 std::cout <<
"USERTAGS: " << alignment_id <<
" " << user_tag << std::endl;
407 if (( (option[ OptionKeys::score::weights ]() ==
"score0") ||
408 (option[ OptionKeys::score::weights ]() ==
"score2") ||
409 (option[ OptionKeys::score::weights ]() ==
"score3") ||
410 (option[ OptionKeys::score::weights ]() ==
"score5") ||
411 (option[ OptionKeys::score::weights ]() ==
"score_membrane"))
413 std::cout <<
"switching to centroid" << std::endl;
431 TR <<
"Working on: " << tag << std::endl;
439 if ( option[ OptionKeys::score::weights ]() ==
"score_membrane" && option[in::file::spanfile].user() && option[ in::file::centroid_input ].user() ) {
440 std::string const spanfile = option[ in::file::spanfile ]();
447 #ifdef BOINC_GRAPHICS
449 protocols::boinc::Boinc::attach_graphics_current_pose_observer( *the_pose );
454 if ( option[ OptionKeys::run::idealize_before_protocol ].user() ) {
456 idealizer.
fast(
false );
457 idealizer.
apply( *the_pose );
461 for(
int repeat = 0; repeat <
int(option[ run::repeat ]()); ++repeat ){
462 mover.
apply( *the_pose );
467 if ( option[ in::file::native ].user() ){
472 if( ! option[ out::nooutput ]() ){
474 if (!silent_output) {
475 jobdist->dump_pose_and_map( curr_job_tag, *the_pose );
486 pss->fill_struct( *the_pose, curr_job_tag );
488 evaluator->apply( *the_pose, curr_job_tag, *pss );
489 if ( user_tag !=
"" ) pss->add_string_value(
"user_tag", user_tag );
490 if ( alignment_id !=
"" ) pss->add_string_value(
"alignment_id", alignment_id );
491 jd->dump_silent( curr_nstruct, *pss );
496 if ( option[ out::file::scorefile ].user() || !silent_output ) {
498 ss->fill_struct( *the_pose );
500 evaluator->apply( *the_pose, curr_job_tag, *ss );
501 if ( user_tag !=
"" ) ss->add_string_value(
"user_tag", user_tag );
502 if ( alignment_id !=
"" ) ss->add_string_value(
"alignment_id", alignment_id );
509 num_structures_processed += 1;
510 time_t pdb_end_time = time(NULL);
511 TR <<
"Finished " << curr_job_tag <<
" in " << (long)(pdb_end_time - pdb_start_time) <<
" seconds." << std::endl;
519 end = requested_tags.end(); it !=
end; ++it ) {
520 std::cerr <<
"WARNING: Cannot find tag: " << (*it) << std::endl;
526 if( option[ in::file::s ].user() || option[ in::file::l ].user() ){
529 time_t overall_start_time = time(NULL);
535 using basic::options::option;
536 using namespace basic::options::OptionKeys;
538 bool const silent_output = option[ out::file::silent ].user();
539 if ( silent_output ) {
540 TR <<
"Silent Output Mode " << std::endl;
543 TR <<
"PDB Output Mode " << std::endl;
547 if( option[ out::nooutput ]() ){
548 jobdist->disable_output();
549 jobdist->enable_ignorefinished();
553 int curr_nstruct, num_structures_processed = 0;
556 while( jobdist->next_job(curr_job, curr_nstruct) ) {
558 if(
RG.uniform() < thinout_factor ){
566 if ( option[ in::file::centroid_input ].user() ) {
573 #ifdef BOINC_GRAPHICS
575 boinc::Boinc::set_graphics_native_pose( native_pose );
579 std::string curr_job_tag = curr_job->output_tag(curr_nstruct);
581 time_t pdb_start_time = time(NULL);
583 TR <<
"Starting " << curr_job->output_tag(curr_nstruct) <<
" ..." << std::endl;
586 if( curr_job.get() != prev_job.get() || input_pose.get() == NULL ) {
588 if ( option[ in::file::centroid_input ].user() ) {
595 if( input_pose->total_residue() == 0 ){
596 utility_exit_with_message(
"Unable to read PDB file: " + curr_job->input_tag() +
'\n' );
607 if ( option[ OptionKeys::score::weights ]() ==
"score_membrane" && option[in::file::spanfile].user() && option[ in::file::centroid_input ].user() ) {
608 std::string const spanfile = option[ in::file::spanfile ]();
615 #ifdef BOINC_GRAPHICS
617 protocols::boinc::Boinc::attach_graphics_current_pose_observer( *the_pose );
621 if ( option[ OptionKeys::run::idealize_before_protocol ].user() ) {
623 idealizer.
fast(
false );
624 idealizer.
apply( *the_pose );
627 for(
int repeat = 0; repeat <
int(option[ run::repeat ]()); ++repeat ){
628 mover.
apply( *the_pose );
633 if ( option[ in::file::native ].user() )
637 if (!silent_output) {
638 jobdist->dump_pose_and_map( curr_job_tag, *the_pose );
649 pss->fill_struct( *the_pose, curr_job_tag );
650 jd->dump_silent( curr_nstruct, *pss );
653 if ( option[ out::file::scorefile ].user() || !silent_output ) {
655 ss->fill_struct( *the_pose );
661 num_structures_processed += 1;
662 time_t pdb_end_time = time(NULL);
663 TR <<
"Finished " << curr_job->output_tag(curr_nstruct) <<
" in " << (long)(pdb_end_time - pdb_start_time) <<
" seconds." << std::endl;
667 time_t overall_end_time = time(NULL);
668 TR <<
"Finished all " << num_structures_processed <<
" structures in " << (long)(overall_end_time - overall_start_time) <<
" seconds." << std::endl;
669 if ( num_structures_processed == 0 )
670 basic::Warning() <<
"No structures processed. Existing output files may have been skipped, did you mean to delete them or to use the -overwrite flag?" << std::endl;
688 bool random_permutation
692 using basic::datacache::CacheableString;
694 time_t overall_start_time = time(NULL);
700 if( random_permutation ) {
706 int curr_nstruct, num_structures_processed = 0;
713 using basic::options::option;
714 using namespace basic::options::OptionKeys;
717 bool const is_raw = option[ out::file::raw ]();
718 bool const silent_output = option[ out::file::silent ].user();
719 if ( is_raw || silent_output ) {
725 if( option[ out::nooutput ]() ){
726 jobdist->disable_output();
727 jobdist->enable_ignorefinished();
730 std::map < std::string, core::Real > score_map;
733 while( jobdist->next_job(curr_job, curr_nstruct) ) {
734 time_t pdb_start_time = time(NULL);
735 TR <<
"Starting " << curr_job->output_tag(curr_nstruct) <<
" ..." << std::endl;
736 jobdist->temp_file( curr_job->output_tag(curr_nstruct) );
739 if( curr_job.get() != prev_job.get() || input_pose.get() == NULL ) {
741 if ( option[ in::file::centroid_input ].user() ) {
758 mover.
apply( *the_pose );
761 num_structures_processed += 1;
762 time_t pdb_end_time = time(NULL);
763 TR <<
"Finished " << curr_job->output_tag(curr_nstruct) <<
" in " << (long)(pdb_end_time - pdb_start_time) <<
" seconds." << std::endl;
767 if ( option[ run::timer ].user() ){
768 score_map[
"time"] = pdb_end_time - pdb_start_time;
771 jobdist->score_map( score_map );
772 jobdist->dump_pose_and_map( curr_job->output_tag(curr_nstruct), *the_pose );
777 time_t overall_end_time = time(NULL);
778 TR <<
"Finished all " << num_structures_processed <<
" structures in " << (long)(overall_end_time - overall_start_time) <<
" seconds." << std::endl;
779 if ( num_structures_processed == 0 )
780 basic::Warning() <<
"No structures processed. Existing output files may have been skipped, did you mean to delete them?" << std::endl;
797 using basic::datacache::CacheableString;
799 time_t overall_start_time = time(NULL);
811 using basic::options::option;
812 using namespace basic::options::OptionKeys;
814 bool const silent_output = option[ out::file::silent ].user();
815 if ( silent_output ) {
816 TR <<
"Silent Output Mode " << std::endl;
819 TR <<
"PDB Output Mode " << std::endl;
823 if( option[ out::nooutput ]() ){
824 jobdist->disable_output();
825 jobdist->enable_ignorefinished();
830 if ( option[ in::file::native ].user() ) {
835 int curr_nstruct, num_structures_processed = 0;
838 while( jobdist->next_job(curr_job, curr_nstruct) ) {
839 time_t pdb_start_time = time(NULL);
840 TR <<
"Starting " << curr_job->output_tag(curr_nstruct) <<
" ..." << std::endl;
843 if( curr_job.get() != prev_job.get() || input_pose.get() == NULL ) {
845 if ( option[ in::file::centroid_input ].user() ) {
856 for(
int repeat = 0; repeat <
int(option[ run::repeat ]()); ++repeat ){
857 mover.
apply( *the_pose );
864 (*scorefxn)( *the_pose );
870 if ( option[ in::file::native ].user() )
874 if (!silent_output) {
875 jobdist->dump_pose_and_map( curr_job->output_tag(curr_nstruct), *the_pose );
880 pss.
fill_struct( *the_pose, curr_job->output_tag(curr_nstruct) );
881 jd->dump_silent( curr_nstruct, pss );
885 num_structures_processed += 1;
886 time_t pdb_end_time = time(NULL);
887 TR <<
"Finished " << curr_job->output_tag(curr_nstruct) <<
" in " << (long)(pdb_end_time - pdb_start_time) <<
" seconds." << std::endl;
891 time_t overall_end_time = time(NULL);
892 TR <<
"Finished all " << num_structures_processed <<
" structures in " << (long)(overall_end_time - overall_start_time) <<
" seconds." << std::endl;
893 if ( num_structures_processed == 0 )
894 basic::Warning() <<
"No structures processed. Existing output files may have been skipped, did you mean to delete them or to use the -overwrite flag?" << std::endl;
910 using basic::datacache::CacheableString;
912 time_t overall_start_time = time(NULL);
919 int curr_nstruct, num_structures_processed = 0;
922 while( jobdist.
next_job(curr_job, curr_nstruct) ) {
923 time_t pdb_start_time = time(NULL);
924 TR <<
"Starting " << curr_job->output_tag(curr_nstruct) <<
" ..." << std::endl;
927 if( curr_job.get() != prev_job.get() || input_pose.get() == NULL ) {
935 mover.
apply( *the_pose );
938 std::map< std::string, core::Real > scores;
940 jobdist.
dump_pose( curr_job->output_tag(curr_nstruct), scores, *input_pose, *the_pose );
943 num_structures_processed += 1;
944 time_t pdb_end_time = time(NULL);
945 TR <<
"Finished " << curr_job->output_tag(curr_nstruct) <<
" in " << (long)(pdb_end_time - pdb_start_time) <<
" seconds." << std::endl;
949 time_t overall_end_time = time(NULL);
950 TR <<
"Finished all " << num_structures_processed <<
" structures in " << (long)(overall_end_time - overall_start_time) <<
" seconds." << std::endl;
951 if ( num_structures_processed == 0 )
952 basic::Warning() <<
"No structures processed. Existing output files may have been skipped, did you mean to delete them or use the -overwrite flag?" << std::endl;