49 #include <basic/Tracer.hh>
56 #include <utility/string_util.hh>
57 #include <utility/tag/Tag.hh>
58 #include <utility/vector1.hh>
66 #include <utility/vector0.hh>
67 #include <utility/io/ozstream.hh>
68 #include <utility/file/file_sys_util.hh>
69 #include <ObjexxFCL/format.hh>
70 #include <basic/options/keys/OptionKeys.hh>
72 #include <boost/assign/list_inserter.hpp>
73 #include <boost/assign/list_of.hpp>
74 #include <boost/foreach.hpp>
75 #include <boost/lexical_cast.hpp>
77 using namespace basic::options;
78 using namespace basic::options::OptionKeys;
81 static basic::Tracer
TR(
"protocols.flxbb.LayerDesignOperation");
87 LayerDesignOperationCreator::create_task_operation()
const
92 CombinedTaskOperation::CombinedTaskOperation(
VecTaskOP ops ):
93 task_operations_( ops )
100 t_op->apply( pose, task );
107 add_helix_capping_( true ),
108 use_original_( true ),
109 repack_non_designed_residues_( true ),
111 restrict_restypes_( true ),
112 make_pymol_script_( false ),
113 srbl_( new toolbox::SelectResiduesByLayer )
121 add_helix_capping_( true ),
122 use_original_( true ),
123 repack_non_designed_residues_( true ),
125 restrict_restypes_( true ),
126 make_pymol_script_( false ),
127 srbl_( new toolbox::SelectResiduesByLayer )
147 srbl_->set_design_layer( dsgn_core, dsgn_boundary, dsgn_surface );
154 srbl_->sasa_surface( r, ss );
161 srbl_->sasa_core( r, ss );
168 srbl_->pore_radius( ps );
178 str = boost::lexical_cast<
std::string >( pos[1] );
179 for(
Size i = 2; i <= pos.size(); i++)
180 str +=
"+" + boost::lexical_cast< std::string >( pos[i] );
187 using utility::io::ozstream;
189 typedef std::map< std::string, utility::vector1<bool> > LayerSpecification;
190 TR <<
"Writing pymol script with the layer information to "<< filename << std::endl;
191 ozstream pymol( filename );
192 TR <<
"Dumping pose for the script as layer_design_input.pdb" << std::endl;
193 pose.
dump_pdb(
"layer_design_input.pdb");
196 pymol <<
"from pymol import cmd" << std::endl;
198 pymol <<
"cmd.load('layer_design_input.pdb')" << std::endl;
199 pymol <<
"cmd.hide('all') " << std::endl;
200 pymol <<
"cmd.show('spheres')" << std::endl;
202 VecSize core_residues = srbl->selected_core_residues();
203 pymol <<
"cmd.select('core', 'resi " <<
pos2select( core_residues )<<
"')" << std::endl;
204 pymol <<
"cmd.color('red', 'core')" << std::endl;
205 VecSize boundary_residues = srbl->selected_boundary_residues();
206 pymol <<
"cmd.select('boundary', 'resi " <<
pos2select( boundary_residues )<<
"')" << std::endl;
207 pymol <<
"cmd.color('orange', 'boundary')" << std::endl;
208 VecSize surface_residues = srbl->selected_surface_residues();
209 pymol <<
"cmd.select('surface', 'resi " <<
pos2select( surface_residues ) <<
"')" << std::endl;
210 pymol <<
"cmd.color('yellow', 'surface')" << std::endl;
213 colors.push_back(
"green" );
214 colors.push_back(
"magenta" );
215 colors.push_back(
"cyan" );
216 colors.push_back(
"purpleblue" );
217 colors.push_back(
"hotpink" );
218 colors.push_back(
"olive" );
220 for(LayerSpecification::const_iterator it = layer_specification.begin(); it != layer_specification.end(); it++){
225 pymol <<
"cmd.select('"<< it->first <<
"', 'resi " <<
pos2select( pos )<<
"')" << std::endl;
226 pymol <<
"cmd.color('" << colors[ layer % 6 ] <<
"','" << it->first <<
"')" << std::endl;
230 pymol <<
"cmd.select('ligand', 'organic')" << std::endl;
231 pymol <<
"cmd.show('sticks','ligand')" << std::endl;
232 pymol <<
"cmd.color('gray','ligand')" << std::endl;
239 TR <<
"Initializing the layers with the default residues" << std::endl;
241 (
"core", boost::assign::map_list_of
242 (
"all",
"AFILPVWYDNST")
246 (
"HelixStart",
"AFILVWYP")
247 (
"HelixCapping",
"DNST")
249 (
"boundary", boost::assign::map_list_of
250 (
"all",
"ADEFGIKLNPQRSTVWY")
251 (
"Loop",
"ADEFGIKLNPQRSTVWY")
252 (
"Strand",
"DEFIKLNQRSTVWY")
253 (
"Helix",
"ADEIKLNQRSTVWY")
254 (
"HelixStart",
"ADEIKLNQRSTVWYP")
255 (
"HelixCapping",
"DNST")
257 (
"surface", boost::assign::map_list_of
258 (
"all",
"DEGHKNPQRST")
259 (
"Loop",
"DEGHKNPQRST")
260 (
"Strand",
"DEHKNQRST")
261 (
"Helix",
"DEHKNQRST")
262 (
"HelixStart",
"DEHKNQRSTP")
263 (
"HelixCapping",
"DNST")
277 BOOST_FOREACH(
char restype,
layer_residues_.find(layer)->second.find(ss_type)->second) {
280 return restrict_to_aa;
288 typedef std::map< std::string, utility::vector1<bool> > LayerSpecification;
293 LayerSpecification layer_specification;
294 BOOST_FOREACH(
const TaskLayers::value_type& task_pair,
task_layers_) {
295 TR <<
"Residues for task layer " << task_pair.first <<
": " <<std::endl;
297 task_pair.second->apply(input_pose, layer_task);
299 for(
Size i = 1; i <= designable_residues.size(); i++)
300 if( designable_residues[i] )
301 TR <<
"\t- residue " << i <<
" is designable" << std::endl;
302 layer_specification[ task_pair.first ] = designable_residues;
307 TR <<
"Symmetry detected, extracting asymmetric unit." << std::endl;
319 bool has_ligand =
false;
320 TR <<
"secstruct is:" << secstruct << std::endl;
321 for(
Size i=1; i <= ligands.size(); i++) {
322 TR <<
"adding an L to the secstruct string due to unknown AA" << std::endl;
326 srbl_->compute( pose, secstruct );
330 TR <<
"writing pymol script with the layer specification and saving it as layers.py" << std::endl;
342 if( ss ==
'H' && flag ==
false && i != 1 ) {
343 initial_helix[ i ] =
true;
344 helix_capping[ i-1 ] =
true;
347 if( ss !=
'H' && flag ==
true ) {
357 TR <<
"---------------------------------------" << std::endl;
366 BOOST_FOREACH(
const LayerSpecification::value_type& layer_pair, layer_specification) {
367 if( (layer_pair.second)[i] ==
true)
368 active_layers.push_back( layer_pair.first );
372 TR <<
"Residue " << i << std::endl;
373 TR <<
" ss=" << ss <<
" "
374 <<
" Sasa=" << ObjexxFCL::fmt::F( 6, 2,
srbl_->rsd_sasa( i ) ) << std::endl;
375 TR <<
" basic layer = " << srbl_layer << std::endl;
380 if(
design_layer_.find(srbl_layer)->second || !active_layers.empty() ) {
381 if( active_layers.empty() )
382 active_layers.push_back( srbl_layer );
386 TR <<
" restricting aminoacid to repacking" << std::endl;
390 TR <<
" prenventing aminoacid from repacking" << std::endl;
393 TR <<
" Active layers: ";
397 if(active_layers.empty())
398 TR <<
"none" << std::endl;
401 TR <<
"---------------------------------------" << std::endl;
406 if( resfile_cmd.find(
"PIKAA" ) != std::string::npos || resfile_cmd.find(
"NATRO" ) != std::string::npos ){
408 TR <<
" ,Resfile info is used. (" << resfile_cmd <<
")"<< std::endl;
417 }
else if( initial_helix[i] ) {
420 }
else if( ss ==
'E') {
423 }
else if( ss ==
'L') {
426 }
else if( ss ==
'H') {
438 typedef std::pair< std::string, bool > DesignLayerPair;
440 use_original_ = tag->getOption<
bool >(
"use_original_non_designed_layer", 1 );
442 String design_layers = tag->getOption<
String >(
"layer",
"core_boundary_surface" );
443 if (design_layers ==
"all")
444 design_layers =
"core_boundary_surface";
445 if (design_layers ==
"other" || design_layers ==
"user")
454 srbl_->set_design_layer(
true,
true,
true);
456 if( tag->hasOption(
"pore_radius" ) ) {
457 srbl_->pore_radius( tag->getOption<
Real >(
"pore_radius" ) );
460 if( tag->hasOption(
"core" ) ) {
461 srbl_->sasa_core( tag->getOption<
Real >(
"core" ) );
463 if( tag->hasOption(
"surface" ) ) {
464 srbl_->sasa_surface( tag->getOption<
Real >(
"surface" ) );
467 if( tag->hasOption(
"core_E" ) ) {
468 srbl_->sasa_core( tag->getOption<
Real >(
"core_E" ),
"E" );
470 if( tag->hasOption(
"core_L" ) ) {
471 srbl_->sasa_core( tag->getOption<
Real >(
"core_L" ),
"L" );
473 if( tag->hasOption(
"core_H" ) ) {
474 srbl_->sasa_core( tag->getOption<
Real >(
"core_H" ),
"H" );
477 if( tag->hasOption(
"surface_E" ) ) {
478 srbl_->sasa_surface( tag->getOption<
Real >(
"surface_E" ),
"E" );
480 if( tag->hasOption(
"surface_L" ) ) {
481 srbl_->sasa_surface( tag->getOption<
Real >(
"surface_L" ),
"L" );
483 if( tag->hasOption(
"surface_H" ) ) {
484 srbl_->sasa_surface( tag->getOption<
Real >(
"surface_H" ),
"H" );
487 if( tag->hasOption(
"make_rasmol_script" ) ) {
488 srbl_->make_rasmol_format_file( tag->getOption<
bool >(
"make_rasmol_script" ) );
491 set_verbose( tag->getOption<
bool >(
"verbose",
false ) );
498 if( layer ==
"core" || layer ==
"boundary" || layer ==
"surface" ||
task_layers_.count( layer ) ) {
499 TR <<
"Modifying specification for layer " << layer << std::endl;
500 }
else if(layer ==
"CombinedTasks" ) {
502 TR <<
"Making a combined task named "<< comb_name << std::endl;
507 task_ops.push_back( task );
517 TR <<
"Defining new layer from task type "<< layer <<
" named " << task_name << std::endl;
526 utility_exit_with_message(
"Invalid layer " + layer +
", valid layers are core, boundary, surface, TaskOperations or CombinedTasks" );
531 if( secstruct ==
"all" && secstruct_tag->hasOption(
"copy_layer") ) {
533 TR <<
"Copying definitions from layer " << layer_to_copy <<
" to layer " << layer << std::endl;
537 if( secstruct ==
"all" && secstruct_tag->hasOption(
"append") ) {
540 TR <<
"Appending residues " << aas <<
" to layer " << lrs->first << std::endl;
541 for(LayerDefinitions::iterator ld = lrs->second.begin(); ld != lrs->second.end(); ld++) {
542 std::set<char> temp_def_res_set( ld->second.begin(), ld->second.end());
543 temp_def_res_set.insert( aas.begin(), aas.end() );
548 if( secstruct ==
"all" && secstruct_tag->hasOption(
"exclude") ) {
551 TR <<
"Excluding residues " << aas <<
" from layer " << lrs->first << std::endl;
552 for(LayerDefinitions::iterator ld = lrs->second.begin(); ld != lrs->second.end(); ld++) {
553 std::set<char> temp_def_res_set( ld->second.begin(), ld->second.end());
554 BOOST_FOREACH(
char aa, aas)
555 temp_def_res_set.erase(aa);
560 if( secstruct_tag->hasOption(
"aa") ) {
562 TR <<
"Setting layer residues for " << layer <<
" "<< secstruct <<
" to " << aas << std::endl;
566 if( secstruct_tag->hasOption(
"append") ) {
568 TR <<
"Appending residues "<< aas <<
" to layer " << layer <<
" "<< secstruct << std::endl;
570 std::set<char> temp_def_res_set( layer_res.begin(), layer_res.end());
571 temp_def_res_set.insert( aas.begin(), aas.end() );
575 if( secstruct_tag->hasOption(
"exclude") ) {
577 TR <<
"Excluding residues "<< aas <<
" to layer " << layer <<
" "<< secstruct << std::endl;
579 std::set<char> temp_def_res_set( layer_res.begin(), layer_res.end());
580 BOOST_FOREACH(
char aa, aas)
581 temp_def_res_set.erase(aa);
588 std::set< std::string > ss_def_names;
589 LayerResidues::const_iterator default_layer_it =
layer_residues_.find(
"core");
590 BOOST_FOREACH(
LayerDefinition const & layer_def, default_layer_it->second )
591 ss_def_names.insert( layer_def.first );
592 ss_def_names.erase(
"all");
597 BOOST_FOREACH(
std::string const & ss_def_name, ss_def_names){
598 LayerDefinitions::iterator ld_it =
layer_residues_[ task_layer.first ].find( ss_def_name );
600 TR <<
"layer " << task_layer.first <<
" has no specification for residues in " << ss_def_name <<
", the layer will be filled with the residues defined for all secondary structure types." << std::endl;
601 layer_residues_[ task_layer.first ][ ss_def_name ] = all_layers_residues;
607 TR <<
"Layers to be designed:";
610 TR <<
"\t" << l_p.first;
616 TR <<
"Layer " << layer.first << std::endl;
618 TR <<
"\t" << ObjexxFCL::fmt::LJ(15,layer_def.first) <<
"aa = " << layer_def.second << std::endl;