Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProteinInterfaceMultiStateDesignMover.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 ProteinInterfaceMultiStateDesignMover.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@uw.edu)
13 
14 // Unit headers
17 
18 // Project headers
19 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
23 // AUTO-REMOVED #include <protocols/toolbox/task_operations/ProteinInterfaceDesignOperation.hh>
29 
30 // AUTO-REMOVED #include <core/chemical/ResidueSelector.hh>
31 // AUTO-REMOVED #include <core/chemical/ResidueTypeSet.hh>
33 #include <basic/options/option.hh>
39 #include <core/pose/PDBInfo.hh>
40 #include <core/pose/Pose.hh>
42 // AUTO-REMOVED #include <core/scoring/ScoreFunctionFactory.hh>
43 #include <basic/Tracer.hh>
44 
45 #include <utility/exit.hh>
46 // AUTO-REMOVED #include <utility/string_util.hh> // string_split
47 #include <utility/tag/Tag.hh>
48 #include <boost/foreach.hpp>
49 #define foreach BOOST_FOREACH
50 
51 // option key includes
52 #include <basic/options/keys/out.OptionKeys.gen.hh>
53 // AUTO-REMOVED #include <basic/options/keys/score.OptionKeys.gen.hh>
54 #include <basic/options/keys/ms.OptionKeys.gen.hh>
55 #include <basic/options/keys/packing.OptionKeys.gen.hh>
56 
59 #include <utility/vector0.hh>
60 #include <utility/vector1.hh>
61 #include <ObjexxFCL/format.hh>
62 
63 //Auto Headers
64 #include <utility/excn/Exceptions.hh>
66 
67 
68 namespace protocols {
69 namespace protein_interface_design {
70 namespace movers {
71 
72  using utility::vector1;
73  using namespace core;
74  using namespace chemical;
75  using namespace basic::options;
76  using namespace pack;
77  using namespace task;
78  using namespace operation;
79  using namespace scoring;
80 
81 using namespace ObjexxFCL::fmt;
82 
83 using namespace multistate_design;
84 using namespace genetic_algorithm;
85 
86 using basic::t_error;
87 using basic::t_info;
88 using basic::t_debug;
89 using basic::t_trace;
90 static basic::Tracer TR("protocols.protein_interface_design.movers.ProteinInterfaceMultiStateDesignMover",t_info);
91 
94 {
96 }
97 
101 }
102 
105 {
106  return "ProteinInterfaceMS";
107 }
108 
110  protocols::simple_moves::PackRotamersMover( ProteinInterfaceMultiStateDesignMoverCreator::mover_name() ),
111  gen_alg_(0),
112  multistate_packer_(0),
113  // option flags/parameters: default to command line options
114  // parse_my_tag method may change them
115  rb_jump_( 1 ),
116  scorefxn_( 0 ),
117  generations_( option[ OptionKeys::ms::generations ]() ),
118  pop_size_( option[ OptionKeys::ms::pop_size ]() ),
119  num_packs_( option[ OptionKeys::ms::num_packs ]() ),
120  pop_from_ss_( option[ OptionKeys::ms::pop_from_ss ]() ),
121  numresults_( option[ OptionKeys::ms::numresults ]() ),
122  fraction_by_recombination_( option[ OptionKeys::ms::fraction_by_recombination ]() ),
123  mutate_rate_( option[ OptionKeys::ms::mutate_rate ]() ),
124  boltz_temp_( option[ OptionKeys::ms::Boltz_temp ]() ),
125  anchor_offset_( option[ OptionKeys::ms::anchor_offset ]() ),
126  checkpoint_prefix_( option[ OptionKeys::ms::checkpoint::prefix ]() ),
127  checkpoint_interval_( option[ OptionKeys::ms::checkpoint::interval ]() ),
128  checkpoint_gz_( option[ OptionKeys::ms::checkpoint::gz ]() ),
129  checkpoint_rename_( option[ OptionKeys::ms::checkpoint::rename ]() ),
130  unbound_( true ),
131  unfolded_( true ),
132  input_is_positive_( true ),
133  use_unbound_for_sequence_profile_( true ),
134  bump_threshold_( 1.0 ),
135  compare_energy_to_ground_state_( false ),
136  fname_prefix_("")
137 {
138  state_poses_.clear();
139  saved_state_poses_.clear();
140  state_positive_.clear();
141  state_unfolded_.clear();
142  state_unbound_.clear();
143 }
144 
146 
147 void
149  using namespace protocols::moves;
151  translate->step_size( 1000.0 );
152  translate->apply( *pose );
153 }
154 
155 void
157  for( core::Size i( 1 ), end( pose->total_residue() ); i<=end; ++i ){
158  // unfold the unfolded protein
159  if ( !pose->residue_type(i).is_protein() ) continue;
160  std::string const restype( pose->residue(i).type().name() );
161  if ( restype == "PRO" || ( i>1 && pose->residue(i-1).type().name() == "PRO" ) ) continue; // don't unfold prolines and preprolines
162  /// numbers for extended from Nobu
163  pose->set_phi( i, -130.0 );
164  pose->set_psi( i, 130.0 );
165  }
166 }
167 
168 
169 void
171 {
172  initialize( pose );
173  run();
174  output_results( pose );
176 }
177 
181 }
182 
183 void
185  core::pose::Pose const & pose,
187 ) const
188 {
189  using namespace core::chemical;
190  using namespace core::pack;
191  using namespace core::pack::task;
192  using core::pose::Pose;
193  using core::pose::PoseOP;
194  using utility::vector1;
195  using std::list;
196  using std::vector;
198  using core::scoring::fa_rep;
199 
200  unsigned long const seq_space_before( sequence_space( ptask ) );
201  TR<<"Total number of sequence possibilites: "<<seq_space_before<<std::endl;
203  return;
204  TR<<"Restricting the packer task to residues that would not clash in the unbound monomer..."<<std::endl;
205 /// Turn all designable positions to ala. Freeze everything else
206  PoseOP ala_pose = new Pose( pose );
207  part_complex( ala_pose, rb_jump_ );
208  PackerTaskOP ala_task = ptask->clone();
209  vector1< bool > allow_ala( num_canonical_aas, false );
210  allow_ala[ aa_ala ] = true;
211  vector< Size > designable; //which residues are designable? used below
212  designable.clear();
213  for( Size i( 1 ), end( ala_task->total_residue() ); i <= end; ++i ){
214  if( !pose.residue_type( i ).is_protein() ) continue;
215  ResidueLevelTask & rtask( ala_task->nonconst_residue_task(i) );
216  if( !rtask.being_designed() ) // undesignable
217  rtask.prevent_repacking();
218  else{ //designable
219  rtask.restrict_absent_canonical_aas( allow_ala );
220  designable.push_back( i );
221  }
222  }
223  pack_rotamers( *ala_pose, *scorefxn_, ala_task );
224 
225  // scorefxn for the bump check
227  bump_scorefxn->reset();
228  bump_scorefxn->set_weight( fa_rep, 1.0 );
229 
230  foreach( Size const pos, designable ){
231  EnergyPerResidueFilter const eprf( pos, bump_scorefxn, fa_rep, 0 );
232  core::Real const ref_bump_energy( eprf.compute( *ala_pose ) );
233  PackerTaskOP template_substitution_task( ptask->clone() ); //prevent repacking at all but positions but pos
234  for( Size i( 1 ); i<=pose.total_residue(); ++i )
235  if( i!=pos )
236  template_substitution_task->nonconst_residue_task(i).prevent_repacking();
237 
238  ResidueLevelTask & rtask( ptask->nonconst_residue_task( pos ) );
239  list< ResidueTypeCOP > const & allowed( rtask.allowed_residue_types() );
240  Pose ala_pose_and_single_residue( *ala_pose );
241  vector1< bool > allowed_aas_in_pos( num_canonical_aas, false );
242  foreach( ResidueTypeCOP const t, allowed ){
243  AA const aa( t->aa() );
244  PackerTaskOP specific_substitution_task( template_substitution_task->clone() );
245  utility::vector1< bool > allow_aa( num_canonical_aas, false );
246  allow_aa[ aa ] = true;
247  specific_substitution_task->nonconst_residue_task(pos).restrict_absent_canonical_aas( allow_aa );
248  rotamer_trials( ala_pose_and_single_residue, *bump_scorefxn, specific_substitution_task );
249  core::Real const bump_energy( eprf.compute( ala_pose_and_single_residue ) );
250  if( bump_energy - ref_bump_energy <= bump_threshold_ )
251  allowed_aas_in_pos[ aa ] = true;
252  }///foreach ResidueTypeCOP const t
253  rtask.restrict_absent_canonical_aas( allowed_aas_in_pos );
254  AA const aa_in_pose( pose.residue( pos ).aa() );
255  if( !allowed_aas_in_pos[ aa_in_pose ] ){
256  TR<<"Native identity "<<pose.residue( pos ).name3()<<" at position "<<pos<<" in input pdb is not allowed by bump_test! Increase the bump_cutoff from the current "<<bump_threshold_<<std::endl;
257  utility_exit();
258  }//fi
259  }//foreach pos
260  unsigned long const seq_space_after( sequence_space( ptask ) );
261  TR<<"Finished restricting. Total number of sequences after restriction: "<<seq_space_after<<'\n';
262  TR<<"Orders of magnitude change: "<<log10( (double)seq_space_after ) - log10( (double)seq_space_before )<<std::endl; // REQUIRED FOR WINDOWS
263 }
264 
265 unsigned long
267 {
268  using namespace core::pack::task;
269 
270  unsigned long size( 1 );
271  for( core::Size i( 1 ); i<=ptask->total_residue(); ++i ){
272  ResidueLevelTask const & rtask( ptask->residue_task( i ) );
273  if( !rtask.being_designed() ) continue;
274  core::Size const pos_allowed( rtask.allowed_residue_types().size() );
275  size *= pos_allowed;
276  }
277  return( size );
278 }
279 
280 void
282 {
283  // clear out (any) pre-existing info strings (from previous apply calls)
284  info().clear();
285 
286  // always start with a fresh GeneticAlgorithm
287  // important when reusing ProteinInterfaceMultistateDesign mover
289 
290  // set up genetic algorithm
291  gen_alg_->set_max_generations( generations_ );
292  gen_alg_->set_max_pop_size( pop_size_ );
293  gen_alg_->set_num_to_propagate( static_cast<core::Size>( 0.5 * pop_size_ ) );
294  gen_alg_->set_frac_by_recomb( fraction_by_recombination_ );
295 
296  // set up sequence randomizer
298  rand->set_mutation_rate( mutate_rate_ );
299 
300  TaskFactoryOP my_tf;
301  // if PackRotamerMover base class has no initialized TaskFactory, create default one here
302  if ( ! task_factory() )
303  // Protein-interface design-specific TaskFactory -> PackerTask -> figure out positions to design
304  my_tf = new TaskFactory;
305  else // TaskFactory already exists, add to it
306  my_tf = new TaskFactory( *task_factory() );
307 
308  my_tf->push_back( new InitializeFromCommandline );
309  if ( option[ OptionKeys::packing::resfile ].user() ) my_tf->push_back( new ReadResfile );
310 
311  task_factory( my_tf ); // PackRotamersMover base class setter
312 
313  PackerTaskOP ptask = task_factory()->create_task_and_apply_taskoperations( pose );
314 
315  // figure out design positions/choices from PackerTask
316  restrict_sequence_profile( pose, ptask );
317  vector1< Size > design_positions;
318  for ( Size i(1), end( ptask->total_residue() ); i <= end; ++i ) {
319  if ( !pose.residue_type(i).is_protein() ) continue;
320  ResidueLevelTask const & rtask( ptask->residue_task(i) );
321  if ( rtask.being_designed() ) {
322  design_positions.push_back(i);
323  // will be passed to randomizer
324  EntityElements choices;
325  // to avoid duplicate AA's (such as for multiple histidine ResidueTypes)
326  std::set< core::chemical::AA > aaset;
327  std::list< ResidueTypeCOP > const & allowed( rtask.allowed_residue_types() );
328  for ( std::list< ResidueTypeCOP >::const_iterator t( allowed.begin() ), end( allowed.end() );
329  t != end; ++t ) {
330  core::chemical::AA aa( (*t)->aa() );
331  // avoid duplicate AA's (such as for multiple histidine ResidueTypes)
332  if ( aaset.find( aa ) != aaset.end() ) continue;
333  aaset.insert(aa);
334  TR(t_debug) << "adding choice " << aa << std::endl;
335  choices.push_back( new PosType( i, aa ) );
336  }
337  rand->append_choices( choices );
338  }
339  }
340  // done setting up randomizer
341  gen_alg_->set_rand( rand );
342  TR(t_info) << "There will be " << rand->library_size() << " possible sequences." << std::endl;
343 
344  // set up fitness function
346 
347  multistate_packer_->set_aggregate_function(
349 
350  multistate_packer_->set_scorefxn( scorefxn_ );
351 
352  // add target and competitor to fitness function
353  add_states( pose );
354 
355  TR(t_info) << "There are " << multistate_packer_->num_positive_states() << " positive states and "
356  << multistate_packer_->num_negative_states() << " negative states" << std::endl;
357 
358  // do single-state designs to find best theoretical single-state energy
359  multistate_packer_->single_state_design( );
360 
361  // done setting up fitness function
362  gen_alg_->set_func( multistate_packer_ );
363 
364  // enable checkpointing
365  gen_alg_->set_checkpoint_prefix( checkpoint_prefix_ );
366  gen_alg_->set_checkpoint_write_interval( checkpoint_interval_ );
367  gen_alg_->set_checkpoint_gzip( checkpoint_gz_ );
368  gen_alg_->set_checkpoint_rename( checkpoint_rename_ );
369  gen_alg_->read_checkpoint();
370 
371  // start the genetic algorithm from scratch if not resuming from a checkpoint
372  if ( gen_alg_->population( gen_alg_->current_generation() ).size() == 0 ) {
373  // add single-state design sequence(s) to genetic algorithm starting population
374  SingleStateCOPs states( multistate_packer_->positive_states() );
375  TR(t_info) << "Adding single-state design entities:" << std::endl;
376  for ( SingleStateCOPs::const_iterator s( states.begin() ), end( states.end() );
377  s != end; ++s ) {
378  EntityElements traits;
379  for ( vector1<Size>::const_iterator i( design_positions.begin() ),
380  end( design_positions.end() ); i != end; ++i ) {
381  PosType pt( *i, (*s)->pose().residue_type(*i).aa() );
382  traits.push_back( new PosType( pt ));
383  TR(t_info) << pt.to_string() << " ";
384  }
385  gen_alg_->add_entity( traits );
386  gen_alg_->add_parent_entity( traits );
387  TR(t_info) << std::endl;
388  }
389 
390  // make more entities by mutation of single-state seeds
391  gen_alg_->fill_by_mutation( pop_from_ss_ );
392  // the rest are fully random
393  gen_alg_->fill_with_random_entities();
394  // clear parents for the next generation
395  gen_alg_->clear_parents();
396  }
397  task( ptask ); //For InterfaceSequenceRecapitulation ot konw of the designable task
398 }
399 
400 void
402 {
403  // loop over generations
404  while ( !gen_alg_->complete() ) {
405  if ( gen_alg_->current_generation_complete() ) gen_alg_->evolve_next_generation();
406  TR(t_info) << "Generation " << gen_alg_->current_generation() << ":" << std::endl;
407  gen_alg_->evaluate_fitnesses();
408  gen_alg_->print_population( TR(t_info) );
409  }
410 }
411 
412 void
414 {
415  using namespace core::pack::task;
416  using namespace core::pack::task::operation;
417 
418  TaskFactoryOP tf( new TaskFactory( *task_factory() ) );// Allow all repackable residues to move, but not redesign
419  tf->push_back( new InitializeFromCommandline );
420  tf->push_back( new RestrictToRepacking );
421  PackerTaskCOP ptask_output_pose = tf->create_task_and_apply_taskoperations( output_pose );
422  std::string const output_pose_fname( fname_prefix_ + "_ms_pos_0000.pdb" );
423  core::pose::Pose copy_pose( output_pose );
424  pack_rotamers( copy_pose, *scorefxn_, ptask_output_pose );
425  (*scorefxn_)(copy_pose );
426  copy_pose.dump_scored_pdb( output_pose_fname, *scorefxn_ );
427 
428  if( saved_state_poses_.size() == 0 ) return;
429  runtime_assert( saved_state_poses_.size() == state_positive_.size() );
430  for( core::Size count( 1 ); count<=saved_state_poses_.size(); ++count ){
431  core::pose::Pose state_i( *saved_state_poses_[ count ] );
432  (*scorefxn_)(state_i); // to set up the energy graph or else interface task operation will work well. arggg!
433  PackerTaskCOP unmodifed_ptask( task_factory()->create_task_and_apply_taskoperations( state_i ));
434  for( core::Size resi( 1 ); resi<=state_i.total_residue(); ++resi ){//thread output-pose's sequence on alternative state
435  if( !unmodifed_ptask->residue_task( resi ).being_designed() ) continue;
436  state_i.replace_residue( resi, output_pose.residue( resi ), true );
437  }
438  state_i.update_residue_neighbors();
439  PackerTaskCOP ptask_statei = tf->create_task_and_apply_taskoperations( state_i );
440  pack_rotamers( state_i, *scorefxn_, ptask_statei );
441  (*scorefxn_)( state_i );
442 
443  std::string const neg_pos( state_positive_[ count ] ? "_pos_" : "_neg_" );
444 
445  std::string const pdbname( fname_prefix_ + "_ms" + neg_pos + ObjexxFCL::lead_zero_string_of( count, 4 ) + ".pdb" );
446  state_i.dump_scored_pdb( pdbname, *scorefxn_ );
447  TR<<"\nDumped "<<pdbname<<'\n';
448  }
449  TR.flush();
450 }
451 
452 void
454 {
456  pdboutput->score_function( *scorefxn_ );
457  pdboutput->reference_pose( pose );
458 
459  std::string prefix("result");
460  if ( option[ OptionKeys::out::prefix ].user() ) prefix = option[ OptionKeys::out::prefix ]();
461 
462  typedef GeneticAlgorithm::TraitEntityHashMap TraitEntityHashMap;
463  TraitEntityHashMap const & cache( gen_alg_->entity_cache() );
465  for ( TraitEntityHashMap::const_iterator it( cache.begin() ), end( cache.end() ); it != end; ++it ) {
466  sortable.push_back( it->second );
467  }
468  std::sort( sortable.begin(), sortable.end(), lt_OP_deref< Entity > );
469 
470  TR(t_info) << "Evaluated " << sortable.size() << " sequences.\nBest sequences:\n";
471  // list and output top solutions
472  Size counter(0);
473 
474  for ( vector1< Entity::OP >::const_iterator it( sortable.begin() ),
475  end( sortable.end() ); it != end; ++it ) {
476  Entity & entity(**it);
477 
478  // apply sequence to existing positive state(s)
479  multistate_packer_->evaluate_positive_states( entity );
480  // copy pose
481  Pose solution_pose = multistate_packer_->positive_states().front()->pose();
482  // output pdb with information
483  std::string pdbname( prefix + "_ms_" + ObjexxFCL::lead_zero_string_of(counter,4) + ".pdb" );
484  Strings extra_lines;
485  std::ostringstream ms_info;
486  ms_info << "REMARK MultiState Fitness: " << F(5,4,entity.fitness());
487  extra_lines.push_back( ms_info.str() );
488  ms_info.str(""); // funky way to 'empty' ostringstream
489  ms_info << "REMARK MultiState Sequence:";
490  for ( EntityElements::const_iterator pos( entity.traits().begin() ), end( entity.traits().end() );
491  pos != end; ++pos ) {
492  ms_info << " " << (*pos)->to_string();
493  TR(t_info) << (*pos)->to_string() << " ";
494  }
495  TR(t_info) << "fitness " << F(5,4,entity.fitness()) << '\n';
496  extra_lines.push_back( ms_info.str() );
497  if ( counter == 0 ) {
498  // copy top result to input pose
499  pose = solution_pose;
500  // save info for top result
501  info().insert( info().end(), extra_lines.begin(), extra_lines.end() );
502  // ensure that pose has up-to-date score information
503  (*scorefxn_)(pose);
504  }
505  // set numresults to 0 to suppress output
506  if ( counter >= numresults_ ) break;
507  pdboutput->add_info( "multistate_design", extra_lines, false );
508  (*pdboutput)( solution_pose, pdbname );
509  ++counter;
510  }
511  TR(t_info) << std::endl;
512 }
513 
515  TagPtr const tag,
516  moves::DataMap & datamap,
518  moves::Movers_map const &,
519  Pose const &
520 )
521 {
522  // flags/parameters (override options settings)
523  if ( tag->hasOption("generations") ) generations_ = tag->getOption<Size>("generations");
524  if ( tag->hasOption("pop_size") ) pop_size_ = tag->getOption<Size>("pop_size");
525  if ( tag->hasOption("num_packs") ) num_packs_ = tag->getOption<Size>("num_packs");
526  if ( tag->hasOption("pop_from_ss") ) pop_from_ss_ = tag->getOption<Size>("pop_from_ss");
527  if ( tag->hasOption("numresults") ) numresults_ = tag->getOption<Size>("numresults");
528  if ( tag->hasOption("fraction_by_recombination") )
529  fraction_by_recombination_ = tag->getOption<Real>("fraction_by_recombination");
530  if ( tag->hasOption("mutate_rate") ) mutate_rate_ = tag->getOption<Real>("mutate_rate");
531  if ( tag->hasOption("boltz_temp") ) boltz_temp_ = tag->getOption<Real>("boltz_temp");
532  if ( tag->hasOption("anchor_offset") ) anchor_offset_ = tag->getOption<Real>("anchor_offset");
533  // checkpointing options
534  if ( tag->hasOption("checkpoint_prefix") )
535  checkpoint_prefix_ = tag->getOption<std::string>("checkpoint_prefix");
536  if ( tag->hasOption("checkpoint_interval") )
537  checkpoint_interval_ = tag->getOption<Size>("checkpoint_interval");
538  if ( tag->hasOption("checkpoint_gz") ) checkpoint_gz_ = tag->getOption<bool>("checkpoint_gz");
539  if ( tag->hasOption("checkpoint_rename") )
540  checkpoint_rename_ = tag->getOption<bool>("checkpoint_rename");
541 
542  fname_prefix_ = tag->getOption< std::string >( "output_fname_prefix", "" );
543  // calls to PackRotamersMover base class methods
544  std::string const scorefxn_key( tag->getOption<std::string>("scorefxn", "score12" ));
545  if ( datamap.has( "scorefxns", scorefxn_key ) ) {
546  scorefxn_ = datamap.get< ScoreFunction * >( "scorefxns", scorefxn_key );
547  } else {
548  throw utility::excn::EXCN_RosettaScriptsOption("ScoreFunction " + scorefxn_key + " not found in DataMap.");
549  }
550 
552  if( tf ) task_factory( tf );
553  rb_jump_ = tag->getOption< core::Size >( "rb_jump", 1 );
554 
555  unfolded_ = tag->getOption< bool >( "unfolded", 1 );
556  unbound_ = tag->getOption< bool >( "unbound", 1 );
557  input_is_positive_ = tag->getOption< bool >( "input_is_positive", 1 );
558  use_unbound_for_sequence_profile_ = tag->getOption< bool >( "unbound_for_sequence_profile", unbound_ );
559  bump_threshold_ = tag->getOption< core::Real >( "profile_bump_threshold", 1.0 );
560 /// Read additional positive and negative states
561  utility::vector0< TagPtr > const branch_tags( tag->getTags() );
562  bool at_least_one_negative_state( unfolded_ || unbound_ );
563  compare_energy_to_ground_state_ = tag->getOption< bool >( "compare_to_ground_state", branch_tags.size() );
564  TR<<"Compare energy to ground state set to: "<<compare_energy_to_ground_state_<<std::endl;
565  foreach( TagPtr const btag, branch_tags ){
566  if( unfolded_ || unbound_ ){
567  TR<<"ERROR: If you specify additional pdb files as states, it is assumed that those would have different energies than the starting pdb. As such, comparison of energies across different states is automatically done by grounding each pdb file to its starting 'best-score design' and comparing energy differences from that state. The energies of unbound and unfolded states then become tricky to interpret. You can use anchor_offset to get much of the effect of these additional states. Or, ask Sarel."<<std::endl;
568  throw utility::excn::EXCN_RosettaScriptsOption("");
569  }
570  std::string const fname( btag->getOption< std::string >( "pdb" ) );
571  bool const unbound( btag->getOption< bool >( "unbound", 0 ) );
572  bool const unfolded( btag->getOption< bool >( "unfolded", 0 ) );
573 
574  core::pose::PoseOP new_pose( new core::pose::Pose );
575  state_poses_.push_back( new_pose );
576  core::import_pose::pose_from_pdb( *new_pose, fname );
577  saved_state_poses_.push_back( new core::pose::Pose( *new_pose ) ); //deep copying new pose so that its saved throughout the run
578  state_unbound_.push_back( unbound );
579  state_unfolded_.push_back( unfolded );
580 
582  state_task_factory_.push_back( state_tf );
583 
584  if( btag->getName() == "Positive" )
585  state_positive_.push_back( true );
586  else if( btag->getName() == "Negative" ){
587  state_positive_.push_back( false );
588  at_least_one_negative_state = true;
589  }
590  else
591  throw utility::excn::EXCN_RosettaScriptsOption( "Name "+btag->getName()+" is not recognized in ProteinInterfaceMultistateDesign::parse_my_tag." );
593  }
594  runtime_assert( at_least_one_negative_state );
595 }
596 
597 ///@brief required in the context of the parser/scripting scheme
600 {
602 }
603 
604 ///@brief required in the context of the parser/scripting scheme
607 {
608  return new ProteinInterfaceMultiStateDesignMover( *this );
609 }
610 
611 /// @details we build one target (bound) and two competitor (unbound and unfolded) states.
612 void
614  Pose const & pose
615 )
616 {
617  using namespace core::pose;
618  using namespace protocols::multistate_design;
619 
620  runtime_assert( multistate_packer_ );
621 
622  runtime_assert( task_factory() );
623  PackerTaskCOP ptask = task_factory()->create_task_and_apply_taskoperations( pose );
624 
625  Pose const bound( pose );
626  PoseOP unbound( new core::pose::Pose( pose ) );
627  PoseOP unfolded( new core::pose::Pose( pose ) );
628 
629  if( unbound_ ){
630  part_complex( unbound, rb_jump_ );
631  part_complex( unfolded, rb_jump_ );
632  }
633  if( unfolded_ )
634  unfold_complex( unfolded );
635  PackingStateOP bound_state = new PackingState( bound, input_is_positive_ );
636  PackingStateOP unbound_state = new PackingState( *unbound, false );
637  PackingStateOP unfolded_state = new PackingState( *unfolded, false );
638 
639  bound_state->create_packer_data( scorefxn_, ptask );
640 /// Sharing data is only appropriate if the interaction graph is identical
641 /// between the states (e.g., in specificity calculations), but that is
642 /// clearly not the case here.
643 // unfolded_state->share_packer_data_from( *bound_state );
644 // unbound_state->share_packer_data_from( *bound_state );
645 // unfolded_state->create_packer_data( scorefxn_, ptask );
646  unbound_state->create_packer_data( scorefxn_, ptask );
647  unfolded_state->create_packer_data( scorefxn_, ptask );
648 
649  multistate_packer_->add_state( bound_state );
650  if( unbound_ )
651  multistate_packer_->add_state( unbound_state );
652  if( unfolded_ )
653  multistate_packer_->add_state( unfolded_state );
654 
655  runtime_assert( state_unbound_.size() == state_unfolded_.size() );
656  runtime_assert( state_unbound_.size() == state_positive_.size() );
657  runtime_assert( state_unbound_.size() == state_poses_.size() );
658  runtime_assert( state_unbound_.size() == state_task_factory_.size() );
659 
660  for( core::Size i( 1 ); i<=state_poses_.size();++i ){
661  if( state_unbound_[ i ] || state_unfolded_[ i ] ){
664  }
665  if( state_unfolded_[ i ] ){
668  }
669  PackingStateOP state = new PackingState( *state_poses_[ i ], state_positive_[ i ] );
670  PackerTaskOP state_ptask = task_factory()->create_task_and_apply_taskoperations( *state_poses_[ i ] );
671  if( state_task_factory_[ i ] )
672  state_task_factory_[ i ]->modify_task( pose, state_ptask );
673  state->create_packer_data( scorefxn_, state_ptask );
674  multistate_packer_->add_state( state );
675  }
676 }
677 
678 
679 
680 } // namespace movers
681 } // namespace protein_interface_design
682 } // namespace protocols