33 #include <basic/options/option.hh>
41 #include <basic/Tracer.hh>
43 #include <utility/exit.hh>
44 #include <utility/string_util.hh>
45 #include <utility/tag/Tag.hh>
48 #include <basic/options/keys/out.OptionKeys.gen.hh>
49 #include <basic/options/keys/score.OptionKeys.gen.hh>
50 #include <basic/options/keys/ms.OptionKeys.gen.hh>
51 #include <basic/options/keys/packing.OptionKeys.gen.hh>
54 #include <utility/vector0.hh>
55 #include <utility/vector1.hh>
56 #include <ObjexxFCL/format.hh>
63 using utility::string_split;
65 using namespace chemical;
66 using namespace basic::options;
69 using namespace operation;
70 using namespace scoring;
72 using namespace ObjexxFCL::fmt;
74 using namespace multistate_design;
75 using namespace genetic_algorithm;
81 static basic::Tracer
TR(
"protocols.dna.DnaInterfaceMultiStateDesign",t_info);
97 return "DnaInterfaceMultiStateDesign";
103 multistate_packer_(0),
107 generations_( option[ OptionKeys::ms::generations ]() ),
108 pop_size_( option[ OptionKeys::ms::pop_size ]() ),
109 num_packs_( option[ OptionKeys::ms::num_packs ]() ),
110 pop_from_ss_( option[ OptionKeys::ms::pop_from_ss ]() ),
111 numresults_( option[ OptionKeys::ms::numresults ]() ),
112 fraction_by_recombination_( option[ OptionKeys::ms::fraction_by_recombination ]() ),
113 mutate_rate_( option[ OptionKeys::ms::mutate_rate ]() ),
114 boltz_temp_( option[ OptionKeys::ms::Boltz_temp ]() ),
115 anchor_offset_( option[ OptionKeys::ms::anchor_offset ]() ),
116 checkpoint_prefix_( option[ OptionKeys::ms::checkpoint::prefix ]() ),
117 checkpoint_interval_( option[ OptionKeys::ms::checkpoint::interval ]() ),
118 checkpoint_gz_( option[ OptionKeys::ms::checkpoint::gz ]() ),
119 checkpoint_rename_( option[ OptionKeys::ms::checkpoint::rename ]() )
135 runtime_assert( dna_chains );
158 if ( option[ OptionKeys::score::weights ].user() )
159 weights_tag = option[ OptionKeys::score::weights ]();
183 if ( option[ OptionKeys::packing::resfile ].user() ) my_tf->push_back(
new ReadResfile );
187 my_tf->push_back( rest_to_dna_int );
201 for (
Size i(1),
end( ptask->total_residue() ); i <=
end; ++i ) {
205 if ( rtask.being_designed() ) {
206 design_positions.push_back(i);
210 std::set< core::chemical::AA > aaset;
211 std::list< ResidueTypeCOP >
const & allowed( rtask.allowed_residue_types() );
212 for ( std::list< ResidueTypeCOP >::const_iterator
t( allowed.begin() ),
end( allowed.end() );
216 if ( aaset.find( aa ) != aaset.end() )
continue;
218 TR(t_debug) <<
"adding choice " << aa << std::endl;
219 choices.push_back(
new PosType( i, aa ) );
221 rand->append_choices( choices );
226 TR(t_info) <<
"There will be " << rand->library_size() <<
" possible sequences." << std::endl;
239 TR(t_info) <<
"There are " <<
multistate_packer_->num_positive_states() <<
" positive states and "
258 TR(t_info) <<
"Adding single-state design entities:" << std::endl;
259 for ( SingleStateCOPs::const_iterator s( states.begin() ),
end( states.end() );
263 end( design_positions.end() ); i !=
end; ++i ) {
265 traits.push_back( pt );
266 TR(t_info) << pt->to_string() <<
" ";
269 gen_alg_->add_parent_entity( traits );
270 TR(t_info) << std::endl;
276 gen_alg_->fill_with_random_entities();
287 if (
gen_alg_->current_generation_complete() )
gen_alg_->evolve_next_generation();
288 TR(t_info) <<
"Generation " <<
gen_alg_->current_generation() <<
":" << std::endl;
299 pdboutput->reference_pose( pose );
302 if ( option[ OptionKeys::out::prefix ].user() ) prefix = option[ OptionKeys::out::prefix ]();
306 TraitEntityHashMap
const & cache(
gen_alg_->entity_cache() );
309 for ( TraitEntityHashMap::const_iterator it( cache.begin() ),
end( cache.end() );
311 sortable.push_back( it->second );
313 std::sort( sortable.begin(), sortable.end(), lt_OP_deref< Entity > );
315 TR(t_info) <<
"Evaluated " << sortable.size() <<
" sequences.\nBest sequences:\n";
320 end( sortable.end() ); it !=
end; ++it ) {
327 std::string pdbname( prefix +
"_ms_" + ObjexxFCL::lead_zero_string_of(counter,4) +
".pdb" );
329 std::ostringstream ms_info;
330 ms_info <<
"REMARK MultiState Fitness: " << F(5,4,entity.
fitness());
331 extra_lines.push_back( ms_info.str() );
333 ms_info <<
"REMARK MultiState Sequence:";
334 for ( EntityElements::const_iterator
336 pos !=
end; ++pos ) {
337 ms_info <<
" " << (*pos)->to_string();
338 TR(t_info) << (*pos)->to_string() <<
" ";
340 TR(t_info) <<
"fitness " << F(5,4,entity.
fitness()) <<
'\n';
341 extra_lines.push_back( ms_info.str() );
342 if ( counter == 0 ) {
344 pose = solution_pose;
346 info().insert(
info().
end(), extra_lines.begin(), extra_lines.end() );
352 pdboutput->add_info(
"multistate_design", extra_lines,
false );
353 (*pdboutput)( solution_pose, pdbname );
356 TR(t_info) << std::endl;
374 if ( tag->hasOption(
"generations") )
generations_ = tag->getOption<
Size>(
"generations");
375 if ( tag->hasOption(
"pop_size") )
pop_size_ = tag->getOption<
Size>(
"pop_size");
376 if ( tag->hasOption(
"num_packs") )
num_packs_ = tag->getOption<
Size>(
"num_packs");
377 if ( tag->hasOption(
"pop_from_ss") )
pop_from_ss_ = tag->getOption<
Size>(
"pop_from_ss");
378 if ( tag->hasOption(
"numresults") )
numresults_ = tag->getOption<
Size>(
"numresults");
379 if ( tag->hasOption(
"fraction_by_recombination") )
381 if ( tag->hasOption(
"mutate_rate") )
mutate_rate_ = tag->getOption<
Real>(
"mutate_rate");
382 if ( tag->hasOption(
"boltz_temp") )
boltz_temp_ = tag->getOption<
Real>(
"boltz_temp");
383 if ( tag->hasOption(
"anchor_offset") )
anchor_offset_ = tag->getOption<
Real>(
"anchor_offset");
385 if ( tag->hasOption(
"checkpoint_prefix") )
387 if ( tag->hasOption(
"checkpoint_interval") )
389 if ( tag->hasOption(
"checkpoint_gz") )
checkpoint_gz_ = tag->getOption<
bool>(
"checkpoint_gz");
390 if ( tag->hasOption(
"checkpoint_rename") )
422 Pose mutpose( pose );
428 TR(t_info) <<
"\nBuilding dna target state:\n";
431 for ( DnaPositions::const_iterator itr(
dna_chains_->begin() );
436 runtime_assert( index == itr->first );
438 if ( !ptask->has_behavior(
"TARGET",index) )
continue;
440 std::ostringstream pdbtag;
442 pdbtag << pose.
pdb_info()->chain(index) <<
'.' << pose.
pdb_info()->number(index);
444 pdbtag << pose.
chain(index) <<
'.' << index;
446 ResidueTypeCOP target_type( ptask->residue_task( index ).target_type() );
447 if ( ! target_type ) {
448 TR(t_error) <<
"No target type found for " << pdbtag.str() <<
'\n'
449 <<
"(Did the DNA definition string indicate a target nucleotide type?" << std::endl;
452 runtime_assert( pos.
paired() );
453 std::ostringstream pdbtag_btm;
461 if ( ! target_type ) {
462 TR(t_error) <<
"No target type found for " << pdbtag_btm.str() <<
'\n'
463 <<
"(Did the DNA definition string indicate a target nucleotide type?" << std::endl;
466 TR(t_info) << pdbtag.str() <<
'.' << target_type->name() <<
'/';
467 TR(t_info) << pdbtag_btm.str() <<
'.' << bot_type->name() <<
", ";
476 TR(t_info) <<
"Building dna sequence competitors:\n";
479 for ( DnaPositions::const_iterator itr(
dna_chains_->begin() );
484 assert( index == itr->first );
485 if ( !ptask->has_behavior(
"TARGET",index) )
continue;
487 TR(t_info) << pose.
pdb_info()->number( index ) <<
"/"
490 TR(t_info) << index <<
"/" << pos.
bottom() <<
":";
498 for ( ResidueTypeCOPs::const_iterator rt( dna_types.begin() ); rt != dna_types.end(); ++rt ) {
500 if ( (*rt)->name3() == orig_top.name3() )
continue;
502 TR(t_info) <<
" " <<
name <<
"/" << bot_type.name() <<
",";
506 competitor_state->share_packer_data_from( *target_state );
514 TR(t_info) << std::endl;