Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_FragmentsClasses.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 // CVS information:
4 // $Revision: 1.1.2.1 $
5 // $Date: 2005/11/07 21:05:35 $
6 // $Author: rhiju $
7 // (c) Copyright Rosetta Commons Member Institutions.
8 // (c) This file is part of the Rosetta software suite and is made available under license.
9 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
10 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
11 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
12 
13 #ifndef INCLUDED_protocols_rna_RNA_FragmentsClasses_hh
14 #define INCLUDED_protocols_rna_RNA_FragmentsClasses_hh
15 
17 
18 
19 // ObjexxFCL Headers
20 // AUTO-REMOVED #include <ObjexxFCL/ObjexxFCL.hh>
21 #include <ObjexxFCL/FArray1D.hh>
22 #include <ObjexxFCL/FArray2D.hh>
23 #include <ObjexxFCL/FArray3D.hh>
24 // AUTO-REMOVED #include <ObjexxFCL/FArray4D.hh>
25 // AUTO-REMOVED #include <ObjexxFCL/StaticIndexRange.hh>
26 
27 #include <core/pose/Pose.fwd.hh>
28 #include <core/types.hh>
29 #include <utility/pointer/ReferenceCount.hh>
30 // AUTO-REMOVED #include <utility/vector1.fwd.hh>
31 
32 // C++ Headers
33 #include <string>
34 #include <map>
35 #include <vector>
36 
37 //Auto using namespaces
38 namespace ObjexxFCL { } using namespace ObjexxFCL; // AUTO USING NS
39 //Auto using namespaces end
40 
41 
42 
43 /////////////////////////////////////////////////////////////////////////////////////
44 /////////////////////////////////////////////////////////////////////////////////////
45 // Goal: to make a fragment object that can choose fragments
46 // "on the fly" for RNA ab inito folding.
47 //
48 // After reading in a set of torsions from, e.g., the ribosome crystal structure,
49 // should be able to generate fragments of size 1, 2, or 3, with
50 // exact sequence matches, partial Y/R matches, or ignoring sequence.
51 //
52 namespace protocols{
53 namespace rna{
54 
55  /// name MATCH_ENUM added for PyRosetta compatability
56  enum MATCH_ENUM { MATCH_ALL /* 0 */, MATCH_YR /* 1 */, MATCH_EXACT /* 2 */};
57 
58  /////////////////////////////////////////////////////////////////////////////////////////////////
59  /////////////////////////////////////////////////////////////////////////////////////////////////
60  class TorsionSet {
61  public:
62  TorsionSet & operator =( TorsionSet const & src );
63  TorsionSet( core::Size const size );
64 
65  //make this private?
66  FArray2D <core::Real> torsions; // dimensions: (NUM_RNA_TORSIONS, SRange(0, size) );
67  FArray1D <std::string> torsion_source_name; // dimensions: ( SRange(0, size) );
68  FArray1D <char> secstruct;
69 
70  FArray3D <core::Real> non_main_chain_sugar_coords;
71  bool non_main_chain_sugar_coords_defined;
72 
73  inline
74  core::Size get_size() const { return size_; }
75 
76  private:
77  core::Size size_;
78 
79  };
80 
81  /////////////////////////////////////////////////////////////////////////////////////////////////
82  /////////////////////////////////////////////////////////////////////////////////////////////////
83  class FragmentLibrary : public utility::pointer::ReferenceCount {
84  public:
85 
86  //constructor!
87  //FragmentLibrary();
88 
89  //destructor -- necessary?
90  //~FragmentLibrary();
91 
92  core::Real get_fragment_torsion(
93  core::Size const num_torsion,
94  Size const which_frag,
95  core::Size const offset );
96 
97  TorsionSet const get_fragment_torsion_set( core::Size const which_frag );
98 
99  void add_torsion( TorsionSet const torsion_set );
100 
101  void add_torsion(
102  RNA_Fragments const & vall,
103  core::Size const position,
104  core::Size const size
105  );
106 
107  core::Size get_align_depth();
108 
109  private:
110  std::vector< TorsionSet > align_torsions_;
111 
112  };
113 
114  /////////////////////////////////////////////////////////////////////////////////////////////////
116  typedef std::pair< std::string, std::string > SequenceSecStructPair;
117  typedef std::map< SequenceSecStructPair, FragmentLibraryOP > FragmentLibraryPointerMap;
118 
119  /////////////////////////////////////////////////////////////////////////////////////////////////
120  class RNA_Fragments : public utility::pointer::ReferenceCount {
121  public:
122  //Constructor -- needs vall_torsions_file to get started.
123  // RNA_Fragments();
125  read_vall_torsions( filename );
126  }
127 
128  //We need an explicit destructor, I think, because each
129  // of the fragment libraries is "new". Not anymore, with
130  // the owning pointer business!
131  // ~RNA_Fragments(){
132  // FragmentLibraryPointerMap::iterator it;
133  // for (it = fragment_library_pointer_map.begin();
134  // it != fragment_library_pointer_map.end();
135  // it++ ){
136  // delete it->second;
137  // }
138  // }
139 
140  void read_vall_torsions( std::string const filename );
141 
142  //Probably the only thing that will actually get called publicly:
143  void
144  pick_random_fragment(
145  TorsionSet & torsion_set,
146  core::pose::Pose & pose,
147  core::Size const position,
148  core::Size const size,
149  core::Size const type = MATCH_YR );
150 
151  core::Real
152  torsions( core::Size const & i, core::Size const & j ) const { return vall_torsions_( i, j ); }
153 
155  name( core::Size const & i ) const { return vall_name_( i ); }
156 
157  char
158  secstruct( core::Size const & i ) const { return vall_secstruct_( i ); }
159 
160  bool
161  non_main_chain_sugar_coords_defined() const { return vall_non_main_chain_sugar_coords_defined_; }
162 
163  core::Real
164  non_main_chain_sugar_coords( core::Size const & i, core::Size const & j, core::Size const & k ) const{ return vall_non_main_chain_sugar_coords_( i, j, k);}
165 
166  private:
167 
168  void
169  pick_random_fragment(
170  TorsionSet & torsion_set,
171  std::string const RNA_string,
172  std::string const RNA_secstruct_string,
173  core::Size const type = MATCH_YR );
174 
175  std::string const
176  convert_based_on_match_type( std::string const RNA_string, core::Size const type );
177 
178  bool
179  compare_RNA_char( char const char1, char const char2 );
180 
181  bool
182  compare_RNA_secstruct( char const char1, char const char2 );
183 
184 
185  private:
186 
187  // Probably should make following "vall" stuff a different object
188  // and, come on, these could be a vector to save memory!
189  FArray2D <core::Real> vall_torsions_;
190  FArray3D <core::Real> vall_non_main_chain_sugar_coords_;
191  FArray1D <char> vall_sequence_;
192  FArray1D <bool> vall_is_chainbreak_;
193  FArray2D <bool> vall_edge_is_base_pairing_;
195  FArray1D <char> vall_secstruct_;
196  FArray1D <std::string> vall_name_;
199 
200  // Need to hold on to some fragment libraries. These
201  // will be picked on the fly when the code requires them.
202  // Indexed by sequence, e.g., AAA, AGA, GUA ... or even RYR ... or even NNN (totally generic!)
204 
205  void pick_fragment_library( SequenceSecStructPair const & key );
206 
207  void pick_random_fragment( FArray1D <core::Real> & RNA_torsions, std::string const RNA_string );
208 
209  };
210 
211  /////////////////////////////////////////////////////////////////////////////////////////////////
212  /////////////////////////////////////////////////////////////////////////////////////////////////
213 
214 
215 }
216 }
217 
218 #endif