Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SeedFoldTree.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 sw=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
11 /// @author Eva-Maria Strauch ( evas01@u.washington.edu )
12 
13 //Unite headers
18 
22 #include <numeric/xyzVector.hh>
24 //Auto Headers
25 #include <core/types.hh>
29 #include <core/pose/PDBInfo.hh>
30 #include <core/pose/Pose.fwd.hh>
31 #include <core/pose/Pose.hh>
32 #include <core/pose/util.hh>
33 #include <core/scoring/Energies.hh>
36 #include <protocols/loops/Loop.hh>
44 #include <utility/vector1.hh>
45 #include <utility/tag/Tag.fwd.hh>
46 #include <utility/tag/Tag.hh>
47 #include <numeric/random/random.hh>
48 #include <set>
49 #include <string>
50 #include <utility>
51 #include <basic/Tracer.hh>
52 #include <boost/foreach.hpp>
54 
55 #define foreach BOOST_FOREACH
56 
57 using namespace core::scoring;
58 using namespace protocols::seeded_abinitio;
59 
60 static basic::Tracer TR( "protocols.seeded_abinitio.SeedFoldTree" );
61 static numeric::random::RandomGenerator RG(124523); // <- Magic number, do not change it!!!
62 
63 namespace protocols{
64  namespace seeded_abinitio{
65 
66  using namespace protocols::moves;
67  using namespace core;
68 
70  SeedFoldTreeCreator::keyname() const
71  {
72  return SeedFoldTreeCreator::mover_name();
73  }
74 
76  SeedFoldTreeCreator::create_mover() const {
77  return new SeedFoldTree;
78  }
79 
81  SeedFoldTreeCreator::mover_name()
82  {
83  return "SeedFoldTree";
84  }
85 
86  SeedFoldTree::~SeedFoldTree() {
87  }
88 
89  SeedFoldTree::SeedFoldTree() :
90  protocols::moves::Mover( SeedFoldTreeCreator::mover_name() ),
91  fold_tree_( NULL ),
92  scorefxn_( NULL )
93  {}
94 
96  protocols::moves::Mover( SeedFoldTreeCreator::mover_name() )
97  {
98  fold_tree_ = ft;
99  pdb_contains_target_ = false;
100  anchor_specified_ = false;
101  twochains_ = false;
102  cut_points_.clear();
103  all_seeds_.clear();
104  set_jumps_manually = false;
105  anchors_.clear();
106  ddg_based_ = true;
107  anchors_.clear();
108  //manual_jump_pairs_.clear();
109  folding_verteces_.clear();
110 
111  }
112 
115  return( protocols::moves::MoverOP( new SeedFoldTree( *this ) ) );
116 }
117 
121 }
122 
123 void
125  fold_tree_ = ft;
126 }
127 
130  return( fold_tree_ );
131 }
132 
135  return scorefxn_;
136 }
137 
138 bool
140  return ddg_based_;
141 }
142 
143 void
145  ddg_based_ = ddgb;
146 }
147 
148 
149 void
152 }
153 
154 
155 void
157  anchors_.clear();
158  for( Size i = 1; i <= anchor.size(); ++i)
159  anchors_.push_back( anchor[i] );
160 }
161 
162 void
163 SeedFoldTree::anchor_specified( bool anchor_specified ){
165 }
166 
167 bool
169  return anchor_specified_;
170 }
171 
173  Size start_resi,
174  Size stop_resi,
175  std::string secondarystruct_seq,
176  core::Size start_fold_pose
177  ){
178  TR <<"defining cut points stochasticly between the given two residues: "<<start_resi<<" and "<<stop_resi <<std::endl;
179  utility::vector1<Size> loopy_regions;
180  char ss;
181 
182  TR<<"start and stop: " << start_resi << " " << stop_resi << "\nsecondary structure string between seeds: \n";
183  //going through the regions beteween the seeds, to identify loops and assign a cut point at random
184  for (Size resi = start_resi + 1 /*+1 since strings count from 0 */ ; resi < stop_resi - 1/*as long as it is a set*/; ++resi) {
185  ss = secondarystruct_seq[ resi - 1 ];
186  TR << ss ;
187  if (ss == 'L')
188  loopy_regions.push_back( resi );//to adjust for string counting
189  }
190  TR << std::endl;
191  //picking one at random:
192  if( loopy_regions.size() < 1 )
193  utility_exit_with_message("there are no loopy residues between the motifs, this is currently not supported.");
194 
195  int low = 1;
196  int high = loopy_regions.size();
197  core::Size ran = RG.random_range( low, high ); // todo: bias more for center
198  core::Size cutpoint = loopy_regions[ ran ] + start_fold_pose -1 ;
199 
200  TR.Debug <<"random number: "<< ran << ", number from loop container: " << loopy_regions[ran]<< ", adjusting by " << start_fold_pose - 1 <<", cutpoint: " << cutpoint << std::endl;
201  TR<<"picked a cutpoint between "<<start_resi << " and " << stop_resi << " ( "<<cutpoint - start_fold_pose <<" ). Renumbering will be adjusted by "<< start_fold_pose -1 << std::endl;
202 
203  return cutpoint;
204 }
205 
206 
207 //this method identifies the closest pair of residues between the target and the seed
208 std::pair< Size, Size >
210  Size seed_start,
211  Size seed_stop,
212  core::pose::PoseOP & target_seed_pose
213  ){
214 
215  using namespace core::conformation;
216  using namespace core::chemical;
217 
218  core::Size nearest_resi( 0 );
219  core::Size nearest_resi_target( 0 );
220  core::Real nearest_dist( 100000.0 );
221  core::Real nearest_dist2 (100000.0 );
222  std::pair<Size,Size> closest_pair;
223  if( target_seed_pose->conformation().num_chains() != 2 )
224  utility_exit_with_message("only two chains as input supported" );
225  Size target_length = target_seed_pose->split_by_chain( 1 ).total_residue();
226 
227  TR<<"iterating through each seed residue to find the closest target residue" <<std::endl;
228 
229  for (Size seed_resi = seed_start; seed_resi <= seed_stop ; ++seed_resi) {
230  for (Size target_resi = 1; target_resi <= target_length ; ++target_resi) {
231 
232  //should be made fancier, using CB instead except for gly (todo)
233  core::Real const distance( target_seed_pose->residue(target_resi).xyz( "CA" ).distance(target_seed_pose->residue(seed_resi).xyz( "CA" ) ) );
234 
235  if( distance < nearest_dist ){
236  nearest_resi_target = target_resi;
237  nearest_dist = distance;
238  }
239 
240  if( nearest_dist < nearest_dist2 ){
241  nearest_resi = seed_resi ;
242  nearest_dist2 = nearest_dist;
243  }
244  }
245  }
246  runtime_assert( nearest_resi );
247  runtime_assert( nearest_resi_target );
248  TR<<"closest pair between seed and target: "<<nearest_resi <<" and: " <<nearest_resi_target <<", distance: "<<nearest_dist<<std::endl;
249  closest_pair.second = nearest_resi;
250  closest_pair.first = nearest_resi_target;
251 
252  return ( closest_pair );
253 }
254 
255 std::pair< Size, Size >
256 find_nearest_residue( Size anchor , pose::PoseOP & target_seed_pose ){
257  using namespace core::conformation;
258  using namespace core::chemical;
259 
260  Size nearest_resi( 0 );
261  Real nearest_dist( 100000.0 );
262  std::pair<Size,Size> closest_pair;
263  if( target_seed_pose->conformation().num_chains() != 2 )
264  utility_exit_with_message("only two chains as input are currently supported" );
265  Size target_length = target_seed_pose->split_by_chain( 1 ).total_residue();
266 
267  std::string anchor_atom = "CB";
268  Residue res_anchor( target_seed_pose->residue( anchor ));
269  if( res_anchor.name3() == "GLY" )
270  anchor_atom = "CA";
271 
272  for (Size target_resi = 1; target_resi <= target_length ; ++target_resi) {
273 
274  std::string connect_atom = "CB";
275  Residue res( target_seed_pose->residue( target_resi ));
276  if( res.name3() == "GLY" )
277  connect_atom = "CA";
278 
279  core::Real const distance( res.xyz( connect_atom ).distance( res_anchor.xyz( anchor_atom ) ) );
280 
281  if( distance < nearest_dist ){
282  nearest_resi = target_resi;
283  nearest_dist = distance;
284  }
285  }
286  runtime_assert( nearest_resi );
287  TR<<"closest residue to anchor residue "<< anchor <<" is "<<nearest_resi <<", distance: "<<nearest_dist<<std::endl;
288 
289  closest_pair.second = anchor;
290  closest_pair.first = nearest_resi;
291 
292  return ( closest_pair );
293 
294 }
295 
298  //runtime_assert( end <= ts_pose->total_residue() );
299  TR << "tspose: " << ts_pose->total_residue() <<std::endl;
300  TR <<"----------alanine scanning to identify the best jump atom in seed ------------"<<std::endl;
302  ala_scan.repack( 0 );
303  ala_scan.repeats( 1 );
304  ala_scan.jump( 1 );
305  ala_scan.scorefxn( scorefxn() );
306 
307  protocols::simple_filters::DdgFilter ddg_filter( 100/*ddg_threshold*/, scorefxn(), 1 /*jump*/, 1 /*repeats*/ );
308  core::Real orig_dG(0.0);
309  core::Real lowest_dG = 1000000;
310  Size lowest_res = 0;
311  pose::Pose pose( *ts_pose );
312  orig_dG = ddg_filter.compute( pose );
313  TR <<"\noriginal seed complex dG "<<orig_dG<<std::endl;
314 
315  TR.Debug <<"start: " << start << "stop : " << end << std::endl;
316 
317  for( core::Size resi=start; resi<=end; ++resi ){
318  core::Real const ala_scan_dG( ala_scan.ddG_for_single_residue( pose, resi ) );
319  core::Real const dG( ala_scan_dG - orig_dG );
320  TR<<"dG for resi "<<pose.residue( resi ).name3()<<resi<<" is "<<dG<<std::endl;
321  if( dG < lowest_dG ){
322  lowest_dG = dG;
323  lowest_res = resi;
324  }
325  }
326  TR<<"seed residue with lowest dG based on ala scanning is : "<< lowest_res << " with dG of: " << lowest_dG << std::endl;
327  return lowest_res;
328 }
329 
332  pose::PoseOP & target_seed_pose,
333  std::string secstr,
334  protocols::loops::Loops & loops,
335  bool protein_not_folded_yet ){
336 
337  using namespace core;
338  using namespace kinematics;
339  using namespace protocols::seeded_abinitio;
340 
341  fold_tree_ = new core::kinematics::FoldTree;
342  fold_tree_->clear();
343  Size seed_num = loops.size();
344 
345  if( target_seed_pose->conformation().num_chains() == 2 ){
346 
347  TR<<"two chains were were submitted for the seed pdb, reading target info"<< std::endl;
348 
349  target_chain_ = new pose::Pose( target_seed_pose->split_by_chain( 1 ) );
350  TR<<"input pdb: "<< secstr.length() <<" target chain: " <<target_chain_->total_residue() << std::endl;
351  seeds_only_ = new pose::Pose( target_seed_pose->split_by_chain( 2 ) );
352 
353  Size rb_jump =1;
354  Size target_length = target_chain_->total_residue();
355  /// this one needs better assertions....
356  Size total_size_complex = secstr.length() + target_length;
357  Size start_new_protein = target_length + 1 ;
358  Size seed_start;// indeces for seeds in the complete pose
359  Size seed_stop;
360  Size pdb_start; // indeces for seeds in trunctated version
361  Size pdb_stop;
362  Size position_adjustment = 0;//1
363  Size seed_res_counter = 1;
364  std::set< core::Size > res_on_target;
365  std::set< core::Size > res_on_design;
366  utility::vector1 < std::pair < Size, Size > > jump_pair_collection ;
367 
368  //informing vertex container with the total length of the new protein
369  folding_verteces_.insert( total_size_complex );
370  folding_verteces_.insert( start_new_protein );
371 
372  if(seed_num <= 0 )
373  utility_exit_with_message( "NO SEEDS SPECIFIED!!!" );
374 
375  //if there is more than one seed, an extra cutpoint is necessary
376  if( seed_num > 1 ){
377  //need to make sure that the cutpoints are not the same as the seed starts and stops below
378  //will cause problem with the set container and the growing peptides mover
379  TR<<"finding cutpoints..."<<std::endl;
380 
381  for(Size seed_it = 2 ; seed_it <= seed_num ; ++seed_it ){
382  TR.Debug <<"loops[seed_it - 1].stop()"<< loops[seed_it - 1].stop()<<" and loops[seed_it - 1].stop()" <<loops[seed_it - 1].stop() << std::endl;
383  Size end_seed = loops[seed_it - 1].stop();
384  Size start_new_seed = loops[seed_it].start();
385  TR<<"... between: "<< end_seed << " and " << start_new_seed << std::endl;
386  Size cut = define_cut_point_stochasticly( end_seed, start_new_seed, secstr , start_new_protein);
387  cut_points_.push_back( cut );
388  folding_verteces_.insert( cut );
389  folding_verteces_.insert( cut + 1 );
390  TR<<"vector: "<<cut_points_[seed_it - 1] << "method cut: " << cut << std::endl;
391  }
392  }//end additional cutpoints
393 
394 
395  for(Size seed_it = 1 ; seed_it <= seed_num ; ++seed_it ){
396 
397  std::pair<Size,Size> jump_pair;
398 
399  if( protein_not_folded_yet){
400 
401  TR << "assuming that the pose does not have full length yet" << std::endl;
402  TR.Debug<<"seed_res_counter "<< seed_res_counter << std::endl;
403  TR.Debug<<"seed start " << loops[seed_it].start() + target_length << std::endl;
404  TR.Debug<<"seed stop " << loops[seed_it].stop() + target_length << std::endl;
405 
406  //values for seeds
407  seed_start = loops[seed_it].start() + target_length;
408  seed_stop = loops[seed_it].stop() + target_length;
409 
410  //adjusting values for truncated version from the input pdb
411  pdb_start = seed_res_counter + target_length;
412  pdb_stop = pdb_start + loops[seed_it].stop() - loops[seed_it].start(); //// - 1;
413 
414  TR.Debug<<"pdb_start for seed " << pdb_start << std::endl;
415  TR.Debug<<"pdb_stop for seed: " << pdb_stop << std::endl;
416 
417  TR<<"seed_residue_counter: "<<seed_res_counter<<std::endl;
418  //populating container for peptide growth
419  folding_verteces_.insert(seed_start);
420  folding_verteces_.insert(seed_stop);
421 
422  TR<<"numbering for seed(only)-target pose with target\n ----- SEED: "<< seed_it << " start: "<<seed_start<<", stop: "<<seed_stop<<" ---------" <<std::endl;
423  TR<<"position adjustment of TRUNCATED seed motif by "<<position_adjustment<<std::endl;
424 
425  if( anchor_specified() ){
426  if( anchors_.size() < 1 )
427  utility_exit_with_message("no anchor specified?!");
428  Size adjust_anchor = anchors_[seed_it] - loops[seed_it].start() + seed_res_counter;
429  TR.Debug << "anchor defined: "<< anchors_[seed_it]<< ", adjusted to " << adjust_anchor << std::endl;
430  jump_pair = find_nearest_residue( adjust_anchor, target_seed_pose );
431  jump_pair.second += loops[seed_it].start() - seed_res_counter;
432  TR<< "jump pairs: " << jump_pair.first << " " << jump_pair.second << std::endl;
433  }
434 
435  if( !anchor_specified() ){
436  if( ddg_based_ ){
437  TR<<"computing dG for seed " << seed_it <<" to identify jump atom "<< std::endl;
438  Size seed_jump_residue = best_by_ala_scan( pdb_start, pdb_stop, target_seed_pose );
439  jump_pair = find_nearest_residue( seed_jump_residue, target_seed_pose );
440  }
441 
442  if( !ddg_based_ ){
443  //get cloesest pairs between target and seeds to set the jumps
444  jump_pair = get_closest_residue_pair( pdb_start, pdb_stop, target_seed_pose );
445  }
446  TR.Debug<<"loops[seed_it].start(): "<<loops[seed_it].start() << " seed_res_counter " << seed_res_counter << std::endl;
447 
448  position_adjustment = loops[seed_it].start() - seed_res_counter; //-1
449  jump_pair.second += position_adjustment;
450  }
451 
452  seed_res_counter += loops[seed_it].stop() - loops[seed_it].start() + 1;
453  TR<<"updating seed res counter: "<<seed_res_counter<<std::endl;
454 
455  }//end not folded yet
456 
457  //when the protein is already folded!
458  else {
459  TR << "assuming pose has its full length" <<std::endl;
460  seed_start = loops[seed_it].start()+ target_length;
461  seed_stop = loops[seed_it].stop() + target_length;
462  TR<<"--------- SEED: " << seed_start <<" " << seed_stop << std::endl;
463  //reset the total size of the complex:
464  //total_size_complex = template_pose.total_residue();
465  TR<<"total size complex: " << total_size_complex << std::endl;
466  //pose::PoseOP templ = new pose::Pose( template_pose );
467 
468  /// setting jump pairs:
469  if( anchor_specified_ ){
470  if( anchors_[ seed_it ] == 0 )
471  jump_pair = get_closest_residue_pair( seed_start, seed_stop, target_seed_pose );
472  else
473  jump_pair = find_nearest_residue( anchors_[seed_it], target_seed_pose );
474  }
475  else{
476  if( ddg_based_ ){
477  TR<<"computing dG for seed " << seed_it <<" to identify jump atom "<< std::endl;
478  Size seed_jump_residue = best_by_ala_scan( seed_start, seed_stop, target_seed_pose );
479  jump_pair = find_nearest_residue( seed_jump_residue, target_seed_pose );
480  }
481  else{
482  jump_pair = get_closest_residue_pair( seed_start, seed_stop, target_seed_pose );
483  }
484  }
485  }
486 
487  rb_jump = seed_it;
488  TR<<"finding closest opposing residues pair for seed starting IDs: " << seed_start <<" " <<seed_stop<<" as jump: "<<rb_jump<<std::endl;
489  TR.Debug<<"after adjustment "<< jump_pair.second << std::endl;
490 
491  res_on_target.insert( jump_pair.first );
492  res_on_design.insert( jump_pair.second );
493  fold_tree_->add_edge( jump_pair.first, jump_pair.second, rb_jump );
494  //cant connected the edges yet since it is going to be unordered. need to do that in a second loop :(
495  TR<<"SEED: "<<seed_it <<", seed and target jump pairs: " <<jump_pair.first<<" and " <<jump_pair.second <<"\n";
496  TR<<"registered jump pairs after full-length adjustments: " << position_adjustment <<std::endl;
497 
498  }//end jump loop
499 
500  TR<<"new SeedFoldTree jumps: " <<*fold_tree_ << std::endl;
501 
502  //now connect folding pieces/chunks
503 
504  ///target first:
505  Size target_head = 1;
506  foreach( core::Size const res, res_on_target ){
507  /// connect chain1 with no breaks
508  fold_tree_->add_edge( target_head, res, Edge::PEPTIDE );
509  target_head = res;
510  }
511 
512  /// connect the last anchor residue on the target chain with the last residue on the target chain
513  core::Size const target_lastjump( *res_on_target.rbegin() );
514  fold_tree_->add_edge( target_lastjump, target_length , Edge::PEPTIDE );
515 
516  ///connecting jump positions on fold pose with cutpoints
517  Size cut_iter = 1;
518  Size last_cut = 0;
519  //Size last_jump = 0;
520 
521  foreach ( core::Size const jpos, res_on_design){
522  TR<<"foldpose iterator: "<< jpos <<"and +1 "<< jpos+1 << std::endl;
523  if( last_cut != 0 )
524  fold_tree_->add_edge( last_cut+1 , jpos , Edge::PEPTIDE ); //this way the cut is after the specified cut position, should it be before?
525  if( jpos != *res_on_design.rbegin() ) {
526  fold_tree_->add_edge( jpos, cut_points_[cut_iter], Edge::PEPTIDE );
527  last_cut = cut_points_[cut_iter];
528  ++cut_iter;
529  }
530  else break;
531  }
532 
533  /// refold chain2 from the first jump residue to the beginning of the chain and from the last key residue to its end
534  core::Size const first( *res_on_design.begin() );
535  core::Size const last( *res_on_design.rbegin() );
536  TR<<"first: " << *res_on_design.begin() << " and " << last << std::endl;
537 
538  //N-terminus of the new protein
539  if( first - 1 >= start_new_protein ) {
540  fold_tree_->add_edge( first, start_new_protein , Edge::PEPTIDE );
541  }
542  //C-terminus of the new protein
543  if( last < total_size_complex ){
544  TR << "--- total_size_complex: " << total_size_complex << std::endl;
545  fold_tree_->add_edge( last, total_size_complex, Edge::PEPTIDE );
546  }
547 
548  TR <<"before deleting self edges: " << *fold_tree_ << std::endl;
549  fold_tree_->delete_self_edges();
550  TR<<"before reordering: " << *fold_tree_ <<std::endl;
551  fold_tree_->reorder( 1 );
552 
553  TR<<"Fold tree:\n"<<*fold_tree_<<std::endl;
554 
555 }//end set_foldtree with target
556 
557 
558 //////////////////////// foldtree set up without target chain ///////////////////////////////////
559 /////this part was taken from bcorreia's code and hasnt been tested yet or integrated
560 
561  //this should be also activatable and general in case the usere wants to fold in the absence of the target
562 else if( target_seed_pose->conformation().num_chains() == 1 ){
563 
564  TR<<"there is no target chain, either because you turned off the option, or it was not loaded" <<std::endl;
565 
566  if( loops.size() > 1 ){
567  using namespace core;
568  using namespace kinematics;
569  //utility::vector1<Size> cut_points_;
570  Size start_protein = 1;//silly type conversion
571 
572  TR<<"more than one seed is defined " << std::endl;
573  for (Size seed_it = 2 ; seed_it <= seed_num; ++seed_it ){
574  Size starting = loops[seed_it - 1].stop();
575  Size ending = loops[seed_it].start();
576  Size cut = define_cut_point_stochasticly( starting, ending, target_seed_pose->secstruct(), start_protein /*or 0? start fold pose */ );
577  TR<<"adding cut: " << cut <<std::endl;
578  cut_points_.push_back( cut );
579  fold_tree_->add_edge( 1, target_seed_pose->total_residue(), Edge::PEPTIDE );
580  }
581 
582  for (Size i=1; i < loops.size() ; ++i){
583  TR<<"seed "<< i <<std::endl;
584  TR<<"cut point"<< cut_points_[i]<<std::endl;
585  Size cutpoint = cut_points_[i];
586  core::pose::add_variant_type_to_pose_residue(*target_seed_pose, chemical::CUTPOINT_LOWER, cutpoint); // residue on the pose has to be assigned as a cut
588  Size loop1_midpoint = ((loops[1].stop()-loops[1].start())/2) + loops[1].start();
589  TR<<"loop 1 mid point"<< loop1_midpoint<<std::endl;
590  Size variable_midpoint = ((loops[i+1].stop()-loops[i+1].start())/2) + loops[i+1].start();
591  TR<<"Variable mid_point"<< variable_midpoint <<std::endl;
592  fold_tree_->new_jump( loop1_midpoint, variable_midpoint, cutpoint );
593  }
594  TR << "Fold Tree for the scaffold " << *fold_tree_ << std::endl;
595 
596  return fold_tree_;
597 
598  }//end more than 1 seed
599  }//end without target section
600 
601 
602 else {
603  TR<<"no special foldtree needed. There is no target chain addition and less then 2 or no seed defined"<<std::endl;
604  fold_tree_->add_edge( 1, target_seed_pose->total_residue(), Edge::PEPTIDE );
605  TR << "Pose fold tree " << fold_tree_ << std::endl;
606  }
607 
608  return fold_tree_;
609 
610 }//end set foldtree method
611 
612 /*
613 //needs some fixes... (todo)
614 core::kinematics::FoldTreeOP
615 SeedFoldTree::set_foldtree_manually(
616  utility::vector1 < std::pair < Size, Size > > & manual_jump_pairs,
617  core::pose::Pose & pose
618  ){
619 
620  using namespace core;
621  using namespace kinematics;
622  using namespace protocols::seeded_abinitio;
623 
624  fold_tree_ = new core::kinematics::FoldTree;
625  fold_tree_->clear();
626 
627  if( pose.conformation().num_chains() == 2 ){
628  //Size start_design = pose.conformation().chain_begin( 2 );
629 
630  cut_points_.push_back( pose.conformation().chain_end( 1 ) );
631 
632  //if there is more than one jump defined we need cutpoints
633  if( manual_jump_pairs.size() > 1 ){
634 
635  for(Size it = 2 ; it <=manual_jump_pairs.size(); ++it){
636  if( manual_jump_pairs.size() > 1 ){
637  Size end_last_jump = manual_jump_pairs[it-1].second;
638  Size start_new_jump = manual_jump_pairs[it].second;
639  Size cut = define_cut_point_stochasticly( end_last_jump, start_new_jump, pose, 0 );
640  cut_points_.push_back( cut );
641  }
642  }
643  }
644 
645  fold_tree_->add_edge( 1 , pose.conformation().chain_end( 1 ), Edge::PEPTIDE );
646  fold_tree_->add_edge(pose.conformation().chain_begin( 2 ), pose.conformation().chain_end( 2 ), Edge::PEPTIDE );
647  TR<<"foldtree before adding extra jumps: "<<*fold_tree_ <<std::endl;
648 
649  for( Size jpair_it = 1; jpair_it <= manual_jump_pairs.size(); ++jpair_it ){
650  fold_tree_->new_jump( manual_jump_pairs[jpair_it].first, manual_jump_pairs[jpair_it].second, cut_points_[jpair_it]);
651  TR<<"adding jump between residues: "<< manual_jump_pairs[jpair_it].first <<" and " << manual_jump_pairs[jpair_it].second <<" with cut " << cut_points_[jpair_it] << std::endl;
652  }
653 
654  TR<<"before deleting self edges: " << *fold_tree_ << std::endl;
655  fold_tree_->delete_self_edges();
656  TR<<"before reordering: " << *fold_tree_ <<std::endl;
657  fold_tree_->reorder( 1 );
658 
659  }
660 
661  else {
662  utility_exit_with_message( "manual jumps are currently only set up for 2 chain targets, but super easy to set up for just 1" );
663  }
664 
665  return fold_tree_;
666 
667 }//end manual jump setfoldtree
668 
669 */
670 
671 ///////apply///////////
672 void
674 {
675 
676  /* (todo)
677  if (set_jumps_manually )
678  fold_tree_ = set_foldtree_manually( manual_jump_pairs_, input_pose );
679  */
680 
681  bool protein_not_folded = true;
682  Size chain_num = pose.conformation().num_chains();
683 
684  //if last chain and template pose have the same length, then the protein is at its full length
685  if( pose.split_by_chain( chain_num ).total_residue() == template_pdb_->total_residue() ){
686  protein_not_folded = false;
687  TR<<"assuming pose has full size" << std::endl;
688  }
689 
690  if( chain_num <= 2 ){
691  TR<<"Previous fold tree: "<< pose.fold_tree()<<'\n';
692  TR<<"reseting foldtree"<<std::endl;
693  pose::PoseOP poseOP = new pose::Pose( pose );
694  fold_tree_ = set_foldtree( poseOP, template_pdb_->secstruct(), all_seeds_ , protein_not_folded );
695  //fold_tree_ = set_foldtree( pose, template_pdb_ , all_seeds_ , protein_not_folded );
696  }
697 
698  if( pose.conformation().num_chains() > 2 ){
699  utility_exit_with_message( "more than 2 chains as input are currently not supported" );
700  }
701 
702  runtime_assert( fold_tree_ );
703 
704  TR<<"Previous fold tree: "<< pose.fold_tree()<<'\n';
705  pose.fold_tree( *fold_tree_ );
706  TR<<"New fold tree: "<< pose.fold_tree()<<std::endl;
708  TR.flush();
709 }
710 
712 SeedFoldTree::get_cutpoints(){ return cut_points_ ;}
713 
714 std::set< core::Size >
715 SeedFoldTree::get_folding_verteces(){ return folding_verteces_;}
716 
720  }
721 
722 
723 void
725  DataMap & data,
727  Movers_map const &,
728  Pose const & /*input_pose*/){
729 
730  TR<<"SeedFoldTree has been invoked"<<std::endl;
731 
732  ddg_based_ = tag->getOption< bool >( "ddG_based", 0 );
733  std::string const scorefxn_name( tag->getOption< std::string >( "scorefxn", "score12" ) );
734  scorefxn( data.get< core::scoring::ScoreFunction * >( "scorefxns", scorefxn_name ) );
735 
736  //parsing branch tags
737  utility::vector0< TagPtr > const branch_tags( tag->getTags() );
738 
739  foreach( TagPtr const btag, branch_tags ){
740  /* this parsing option works, it is just not hooked in yet
741  //in case anybody ever wanted to set them manually
742  if( btag->getName() == "cut_points" ) {
743 
744  utility::vector1< Size > cut_points_;
745  core::Size const resnum( protocols::rosetta_scripts::get_resnum( btag, input_pose ) );
746  cut_points_.push_back( resnum );
747  TR<< "adding cut point: "<< resnum << std::endl;
748  }//end cut points
749  */
750 
751  anchor_specified_ = false;
752 
753  if( btag->getName() == "Seeds" ) { //need an assertion for the presence of these or at least for the option file
754 
755  core::Size const begin( btag->getOption<core::Size>( "begin", 0 ) );
756  core::Size const end( btag->getOption<core::Size>( "end", 0 ) );
757  all_seeds_.add_loop( begin , end , 0, 0, false );
758  if( btag->hasOption( "anchor" )){
759  Size anchor_res = btag->getOption< core::Size >("anchor", 0 );
760  TR<<"anchor residue: " << anchor_res << std::endl;
761  anchors_.push_back( anchor_res );
762  anchor_specified_ = true;
763  }
764  else
765  anchors_.push_back( 0 );
766  }//end seed tags
767 
768 
769  //add option for manual setting of the jumps. this optioh should turn off the automatic foldtree
770  if( btag->getName() == "Jumps" ) { //need an assertion for the presence of these or at least for the option file
771  set_jumps_manually = true;
772  std::pair< Size, Size > jump_pair;
773  jump_pair.first = btag->getOption<core::Size>( "from", 0 ) ;
774  jump_pair.second = ( btag->getOption<core::Size>( "to", 0 ) );
775  if( jump_pair.first > jump_pair.second)
776  utility_exit_with_message("specifiied jumps need to be defined in sequence order" );
777  manual_jump_pairs_.push_back( jump_pair );
778 
779  }//end jump tags
780  }//end b-tags
781 
782  std::string const template_pdb_fname( tag->getOption< std::string >( "template_pdb" ));
783  template_pdb_ = new core::pose::Pose ;
784  core::import_pose::pose_from_pdb( *template_pdb_, template_pdb_fname );
785 
786  }//end parse my tag
787 }//end seeded_abinitio
788 }//end protocols