26 #include <basic/datacache/BasicDataCache.hh>
31 #include <utility/exit.hh>
32 #include <utility/excn/Exceptions.hh>
33 #include <numeric/util.hh>
35 #include <basic/Tracer.hh>
36 #include <basic/prof.hh>
41 #include <basic/options/option.hh>
42 #include <basic/options/option_macros.hh>
45 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
47 #include <basic/options/keys/in.OptionKeys.gen.hh>
51 #include <utility/vector1.hh>
54 static basic::Tracer
tr(
"protocols.jd2.Archive");
58 OPT_1GRP_KEY( Boolean, iterative, evaluate_only_on_slaves )
70 NEW_OPT( iterative::evaluate_only_on_slaves,
"do not re-evaluate decoys when they are read into archvie (e.g. on BlueGene)",
false );
71 NEW_OPT( iterative::penalize_initial_decoys,
"decoys read from input_pool have X extra score", 1000.0 );
76 #define OBSOLETE(key) \
77 if ( basic::options::option[ key ].user() ) { \
78 tr.Warning << "WARNING: Option "<< #key<< " is deprecated!" << std::endl; \
87 using namespace core::io::silent;
94 scores_are_clean_( true ),
95 b_evaluate_incoming_decoys_( !basic::options::option[ basic::options::OptionKeys::iterative::evaluate_only_on_slaves ]() )
99 OBSOLETE(basic::options::OptionKeys::iterative::evaluate_only_on_slaves)
105 scores_are_clean_( true ),
106 b_evaluate_incoming_decoys_( !basic::options::option[ basic::options::OptionKeys::iterative::evaluate_only_on_slaves ]() )
114 tr.Trace <<
"start evaluation" << std::endl;
118 using namespace basic::options;
119 tr.Info <<
"add structure" << std::endl;
133 if ( numeric::isnan( new_decoy_score ) )
return false;
136 SilentStructs::iterator iss =
decoys().begin();
141 int now = time(NULL);
143 evaluated_decoy->add_energy(
"eval_time", 1.0*eval_time, 1.0 );
144 tr.Trace <<
"add evaluated structure " << evaluated_decoy->decoy_tag() <<
" after " << eval_time <<
" seconds of evaluation."<< std::endl;
154 tr.Info <<
"structures are scored with the following weights: " << std::endl;
159 tr.Info << name <<
" " << weight <<
" " << weight / variations.find( name )->second << std::endl;
162 tr.Info <<
"The score will be computed according to " << std::endl;
164 tr.Info << std::endl;
167 tr.Info <<
"finished reading structures for batch: " << batch.
batch() << std::endl;
182 tr.Trace <<
"don't evaluate local: trust energies saved in " << iss->decoy_tag() << std::endl;
186 tr.Trace <<
"evaluate local for " << iss->decoy_tag() << std::endl;
188 using namespace core::io::silent;
190 pss->clear_energies();
196 PROF_START( basic::ARCHIVE_FILL_POSE );
198 pss->fill_pose( pose );
200 pose.energies().clear();
201 PROF_STOP( basic::ARCHIVE_FILL_POSE );
208 if ( it->name() !=
"_archive_select_score_" && !pss->has_energy( it->name() )) {
209 pss->add_energy( it->name(), it->value(), it->weight() );
214 if ( pss->has_energy(
"total_eval_time" ) ) {
215 total_time = pss->get_energy(
"total_eval_time" );
218 pss->add_energy(
"total_eval_time", total_time, 1.0 );
226 tr.Trace <<
"evaluate decoy " << iss->decoy_tag() << std::endl;
229 PROF_START( basic::ARCHIVE_SCORE_POSE );
231 iss->energies_from_pose( pose );
232 PROF_STOP( basic::ARCHIVE_SCORE_POSE );
235 PROF_START( basic::ARCHIVE_EVALUATORS );
240 it->second->apply( pose, iss->decoy_tag(), *iss );
242 PROF_STOP( basic::ARCHIVE_EVALUATORS );
254 if ( evaluated_decoy->has_energy(
"_archive_select_score_" ) ) {
255 return evaluated_decoy->get_energy(
"_archive_select_score_" );
264 Real const& weight( it->second );
265 if ( weight == 0.0 )
continue;
269 if ( evaluated_decoy->get_comment(
"source_file" ).find(
"batch_000000/" ) != std::string::npos ) {
273 if ( !evaluated_decoy->has_energy( name ) ) {
274 throw EXCN_Archive(
"energy name "+name+
" not found in returned decoys -- run with rescoring in archive to avoid this or fix your batches" );
276 if ( weight > 0.01 ) {
277 sum += weight * evaluated_decoy->get_energy( name ) / variations.find( name )->second;
283 tr.Trace <<
"evaluated select_score for " << evaluated_decoy->decoy_tag()
284 <<
" that was tagged as " << evaluated_decoy->get_comment(
"tag_in_file")
285 <<
" : " << sum <<
" with " <<
select_weights_.size() <<
" evaluators" << std::endl;
288 evaluated_decoy->add_energy(
"_archive_select_score_", sum );
301 return b_have_restored;
310 return arc_.select_score( pss1 ) < arc_.select_score( pss2 );
324 tr.Debug <<
"rescore " <<
name() <<
" decoys " << std::endl;
325 tr.Info <<
"structures are rescored with the following weights: " << std::endl;
330 tr.Info << name <<
" " << weight <<
" " << weight / variations.find( name )->second << std::endl;
333 for ( SilentStructs::iterator iss =
decoys().begin(); iss !=
decoys().end(); ++iss ) {
339 tr.Debug <<
"...done rescoring and sorting " << std::endl;
351 tr.Info <<
"added evaluator " << eval->name( 1 ) <<
" with weight " << weight <<
" to EvaluatedArchive " <<
name() << std::endl;
352 for (
Size i=1; i<= eval->size(); i++ ) {
361 tr.Info <<
"remve evaluator " << name << std::endl;
364 EvaluatorMap::iterator iter =
evaluators_.find( column );
375 tr.Info <<
"set_weight " << column <<
" to " << weight <<
" in " <<
name() << std::endl;
378 if ( iter !=
select_weights_.end() && std::abs( iter->second - weight ) < 0.001 )
return;
379 tr.Info <<
"set_weight " << column <<
" to " << weight <<
" in " <<
name() << std::endl;
381 if ( weight > 0.01 ) {
391 for ( WeightMap::const_iterator it = setting.begin(); it != setting.end(); ++it ) {
402 for ( EvaluatorMap::const_iterator it = evaluators.begin(); it != evaluators.end(); ++it ) {
403 WeightMap::const_iterator itfind=weights.find( it->first );
420 EvaluatorMap::const_iterator iter =
evaluators_.find( column );
442 using namespace basic::options;
443 using namespace basic::options::OptionKeys;
453 if ( option[ OptionKeys::iterative::penalize_initial_decoys ]() > 0.0 ) {