22 #include <basic/Tracer.hh>
26 #include <utility/string_util.hh>
28 #include <basic/options/option.hh>
29 #include <basic/options/keys/lh.OptionKeys.gen.hh>
31 #include <utility/vector1.hh>
33 #include <numeric/random/random.hh>
34 #include <numeric/random/random_permutation.hh>
37 #if defined(WIN32) || defined(__CYGWIN__)
49 static basic::Tracer
TR(
"LocalHashSampler");
60 max_bbrms_ ( 100000.0 ),
64 max_struct_per_radius_ (10),
75 using namespace basic::options;
76 using namespace basic::options::OptionKeys;
105 sample_weight_input_parameters =
utility::split(sample_weight_str);
110 if( res_count < sample_weight_input_parameters.size() ){
111 new_sample_weight = utility::string2float( sample_weight_input_parameters[res_count] );
113 sample_weight.push_back( new_sample_weight );
116 return sample_weight;
123 const std::vector< core::Real > &
phi,
124 const std::vector< core::Real > &
psi,
129 runtime_assert( phi.size() == psi.size() )
138 for(
core::Size bs_position = 0; bs_position < phi.size() ; ++bs_position ){
139 int sequence_position = ir - 1 + bs_position;
142 if( sequence[sequence_position] ==
'P' ) {
143 if( phi[bs_position] < -103 || phi[bs_position] > -33 ) filter_pro =
true;
146 if( sequence[sequence_position] ==
'I' || sequence[sequence_position] ==
'V' || sequence[sequence_position] ==
'T' ) {
147 if( phi[bs_position] > -40 ) filter_beta =
true;
151 if( sequence[sequence_position] !=
'G' ) {
152 if( phi[bs_position] > 70 ) filter_gly =
true;
154 if( sequence[sequence_position] !=
'G' ) {
155 if( psi[bs_position] < -75 && psi[bs_position] > -170 ) filter_gly =
true;
160 return !( filter_pro || filter_beta || filter_gly );
183 std::vector< core::io::silent::SilentStructOP > &lib_structs
186 using namespace core;
187 using namespace core::pose;
188 using namespace conformation;
189 using namespace kinematics;
190 using namespace numeric::geometry::hashing;
191 using namespace optimization;
193 using namespace basic::options;
194 using namespace basic::options::OptionKeys;
198 long starttime = time(NULL);
201 Size count_filter_rejects = 0;
202 Size count_total_loops = 0;
203 Size count_loop_builds = 0;
204 Size count_filter_pro = 0;
205 Size count_filter_beta = 0;
206 Size count_filter_gly = 0;
207 Size count_rejected_carms = 0;
208 Size count_rejected_bbrms = 0;
209 Size count_max_rad = 0;
214 core::Size fragments_tried_this_loopsize_max = models_build_this_loopsize_max * 200;
215 TR <<
"LoopHashSampler limits: " <<
max_struct_ <<
" " << models_build_this_loopsize_max <<
" " << models_build_this_loopsize_per_rad_max <<
" " << fragments_tried_this_loopsize_max << std::endl;
234 if ( stop_res == 0 ) stop_res = nres;
235 start_res = std::max( start_res, (
core::Size)2 );
237 if( start_res > stop_res ) stop_res = start_res;
239 TR <<
"Running: Start:" << start_res <<
" End: " << stop_res << std::endl;
240 for( ir = start_res; ir <= stop_res; ir ++ ){
247 if ( ir > nres )
continue;
248 if ( jr > nres )
continue;
253 Real6 loop_transform;
269 count_max_rad = std::max( count_max_rad, radius );
270 core::Size models_build_this_loopsize_this_rad = 0;
271 std::vector < core::Size > leap_index_bucket;
272 std::vector < FilterBucket > filter_leap_index_bucket;
274 hashmap.
radial_lookup( radius, loop_transform, leap_index_bucket );
275 TR.Debug <<
"Rad: " << radius <<
" " << leap_index_bucket.size() << std::endl;
276 if( leap_index_bucket.size() == 0)
continue;
280 for( std::vector < core::Size >::const_iterator it = leap_index_bucket.begin();
281 it != leap_index_bucket.end();
296 count_rejected_bbrms ++;
303 bucket.
BBrms = BBrms;
315 filter_leap_index_bucket.push_back( bucket );
317 count_filter_rejects++;
321 fragments_tried_this_loopsize++;
322 if( fragments_tried_this_loopsize > fragments_tried_this_loopsize_max )
break;
327 numeric::random::random_permutation(filter_leap_index_bucket.begin(), filter_leap_index_bucket.end(),
numeric::random::RG);
330 for( std::vector < FilterBucket >::const_iterator it = filter_leap_index_bucket.begin();
331 it != filter_leap_index_bucket.end();
334 clock_t starttime = clock();
336 core::Size retrieve_index = it->retrieve_index;
345 core::Real final_rms =
inserter_->make_local_bb_change( newpose, original_pose, new_bs, ir );
359 new_struct->fill_struct( mynewpose );
360 new_struct->energies_from_pose( newpose );
361 new_struct->add_energy(
"lh_carms", final_rms );
362 new_struct->add_energy(
"lh_bbrms", it->BBrms );
363 new_struct->add_energy(
"lh_radius", radius );
364 new_struct->add_energy(
"lh_loopsize", loop_size );
365 new_struct->add_energy(
"lh_filter_pro", it->filter_pro );
366 new_struct->add_energy(
"lh_filter_beta", it->filter_beta );
367 new_struct->add_energy(
"lh_filter_gly", it->filter_gly );
377 std::string donorhistory = new_struct->get_comment(
"donorhistory");
379 std::cerr <<
"ERROR: No extra data ?: " <<
library_->backbone_database().extra_size() <<
" < " << bb.
extra_key << std::endl;
381 donorhistory = donorhistory
382 + utility::to_string( loop_size )
383 +
"/" + utility::to_string(
library_->loopdb_range().first + cp.
index )
384 +
"/" + utility::to_string( cp.
offset/3 )
385 +
"/" + utility::to_string( ir-1 ) +
";";
390 donorhistory = donorhistory
391 + utility::to_string( loop_size )
392 +
"/" + utility::to_string( bbextra.
pdb_id)
394 +
"/" + utility::to_string(
library_->loopdb_range().first + cp.
index )
395 +
"/" + utility::to_string( cp.
offset/3 )
396 +
"/" + utility::to_string( ir-1 ) +
";";
398 new_struct->erase_comment(
"donorhistory" );
399 new_struct->add_comment(
"donorhistory", donorhistory );
400 lib_structs.push_back( new_struct );
402 models_build_this_loopsize++;
403 models_build_this_loopsize_this_rad++;
408 count_rejected_carms ++;
413 clock_t endtime = clock();
415 TR.Debug <<
"Clocks: " << endtime - starttime <<
" " << final_rms << (isok ?
" OK" :
" Reject") << std::endl;
417 if( models_build_this_loopsize >= models_build_this_loopsize_max )
break;
418 if( models_build_this_loopsize_this_rad >= models_build_this_loopsize_per_rad_max )
break;
422 if( models_build_this_loopsize >= models_build_this_loopsize_max )
break;
423 if( fragments_tried_this_loopsize >= fragments_tried_this_loopsize_max)
break;
426 TR.Debug <<
" IR: " << ir <<
" LS: " << loop_size
427 <<
" Frag: " << fragments_tried_this_loopsize <<
" ( " << fragments_tried_this_loopsize_max <<
" ) "
428 <<
" Modls: " << models_build_this_loopsize <<
" ( " << models_build_this_loopsize_max <<
" ) "
437 long endtime = time(NULL);
438 TR.Info <<
"LHS: " << start_res <<
"-" << stop_res <<
": "
439 <<
" struc " << lib_structs.size()
441 <<
" secs " << endtime - starttime <<
" secs "
442 <<
" Total: " << count_total_loops
443 <<
" RjTor: " << count_filter_rejects
444 <<
" RjPro: " << count_filter_pro
445 <<
" RjBeta: " << count_filter_beta
446 <<
" RjGly: " << count_filter_gly
448 <<
" RjBB: " << count_rejected_bbrms
449 <<
" Built: " << count_loop_builds
450 <<
" MaxRad: " << count_max_rad
454 for( std::vector< core::io::silent::SilentStructOP >::iterator it=lib_structs.begin();
455 it != lib_structs.end(); ++it ){
456 TR.Debug <<
"Samples: " << (*it)->get_energy(
"censcore") << std::endl;
468 std::vector< core::pose::Pose> &,