Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DistanceHistogram.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 core/scoring/saxs/FormFactor.hh
11 /// @brief Collects histogram of distances between atoms of given SAXS-types, e.g. distances between ARG-CEN and TRP-CEN
12 /// @detailed The histogram is used in fast SAXS spectrum evaluation (slightly approximate)
13 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
14 
15 #ifndef INCLUDED_core_scoring_saxs_DistanceHistogram_hh
16 #define INCLUDED_core_scoring_saxs_DistanceHistogram_hh
17 
19 
20 // utility headers
21 #include <core/types.hh>
22 #include <utility/pointer/owning_ptr.hh>
23 #include <utility/pointer/ReferenceCount.hh>
24 
25 // AUTO-REMOVED #include <numeric/interpolation/spline/Interpolator.hh>
26 
27 // AUTO-REMOVED #include <string>
28 // AUTO-REMOVED #include <iostream>
29 
30 #include <utility/vector1.hh>
31 
32 
33 namespace core {
34 namespace scoring {
35 namespace saxs {
36 
37 /// @brief
39 public:
40 
41  /// @brief Create a histogram that collects distances between two predefined atom types
42  DistanceHistogram(void) : factor_(10.0), max_dist_(300),h_(10*300) { }
43 
44  /// @brief Returns the number of counts for a given distance
45  Size operator()(Real distance) const { return h_[(Size)(distance*factor_)]; }
46 
47  /// @brief Returns the number of counts for a given distance
48  Size get(Real distance) const { return h_[(Size)(distance*factor_)]; }
49 
50  /// @brief Returns the number of counts for a given bin
51  Size get(Size bin) const { return h_[bin]; }
52 
53  /// @brief tells waht distance falls into a certain bin
54  Real distance(Size bin) const { return bin/factor_; }
55 
56  /// @brief Adds a distance observation to the histogram
57  void inline insert(Real distance) {
58  Size b = (Size)(distance*factor_);
60  if ( b>0)
61  h_[b] ++;
62  }
63 
64  /// @brief Returns the size of this histogram
65  Size size() { return h_.size(); }
66 
67  /// @brief Clears this histogram by filling each cell with 0.0
68  void zeros() { for(Size i=1;i<=h_.size();i++) h_[i] = 0; last_nonempty_bin_ = 0; }
69 
70  /// @brief Returns the total number of counts in this histogram
71  Size total() const {
72  Size cnt = 0;
73  for(Size i=1;i<=h_.size();i++)
74  cnt+=h_[i];
75  return cnt;
76  }
77 
79 private:
84 };
85 
86 } // core
87 } // scoring
88 } // saxs
89 
90 #endif /* INCLUDED_core_scoring_saxs_DistanceHistogram_HH */