A toolkit for working with phylogenetic data.
v0.24.0
sequence/functions/entropy.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_SEQUENCE_FUNCTIONS_ENTROPY_H_
2 #define GENESIS_SEQUENCE_FUNCTIONS_ENTROPY_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 #include <cstddef> // size_t
35 #include <type_traits> // underlying_type_t
36 #include <string>
37 
38 namespace genesis {
39 namespace sequence {
40 
41 // =================================================================================================
42 // Forwad Declarations
43 // =================================================================================================
44 
45 class Sequence;
46 class SiteCounts;
47 class SequenceSet;
48 
49 // =================================================================================================
50 // Entropy
51 // =================================================================================================
52 
70 enum class SiteEntropyOptions : unsigned char
71 {
76  kDefault = 0,
77 
106  kIncludeGaps = 1,
107 
123  kWeighted = 2,
124 
136  kNormalized = 4
137 };
138 
150 {
151  using T = std::underlying_type< SiteEntropyOptions >::type;
152  return static_cast< SiteEntropyOptions >(
153  static_cast< T >( lhs ) | static_cast< T >( rhs )
154  );
155 }
156 
169 {
170  using T = std::underlying_type< SiteEntropyOptions >::type;
171  lhs = static_cast< SiteEntropyOptions >(
172  static_cast< T >( lhs ) | static_cast< T >( rhs )
173  );
174  return lhs;
175 }
176 
191 {
192  using T = std::underlying_type< SiteEntropyOptions >::type;
193  return static_cast< T >( lhs ) & static_cast< T >( rhs );
194 }
195 
207 double site_entropy(
208  SiteCounts const& counts,
209  size_t site_index,
211 );
212 
232 double site_information(
233  SiteCounts const& counts,
234  size_t site_index,
235  bool use_small_sample_correction = false,
237 );
238 
246 double absolute_entropy(
247  SiteCounts const& counts,
249 );
250 
268 double averaged_entropy(
269  SiteCounts const& counts,
270  bool only_determined_sites = false,
272 );
273 
274 } // namespace sequence
275 } // namespace genesis
276 
277 #endif // include guard
In addition to the characters of the SiteCounts object, use the undetermined and gap characters...
Store counts of the occurence for certain characters at the sites of Sequences.
Definition: counts.hpp:85
SiteEntropyOptions & operator|=(SiteEntropyOptions &lhs, SiteEntropyOptions rhs)
Or-assignment-operator to combine two SiteEntropyOptionss.
double absolute_entropy(SiteCounts const &counts, SiteEntropyOptions per_site_options)
Return the sum of all site entropies.
bool operator&(SiteEntropyOptions lhs, SiteEntropyOptions rhs)
And-operator to check whether a SiteEntropyOptions is set.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
double site_entropy(SiteCounts const &counts, size_t site_idx, SiteEntropyOptions options)
Calculate the entropy at one site of a SiteCounts object.
Normalize the resulting entropy using the maximum entropy possible.
SiteEntropyOptions
Option flags to refine the calculation of site_entropy().
double site_information(SiteCounts const &counts, size_t site_index, bool use_small_sample_correction, SiteEntropyOptions options)
Calculate the information content at one site of a SiteCounts object.
Weight the entropy using the summed relative frequencies of the characters.
SiteEntropyOptions operator|(SiteEntropyOptions lhs, SiteEntropyOptions rhs)
Or-operator to combine two SiteEntropyOptionss.
Default option, simply calculate the site entropy using the characters used in the SiteCounts object...
double averaged_entropy(SiteCounts const &counts, bool only_determined_sites, SiteEntropyOptions per_site_options)
Return the averaged sum of all site entropies.