Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TorsionFragment.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_frags_TorsionFragment_hh
11 #define INCLUDED_protocols_frags_TorsionFragment_hh
12 
13 // Unit Headers
15 
16 // Rosetta Headers
17 #include <core/types.hh>
18 #include <core/pose/Pose.fwd.hh>
19 
20 // ObjexxFCL Headers
21 // AUTO-REMOVED #include <utility/vector1.hh>
22 #include <utility/pointer/ReferenceCount.hh>
23 
24 #include <utility/vector1.hh>
25 
26 
27 /// ******************************************************************************************************
28 /// Code duplication alert: TorsionFragment is going to be phased out
29 /// Please avoid writing any new code using these classes: look in core/fragment/ instead
30 /// look in /protocols/abinitio/FragmentMover for usage examples
31 ///
32 /// ******************************************************************************************************
33 
34 // C++ Headers
35 // #include <cmath>
36 // #include <cstdlib>
37 // #include <iostream>
38 // #include <fstream>
39 // #include <sstream>
40 
41 namespace protocols {
42 namespace frags {
43 
44 using core::Real;
45 using core::Size;
46 
47 ///\brief a class for single piece of torsion fragment
48 ///
49 ///It stores torsion angles and secondary structure.
50 ///Torsions are stored as vector of vector, such as TorsionFragment[frag_size][n_bb_torsion];
51 ///SS are stored as vector, such as TorsionFragment[frag_length]
53 
54 public:
55 
56  /// constructor, fragment_size (3mer or 9mer) and number of backbone torsions(3 for protein)
57  TorsionFragment( Size const size_in, Size const nbb_in ):
58  torsions_( size_in ),
59  secstruct_( size_in )
60  {
61  for ( Size k=1; k<= size_in; ++k ) {
62  torsions_[k].resize( nbb_in );
63  }
64  }
65  virtual ~TorsionFragment();
66 
67  /// fragment size, 3mer or 9mer?
68  inline
69  Size
70  size() const
71  {
72  return torsions_.size();
73  }
74 
75  /// number of backbone torsions.
76  inline
77  Size
78  nbb() const
79  {
80  return ( torsions_.empty() ? 0 : torsions_[1].size() );
81  }
82 
83  // insert this piece of fragment to a pose at position "begin"
84  void
85  insert( core::pose::Pose & pose, Size const begin ) const;
86 
87  /// set value for specific torsion in this piece of fragment.
88  void
89  set_torsion( Size const pos, Size const tor, Real const setting )
90  {
91  torsions_[pos][tor] = setting;
92  }
93 
94  /// set secstruct for this position
95  void
96  set_secstruct( Size const pos, char const setting )
97  {
98  secstruct_[pos] = setting;
99  }
100 
101  /// get value for specific torsion in this piece of fragment
102  Real
103  get_torsion( Size const pos, Size const tor ) const
104  {
105  return torsions_[pos][tor];
106  }
107 
108  char
109  get_secstruct( Size const pos ) const
110  {
111  return secstruct_[pos];
112  }
113 
114 private:
115  /// torsion angles, the first dimension is fragment size, the second dimension is number of backbone torsions.
117  /// secstruct, dimensioned as fragment size
119 };
120 
122 
123 /////////////////////////////////////////////////////////////////////////////
124 ///\brief a class for collection of fragments for a single residue position
125 ///
126 ///essentially a vector of TorsionFragment (owning pointers)
128 /// ******************************************************************************************************
129 /// Code duplication alert: TorsionFragment is going to be phased out
130 /// Please avoid writing any new code using these classes: look in core/fragment/ instead
131 /// look in /protocols/abinitio/FragmentMover for usage examples
132 ///
133 /// ******************************************************************************************************
134 
135 public:
137 
138  /// insert one piece of fragment in the front
139  void
141  {
142  fragments_.insert( fragments_.begin(), fragment );
143  }
144 
145  /// append one piece of fragment at the end
146  void
148  {
149  fragments_.push_back( fragment );
150  }
151 
152  /// number of available fragment pieces for this position
153  Size
154  size() const
155  {
156  return fragments_.size();
157  }
158 
159  /// overloaded [] operator to get single piece of fragment (actual object, not owning pointers)
160  TorsionFragment const &
161  operator[]( Size const index ) const
162  {
163  return *( fragments_[ index ] );
164  }
165 
166 
167 private:
168  /// a collection of TorsionFragments (by owning pointers)
170 };
171 
173 
174 /////////////////////////////////////////////////////////////////////////////
175 ///\brief a class for classic Rosetta fragment library
176 ///
177 ///essentially a collection of SingleResidueTorsionFragmentLibrary (indexed by residue position)
178 ///
180 /// ******************************************************************************************************
181 /// Code duplication alert: TorsionFragment is going to be phased out
182 /// Please avoid writing any new code using these classes: look in core/fragment/ instead
183 /// look in /protocols/abinitio/FragmentMover for usage examples
184 ///
185 /// ******************************************************************************************************
186 
187 public:
188  /// default constructor
190  virtual ~TorsionFragmentLibrary();
191 
192  /// constructor with size (number of residue positions)
193  TorsionFragmentLibrary( Size const size_in )
194  {
195  resize( size_in );
196  }
197 
198  /// number of residues
199  inline
200  Size
201  size() const {
202  return fragments_.size();
203  }
204 
205  /// overloaded [] operator to get framgnet pieces for a certain residue position
207  operator[]( Size const pos )
208  {
209  return *(fragments_[pos]);
210  }
211 
212  /// overloaded [] operator to get framgnet pieces for a certain residue position (access only)
214  operator[]( Size const pos ) const
215  {
216  return *(fragments_[pos]);
217  }
218 
219  /// change the size of fragment library
220  void
221  resize( Size const new_size )
222  {
223  Size const old_size( fragments_.size() );
224  fragments_.resize( new_size );
225  for ( Size i=old_size+1; i<= new_size; ++i ) {
227  }
228  }
229 
230  // initialize fragment data from a classic Rosetta fragment library
231  bool
232  read_file( std::string const name, Size const frag_size, Size const nbb );
233 
234  // extract a fragment library with smaller fragment size from the one with larger lize
235  bool
236  derive_from_src_lib( Size const my_size, Size const src_size, TorsionFragmentLibraryCOP src_lib_op );
237 
238  /// @brief Show some info -- right now just for debugging, ie not a full dump of the library
239  void
240  print( std::ostream & os ) const;
241 
242 private:
243  ///a collection of SingleResidueTorsionFragmentLibrary owning pointers
245 
246 };
247 
248 
249 } // ns frags
250 } // ns protocols
251 
252 #endif