Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AllResiduesChanged.hh
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 #ifndef INCLUDED_protocols_hybridization_AllResiduesChanged_hh
11 #define INCLUDED_protocols_hybridization_AllResiduesChanged_hh
12 
14 
15 #include <core/pose/Pose.hh>
18 
19 #include <utility/vector1.hh>
20 #include <set>
21 
22 namespace protocols {
23 namespace hybridization {
24 
25 /// @brief (helper) functor class which keeps track of initial phi/psi values.
26 /// @detail
27 /// calls of operator ( pose ) compare the initial phi/psi values
28 ////to the current values of the given pose. Returns false once all phi/psi values
29 /// have been modified.
31 public:
33  utility::vector1< core::Real > const residue_weights,
35  ) :
36  insert_pos_( pose.total_residue(), false )
37  {
38  set_initial_pose( pose );
39  for (core::Size i_anchor = 1; i_anchor <= anchor_residues.size(); ++i_anchor)
40  anchor_residues_.insert(anchor_residues[i_anchor]);
41  compute_insert_pos( residue_weights );
42  }
43 
45  insert_pos_( pose.total_residue(), true )
46  {
47  set_initial_pose( pose );
48  }
49 
50 private:
51 
53  utility::vector1< core::Real > const residue_weights
54  ) {
55  for ( core::Size ires=1; ires<= residue_weights.size(); ++ires ) {
56  if (ires > insert_pos_.size() ) break;
57  if (residue_weights[ires] > 0.0 && !anchor_residues_.count(ires) )
58  insert_pos_[ires] = true;
59  }
60  }
61 
62  void set_initial_pose( const core::pose::Pose & pose ) {
63  initial_phis.resize(pose.total_residue());
64  initial_psis.resize(pose.total_residue());
65  for ( unsigned int i = 1; i <= pose.total_residue(); ++i ) {
66  if ( ! pose.residue(i).is_protein() ) continue;
67  initial_phis[i] = pose.phi(i);
68  initial_psis[i] = pose.psi(i);
69  }
70 
72  }
73 
74 public:
75  void show_unmoved( const core::pose::Pose & pose, std::ostream& out ) {
76  runtime_assert( original_sequence_ == pose.sequence() );
77  for ( core::Size i = 1; i <= pose.total_residue(); ++i ) {
78  if ( ! pose.residue(i).is_protein() ) continue;
79  if ( initial_phis[i] == pose.phi(i) && insert_pos_[ i ] ) {
80  out << i << " ";
81  continue;
82  }
83  if ( initial_psis[i] == pose.psi(i) && insert_pos_[ i ] ) {
84  out << i << " ";
85  }
86  }
87  out << std::endl;
88  }
89 
90  virtual bool operator() ( const core::pose::Pose & pose ) {
91  runtime_assert( original_sequence_ == pose.sequence() ); // imperfect attempt to check that Pose hasn't changed ...
92  for ( unsigned int i = 1; i <= pose.total_residue(); ++i ) {
93  if ( ! pose.residue(i).is_protein() ) continue;
94  if ( initial_phis[i] == pose.phi(i) && insert_pos_[ i ] ) {
95  return false;
96  }
97  if ( initial_psis[i] == pose.psi(i) && insert_pos_[ i ] ) {
98  return false;
99  }
100  }
101  return true;
102  }
103 
104 private:
107 
108  std::set<core::Size> anchor_residues_;
111 };
112 
113 }
114 }
115 
116 #endif