A library for working with phylogenetic and population genetic data.
v0.32.0
sample_counts.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_POPULATION_SAMPLE_COUNTS_H_
2 #define GENESIS_POPULATION_SAMPLE_COUNTS_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2024 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 <lczech@carnegiescience.edu>
23  Department of Plant Biology, Carnegie Institution For Science
24  260 Panama Street, Stanford, CA 94305, USA
25 */
26 
35 
36 #include <array>
37 #include <string>
38 #include <vector>
39 
40 namespace genesis {
41 namespace population {
42 
43 // =================================================================================================
44 // Sample Counts
45 // =================================================================================================
46 
57 {
61  using size_type = size_t;
62 
67 
72 
77 
82 
87 
92 
97 
98 };
99 
100 // =================================================================================================
101 // Sorted Sample Counts
102 // =================================================================================================
103 
111 {
115  struct BaseCount
116  {
117  char base;
118  size_t count;
119 
121  : base('N')
122  , count(0)
123  {}
124 
125  BaseCount( char b, size_t c )
126  : base(b)
127  , count(c)
128  {}
129  };
130 
131  SortedSampleCounts() = default;
132 
134  char b0, size_t c0, char b1, size_t c1, char b2, size_t c2, char b3, size_t c3
135  )
136  : data( std::array<BaseCount, 4>{{
137  BaseCount{ b0, c0 }, BaseCount{ b1, c1 }, BaseCount{ b2, c2 }, BaseCount{ b3, c3 },
138  }})
139  {}
140 
141  BaseCount& operator[]( size_t index )
142  {
143  return data[index];
144  }
145 
146  BaseCount const& operator[]( size_t index ) const
147  {
148  return data[index];
149  }
150 
151  std::array<BaseCount, 4> data;
152 };
153 
154 } // namespace population
155 } // namespace genesis
156 
157 #endif // include guard
genesis::population::SortedSampleCounts::BaseCount::BaseCount
BaseCount()
Definition: sample_counts.hpp:120
genesis::population::SortedSampleCounts::BaseCount::BaseCount
BaseCount(char b, size_t c)
Definition: sample_counts.hpp:125
genesis::population::SampleCounts
One set of nucleotide sample counts, for example for a given sample that represents a pool of sequenc...
Definition: sample_counts.hpp:56
genesis::population::SortedSampleCounts::BaseCount
Combination of a nucleotide base and its count.
Definition: sample_counts.hpp:115
genesis::population::SampleCounts::a_count
size_type a_count
Count of all A nucleotides that are present in the sample.
Definition: sample_counts.hpp:66
genesis::population::FilterStatus
Tag class to assign a filter status to a Variant or SampleCounts.
Definition: filter_status.hpp:65
genesis::population::SampleCounts::status
FilterStatus status
Status to indicate whether any applied filters failed to pass.
Definition: sample_counts.hpp:96
genesis::population::SortedSampleCounts::data
std::array< BaseCount, 4 > data
Definition: sample_counts.hpp:151
genesis::population::SampleCounts::t_count
size_type t_count
Count of all T nucleotides that are present in the sample.
Definition: sample_counts.hpp:81
genesis::population::SortedSampleCounts::BaseCount::count
size_t count
Definition: sample_counts.hpp:118
genesis::population::SortedSampleCounts
Ordered array of sample counts for the four nucleotides.
Definition: sample_counts.hpp:110
genesis::population::SampleCounts::n_count
size_type n_count
Count of all N (undetermined/any) nucleotides that are present in the sample.
Definition: sample_counts.hpp:86
genesis::population::SampleCounts::c_count
size_type c_count
Count of all C nucleotides that are present in the sample.
Definition: sample_counts.hpp:71
filter_status.hpp
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::population::SortedSampleCounts::SortedSampleCounts
SortedSampleCounts(char b0, size_t c0, char b1, size_t c1, char b2, size_t c2, char b3, size_t c3)
Definition: sample_counts.hpp:133
genesis::population::SortedSampleCounts::SortedSampleCounts
SortedSampleCounts()=default
genesis::population::SortedSampleCounts::BaseCount::base
char base
Definition: sample_counts.hpp:117
genesis::population::SampleCounts::d_count
size_type d_count
Count of all deleted (*) nucleotides that are present in the sample.
Definition: sample_counts.hpp:91
genesis::population::SampleCounts::size_type
size_t size_type
Public alias for the size type that the class uses to store its counts.
Definition: sample_counts.hpp:61
genesis::population::SortedSampleCounts::operator[]
BaseCount const & operator[](size_t index) const
Definition: sample_counts.hpp:146
genesis::population::SortedSampleCounts::operator[]
BaseCount & operator[](size_t index)
Definition: sample_counts.hpp:141
genesis::population::SampleCounts::g_count
size_type g_count
Count of all G nucleotides that are present in the sample.
Definition: sample_counts.hpp:76