OpenStructure
reduced_statistics.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_QA_REDUCED_STATISTICS_HH
20 #define OST_QA_REDUCED_STATISTICS_HH
21 
22 #include <ost/qa/histogram.hh>
23 #include <ost/qa/amino_acids.hh>
24 namespace ost {
25 
26 namespace mol {
27 
28 class EntityHandle;
29 
30 }
31 namespace qa {
32 
35  ReducedStatOptions(): lower_cutoff(0), upper_cutoff(0),
36  num_angular_bins(0), num_dist_bins(0),
37  sequence_sep(0)
38  { }
39 
40  ReducedStatOptions(Real l_cutoff, Real u_cutoff, uint n_ang_bins,
41  uint n_dist_bins, uint ssep):
42  lower_cutoff(l_cutoff), upper_cutoff(u_cutoff),
43  num_angular_bins(n_ang_bins), num_dist_bins(n_dist_bins),
44  sequence_sep(ssep)
45  { }
51 
52 
53  template <typename DS>
54  void Serialize(DS& ds)
55  {
56  ds & lower_cutoff;
57  ds & upper_cutoff;
58  ds & num_angular_bins;
59  ds & num_dist_bins;
60  ds & sequence_sep;
61  }
62 };
63 
64 
66 typedef boost::shared_ptr<ReducedStatistics> ReducedStatisticsPtr;
67 
68 
69 // parametrized as first amino acid, second amino acid,
70 // calpha-calpha distance, angle
72 
74 public:
75  ReducedStatistics(Real l_cutoff, Real u_cutoff, uint num_ang_bins,
76  uint num_dist_bins, uint ssep):
77  opts_(l_cutoff, u_cutoff, num_ang_bins, num_dist_bins, ssep),
78  histo_(IntegralClassifier(20, 0), IntegralClassifier(20, 0),
79  ContinuousClassifier(num_dist_bins, l_cutoff, u_cutoff),
80  ContinuousClassifier(num_ang_bins, 0.0, M_PI))
81  { }
82 
83  const ReducedStatOptions& GetOptions() const { return opts_; }
84 
86  void Extract(mol::EntityHandle ent);
87 
89  void Extract(mol::EntityView ent);
90 
91  void Save(const String& filename);
92 
93 
94  static ReducedStatisticsPtr Load(const String& filename);
96  template <typename DS>
97  void Serialize(DS& ds);
98 
99  uint64_t GetTotalCount() const;
100 
101  uint64_t GetCount(AminoAcid aa_one, AminoAcid aa_two) const;
102 
103 
104  uint64_t GetCount(AminoAcid aa_one, AminoAcid aa_two, int dist_bin,
105  int ang_bin)
106  {
107  return histo_.Get(ReducedHistogram::IndexType(aa_one, aa_two, dist_bin,
108  ang_bin));
109  }
110 
111  uint64_t GetCount(int dist_bin, int ang_bin) const;
112 private:
113  ReducedStatistics(): opts_(), histo_() {}
114  ReducedStatOptions opts_;
115  ReducedHistogram histo_;
116 };
117 
118 
119 
120 }}
121 
122 
123 #endif