Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RNA_DataReader.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 RNA de novo fragment assembly Structure Parameters
11 /// @brief User input parameters for RNA structure inference
12 /// @detailed
13 /// @author Rhiju Das
14 
15 
16 // Unit Headers
21 
22 // Package Headers
23 #include <core/pose/Pose.hh>
24 
25 // ObjexxFCL Headers
26 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
27 #include <ObjexxFCL/string.functions.hh>
28 
29 #include <utility/io/izstream.hh>
30 #include <utility/exit.hh>
31 
32 #include <core/types.hh>
33 #include <basic/Tracer.hh>
34 
35 // C++ headers
36 #include <fstream>
37 #include <iostream>
38 
39 #include <utility/vector1.hh>
40 
41 
42 namespace protocols {
43 namespace rna {
44 
45 /// @details Auto-generated virtual destructor
47 
48 static basic::Tracer tr( "protocols.rna.rna_structure_parameters" ) ;
49 
50 using namespace core;
51 
53 }
54 
55 //////////////////////////////////////////////////////////////////
56 void
58  core::pose::Pose & pose,
59  std::string const rna_data_file )
60 {
61 
62  if ( rna_data_file.length() == 0 ) return;
63 
64  Size const nres( pose.total_residue() );
65 
66  backbone_burial_.dimension( nres, false );
67  backbone_exposed_.dimension( nres, false );
68 
69  read_data_from_file( rna_data_file );
70 
71  for (Size i = 1; i <= nres; i++ ) {
72  if ( backbone_burial_( i ) && backbone_exposed_( i ) ) {
73  utility_exit_with_message( "Cannot ask for both backbone exposure and burial: "+ObjexxFCL::string_of(i) );
74  }
75  }
76 
77  setup_rna_data( pose );
78 
79 }
80 
81 
82 /////////////////////////////////////////////////////////////////////////////////////
83 void
84 RNA_DataReader::read_burial_info( std::istringstream & line_stream, ObjexxFCL::FArray1D< bool > & array_to_fill ) {
85 
86  using namespace core::scoring::rna;
87 
88  Size pos( 0 );
89 
90 
91  while ( !line_stream.fail() ) {
92 
93  line_stream >> pos;
94 
95  if ( pos > array_to_fill.size() ) {
96  utility_exit_with_message( "Problem with data format on BACKBONE_BURIAL line. " );
97  }
98 
99  array_to_fill( pos ) = true;
100 
101  }
102 
103 }
104 
105 
106 
107 /////////////////////////////////////////////////////////////////////////////////////
108 void
109 RNA_DataReader::read_data_info( std::istringstream & line_stream ) {
110 
111  using namespace core::scoring::rna;
112 
113  Size pos( 0 );
114  char edge( 'X' );
115  Real weight( 0.0 );
116 
117  while ( !line_stream.fail() ) {
118 
119  line_stream >> pos >> edge >> weight;
120 
121  if ( edge == 'W' ){
122  rna_data_info_.add_datum( RNA_Datum( pos, WATSON_CRICK, weight ) );
123  } else if ( edge == 'H' ) {
124  rna_data_info_.add_datum( RNA_Datum( pos, HOOGSTEEN, weight ) );
125  } else if ( edge == 'S' ) {
126  rna_data_info_.add_datum( RNA_Datum( pos, SUGAR, weight ) );
127  } else if ( edge == 'X' ) {
128  rna_data_info_.add_datum( RNA_Datum( pos, WATSON_CRICK, weight ) );
129  rna_data_info_.add_datum( RNA_Datum( pos, HOOGSTEEN, weight ) );
130  rna_data_info_.add_datum( RNA_Datum( pos, SUGAR, weight ) );
131  } else {
132  utility_exit_with_message( "Problem with data format on DATA line. " );
133  }
134  }
135 
136 }
137 
138 
139 
140 /////////////////////////////////////////////////////////////////////////////////////
141 void
143 
144  tr << "Reading RNA data file: " << filename << std::endl;
145 
146  // Size a;
147 
148  utility::io::izstream data_stream( filename );
149  if ( !data_stream ) {
150  data_stream.close();
151  utility_exit_with_message( "Data file? " + filename );
152  }
153 
154  std::string line, tag;
155 
156  while ( getline( data_stream, line ) ) {
157 
158  std::istringstream line_stream( line );
159  line_stream >> tag;
160 
161  if (line_stream.fail() ) continue; //Probably a blank line.
162 
163  if ( tag == "EXPOSE" ) {
164 
165  read_data_info( line_stream );
166 
167  } else if ( tag == "BACKBONE_BURIAL" ) {
168 
169  read_burial_info( line_stream, backbone_burial_ );
170 
171  } else if ( tag == "BACKBONE_EXPOSE" ) {
172 
173  read_burial_info( line_stream, backbone_exposed_ );
174 
175  } else if ( tag[0] == '#' ) {
176  continue;
177 
178  } else {
179  utility_exit_with_message( "Unrecognized tag in data file: " + tag );
180  }
181  }
182  data_stream.close();
183 
184 }
185 
186 
187 /////////////////////////////////////////////////////////////////////
188 void
190 {
191  rna_data_info_.set_backbone_burial( backbone_burial_ );
192  rna_data_info_.set_backbone_exposed( backbone_exposed_ );
193 
195  core::scoring::rna::RNA_DataInfo & rna_data_info( rna_scoring_info.rna_data_info() );
196  rna_data_info = rna_data_info_;
197 
198  // rna_data_info.set_backbone_burial( backbone_burial_ );
199 
200 }
201 
202 }
203 }
204 
205 
206