Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.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 /// @file protocols/forge/methods/util.hh
11 /// @brief miscellaneous utility functions for forge
12 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
13 
14 #ifndef INCLUDED_protocols_forge_methods_util_hh
15 #define INCLUDED_protocols_forge_methods_util_hh
16 
17 // type headers
18 #include <core/types.hh>
19 
20 // package headers
22 
23 // project headers
26 #include <core/pose/Pose.fwd.hh>
27 #include <protocols/loops/Loop.hh>
28 #include <protocols/loops/Loops.hh>
30 // AUTO-REMOVED #include <core/pack/task/ResfileReader.fwd.hh>
32 
33 // C++ headers
34 #include <set>
35 #include <iostream>
36 
37 #include <utility/vector1.hh>
38 
39 
40 namespace protocols {
41 namespace forge {
42 namespace methods {
43 
44 
45 /// @brief return a set containing values in the closed interval [left, right]
46 /// filled by looping from left -> right with the given increment
47 template< typename T >
48 std::set< T >
50  T const left,
51  T const right,
52  T const increment = 1
53 )
54 {
55  std::set< T > s;
56 
57  for ( T i = left; i <= right; i += increment ) {
58  s.insert( i );
59  }
60 
61  return s;
62 }
63 
64 
65 /// @brief add the values in the closed interval [left, right] to a set
66 /// by looping from left -> right with the given increment
67 template< typename T >
68 void
70  T const left,
71  T const right,
72  std::set< T > & s,
73  T const increment = 1
74 )
75 {
76  for ( T i = left; i <= right; i += increment ) {
77  s.insert( i );
78  }
79 }
80 
81 
82 /// @brief return a set containing values in the half-open interval [left, right)
83 /// filled by looping from left -> right with the given increment
84 template< typename T >
85 std::set< T >
87  T const left,
88  T const right,
89  T const increment = 1
90 )
91 {
92  std::set< T > s;
93 
94  for ( T i = left; i < right; i += increment ) {
95  s.insert( i );
96  }
97 
98  return s;
99 }
100 
101 
102 /// @brief add the values in the half-open interval [left, right) to a set
103 /// by looping from left -> right with the given increment
104 template< typename T >
105 void
107  T const left,
108  T const right,
109  std::set< T > & s,
110  T const increment = 1
111 )
112 {
113  for ( T i = left; i < right; i += increment ) {
114  s.insert( i );
115  }
116 }
117 
118 
119 /// @brief perform union( root, i ) for all 'i' within the closed interval
120 /// [left, right]
121 /// @param[in] root position to union with; can be any number, does not have
122 /// to be a true root of a set
123 /// @param[in] left start of the interval
124 /// @param[in] right end of the interval
125 /// @param[in,out] uf
126 void
128  core::Size const root,
129  core::Size const left,
130  core::Size const right,
132 );
133 
134 
135 /// @brief moving left to right, find the first true cutpoint within the specified
136 /// extent
137 /// @return the cutpoint position, otherwise 0 if not found
140  core::pose::Pose const & pose,
142  core::Size right
143 );
144 
145 
146 /// @brief moving left to right, count the number of true cutpoints within the
147 /// specified extent
150  core::pose::Pose const & pose,
152  core::Size right
153 );
154 
155 
156 /// @brief set omega to 180 for a range of residues [left, right]
157 void
159  core::Size const left,
160  core::Size const right,
161  core::pose::Pose & pose
162 );
163 
164 
165 /// @brief create Loop object w/ random cutpoint from an Interval
168 
169 
170 /// @brief create Loops object w/ random cutpoints from a collection of
171 /// Intervals
172 template< typename IntervalIterator >
175  IntervalIterator begin,
176  IntervalIterator end
177 )
178 {
181 
182  Loops loops;
183 
184  for ( IntervalIterator i = begin; i != end; ++i ) {
185  loops.add_loop( interval_to_loop( *i ) );
186  }
187 
188  return loops;
189 }
190 
191 /// @brief create Loops object w/ random cutpoints from a collection of
192 /// Intervals for KIC confirmation purpose
193 template< typename IntervalIterator >
196  IntervalIterator begin,
197  IntervalIterator end,
198  core::Size nres
199 )
200 {
203 
204  Loops loops;
205 
206  for ( IntervalIterator i = begin; i != end; ++i ) {
207  core::Size const cut = (i->right - i->left +1)/2 + i->left; // just try cutting somewhere in the middle
208  std::cout << "left: " << i->left << " right: " << i->right << " cut: " << cut << std::endl;
209 
211  if (i->left <= 3) { //N-term
212  Loop loop( 1, i->right+2, cut);
213  loops.add_loop(loop);
214  //std::cout << "added loop " << "1" << ":" << i->right+2 << ":" << cut << std::endl;
215  } else if (i->right >= nres-2){ //cterm
216  Loop loop(i->left-2, nres, cut);
217  loops.add_loop(loop);
218  //std::cout << "added loop " << i->left-2 << ":" << nres << ":" << cut << std::endl;
219  } else {
220  Loop loop(i->left-2, i->right+2, cut);
221  loops.add_loop(loop);
222  //std::cout << "added loop " << i->left-2 << ":" << i->right+2 << ":" << cut << std::endl;
223  }
224  }
225  return loops;
226 }
227 
228 /// @brief create fold tree from loops
229 /// @remarks This is a generic replacement function for the one in protocols::loops
230 /// and will be moved there in the near future.
233  core::pose::Pose const & pose,
234  protocols::loops::Loops const & loops
235 );
236 
237 
238 /// @brief set a single loop fold tree
239 /// @remarks This is a generic replacement function for the one in protocols::loops
240 /// and will be moved there in the near future.
241 void
243  core::pose::Pose & pose,
244  protocols::loops::Loop const & loop
245 );
246 
249 );
250 
253 
254 void
256  core::pose::Pose & pose,
258 
259 
260 void
262 
263 
264 } // namespace methods
265 } // namespace forge
266 } // namespace protocols
267 
268 
269 #endif /* INCLUDED_protocols_forge_methods_util_HH */