Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LayerDesignOperation.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/flxbb/LayerDesignOperation.cc
11 /// @brief Design residues with selected amino acids depending on the enviroment: layer.
12 /// The layer of each residue is assigned as core, boundary, or surface, which are defined by
13 /// accessible surface of mainchain + CB. If resfile is read before calling this operation,
14 /// this operation is not applied for the residues defined by PIKAA.
15 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
16 /// @modified Javier Castellanos (javiercv@uw.edu )
17 
18 // The following are using amino acids for each layer
19 /// @CORE
20 // Loop: AFILPVWY
21 // Strand: FIL VWY
22 // Helix: AFIL VWY ( P only at the beginning of helix )
23 // HelixCapping: DNST
24 //
25 /// @BOUNDARY
26 // Loop: ADEFGIKLNPQRSTVWY
27 // Strand: DEF IKLN QRSTVWY
28 // Helix: ADE IKLN QRSTVWY ( P only at the beginning of helix )
29 // HelixCapping: DNST
30 //
31 /// @SURFACE
32 // Loop: DEGHKNPQRST
33 // Strand: DE HKN QRST
34 // Helix: DE HKN QRST ( P only at the beginning of helix )
35 // HelixCapping: DNST
36 
37 
38 // Unit Headers
41 
42 // Project Headers
43 #include <core/pose/Pose.hh>
49 #include <basic/Tracer.hh>
53 
54 // Utility Headers
56 #include <utility/string_util.hh>
57 #include <utility/tag/Tag.hh>
58 #include <utility/vector1.hh>
59 #include <string>
60 
61 using basic::T;
62 using basic::Error;
63 using basic::Warning;
64 
65 
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>
71 
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>
76 
77 using namespace basic::options;
78 using namespace basic::options::OptionKeys;
79 using namespace core;
80 
81 static basic::Tracer TR("protocols.flxbb.LayerDesignOperation");
82 
83 namespace protocols {
84 namespace flxbb {
85 
87 LayerDesignOperationCreator::create_task_operation() const
88 {
89  return new LayerDesignOperation;
90 }
91 
92 CombinedTaskOperation::CombinedTaskOperation( VecTaskOP ops ):
93  task_operations_( ops )
94 { }
95 
96 void
99  BOOST_FOREACH( TaskOperationOP t_op, task_operations_ )
100  t_op->apply( pose, task );
101 }
102 
103 
104 /// @brief default constructor
106  TaskOperation(),
107  add_helix_capping_( true ),
108  use_original_( true ),
109  repack_non_designed_residues_( true ),
110  verbose_( false ),
111  restrict_restypes_( true ),
112  make_pymol_script_( false ),
113  srbl_( new toolbox::SelectResiduesByLayer )
114 {
116 }
117 
118 /// @brief value constructor
119 LayerDesignOperation::LayerDesignOperation( bool dsgn_core, bool dsgn_boundary, bool dsgn_surface ):
120  TaskOperation(),
121  add_helix_capping_( true ),
122  use_original_( true ),
123  repack_non_designed_residues_( true ),
124  verbose_( false ),
125  restrict_restypes_( true ),
126  make_pymol_script_( false ),
127  srbl_( new toolbox::SelectResiduesByLayer )
128 {
129  design_layer( dsgn_core, dsgn_boundary, dsgn_surface );
131 }
132 
133 /// @brief destructor
135 }
136 
137 /// @brief clone
140  return new LayerDesignOperation( *this );
141 }
142 
143 /// @brief layer to be designed
144 void
145 LayerDesignOperation::design_layer( bool const dsgn_core, bool const dsgn_boundary, bool const dsgn_surface )
146 {
147  srbl_->set_design_layer( dsgn_core, dsgn_boundary, dsgn_surface );
148 }
149 
150 /// @brief accessible surface for evaluating residues are in surface or not
151 void
153 {
154  srbl_->sasa_surface( r, ss );
155 }
156 
157 /// @brief accessible surface for evaluating residues are in core or not
158 void
160 {
161  srbl_->sasa_core( r, ss );
162 }
163 
164 /// @brief set pore radius for colculating asa
165 void
167 {
168  srbl_->pore_radius( ps );
169 }
170 
173 {
175  if( pos.empty() )
176  return str;
177  else
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] );
181  return str;
182 }
183 
184 void
185 LayerDesignOperation::write_pymol_script( core::pose::Pose const & pose, toolbox::SelectResiduesByLayerOP srbl, std::map< std::string, utility::vector1<bool> > const & layer_specification, bool has_ligand, std::string const & filename ) const
186 {
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");
194 
195  // importing necessary pymol modules
196  pymol << "from pymol import cmd" << std::endl;
197  //load strucuture into pymol
198  pymol << "cmd.load('layer_design_input.pdb')" << std::endl;
199  pymol << "cmd.hide('all') " << std::endl;
200  pymol << "cmd.show('spheres')" << std::endl;
201  // make the selections for the basic layers
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;
211  // make the selections for the task layers
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" );
219  Size layer = 0;
220  for(LayerSpecification::const_iterator it = layer_specification.begin(); it != layer_specification.end(); it++){
222  for(Size i = 1; i <= pose.total_residue(); i++)
223  if( it->second[ i ])
224  pos.push_back( i );
225  pymol << "cmd.select('"<< it->first <<"', 'resi " << pos2select( pos )<< "')" << std::endl;
226  pymol << "cmd.color('" << colors[ layer % 6 ] << "','" << it->first << "')" << std::endl;
227  layer += 1;
228  }
229  if(has_ligand) {
230  pymol << "cmd.select('ligand', 'organic')" << std::endl;
231  pymol << "cmd.show('sticks','ligand')" << std::endl;
232  pymol << "cmd.color('gray','ligand')" << std::endl;
233  }
234 }
235 
236 
237 void
239  TR << "Initializing the layers with the default residues" << std::endl;
241  ("core", boost::assign::map_list_of
242  ("all", "AFILPVWYDNST")
243  ("Loop", "AFILPVWY")
244  ("Strand", "FILVWY")
245  ("Helix", "AFILVWY")
246  ("HelixStart", "AFILVWYP")
247  ("HelixCapping", "DNST")
248  )
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")
256  )
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")
264  );
265 
267  ("core", false)
268  ("boundary", false)
269  ("surface", false);
270 }
271 
273 LayerDesignOperation::get_restrictions( std::string const & layer, std::string const & default_layer, std::string const & ss_type) const {
274  // if the layer doesn't specify the required ss used the default layer one.
275  std::string used_layer = ( layer_residues_.find(layer)->second.count(ss_type) != 0 ) ? layer : default_layer;
276  utility::vector1<bool> restrict_to_aa( chemical::num_canonical_aas, false );
277  BOOST_FOREACH(char restype, layer_residues_.find(layer)->second.find(ss_type)->second) {
278  restrict_to_aa[chemical::aa_from_oneletter_code( restype )] = true;
279  }
280  return restrict_to_aa;
281 }
282 
283 /// @brief apply
284 void
285 LayerDesignOperation::apply( Pose const & input_pose, PackerTask & task ) const
286 {
288  typedef std::map< std::string, utility::vector1<bool> > LayerSpecification;
289 
290  Pose pose;
291 
292  // find the designable residues for the different task layers
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;
296  PackerTask_ layer_task(input_pose);
297  task_pair.second->apply(input_pose, layer_task);
298  utility::vector1< bool > designable_residues( layer_task.designing_residues() );
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;
303  }
304 
305  // symmetry check
306  if(core::pose::symmetry::is_symmetric( input_pose ) ) {
307  TR << "Symmetry detected, extracting asymmetric unit." << std::endl;
308  core::pose::symmetry::extract_asymmetric_unit( input_pose, pose , false );
309  } else {
310  pose = input_pose;
311  }
312 
313  core::scoring::dssp::Dssp dssp( pose );
314  dssp.dssp_reduced();
315 
316  // we need to add a SS identifier for the ligand if there is one
317  String secstruct = dssp.get_dssp_secstruct();
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;
323  secstruct += 'L';
324  has_ligand = true;
325  }
326  srbl_->compute( pose, secstruct );
327 
328  // make a pymol script for visualizing the layers
329  if( make_pymol_script_ && !utility::file::file_exists( "layers.py" ) ) {
330  TR << "writing pymol script with the layer specification and saving it as layers.py" << std::endl;
331  write_pymol_script(input_pose, srbl_, layer_specification, has_ligand, "layers.py");
332  }
333 
334  // find the position of residues of helix capping and intial residue of helix
335  bool flag( false );
336  utility::vector1< bool > helix_capping( pose.total_residue(), false );
337  utility::vector1< bool > initial_helix( pose.total_residue(), false );
338  for( Size i=1; i<=pose.total_residue(); ++i ) {
339  // if this residue is not a protein residue, we shouldn't process it further
340  if ( ! pose.residue( i ).is_protein() ) continue;
341  char ss( dssp.get_dssp_secstruct( i ) );
342  if( ss == 'H' && flag == false && i != 1 ) {
343  initial_helix[ i ] = true;
344  helix_capping[ i-1 ] = true;
345  flag = true;
346  }
347  if( ss != 'H' && flag == true ) {
348  flag = false;
349  }
350  }
351 
352  // terminal residues set to be all aa
353  utility::vector1<bool> restrict_to_aa( 20, true );
354  task.nonconst_residue_task( 1 ).restrict_absent_canonical_aas( restrict_to_aa );
355  task.nonconst_residue_task( pose.total_residue() ).restrict_absent_canonical_aas( restrict_to_aa );
356 
357  TR << "---------------------------------------" << std::endl;
358  for( Size i=2; i<=pose.total_residue()-1; ++i ) {
359  // if the residue is not a protein, we should continue on to the next one, but make the non-protein residue repackable only
360  if ( ! pose.residue( i ).is_protein() ){ task.nonconst_residue_task( i ).restrict_to_repacking(); continue; }
361 
362  const std::string srbl_layer = srbl_->layer(i);
363  // check if the residue is specified in any of the task defined layer and
364  // append that layer into the active layers
365  utility::vector1< std::string > active_layers;
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 );
369  }
370 
371  char ss( dssp.get_dssp_secstruct( i ) );
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;
376 
377 
378  // If there are no active layers and the working layer is designable
379  // append the working layer
380  if( design_layer_.find(srbl_layer)->second || !active_layers.empty() ) { // srbl_layer is set to be designed
381  if( active_layers.empty() )
382  active_layers.push_back( srbl_layer );
383  } else { // srbl_layer is not set to be designed, the sidechain will be reapcked or left untouched
386  TR << " restricting aminoacid to repacking" << std::endl;
387  }
388  else {
390  TR << " prenventing aminoacid from repacking" << std::endl;
391  }
392  }
393  TR << " Active layers: ";
394  BOOST_FOREACH(std::string s, active_layers){
395  TR << s << " " ;
396  }
397  if(active_layers.empty())
398  TR << "none" << std::endl;
399  else
400  TR << std::endl;
401  TR << "---------------------------------------" << std::endl;
402 
403 
404  // skip the residue if this position is defined as PIKAA, NATRO or NATAA in the resfile
405  const std::string resfile_cmd = task.residue_task( i ).command_string();
406  if( resfile_cmd.find( "PIKAA" ) != std::string::npos || resfile_cmd.find( "NATRO" ) != std::string::npos ){
407  if( verbose_ ) {
408  TR << " ,Resfile info is used. (" << resfile_cmd << ")"<< std::endl;
409  }
410  continue;
411  }
412 
413  BOOST_FOREACH(std::string& layer, active_layers) {
414  if( helix_capping[ i ] == true && add_helix_capping_ ) {
415  task.nonconst_residue_task( i ).restrict_absent_canonical_aas( get_restrictions( layer, srbl_layer, "HelixCapping") );
416 
417  } else if( initial_helix[i] ) {
418  task.nonconst_residue_task( i ).restrict_absent_canonical_aas( get_restrictions( layer, srbl_layer, "HelixStart") );
419 
420  } else if( ss == 'E') {
421  task.nonconst_residue_task( i ).restrict_absent_canonical_aas( get_restrictions( layer, srbl_layer, "Strand") );
422 
423  } else if( ss == 'L') {
424  task.nonconst_residue_task( i ).restrict_absent_canonical_aas( get_restrictions( layer, srbl_layer, "Loop") );
425 
426  } else if( ss == 'H') {
427  task.nonconst_residue_task( i ).restrict_absent_canonical_aas( get_restrictions( layer, srbl_layer, "Helix") );
428 
429  }
430  }
431  } // for( i )
432 } // apply
433 
434 void
436 {
438  typedef std::pair< std::string, bool > DesignLayerPair;
439  protocols::moves::DataMap datamap; // for parsing CombinedTaskOperations
440  use_original_ = tag->getOption< bool >( "use_original_non_designed_layer", 1 );
441 
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")
446  design_layers = "";
447  utility::vector1< String > layers( utility::string_split( design_layers, '_' ) );
448  BOOST_FOREACH(std::string & layer, layers) {
449  design_layer_[ layer ] = true;
450  }
451 
452  repack_non_designed_residues_ = tag->getOption< bool >("repack_non_design", 1);
453 
454  srbl_->set_design_layer( true, true, true);
455 
456  if( tag->hasOption( "pore_radius" ) ) {
457  srbl_->pore_radius( tag->getOption< Real >( "pore_radius" ) );
458  }
459 
460  if( tag->hasOption( "core" ) ) {
461  srbl_->sasa_core( tag->getOption< Real >( "core" ) );
462  }
463  if( tag->hasOption( "surface" ) ) {
464  srbl_->sasa_surface( tag->getOption< Real >( "surface" ) );
465  }
466 
467  if( tag->hasOption( "core_E" ) ) {
468  srbl_->sasa_core( tag->getOption< Real >( "core_E" ), "E" );
469  }
470  if( tag->hasOption( "core_L" ) ) {
471  srbl_->sasa_core( tag->getOption< Real >( "core_L" ), "L" );
472  }
473  if( tag->hasOption( "core_H" ) ) {
474  srbl_->sasa_core( tag->getOption< Real >( "core_H" ), "H" );
475  }
476 
477  if( tag->hasOption( "surface_E" ) ) {
478  srbl_->sasa_surface( tag->getOption< Real >( "surface_E" ), "E" );
479  }
480  if( tag->hasOption( "surface_L" ) ) {
481  srbl_->sasa_surface( tag->getOption< Real >( "surface_L" ), "L" );
482  }
483  if( tag->hasOption( "surface_H" ) ) {
484  srbl_->sasa_surface( tag->getOption< Real >( "surface_H" ), "H" );
485  }
486 
487  if( tag->hasOption( "make_rasmol_script" ) ) {
488  srbl_->make_rasmol_format_file( tag->getOption< bool >( "make_rasmol_script" ) );
489  }
490 
491  set_verbose( tag->getOption< bool >( "verbose", false ) );
492  set_restrict_restypes( tag->getOption< bool >( "restrict_restypes", true ) );
493  make_pymol_script( tag->getOption< bool >("make_pymol_script", false) );
494 
495  BOOST_FOREACH( utility::tag::TagPtr const layer_tag, tag->getTags() ){
496 
497  std::string layer = layer_tag->getName(); // core, residue, boundar orr taskoperation
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" ) {
501  std::string comb_name = layer_tag->getOption< std::string >("name");
502  TR << "Making a combined task named "<< comb_name << std::endl;
504  BOOST_FOREACH( utility::tag::TagPtr const task_tag, layer_tag->getTags() ) {
505  std::string task_op_type = task_tag->getName();
506  TaskOperationOP task = TaskOperationFactory::get_instance()->newTaskOperation(task_op_type, task_tag);
507  task_ops.push_back( task );
508  }
509  CombinedTaskOperationOP comb = new CombinedTaskOperation( task_ops );
510  task_layers_[ comb_name ] = comb;
511  design_layer_[ comb_name ] = true;
512  layer_residues_[ comb_name ] = std::map< std::string, std::string >();
513 
514  } else if( TaskOperationFactory::get_instance()->has_type(layer) ) {
515  std::string task_op_type = layer;
516  std::string task_name = layer_tag->getOption< std::string >("name");
517  TR << "Defining new layer from task type "<< layer << " named " << task_name << std::endl;
518  layer = task_name;
519  TaskOperationOP task = TaskOperationFactory::get_instance()->newTaskOperation(task_op_type, layer_tag);
520  // store the task to use it in apply to find the designable residues for the layer
521  // and add the extra layer to layer_residues_.
522  task_layers_[ task_name ] = task;
523  design_layer_[ task_name ] = true;
524  layer_residues_[ task_name ] = std::map< std::string, std::string >();
525  } else {
526  utility_exit_with_message( "Invalid layer " + layer + ", valid layers are core, boundary, surface, TaskOperations or CombinedTasks" );
527  }
528 
529  BOOST_FOREACH( utility::tag::TagPtr const secstruct_tag, layer_tag->getTags() ) {
530  std::string secstruct = secstruct_tag->getName(); // Strand, Helix, Loop, HelixCapping
531  if( secstruct == "all" && secstruct_tag->hasOption("copy_layer") ) {
532  const std::string layer_to_copy = secstruct_tag->getOption< std::string >("copy_layer");
533  TR << "Copying definitions from layer " << layer_to_copy << " to layer " << layer << std::endl;
534  layer_residues_[ layer ] = layer_residues_[ layer_to_copy ];
535  }
536 
537  if( secstruct == "all" && secstruct_tag->hasOption("append") ) {
538  const std::string aas = secstruct_tag->getOption< std::string >("append");
539  LayerResidues::iterator lrs = layer_residues_.find( layer );
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() );
544  layer_residues_[ lrs->first ][ ld->first ] = std::string(temp_def_res_set.begin(), temp_def_res_set.end() );
545  }
546  }
547 
548  if( secstruct == "all" && secstruct_tag->hasOption("exclude") ) {
549  const std::string aas = secstruct_tag->getOption< std::string >("exclude");
550  LayerResidues::iterator lrs = layer_residues_.find( layer );
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);
556  layer_residues_[ lrs->first ][ ld->first ] = std::string(temp_def_res_set.begin(), temp_def_res_set.end() );
557  }
558  }
559 
560  if( secstruct_tag->hasOption("aa") ) {
561  std::string aas = secstruct_tag->getOption< std::string >("aa");
562  TR << "Setting layer residues for " << layer << " "<< secstruct <<" to " << aas << std::endl;
563  layer_residues_[ layer ][ secstruct ] = aas;
564  }
565 
566  if( secstruct_tag->hasOption("append") ) {
567  std::string aas = secstruct_tag->getOption< std::string >("append");
568  TR << "Appending residues "<< aas << " to layer " << layer << " "<< secstruct << std::endl;
569  const std::string layer_res = layer_residues_[ layer ][ secstruct ];
570  std::set<char> temp_def_res_set( layer_res.begin(), layer_res.end());
571  temp_def_res_set.insert( aas.begin(), aas.end() );
572  layer_residues_[ layer ][ secstruct ] = std::string(temp_def_res_set.begin(), temp_def_res_set.end() );
573  }
574 
575  if( secstruct_tag->hasOption("exclude") ) {
576  std::string aas = secstruct_tag->getOption< std::string >("exclude");
577  TR << "Excluding residues "<< aas << " to layer " << layer << " "<< secstruct << std::endl;
578  const std::string layer_res = layer_residues_[ layer ][ secstruct ];
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);
582  layer_residues_[ layer ][ secstruct ] = std::string(temp_def_res_set.begin(), temp_def_res_set.end() );
583  }
584  }
585  }
586 
587  // fill empty the empty layers of the task layers with the residues at the 'all' layer
588  std::set< std::string > ss_def_names; // pick the ss names from the core layer
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");
593 
594  // check if layer ss is defined and if not fill it up
595  BOOST_FOREACH(TaskLayer const & task_layer, task_layers_) {
596  const std::string all_layers_residues = (layer_residues_.count(task_layer.first)) ? layer_residues_[ task_layer.first ][ "all" ] : "ARNDCEQGHILKMFPSTWYV";
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 );
599  if( ld_it == layer_residues_[ task_layer.first ].end() ) {
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;
602  }
603  }
604  }
605 
606 
607  TR << "Layers to be designed:";
608  BOOST_FOREACH( DesignLayerPair l_p, design_layer_) {
609  if( l_p.second )
610  TR << "\t" << l_p.first;
611  }
612  TR << std::endl;
613  // print the layer definitions
614  TR << std::endl;
615  BOOST_FOREACH( Layer const & layer, layer_residues_) {
616  TR << "Layer " << layer.first << std::endl;
617  BOOST_FOREACH( LayerDefinition const & layer_def, layer.second ) {
618  TR << "\t" << ObjexxFCL::fmt::LJ(15,layer_def.first) << "aa = " << layer_def.second << std::endl;
619  }
620  TR << std::endl;
621  }
622 }
623 
624 } // flxbb
625 } // protocols