Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
chainbreak_eval.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/forge/methods/chainbreak_eval.cc
11 /// @brief methods for chainbreak evaluation
12 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
13 
14 // unit headers
16 
17 // package headers
20 
21 // project headers
24 #include <core/pose/Pose.hh>
30 
31 #include <utility/vector1.hh>
32 
33 
34 
35 namespace protocols {
36 namespace forge {
37 namespace methods {
38 
39 
40 /// @brief evaluate linear chainbreak at a position
41 /// @remarks Copies the Pose, if necessary swaps the Pose with a cut fold tree,
42 /// then evaluates the chainbreak.
45  core::pose::Pose const & pose,
46  core::Size const pos
47 )
48 {
51  using core::pose::Pose;
52 
53  Pose scratch = pose;
54 
55  // topology setup, do it here so the non-const linear_chainbreak()
56  // doesn't copy the Pose a second time
57  if ( !scratch.fold_tree().is_cutpoint( pos ) || scratch.fold_tree().num_cutpoint() > 1 ) {
58  FoldTree ft = fold_tree_from_pose( scratch, scratch.fold_tree().root(), MoveMap() );
59  ft.new_jump( pos, pos + 1, pos );
60  scratch.fold_tree( ft );
61  }
62 
63  return linear_chainbreak( scratch, pos ); // call non-const
64 }
65 
66 
67 /// @brief evaluate linear chainbreak at a position
68 /// @remarks If necessary, will evaluate using a copy of the Pose with a cut
69 /// fold tree. If cutpoint variants are present at chainbreak, will use
70 /// existing variants and not modify them. If cutpoint variants are not
71 /// found will add them and then remove them once calculation is finished.
74  core::pose::Pose & pose,
75  core::Size const pos
76 )
77 {
80  using core::pose::Pose;
85 
86  if (pose.fold_tree().num_cutpoint() == 0){
87  return 0;
88  }
89  assert( pos > 0 );
90  assert( pos < pose.n_residue() );
91 
92  EnergyMap emap;
93  ScoreFunction fx; // dummy, needed for function call
95 
96  // evaluate the break
97  if ( pose.fold_tree().is_cutpoint( pos ) && pose.fold_tree().num_cutpoint() == 1 ) {
98 
99  bool cutpoints_added = add_cutpoint_variants( pose, pos );
100  energy.finalize_total_energy( pose, fx, emap );
101  if ( cutpoints_added ) {
102  remove_cutpoint_variants( pose, pos );
103  }
104 
105  } else { // no cutpoint, copy the Pose and introduce one
106 
107  Pose scratch = pose;
108  FoldTree ft = fold_tree_from_pose( scratch, scratch.fold_tree().root(), MoveMap() );
109  ft.new_jump( pos, pos + 1, pos );
110  scratch.fold_tree( ft );
111 
112  add_cutpoint_variants( scratch, pos );
113  energy.finalize_total_energy( scratch, fx, emap );
114 
115  }
116 
117  // return the energy
118  return emap[ core::scoring::linear_chainbreak ];
119 }
120 
121 
122 /// @brief evaluate overlap chainbreak at a position
123 /// @remarks Copies the Pose, if necessary swaps the Pose with a cut fold tree,
124 /// then evaluates the chainbreak.
127  core::pose::Pose const & pose,
128  core::Size const pos
129 )
130 {
133  using core::pose::Pose;
134 
135  Pose scratch = pose;
136 
137  // topology setup, do it here so the non-const linear_chainbreak()
138  // doesn't copy the Pose a second time
139  if ( !scratch.fold_tree().is_cutpoint( pos ) || scratch.fold_tree().num_cutpoint() > 1 ) {
140  FoldTree ft = fold_tree_from_pose( scratch, scratch.fold_tree().root(), MoveMap() );
141  ft.new_jump( pos, pos + 1, pos );
142  scratch.fold_tree( ft );
143  }
144 
145  return overlap_chainbreak( scratch, pos ); // call non-const
146 }
147 
148 
149 /// @brief evaluate overlap chainbreak at a position
150 /// @remarks If necessary, will evaluate using a copy of the Pose with a cut
151 /// fold tree. If cutpoint variants are present at chainbreak, will use
152 /// existing variants and not modify them. If cutpoint variants are not
153 /// found will add them and then remove them once calculation is finished.
156  core::pose::Pose & pose,
157  core::Size const pos
158 )
159 {
162  using core::pose::Pose;
167 
168  assert( pos > 0 );
169  assert( pos < pose.n_residue() );
170 
171  EnergyMap emap;
172  ScoreFunction fx; // dummy, needed for function call
173  LinearChainbreakEnergy energy; // also calculates the overlap chainbreak
174 
175  // evaluate the break
176  if ( pose.fold_tree().is_cutpoint( pos ) && pose.fold_tree().num_cutpoint() == 1 ) {
177 
178  bool cutpoints_added = add_cutpoint_variants( pose, pos );
179  energy.finalize_total_energy( pose, fx, emap );
180  if ( cutpoints_added ) {
181  remove_cutpoint_variants( pose, pos );
182  }
183 
184  } else { // no cutpoint, copy the Pose and introduce one
185 
186  Pose scratch = pose;
187  FoldTree ft = fold_tree_from_pose( scratch, scratch.fold_tree().root(), MoveMap() );
188  ft.new_jump( pos, pos + 1, pos );
189  scratch.fold_tree( ft );
190 
191  add_cutpoint_variants( scratch, pos );
192  energy.finalize_total_energy( scratch, fx, emap );
193 
194  }
195 
196  // return the energy
197  return emap[ core::scoring::overlap_chainbreak ];
198 }
199 
200 
201 /// @brief evaluate quadratic chainbreak at a position
202 /// @remarks Copies the Pose, if necessary swaps the Pose with a cut fold tree,
203 /// then evaluates the chainbreak.
206  core::pose::Pose const & pose,
207  core::Size const pos
208 )
209 {
212  using core::pose::Pose;
213 
214  Pose scratch = pose;
215 
216  // topology setup, do it here so the non-const quadratic_chainbreak()
217  // doesn't copy the Pose a second time
218  if ( !scratch.fold_tree().is_cutpoint( pos ) || scratch.fold_tree().num_cutpoint() > 1 ) {
219  FoldTree ft = fold_tree_from_pose( scratch, scratch.fold_tree().root(), MoveMap() );
220  ft.new_jump( pos, pos + 1, pos );
221  scratch.fold_tree( ft );
222  }
223 
224  return quadratic_chainbreak( scratch, pos ); // call non-const
225 }
226 
227 
228 /// @brief evaluate quadratic chainbreak at a position
229 /// @remarks If necessary, will evaluate using a copy of the Pose with a cut
230 /// fold tree. If cutpoint variants are present at chainbreak, will use
231 /// existing variants and not modify them. If cutpoint variants are not
232 /// found will add them and then remove them once calculation is finished.
235  core::pose::Pose & pose,
236  core::Size const pos
237 )
238 {
241  using core::pose::Pose;
246 
247  assert( pos > 0 );
248  assert( pos < pose.n_residue() );
249 
250  EnergyMap emap;
251  ScoreFunction fx; // dummy, needed for function call
252  ChainbreakEnergy energy;
253 
254  // evaluate the break
255  if ( pose.fold_tree().is_cutpoint( pos ) && pose.fold_tree().num_cutpoint() == 1 ) {
256 
257  bool cutpoints_added = add_cutpoint_variants( pose, pos );
258  energy.finalize_total_energy( pose, fx, emap );
259  if ( cutpoints_added ) {
260  remove_cutpoint_variants( pose, pos );
261  }
262 
263  } else { // no cutpoint, copy the Pose and introduce one
264 
265  Pose scratch = pose;
266  FoldTree ft = fold_tree_from_pose( scratch, scratch.fold_tree().root(), MoveMap() );
267  ft.new_jump( pos, pos + 1, pos );
268  scratch.fold_tree( ft );
269 
270  add_cutpoint_variants( scratch, pos );
271  energy.finalize_total_energy( scratch, fx, emap );
272 
273  }
274 
275  // return the energy
276  return emap[ core::scoring::chainbreak ];
277 }
278 
279 
280 } // methods
281 } // forge
282 } // protocols