Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SecondaryStructure.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
11 /// @brief secondary structure will hold statistics about secondary structure predictions
12 /// sources can be from
13 /// - fragments
14 /// - psipred files ? other stuff
15 ///
16 /// @detailed
17 /// from converting conformation_pairings.cc of rosetta++ into mini
18 ///
19 ///
20 ///
21 /// @author Oliver Lange
22 
23 #ifndef INCLUDED_core_fragment_SecondaryStructure_hh
24 #define INCLUDED_core_fragment_SecondaryStructure_hh
25 
26 // Unit Headers
28 
29 // Package Headers
30 
31 // Project Headers
32 #include <core/types.hh>
33 
34 #include <core/pose/Pose.fwd.hh>
35 //#include <protocols/loops/LoopClass.hh>
37 
38 // Utility headers
39 #include <utility/pointer/ReferenceCount.hh>
40 #include <utility/exit.hh>
41 #include <utility/vector1.hh>
42 
43 // ObjexxFCL Headers
44 #include <ObjexxFCL/FArray1D.hh>
45 
46 namespace core {
47 namespace fragment {
48 
49 ///@brief tiny helper class that knows the relative fractions of secondary structure L,H,E
50 ///@detail
51 /// so far these fractions can be computed from a FragSet
52 /// other input strategies are conceivable but not implemented, yet: eg. psipred files, a bunch of poses,
53 
55 public:
56  ///@brief Automatically generated virtual destructor for class deriving directly from ReferenceCount
57  virtual ~SecondaryStructure();
58 
60  total_residue_(0) {
61  }
62 
63  ///@brief c'ctor that creates a SecondaryStructure as an average of several SecondaryStructure objects
65 
66  ///@brief c'stor compute fractions from fragments
68  0, bool bJustCenterResidue = false) :
69  total_residue_(nres) {
70  compute_fractions(frags, bJustCenterResidue);
71  }
72 
73  ///@brief c'stor compute fractions from pose ( well it won't be "fractions" )
75 
76  ///@brief return loop fraction at position
78  runtime_assert( pos <= total_residue_ );
79  return loop_fraction_(pos);
80  }
81 
82  ///@brief return strand fraction at position
84  runtime_assert( pos <= total_residue_ );
85  return strand_fraction_(pos);
86  }
87 
88  ///@brief alias for strand-fraction ...
90  return strand_fraction( pos );
91  }
92 
93  ///@brief helix fraction at position
95  runtime_assert( pos <= total_residue_ );
96  return std::max(0.0, 1.0 - loop_fraction_(pos) - strand_fraction_(pos));
97  }
98 
99  ///@brief confidence at position
101  runtime_assert( pos <= total_residue_ );
102  return confidence_(pos);
103  }
104 
105  ///@brief sets secondary structure probabilities at a given position
108  runtime_assert( pos <= total_residue_ );
109 
110  core::Real s = helix_fraction + loop_fraction + sheet_fraction;
111  if (s != 1.0) {
112  sheet_fraction = sheet_fraction / s;
113  loop_fraction = loop_fraction / s;
114  }
115 
116  loop_fraction_(pos) = (float)loop_fraction;
117  strand_fraction_(pos) = (float) sheet_fraction;
118  confidence_(pos)= (float) confidence;
119  }
120 
121  ///@brief return loop fraction - FArray
122  ObjexxFCL::FArray1D_float const& loop_fraction() const {
123  return loop_fraction_;
124  }
125 
126  ///@brief return strand fraction - FArray
127  ObjexxFCL::FArray1D_float const& strand_fraction() const {
128  return strand_fraction_;
129  }
130 
131  ///@brief returns regions (in loop-class format) that belong to contiguous pieces of ss-structure
132  //loops::Loops compute_ss_regions(
133  // core::Real max_loop_frac = 0.3, core::Size min_length = 2
134  //) const;
135 
136  ///@brief number of residues for which information is available
138  return total_residue_;
139  }
140 
141  ///@brief returns the most probably secstruct at that position
142  char secstruct(core::Size pos) const;
143 
144  ///@brief extends with pure 'L' at end until requested size is reached.
145  void extend(core::Size);
146 
147  ///@brief read from file
148  void read_from_file(std::string fn);
149 
150  ///@brief
151  void show(std::ostream&) const;
152 
153  ///@brief write psipred format
154  void write_psipred_ss2(std::ostream& os, std::string const& sequence) const;
155 
156  ///@brief write psipred format
157  void read_psipred_ss2(std::istream& os);
158 
159  ///@brief write psipred format
161 
162  ///@brief read talos+ format
163  void read_talos_ss(std::istream& os);
164 
165  ///@brief read talos+ format
167 
168 private:
170  bool bJustCenterResidue);
171 
172  ///@brief store loop/strand fractions
173  ObjexxFCL::FArray1D_float loop_fraction_;
174  ObjexxFCL::FArray1D_float strand_fraction_;
175 
176  ///@brief store confidence values: used by talos, but not by psipred
177  ObjexxFCL::FArray1D_float confidence_;
178 
179  ///@brief length of FArrays
181 
182 };
183 
184 /// @brief output operator
185 inline std::ostream & operator <<(std::ostream & os,
186  SecondaryStructure const & t) {
187  t.show(os);
188  return os;
189 }
190 
191 } //core
192 } //fragment
193 
194 #endif
195