23 #include <utility/tag/Tag.hh>
24 #include <boost/foreach.hpp>
25 #define foreach BOOST_FOREACH
26 #include <basic/Tracer.hh>
49 #include <utility/string_util.hh>
52 #include <numeric/random/random.hh>
53 #include <numeric/random/random_permutation.hh>
55 #include <utility/sort_predicates.hh>
59 #include <utility/vector0.hh>
60 #include <utility/vector1.hh>
69 using namespace utility;
70 using namespace protocols::moves;
77 static basic::Tracer
TR(
"protocols.loophash.LoopHashMoverWrapper" );
107 max_nstruct_( 1000000 ),
109 ranking_cenfilter_( NULL ),
111 ranking_fafilter_( NULL ),
113 prefilter_scorefxn_( NULL ),
115 sample_weight_const_( 1 )
125 using namespace core::io::silent;
127 Pose const saved_pose( pose );
157 std::vector< SilentStructOP > lib_structs;
158 Size starttime = time( NULL );
164 Size endtime = time( NULL );
165 Size nstructs = lib_structs.size();
166 TR <<
"Found " << nstructs <<
" alternative states in time: " << endtime - starttime << std::endl;
168 numeric::random::random_permutation(lib_structs.begin(), lib_structs.end(),
numeric::random::RG);
170 std::vector< std::pair< Real, SilentStructOP > > cen_scored_structs;
173 structure->fill_pose( rpose );
187 atm_ids.push_back( atm_ij );
188 atm_xyzs.push_back( pose_asu.
xyz( atm_ij ) );
203 new_struct->fill_struct( rpose );
204 cen_scored_structs.push_back( std::pair<Real, SilentStructOP >(-score_i,new_struct) );
209 std::sort( cen_scored_structs.begin(), cen_scored_structs.end(), utility::SortFirst<Real, SilentStructOP>() );
210 if (
ncentroid_ >= cen_scored_structs.size()) {
213 std::vector< std::pair< Real, SilentStructOP > >::const_iterator first = cen_scored_structs.end() -
ncentroid_;
214 std::vector< std::pair< Real, SilentStructOP > >::const_iterator last = cen_scored_structs.end();
215 all_structs_ = std::vector< std::pair< Real, SilentStructOP > >(first, last);
217 TR <<
"After centroid filter: " <<
all_structs_.size() <<
" of " << cen_scored_structs.size() <<
" structures" << std::endl;
221 std::vector< std::pair< Real, SilentStructOP > > fa_scored_structs;
222 std::vector< std::pair< Real, SilentStructOP > >::const_iterator it =
all_structs_.begin();
226 std::vector < SilentStructOP > relax_structs;
230 new_struct = (*it).second->clone();
232 relax_structs.push_back( new_struct );
236 TR <<
"BATCHSIZE: " << relax_structs.size() << std::endl;
243 structure->fill_pose( rpose );
246 bool passed_i =
fafilter_->apply( rpose );
254 new_struct->fill_struct( rpose );
255 fa_scored_structs.push_back( std::pair<Real, SilentStructOP >(-score_i,new_struct) );
261 std::sort( fa_scored_structs.begin(), fa_scored_structs.end(), utility::SortFirst<Real, SilentStructOP>() );
265 std::vector< std::pair< Real, SilentStructOP > >::const_iterator first = fa_scored_structs.end() -
nfullatom_;
266 std::vector< std::pair< Real, SilentStructOP > >::const_iterator last = fa_scored_structs.end();
267 all_structs_ = std::vector< std::pair< Real, SilentStructOP > >(first, last);
269 TR <<
"After fullatom filter: " <<
all_structs_.size() <<
" of " << cen_scored_structs.size() <<
" structures" << std::endl;
273 TR<<
"No structures survived fullatom filter. Consider relaxing filters"<<std::endl;
278 std::pair< Real, SilentStructOP > currbest =
all_structs_.back();
280 TR <<
"Returning score = " << -currbest.first << std::endl;
282 currbest.second->fill_pose( pose );
292 std::pair< core::Real, core::io::silent::SilentStructOP > currbest =
all_structs_.back();
294 TR <<
"Returning score = " << -currbest.first << std::endl;
295 currbest.second->fill_pose( *pose );
318 ideal_ = tag->getOption<
bool >(
"ideal", false );
327 if ( tag->hasOption(
"start_res_num" ) || tag->hasOption(
"start_pdb_num"))
329 if ( tag->hasOption(
"stop_res_num" ) || tag->hasOption(
"stop_pdb_num"))
332 string const loop_sizes_str( tag->getOption<
string >(
"loop_sizes" ) );
333 vector1< string > const loop_sizes_split( utility::string_split( loop_sizes_str,
',' ) );
334 foreach(
string const loop_size, loop_sizes_split )
339 if ( tag->hasOption(
"db_path" )) {
340 std::string db_path = tag->getOption<
string >(
"db_path" );
348 if ( tag->hasOption(
"prefilter_scorefxn" )) {
349 string const prefilter_scorefxn_name( tag->getOption<
string >(
"prefilter_scorefxn" ) );
360 string const centroid_filter_name( tag->getOption<
string >(
"centroid_filter",
"true_filter" ) );
361 Filters_map::const_iterator find_cenfilter( filters.find( centroid_filter_name ) );
362 if( find_cenfilter == filters.end() )
363 utility_exit_with_message(
"Filter " + centroid_filter_name +
" not found in LoopHashMoverWrapper" );
368 if (tag->hasOption(
"relax_mover" )) {
369 string const relax_mover_name( tag->getOption<
string >(
"relax_mover" ) );
370 Movers_map::const_iterator find_mover( movers.find( relax_mover_name ) );
371 bool const mover_found( find_mover != movers.end() );
373 relax_mover( dynamic_cast< protocols::relax::FastRelax* > (find_mover->second()) );
375 utility_exit_with_message(
"Mover " + relax_mover_name +
" not found in LoopHashMoverWrapper" );
388 string const fullatom_filter_name( tag->getOption<
string >(
"fullatom_filter",
"true_filter" ) );
389 Filters_map::const_iterator find_fafilter( filters.find( fullatom_filter_name ) );
390 if( find_fafilter == filters.end() )
391 utility_exit_with_message(
"Filter " + fullatom_filter_name +
" not found in LoopHashMoverWrapper" );
395 if (tag->hasOption(
"batch_size" ) ) TR <<
"Ignoring option batch_size" << std::endl;
396 if (tag->hasOption(
"nfullatom" ) ) TR <<
"Ignoring option nfullatom" << std::endl;
397 if (tag->hasOption(
"fullatom_filter" ) ) TR <<
"Ignoring option fullatom_filter" << std::endl;