Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StepWiseProteinScreener.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 StepWiseProteinScreener
11 /// @brief Makes a list of (phi, psi, omega) at moving_residues that
12 /// could be useful for full-atom packing
13 /// @detailed
14 /// @author Rhiju Dasfi
15 
16 
17 //////////////////////////////////
22 
23 //////////////////////////////////
24 #include <core/types.hh>
25 // AUTO-REMOVED #include <core/chemical/util.hh>
27 #include <core/id/AtomID.hh>
28 #include <core/id/TorsionID.hh>
32 #include <core/pose/Pose.hh>
33 
35 
36 
38 
39 #include <core/pose/util.hh>
40 
41 #include <core/scoring/Energies.hh>
47 #include <basic/Tracer.hh>
48 #include <core/kinematics/Jump.hh>
49 
51 
52 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
53 #include <ObjexxFCL/string.functions.hh>
54 #include <ObjexxFCL/FArray1D.hh>
55 
56 #include <utility/exit.hh>
57 // AUTO-REMOVED #include <time.h>
58 
59 #include <string>
60 
61 //Auto Headers
62 #include <utility/vector1.hh>
63 
64 using namespace core;
65 using core::Real;
66 
67 //////////////////////////////////////////////////////////////////////////
68 //////////////////////////////////////////////////////////////////////////
69 // Core routine for stepwise sampling of proteins (and probably other
70 // biopolymers soon). Take a starting pose and a list of residues to sample,
71 // and comprehensively sample all backbone torsion angles by recursion.
72 //////////////////////////////////////////////////////////////////////////
73 //////////////////////////////////////////////////////////////////////////
74 //////////////////////////////////////////////////////////////////////////
75 
76 static basic::Tracer TR( "protocols.swa.stepwise_residue_sampler" ) ;
77 
78 namespace protocols {
79 namespace swa {
80 namespace protein {
81 
82 
83 
84  //////////////////////////////////////////////////////////////////////////
85  //constructor!
86  StepWiseProteinScreener::StepWiseProteinScreener( StepWiseJobParametersOP & job_parameters ):
87  job_parameters_( job_parameters ),
88  moving_residues_( job_parameters_->working_moving_res_list() ),
89  n_sample_( 18 /* Corresponds to 20 degree bins */ ),
90  rmsd_cutoff_( -1.0 ),
91  centroid_scorefxn_( core::scoring::ScoreFunctionFactory::create_score_function( "score3.wts" )/* score3 */ ),
92  silent_file_( "" ),
93  filter_native_big_bins_( false ),
94  centroid_screen_( false ),
95  centroid_score_ref_( 999999999999999.99),
96  centroid_score_diff_cut_( 20.0 ),
97  apply_vdw_cut_( false ),
98  centroid_vdw_ref_( 9999999999999999.999 ),
99  nstruct_centroid_( 0 ),
100  ghost_loops_( false ),
101  is_pre_proline_( job_parameters_->is_pre_proline() )
102  {
104  }
105 
106  //////////////////////////////////////////////////////////////////////////
107  //destructor
109  {}
110 /////////////////////
113 return "StepWiseProteinScreener";
114 }
115 
116 
117  //////////////////////////////////////////////////////////////////////////
118  //////////////////////////////////////////////////////////////////////
119  void
121  {
122 
123  Size which_res( 1 );
124  Size count( 1 );
125 
126  clock_t const time_start( clock() );
127 
129  centroid_scores_.clear();
130 
131  // convert to centroid
132  pose::Pose pose_save = pose;
133  if ( centroid_screen_ ) convert_to_centroid( pose );
134  if ( ghost_loops_ ) prepare_ghost_pose( pose ); // pose with loops excised
135 
136  sample_residues_recursively( which_res, count, pose );
137 
138  std::cout << "Total time in StepWiseProteinScreener: " <<
139  static_cast<Real>(clock() - time_start) / CLOCKS_PER_SEC << std::endl;
140 
141  pose = pose_save;
142 
144 
145  }
146 
147 
148  ///////////////////////////////////////////////////////////////////////////
149  void
151 
153  for ( Size n = 1; n <= moving_residues_.size(); n++ ) {
155  }
156 
158 
159  }
160 
161  ///////////////////////////////////////////////////////////////////////////
162  void
163  StepWiseProteinScreener::copy_coords( pose::Pose & pose, pose::Pose const & template_pose, ResMap const & ghost_map ) const
164  {
165  using namespace core::id;
166 
167  template_pose.residue( 1 ); // force a refold.
168 
169  for ( ResMap::const_iterator it=ghost_map.begin(); it != ghost_map.end(); it++ ) {
170  Size const & res( it->first );
171  Size const & template_res( it->second );
172 
173  for( Size j = 1; j <= pose.residue_type( res ).natoms(); j++ ) {
174 
175  if ( pose.residue_type( res ).atom_name( j ) !=
176  template_pose.residue_type( template_res ).atom_name( j ) ) {
177  std::cout << "PROBLEM! " << res << " " << pose.residue( res ).atom_name( j ) << " != " <<
178  template_res << " " << template_pose.residue( template_res ).atom_name( j ) << std::endl;
179  utility_exit_with_message( "mismatch in ghost pose" );
180  }
181 
182  pose.set_xyz( AtomID( j, res ), template_pose.xyz( AtomID( j, template_res ) ) );
183 
184  }
185 
186  }
187 
188  pose.residue( 1 ); // force a refold.
189  }
190 
191  ///////////////////////////////////////////////////////////////////////////
194 
195  Size prev_res( 0 ), total_res( 0 );
196  utility::vector1< Size > cutpoints;
197 
198  for ( ResMap::const_iterator it=ghost_map.begin(); it != ghost_map.end(); it++ ) {
199  Size const & res( it->first );
200  Size const & template_res( it->second );
201 
202  std::cout << "MAPPING " << res << " --> " << template_res << std::endl;
203 
204  if ( (template_res-1) != prev_res ) cutpoints.push_back( res-1 );
205  prev_res = template_res;
206 
207  total_res = res;
208  }
209 
210  core::kinematics::FoldTree f( total_res );
211 
212  for ( Size n = 1; n <= cutpoints.size(); n++ ) {
213  std::cout << "Adding jump across: " << cutpoints[ n ] << std::endl;
214  f.new_jump( cutpoints[ n ], cutpoints[ n ] +1, cutpoints[ n ] );
215  }
216 
217  return f;
218 
219  }
220 
221 
222  ////////////////////////////////////////////////////////////////////////////
223  void
225  Size const which_res,
226  Size & count,
227  core::pose::Pose & pose )
228  {
229 
230  using namespace core::chemical;
231  using namespace core::scoring;
232 
233  if ( moving_residues_.size() < 1 ) return; //nothing to do.
234 
235  Size const n = moving_residues_[ which_res ];
236 
237  MainChainTorsionSetList main_chain_torsion_set_list;
238  get_main_chain_torsion_set_list( n, pose, main_chain_torsion_set_list );
239 
240  for ( Size k = 1; k <= main_chain_torsion_set_list.size(); k++ ) {
241 
242  MainChainTorsionSet const & main_chain_torsion_set( main_chain_torsion_set_list[ k ] );
243 
244  pose.set_phi( n, main_chain_torsion_set.phi() );
245  pose.set_psi( n, main_chain_torsion_set.psi() );
246  pose.set_omega( n, main_chain_torsion_set.omega() );
247 
248  main_chain_torsion_set_for_moving_residues_[ which_res ] = main_chain_torsion_set;
249 
250  if ( which_res == moving_residues_.size() ) {
251 
252  count++;
253  std::string const tag = "S_"+ ObjexxFCL::lead_zero_string_of( count, 5 );
254  filter_and_output( pose, tag );
255 
256  } else {
257  sample_residues_recursively( which_res+1, count, pose );
258  }
259 
260  }
261 
262  }
263 
264 
265  //////////////////////////////////////////////////////////////////////
266  // This could even be its own class...
267  void
269  Size const & n,
270  pose::Pose const & pose,
271  MainChainTorsionSetList & main_chain_torsion_set_list )
272  {
273  using namespace core::chemical;
274 
275  main_chain_torsion_set_list.clear();
276 
277  // following is totally hacky... would be much better to
278  // figure out which bins would sum to give probability > 99%, or something like that.
279  Real best_energy_cutoff = 0.8;
280  // Not really necessary...
281  // if ( pose.aa( n ) == aa_gly ) best_energy_cutoff = 0.8;
282  // if ( pose.aa( n ) == aa_pro ) best_energy_cutoff = 0.0;
283 
284  // A few special cases first.
285  if ( n == 1
286  && !pose.residue( 1 ).has_variant_type( "N_ACETYLATION" )
287  //&& !pose.residue( 1 ).has_variant_type( "LOWER_TERMINUS" ) /*new!*/
288  ){
289 
290  // If we're at the N-terminal, there's no point in sampling phi -- just a dinky hydrogen...
291  // or three hydrogens.
292  // basically slave the phi to the psi.
293  get_main_chain_torsion_set_list_n_terminus( n, pose, best_energy_cutoff, main_chain_torsion_set_list );
294 
295  } else if ( n == pose.total_residue()
296  && !pose.residue( n ).has_variant_type( "C_METHYLAMIDATION" )
297  && !pose.residue( n ).has_variant_type( "UPPER_TERMINUS" ) /*new!*/
298  ){
299  // DEFUNCT: If we're at the C-terminal, there's no point in sampling psi -- just an oxygen.
300  // basically slave the psi to the phi.
301  get_main_chain_torsion_set_list_c_terminus( n, pose, best_energy_cutoff, main_chain_torsion_set_list );
302 
303  } else if ( is_fixed_res_[ n ] && (n >= pose.total_residue() || is_fixed_res_[ n+1 ]) && (n > 1 && !is_fixed_res_[ n-1] )){
304 
305  get_main_chain_torsion_set_list_sample_phi_only( n, pose, best_energy_cutoff, main_chain_torsion_set_list );
306  //std::cout << "SAMPLING PHI ONLY for: " << n << ' ' << main_chain_torsion_set_list.size() << std::endl;
307 
308  } else if ( is_fixed_res_[ n ] && (n <= 1 || is_fixed_res_[ n-1 ]) && (n < pose.total_residue() && !is_fixed_res_[n+1] ) ){
309 
310  get_main_chain_torsion_set_list_sample_psi_only( n, pose, best_energy_cutoff, main_chain_torsion_set_list );
311  // std::cout << "SAMPLING PSI ONLY for: " << n << ' ' << main_chain_torsion_set_list.size() << std::endl;
312 
313  } else if ( n > moving_residues_[ 1 ] &&
314  n < moving_residues_[ moving_residues_.size() ] ) {
315 
316  // Trying coarse sample for internal residues -- otherwise number of conformations really blows up.
317 
318  get_main_chain_torsion_set_list_coarse( n, pose, main_chain_torsion_set_list );
319 
320  //get_main_chain_torsion_set_list_full( n, pose, best_energy_cutoff, main_chain_torsion_set_list );
321 
322  } else {
323 
324  /////////////////
325  // General case.
326  /////////////////
327  get_main_chain_torsion_set_list_full( n, pose, best_energy_cutoff, main_chain_torsion_set_list );
328 
329  }
330 
331 
332  if ( filter_native_big_bins_ ) {
333  filter_native_BIG_BINS( n, main_chain_torsion_set_list );
334  } else {
335  filter_based_on_desired_secstruct( pose.secstruct( n ), main_chain_torsion_set_list );
336  }
337 
338  if ( is_pre_proline_[ n ] && ( n == pose.total_residue() || !is_fixed_res_[ n+1 ] ) ) {
339  TR << "----- SAMPLING CIS OMEGA --------" << std::endl;
340  sample_cis_omega( main_chain_torsion_set_list );
341  }
342  }
343 
344  /////////////////////////////////////////////////////////////////////////////////////
345  void
347  Size const & n,
348  pose::Pose const & pose,
349  MainChainTorsionSetList & main_chain_torsion_set_list )
350  {
351  using namespace core::chemical;
352 
353  // Later, can individually dial in cluster centers based on careful
354  // inspection of residue-specific rama plots. For now, this is basically a quick hack.
355  if ( pose.aa( n ) == aa_pro ) {
356 
357  main_chain_torsion_set_list.push_back( MainChainTorsionSet( -70.0, -30.0 ) );
358  main_chain_torsion_set_list.push_back( MainChainTorsionSet( 60.0, 140.0 ) );
359 
360  } else if ( pose.aa( n ) == aa_gly ) {
361 
362  main_chain_torsion_set_list.push_back( MainChainTorsionSet( -80.0, -10.0 ) );
363  main_chain_torsion_set_list.push_back( MainChainTorsionSet( -70.0, 160.0 ) );
364  main_chain_torsion_set_list.push_back( MainChainTorsionSet( 90.0, 10.0 ) );
365  main_chain_torsion_set_list.push_back( MainChainTorsionSet( 100.0, 180.0 ) );
366 
367  } else {
368 
369  main_chain_torsion_set_list.push_back( MainChainTorsionSet( -70.0, -30.0 ) );
370  main_chain_torsion_set_list.push_back( MainChainTorsionSet( -70.0, 140.0 ) );
371  main_chain_torsion_set_list.push_back( MainChainTorsionSet( 50.0, 50.0 ) );
372 
373  }
374 
375  }
376 
377 
378  /////////////////////////////////////////////////////////////////////////////////////
379  void
381  MainChainTorsionSetList & main_chain_torsion_set_list )
382 
383  {
384  //generic -- a residue in the middle of the loop
385  for (Size i = 1; i <= n_sample_; i++ ) {
386  for (Size j = 1; j <= n_sample_; j++ ) {
387  Real const phi = get_rotamer_angle( i, n_sample_ );
388  Real const psi = get_rotamer_angle( j, n_sample_ );
389 
390  if ( ramachandran_.eval_rama_score_residue( pose.aa( n ), phi, psi ) > best_energy_cutoff ) {
391  continue;
392  }
393 
394  main_chain_torsion_set_list.push_back( MainChainTorsionSet( phi, psi ) );
395 
396  }
397  }
398  }
399 
400  /////////////////////////////////////////////////////////////////////////////////////
401  void
403  MainChainTorsionSetList & main_chain_torsion_set_list )
404  {
405  assert( n == 1);
406  for (Size j = 1; j <= n_sample_; j++ ) {
407  Real const psi = get_rotamer_angle( j, n_sample_ );
408  Real best_phi = 0.0;
409  Real best_energy = 999999.9999;
410  for (Size i = 1; i <= n_sample_; i++ ) {
411  Real const phi = get_rotamer_angle( i, n_sample_ );
412  Real temp_rama = ramachandran_.eval_rama_score_residue( pose.aa( n ), phi, psi );
413  if ( temp_rama < best_energy ) {
414  best_energy = temp_rama;
415  best_phi = phi;
416  }
417  }
418  if ( best_energy < best_energy_cutoff ){
419  main_chain_torsion_set_list.push_back( MainChainTorsionSet( best_phi, psi ) );
420  }
421  }
422  }
423 
424  /////////////////////////////////////////////////////////////////////////////////////
425  void
427  MainChainTorsionSetList & main_chain_torsion_set_list )
428  {
429  for (Size i = 1; i <= n_sample_; i++ ) {
430  Real const phi = get_rotamer_angle( i, n_sample_ );
431 
432  Real best_psi = 0.0;
433  Real best_energy = 999999.9999;
434  for (Size j = 1; j <= n_sample_; j++ ) {
435  Real const psi = get_rotamer_angle( j, n_sample_ );
436  Real temp_rama = ramachandran_.eval_rama_score_residue( pose.aa( n ), phi, psi );
437  if ( temp_rama < best_energy ) {
438  best_energy = temp_rama;
439  best_psi = psi;
440  }
441  }
442  if ( best_energy < best_energy_cutoff ){
443  main_chain_torsion_set_list.push_back( MainChainTorsionSet( phi, best_psi ) );
444  }
445  }
446  }
447 
448 
449 
450  /////////////////////////////////////////////////////////////////////////////////////
451  void
453  core::pose::Pose const & pose,
454  core::Real const energy_cutoff,
455  MainChainTorsionSetList & main_chain_torsion_set_list )
456  {
457  TR << "JUNCTION RESIDUE --> PREPEND " << n << std::endl;
458 
459  // we are prepending and this is the junction residue. sample phi only!
460  Real best_rama_energy( 99999.999 ), best_phi( 0.0 );
461  Real const psi = pose.psi( n );
462  for (Size i = 1; i <= n_sample_; i++ ) {
463  Real const phi = get_rotamer_angle( i, n_sample_ );
464  Real const rama_energy = ramachandran_.eval_rama_score_residue( pose.aa( n ), phi, psi );
465  if ( rama_energy < best_rama_energy || i == 1){
466  best_rama_energy = rama_energy;
467  best_phi = phi;
468  }
469  if ( rama_energy > energy_cutoff ) continue;
470  main_chain_torsion_set_list.push_back( MainChainTorsionSet( phi, psi ) );
471  }
472 
473  // Make sure to return something at least...
474  if ( main_chain_torsion_set_list.size() == 0 ) main_chain_torsion_set_list.push_back( MainChainTorsionSet( best_phi, psi ) );
475 
476  }
477 
478  /////////////////////////////////////////////////////////////////////////////////////
479  void
481  core::pose::Pose const & pose,
482  core::Real const energy_cutoff,
483  MainChainTorsionSetList & main_chain_torsion_set_list )
484  {
485  TR << "JUNCTION RESIDUE --> APPEND " << n << std::endl;
486 
487  // we are appending and this is the junction residue. sample psi only!
488  Real best_rama_energy( 99999.999 ), best_psi( 0.0 );
489  Real const phi = pose.phi( n );
490  for (Size j = 1; j <= n_sample_; j++ ) {
491  Real const psi = get_rotamer_angle( j, n_sample_ );
492  Real const rama_energy = ramachandran_.eval_rama_score_residue( pose.aa( n ), phi, psi );
493  if ( rama_energy < best_rama_energy || j == 1){
494  best_rama_energy = rama_energy;
495  best_psi = psi;
496  }
497  if ( rama_energy > energy_cutoff ) continue;
498  main_chain_torsion_set_list.push_back( MainChainTorsionSet( phi, psi ) );
499  }
500 
501  // Make sure to return something at least...
502  if ( main_chain_torsion_set_list.size() == 0 ) main_chain_torsion_set_list.push_back( MainChainTorsionSet( phi, best_psi ) );
503 
504  }
505 
506  //////////////////////////////////////////////////////////////////////////////
507  // Coarse -- see set_ss_from_phipsi in core/pose/util.cc.
508  //////////////////////////////////////////////////////////////////////////////
509  Size
511  {
512  if ( phi < -20.0 && psi > -90.0 && psi < -10.0 ) {
513  return 1;
514  } else if ( phi < -20.0 && (psi > 20.0 || psi < -170.0) ) {
515  return 2;
516  }
517  return 3;
518  }
519 
520 
521  ///////////////////////////////////////////////////////////////
522  // Check set_ss_from_phipsi -- pretty coarse. Could
523  // later use some guess for strand/helix propensity as an
524  // energy term or something.
525  ///////////////////////////////////////////////////////////////
526  void
528  Size const & n,
529  MainChainTorsionSetList & main_chain_torsion_set_list )
530  {
531 
532  if ( get_native_pose() == 0 ) {
533  utility_exit_with_message( "Filter based on native big bins, but not native specified?" );
534  }
535 
536  //big bin not really specified for end residues...
537  pose::Pose const & native_pose( *get_native_pose() );
538 
539  if ( n == 1 ) return;
540  if ( n == native_pose.total_residue() ) return;
541 
542  Size const big_bin = get_big_bin( native_pose.phi(n), native_pose.psi(n) );
543  if ( big_bin == 3 ) return; // If loop, no constraints.
544 
545  filter_big_bin( big_bin, main_chain_torsion_set_list );
546 
547  }
548 
549  //////////////////////////////////////////////////////////////////////////////////
550  void
552  char const & secstruct,
553  MainChainTorsionSetList & main_chain_torsion_set_list )
554  {
555 
556  Size big_bin( 3 );
557  if ( secstruct == 'H' ) big_bin = 1;
558  if ( secstruct == 'E' ) big_bin = 2;
559 
560  // default secstruct is 'L' --> no filtering.
561  if ( big_bin == 3 ) return; // If loop, no constraints.
562 
563  filter_big_bin( big_bin, main_chain_torsion_set_list );
564 
565  }
566 
567  //////////////////////////////////////////////////////////////////////////////////
568  void
570  MainChainTorsionSetList & main_chain_torsion_set_list ) {
571 
572  MainChainTorsionSetList main_chain_torsion_set_list_new;
573 
574  for ( Size n = 1; n <= main_chain_torsion_set_list.size(); n++ ) {
575  Real const phi = main_chain_torsion_set_list[ n ].phi();
576  Real const psi = main_chain_torsion_set_list[ n ].psi();
577  if ( ( big_bin == 1 && get_big_bin( phi, psi ) == 1 ) ||
578  ( big_bin == 2 && get_big_bin( phi, psi ) == 2 ) ) {
579  main_chain_torsion_set_list_new.push_back( main_chain_torsion_set_list[ n ] );
580  }
581  }
582 
583  main_chain_torsion_set_list = main_chain_torsion_set_list_new;
584  }
585 
586  ///////////////////////////////////////////////////////////////////
587  void
589 
590  std::list< std::pair< Real, Size > > energy_index_list;
591  for (Size n = 1; n <= centroid_scores_.size(); n++ ) {
592  energy_index_list.push_back( std::make_pair( centroid_scores_[n], n ) ) ;
593  }
594  energy_index_list.sort();
595 
596  utility::vector1< MainChainTorsionSetList > main_chain_torsion_sets_for_moving_residues_new;
597 
598  for (Size n = 1; n <= centroid_scores_.size(); n++ ) {
599  if ( n > nstruct_centroid_ ) break;
600  main_chain_torsion_sets_for_moving_residues_new.push_back(
602  }
603 
604  main_chain_torsion_sets_for_moving_residues_ = main_chain_torsion_sets_for_moving_residues_new;
605  }
606 
607  /////////////////////////////////////////////////////////////////////////
608  void
610  MainChainTorsionSetList main_chain_torsion_set_list_new;
611 
612  for ( Size n = 1; n <= main_chain_torsion_set_list.size(); n++ ) {
613  Real const phi = main_chain_torsion_set_list[ n ].phi();
614  Real const psi = main_chain_torsion_set_list[ n ].psi();
615  main_chain_torsion_set_list_new.push_back( MainChainTorsionSet( phi, psi, 180.0 ) );
616  main_chain_torsion_set_list_new.push_back( MainChainTorsionSet( phi, psi, 0.0 ) );
617  }
618 
619  main_chain_torsion_set_list = main_chain_torsion_set_list_new;
620 
621  }
622 
623  //////////////////////////////////////////////////////////////////////////
624  void
626  silent_file_ = silent_file;
627  }
628 
629  //////////////////////////////////////////////////////////////////////////
630  void
632  rmsd_cutoff_ = setting;
633  }
634 
635  //////////////////////////////////////////////////////////////////////////
636  void
638  n_sample_ = setting;
639  }
640 
641  //////////////////////////////////////////////////////////////////////////
642  void
644  nstruct_centroid_ = setting;
645  }
646 
647  //////////////////////////////////////////////////////////////////////////
648  void
650  centroid_scorefxn_ = scorefxn;
651  }
652 
653 
654  //////////////////////////////////////////////////////////////////////////
655  void
657  filter_native_big_bins_ = setting;
658  }
659 
660  //////////////////////////////////////////////////////////////////////////
661  void
663  centroid_screen_ = setting;
664  }
665 
666  //////////////////////////////////////////////////////////////////////////
667  void
669  ghost_loops_ = setting;
670  }
671 
672  //////////////////////////////////////////////////////////////////////////
673  void
675  apply_vdw_cut_ = setting;
676  }
677 
678  //////////////////////////////////////////////////////////////////////////
679  void
681  centroid_score_diff_cut_ = setting;
682  }
683 
684  //////////////////////////////////////////////////////////////////////////
687  {
689  }
690 
691  //////////////////////////////////////////////////////////////////////////
694  {
696  for ( Size k = 1; k <= main_chain_torsion_sets_for_moving_residues_.size(); k++ ) {
699  for ( Size n = 1; n <= main_chain_torsion_set_list.size(); n++ ) {
700  output.push_back( main_chain_torsion_set_list[ n ].phi() );
701  output.push_back( main_chain_torsion_set_list[ n ].psi() );
702  output.push_back( main_chain_torsion_set_list[ n ].omega() );
703  }
704  output_list.push_back( output );
705  }
706  return output_list;
707  }
708 
709  //////////////////////////////////////////////////////////////////////////
712  {
713  using namespace core::id;
715  for ( Size k = 1; k <= moving_residues_.size(); k++ ) {
716  for ( Size n = 1; n <= 3; n++ ) {
717  which_torsions.push_back( TorsionID( moving_residues_[ k ], BB, n ) );
718  }
719  }
720  return which_torsions;
721  }
722 
723 
724  //////////////////////////////////////////////////////////////////////////
725  void
727 
728  is_fixed_res_.clear();
729  for ( Size n = 1; n <= job_parameters_->working_sequence().size(); n++ ) is_fixed_res_.push_back( false );
730 
731  utility::vector1< Size > const & working_fixed_res = job_parameters_->working_fixed_res();
732  for ( Size i = 1; i <= working_fixed_res.size(); i++ ){
733  is_fixed_res_[ working_fixed_res[i] ] = true;
734  }
735 
736  }
737 
738  /////////////////////////////////////////////////////////////////////////
739  void
741  moving_residues_ = moving_res;
742  }
743 
744  /////////////////////////////////////////////////////////////////////////
745  void
747  is_fixed_res_.clear();
748  for ( Size n = 1; n <= job_parameters_->working_sequence().size(); n++ ) is_fixed_res_.push_back( false );
749 
750  for ( Size i = 1; i <= fixed_res.size(); i++ ){
751  is_fixed_res_[ fixed_res[i] ] = true;
752  }
753 
754  }
755 
756 
757 
758 
759  /////////////////////////////////////////////////////////////
760  // This is basically deprecated... may not work anymore.
761  /////////////////////////////////////////////////////////////
762  void
764  Real const & centroid_score_diff_cut,
765  std::string const & centroid_weights,
766  Size const nstruct_centroid,
767  bool const ghost_loops) {
768 
769  using namespace core::scoring;
770 
771  ScoreFunctionOP centroid_scorefxn = ScoreFunctionFactory::create_score_function( centroid_weights );
772 
773  set_centroid_screen( true );
774  set_centroid_score_diff_cut( centroid_score_diff_cut );
775 
776  if ( ghost_loops ){
777  // Trying a mode where loops are not included in scoring.
778  // the idea was to cut out poses where secondary structure elements
779  // are in contact -- energy less than a reference pose in which
780  // the secondary structure elements are really far apart.
781  set_ghost_loops( true );
783  // if reference is "expanded", rg doesn't make sense.
784  centroid_scorefxn->set_weight( rg, 0.0 );
785  // disallow steric clashes beyond what it in expanded pose.
786  set_apply_vdw_cut( true );
787  }
788 
789  set_centroid_scorefxn( centroid_scorefxn );
790  set_nstruct_centroid( nstruct_centroid );
791 
792  }
793 
794 
795  ///////////////////////////////////////////////////////////////////////////
796  // pose with loops excised. centroid level.
797  void
799 
800  using namespace core::kinematics;
801  using namespace core::scoring;
802 
803  // Figure out sequence of a pose without the loops (i.e., the "moving residues" );
804  std::string const full_sequence = pose.sequence();
805  ObjexxFCL::FArray1D<bool> moving_array( full_sequence.size(), false );
806  for ( Size n = 1; n <= moving_residues_.size(); n++ ) moving_array( moving_residues_[n] ) = true;
807 
808  ghost_map_.clear();
809  Size count( 0 );
810  std::string desired_sequence = "";
811  for ( Size n = 1; n <= full_sequence.size(); n++ ){
812  if ( moving_array(n) ) continue;
813  count++;
814  desired_sequence += full_sequence[n-1];
815  ghost_map_[ count ] = n;
816  }
817 
818  FoldTree f = figure_out_fold_tree( ghost_map_ ); //chainbreaks, etc.
819 
820  TR << "FULL SEQUENCE " << full_sequence << std::endl;
821  TR << "DESIRED SEQUENCE " << desired_sequence << std::endl;
822 
823  initialize_ghost_pose( ghost_pose_, desired_sequence, pose, ghost_map_, f);
824  ghost_pose_->dump_pdb( "GHOST_START.pdb" );
825 
826  if ( get_native_pose() ) {
827  Pose native_centroid_pose = *get_native_pose();
828  convert_to_centroid( native_centroid_pose );
829  initialize_ghost_pose( ghost_native_pose_, desired_sequence, native_centroid_pose, ghost_map_, f);
830  ghost_native_pose_->dump_pdb( "GHOST_NATIVE_START.pdb" );
831  }
832 
833  // Also need to figure out reference energy.
834  Pose ghost_pose_blowup = *ghost_pose_;
835  for ( Size n = 1; n <= ghost_pose_blowup.num_jump(); n++ ) {
836  Jump jump( ghost_pose_blowup.jump( n ) );
837  jump.set_translation( Vector( 100.0, 0.0, 0.0 ) ); //This is a little dangerous.
838  ghost_pose_blowup.set_jump( n, jump );
839  }
840  ghost_pose_blowup.dump_pdb( "GHOST_BLOWUP.pdb" );
841  centroid_score_ref_ = (*centroid_scorefxn_)( ghost_pose_blowup );
842  centroid_vdw_ref_ = ghost_pose_blowup.energies().total_energies()[ vdw ];
843 
844  centroid_scorefxn_->show( std::cout, ghost_pose_blowup );
845  std::cout << " REFERENCE SCORES " << centroid_score_ref_ << " " << centroid_vdw_ref_ << std::endl;
846 
847  }
848 
849  ///////////////////////////////////////////////////////////////////////////
850  void
852  core::pose::PoseOP & ghost_pose,
853  std::string const & desired_sequence,
854  core::pose::Pose const & template_pose,
855  ResMap const & ghost_map,
857  {
858  using namespace core::chemical;
859  using namespace core::pose;
861 
862  ghost_pose = new Pose;
863  make_pose_from_sequence( *ghost_pose, desired_sequence, *rsd_set );
864  copy_coords( *ghost_pose, template_pose, ghost_map );
865  ghost_pose->fold_tree( f );
866  }
867 
868 
869  ///////////////////////////////////////////////////////////////////////////
870  void
872 
873  core::pose::remove_variant_type_from_pose_residue( pose, "N_ACETYLATION", 1 );
874  core::pose::add_variant_type_to_pose_residue( pose, "LOWER_TERMINUS", 1 );
875 
876  core::pose::remove_variant_type_from_pose_residue( pose, "C_METHYLAMIDATION", pose.total_residue() );
877  core::pose::add_variant_type_to_pose_residue( pose, "UPPER_TERMINUS", pose.total_residue() );
878 
880 
881  // get DSSP, assign secondary structure
882  core::scoring::dssp::Dssp dssp_obj( pose );
883  dssp_obj.insert_ss_into_pose( pose );
884  //pose.dump_pdb( "CENTROID.pdb" );
885 
886  }
887 
888 
889  ///////////////////////////////////////////////////////////////////////////////
890  void
892  std::string const & tag )
893  {
894  using namespace core::scoring;
895  using namespace core::chemical;
896  using namespace core::pose;
897 
898  if ( get_native_pose() && rmsd_cutoff_ > 0.0 ) {
900  TR << "CHECKING: decoy " << tag << ": " << rmsd << " vs. filter " << rmsd_cutoff_ << std::endl;
901  if ( rmsd > rmsd_cutoff_ ) return;
902  }
903 
904  Real centroid_score( 0.0 );
905  if ( centroid_screen_ ) {
906 
907  if ( ghost_loops_ ) {
908  //this may be a little inefficient, since all internal dofs needs to be recalculated. Its safe, though, I think.
910 
911  centroid_score = (*centroid_scorefxn_)( *ghost_pose_ ); // pose with loops excised
912 
913  Real const centroid_vdw = ghost_pose_->energies().total_energies()[ vdw ];
914  if ( apply_vdw_cut_ && centroid_vdw > centroid_vdw_ref_ ) return;
915 
916  } else {
917 
918  centroid_score = (*centroid_scorefxn_)( pose );
919  // Keep running tabs on best score seen so far.
920  if ( centroid_score < centroid_score_ref_ ) centroid_score_ref_ = centroid_score;
921  }
922 
923  Real const centroid_score_diff = centroid_score - centroid_score_ref_;
924 
925  if ( centroid_score_diff > centroid_score_diff_cut_ ) return;
926 
927  //std::cout << "COMPARING " << centroid_score << " " << centroid_score_ref_ << std::endl;
928 
929  }
930 
932  centroid_scores_.push_back( centroid_score );
933 
934  if ( silent_file_.size() > 0 ) {
935 
936  if ( ghost_loops_ ) {
938  } else {
940  }
941 
942  }
943 
944 
945  }
946 
947 
948 
949 
950 }
951 }
952 }