Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Loops.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/loops/Loops.hh
11 /// @brief
12 /// @author Chu Wang
13 /// @author Mike Tyka
14 
15 #ifndef INCLUDED_protocols_loops_Loops_HH
16 #define INCLUDED_protocols_loops_Loops_HH
17 
18 // Unit header
20 
21 // Package headers
22 #ifdef WIN32
23 #include <protocols/loops/Loop.hh>
24 #else
26 #endif
27 
29 
30 // Project headers
31 #include <core/types.hh>
32 #include <core/id/types.hh>
34 #include <core/pose/Pose.fwd.hh>
35 
36 // Utility headers
37 #include <numeric/xyzVector.fwd.hh>
38 #include <utility/pointer/ReferenceCount.hh>
39 #include <utility/vector1.fwd.hh>
40 
41 // C/C++ headers
42 #include <ostream>
43 #include <string>
44 
45 namespace protocols {
46 namespace loops {
47 
48 ///////////////////////////////////////////////////////////////////////////
49 // a list of loops
51 
52 public:
55  typedef LoopList::iterator iterator;
56  typedef LoopList::const_iterator const_iterator;
57 
58 
59 public:
60  bool empty() const;
61  core::Size num_loop() const;
62  const_iterator begin() const;
63  const_iterator end() const;
64  iterator v_begin();
65  iterator v_end();
66 
67  //constructor
68  Loops();
69 
70  //copy constructor
71  Loops( const Loops & src );
72 
73  Loops( SerializedLoopList const & src );
74  Loops( std::string const & loop_file_name );
75  Loops( bool setup_loops_from_options_system );
76 
77  // assignment operator
78  Loops & operator =( Loops const & src );
79 
80  // destructor
81  virtual ~Loops();
82 
83  friend std::ostream & operator<<( std::ostream & os, const Loops & loops );
84 
85  void read_loops_options();
86 
87  void
89  std::string const & filename,
90  std::string token = "LOOP"
91  ) const;
92 
93  void
95  std::ostream& data,
96  std::string token
97  ) const;
98 
99  void
100  add_loop( Loop loop, core::Size minimal_gap = 0 );
101 
102  void
103  add_loop(
104  core::Size const start,
105  core::Size const stop,
106  core::Size const cut = 0,
107  core::Real skip_rate = 0.0,
108  bool const extended = false
109  );
110 
111  void
112  add_loop(
113  const const_iterator & it
114  );
115 
116  void
117  add_loop(
118  const iterator & it
119  );
120 
121  void push_back( Loop loop );
122 
123  void
124  push_back(
125  core::Size const start,
126  core::Size const stop,
127  core::Size const cut = 0,
128  core::Real skip_rate = 0.0,
129  bool const extended = false
130  );
131 
132  void
134  Loops loops
135  );
136 
137  void
139  const Loop loop
140  );
141 
142  void
143  delete_loop(
144  core::Size const start,
145  core::Size const stop
146  );
147 
149 
150  core::Size
151  loop_size(
152  core::Size const loop_num
153  ) const;
154 
155  ///@brief return number of residues in all loops of this definition -- sum_i( loop_size( i ) )
156  core::Size loop_size() const;
157 
158  core::Size size() const;
159 
160  core::Size nr_residues() const;
161 
162  void sequential_order();
163 
164  void clear();
165 
166  LoopList const & loops() const;
167 
169 
170  /// @brief Is seqpos contained in any of my loops?
171  bool
172  is_loop_residue( core::Size const seqpos, int const offset = 0 ) const;
173 
174  /// @brief is seqpos a residue in this Loops container ?
175  bool has( core::Size const seqpos, int const offset = 0 ) const;
176 
177  void set_extended( bool input );
178 
179  void make_sequence_shift( int shift );
180 
181  /// @brief yield the Loop which contains the residue seqpos, returns false if seqpos is not in any residue.
182  bool loop_of_residue( core::Size const seqpos, Loop& loop ) const;
183 
184  /// Given the total number of residues, returns the inverse of this selection.
185  Loops invert(core::Size num_residues) const;
186 
187  //@brief switch DOF_Type for residues in loop. id::CHI, id::BB --- don't use with id::JUMP
188  void switch_movemap( core::kinematics::MoveMap& movemap, core::id::TorsionType, bool allow_moves = true ) const;
189 
190  //@brief return index in list of the loop, 0 if not found
191  core::Size loop_index_of_residue( core::Size const seqpos ) const;
192 
193  //@brief Autochoose a cutpoint using the secondary structure of the pose unless cutpoint is already set
194  void auto_choose_cutpoints( core::pose::Pose const & pose );
195 
196  //@brief Autochoose a cutpoint using the secondary structure of the pose unless cutpoint is already set
197  void choose_cutpoints( core::pose::Pose const & pose );
198 
199  void verify_against( core::pose::Pose const & pose ) const;
200 
201  void remove_terminal_loops( core::pose::Pose const & pose );
202 
203  /// @brief Extend a loop
204  void grow_all_loops(
205  core::Size nres,
206  core::Real magnitude
207  );
208 
209  /// @brief Extend a loop (don't extend across cutpoints)
210  void grow_all_loops(
211  core::pose::Pose const &pose,
212  core::Real magnitude
213  );
214 
215  /// @brief Extend a loop (don't extend across cutpoints)
216  void grow_loop(
217  core::pose::Pose const &pose,
218  Loop & loop,
219  core::Real magnitude
220  );
221 
222  /// @brief if possible grows loop will not cross cutpoints or if possible into sheets
224  core::pose::Pose const &pose,
225  Loop & loop,
226  core::Real magnitude
227  );
228 
229  /// @brief Extend a loop
230  void grow_loop(
231  core::Size nres,
232  Loop & loop,
233  core::Real magnitude
234  );
235 
236  /// @brief Extend a loop unequally in both dirs
237  void grow_loop(
238  core::Size nres,
239  Loop & loop,
240  core::Real mag_left,
241  core::Real mag_right
242  );
243 
244  std::string const & loop_file_name();
245  void set_loop_file_name_and_reset( std::string const & loop_filename );
246 
248  void set_strict_looprelax_checks( bool const check );
249 
251  void set_file_reading_token( std::string const & token );
252 
253  /// @brief Computes the center of mass of the Ca atoms specified by this
254  /// instance, writing the result to <center>. Assumes there is no missing
255  /// backbone density.
256  ///
257  /// Note: if this method is called on an instance without any Loop's, returns (0,0,0).
258  void center_of_mass(const core::pose::Pose& pose, numeric::xyzVector<core::Real>* center) const;
259 
260  ///@brief set each loop-residue in the vector to val.
261  /// input vector of nres length ( if shorter last residues of loop are ignored )
262  template< class T >
264 
265  ///@brief add all residues within this loop definition into selection
266  void get_residues( utility::vector1< Size>& selection ) const;
267 
268  // i know this encourages old style for-loops (i.e. without iterators) but so much of the code
269  // already used such loops, i opted for safety.
270  const Loop & operator[] ( core::Size const i ) const;
271 
272  Loop & operator[] ( core::Size const i );
273 
274  bool operator==( Loops const& other ) const;
275 
276  bool operator!=( Loops const& other ) const;
277 
278 private:
279  void init(
280  LoopList const & loops_in,
281  bool const read_loop_file_from_options = false,
282  std::string const & passed_in_filename = ""
283  );
284 
286 
287  void read_loop_file();
288 
289 private:
290 
293 
295 
298 
299 }; // Loops
300 
301 } //namespace loops
302 } //namespace protocols
303 
304 #endif //INCLUDED_protocols_loops_Loops_HH