31 #include <utility/exit.hh>
32 #include <utility/excn/Exceptions.hh>
34 #include <numeric/util.hh>
36 #include <basic/Tracer.hh>
37 #include <basic/prof.hh>
42 #include <basic/options/option.hh>
43 #include <basic/options/option_macros.hh>
46 #include <basic/options/keys/run.OptionKeys.gen.hh>
47 #include <utility/vector1.hh>
50 static basic::Tracer
tr(
"protocols.jd2.NormalizedEvaluatedArchive");
54 OPT_2GRP_KEY( Boolean, iterative, normalize, activate )
55 OPT_2GRP_KEY( Boolean, iterative, normalize, extra_archive )
56 OPT_2GRP_KEY(
Real, iterative, normalize, keep_adding )
57 OPT_2GRP_KEY( Integer, iterative, normalize, num_struct)
58 OPT_2GRP_KEY( Integer, iterative, normalize,
start )
59 OPT_2GRP_KEY( StringVector, iterative, normalize, force_zero )
60 OPT_2GRP_KEY( Boolean, iterative, normalize, lower_quartile )
70 NEW_OPT( iterative::normalize::activate,
"score-variations are determined to normalize scores",
false );
71 NEW_OPT( iterative::normalize::extra_archive,
"determine score variations from extra archive",
false );
72 NEW_OPT( iterative::normalize::keep_adding,
"keep adding X percent of the incoming structures, throw out old ones randomly", 0.0 );
73 NEW_OPT( iterative::normalize::num_struct,
"number of structures in varaiance archive", 1000 );
74 NEW_OPT(
iterative::normalize::start,
"do not normalize until X structures have been accumulated, if 0 this will be set to normalize:nstruct structures", 0 );
75 NEW_OPT2( iterative::normalize::force_zero,
"for scores whose name starts with XXX compute variance as 0...Q3 instead of Q1..Q3",
"rdc",
"filter_cst" );
76 NEW_OPT( iterative::normalize::lower_quartile,
"use Lo..Q1 instead of Q1..Q3 to determine range",
false );
88 using namespace core::io::silent;
95 score_variations_are_clean_ =
false;
108 using namespace basic::options;
109 insertion_prob_ = option[ OptionKeys::iterative::normalize::keep_adding ]();
115 activated_ = option[ OptionKeys::iterative::normalize::activate ]();
116 positive_scores_ = option[ OptionKeys::iterative::normalize::force_zero ]();
117 lower_quartile_ = option[ OptionKeys::iterative::normalize::lower_quartile ]();
118 if ( option[ OptionKeys::run::test_cycles ] || option[ OptionKeys::run::dry_run ] ) {
136 bool added_variance( added );
138 added_variance =
false;
140 added_variance =
variance_archive_->add_evaluated_structure( evaluated_decoy,batch );
143 tr.Info <<
"offered structure that was " << ( added ?
"" :
"not" ) <<
" relevant to the variances " << std::endl;
161 return b_have_restored;
171 tr.Info <<
"determine score variations in NormalizedEvaluatedArchive " <<
name() <<
"... " << std::endl;
174 for ( WeightMap::const_iterator it =
weights().begin(); it !=
weights().end(); ++it ) {
175 if ( it->first ==
"special_initial_decoy_penalty" )
continue;
176 if ( it->second > 0.01 ) {
189 values.resize( ndecoys );
190 for ( SilentStructs::const_iterator iss = my_decoys.begin(); iss != my_decoys.end(); ++iss, ++ct ) {
191 if ( !(*iss)->has_energy( name ) ) {
192 throw EXCN_Archive(
"energy name "+name+
" not found in returned decoys -- run with rescoring in archive to avoid this or fix your batches" );
194 values[ct]=(*iss)->get_energy( name );
196 runtime_assert( lowQ > 0 && highQ < ndecoys );
197 std::sort(values.begin(), values.end());
201 <<
" between 0 (forced)"
202 <<
" and " << values[highQ] <<
" at " << highQ << std::endl;
206 <<
" between " << values[lowQ] <<
" at " << lowQ
207 <<
" and " << values[highQ] <<
" at " << highQ << std::endl;
223 if ( str.substr( 0, it->size() ) == *it )
return true;