A library for working with phylogenetic and population genetic data.
v0.32.0
sample_counts_filter.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_POPULATION_FILTER_SAMPLE_COUNTS_FILTER_H_
2 #define GENESIS_POPULATION_FILTER_SAMPLE_COUNTS_FILTER_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 <lucas.czech@sund.ku.dk>
23  University of Copenhagen, Globe Institute, Section for GeoGenetics
24  Oster Voldgade 5-7, 1350 Copenhagen K, Denmark
25 */
26 
38 
39 #include <array>
40 #include <cassert>
41 #include <iosfwd>
42 #include <stdexcept>
43 #include <string>
44 #include <type_traits>
45 #include <vector>
46 
47 namespace genesis {
48 namespace population {
49 
50 // =================================================================================================
51 // SampleCounts Filter Tag
52 // =================================================================================================
53 
55 {
59  kPassed = 0,
60 
61  // -------------------------------------------
62  // Position
63  // -------------------------------------------
64 
76 
83 
84  // -------------------------------------------
85  // Missing and Invalid
86  // -------------------------------------------
87 
91  kMissing,
92 
99  kNotPassed,
100 
107  kInvalid,
108 
109  // -------------------------------------------
110  // Numeric
111  // -------------------------------------------
112 
116  kEmpty,
117 
124 
131 
138 
144  kNotSnp,
145 
152 
153  // -------------------------------------------
154  // Special
155  // -------------------------------------------
156 
157  kEnd
158 };
159 
160 // =================================================================================================
161 // SampleCounts Filter Tag Categories
162 // =================================================================================================
163 
172 {
176  kPassed = 0,
177 
181  kMasked,
182 
187 
191  kNumeric,
192 
196  kEnd
197 };
198 
199 // =================================================================================================
200 // SampleCounts Filter Policy
201 // =================================================================================================
202 
212 {
213  kAll,
215 };
216 
217 // =================================================================================================
218 // SampleCounts Filter Stats
219 // =================================================================================================
220 
225 
233 
238 
251  SampleCountsFilterStats const& stats
252 );
253 
259 );
260 
261 // =================================================================================================
262 // Filter Functions
263 // =================================================================================================
264 
265 // --------------------------------------------------------------------------------------
266 // Print sample stats
267 // --------------------------------------------------------------------------------------
268 
273  std::ostream& os,
274  SampleCountsFilterStats const& stats,
275  bool verbose = false
276 );
277 
282  SampleCountsFilterStats const& stats,
283  bool verbose = false
284 );
285 
286 // --------------------------------------------------------------------------------------
287 // Print category stats
288 // --------------------------------------------------------------------------------------
289 
291  std::ostream& os,
292  SampleCountsFilterCategoryStats const& stats,
293  bool verbose = false
294 );
295 
297  SampleCountsFilterCategoryStats const& stats,
298  bool verbose = false
299 );
300 
302  std::ostream& os,
303  SampleCountsFilterStats const& stats,
304  bool verbose = false
305 ) {
307  os, sample_counts_filter_stats_category_counts( stats ), verbose
308  );
309 }
310 
312  SampleCountsFilterStats const& stats,
313  bool verbose = false
314 ) {
317  );
318 }
319 
320 } // namespace population
321 } // namespace genesis
322 
323 #endif // include guard
genesis::population::SampleCountsFilterTag::kAboveDeletionsCountLimit
@ kAboveDeletionsCountLimit
Too many deletions at the position.
genesis::population::SampleCountsFilterTag::kMaskedRegion
@ kMaskedRegion
Position is part of a masked region.
genesis::population::SampleCountsFilterTagCategory::kPassed
@ kPassed
SampleCounts has passed all filters.
genesis::population::SampleCountsFilterPolicy
SampleCountsFilterPolicy
Policy helper to decide how to treat filtered SampleCounts.
Definition: sample_counts_filter.hpp:211
genesis::population::SampleCountsFilterTagCategory::kNumeric
@ kNumeric
Any of the numeric variant filters failed.
sample_counts.hpp
genesis::population::SampleCountsFilterPolicy::kAll
@ kAll
genesis::population::print_sample_counts_filter_stats
std::ostream & print_sample_counts_filter_stats(std::ostream &os, SampleCountsFilterStats const &stats, bool verbose)
Print a textual representation of the counts collected.
Definition: sample_counts_filter.cpp:169
genesis::population::SampleCountsFilterTag::kAboveMaxReadDepth
@ kAboveMaxReadDepth
Sum of counts across all nucleotide counts is above the max read depth threshold.
genesis::population::FilterStatus::IntType
uint32_t IntType
Definition: filter_status.hpp:69
filter_stats.hpp
genesis::population::SampleCountsFilterTagCategory
SampleCountsFilterTagCategory
List of filter categories for a SampleCounts.
Definition: sample_counts_filter.hpp:171
genesis::population::sample_counts_filter_stats_category_counts
SampleCountsFilterCategoryStats sample_counts_filter_stats_category_counts(SampleCountsFilterStats const &stats)
Generate summary counts for a SampleCountsFilterStats counter.
Definition: sample_counts_filter.cpp:95
filter_status.hpp
genesis::population::SampleCountsFilterTag::kBelowMinReadDepth
@ kBelowMinReadDepth
Sum of counts across all nucleotide counts is below the min read depth threshold.
genesis::population::SampleCountsFilterTag::kPassed
@ kPassed
Sample has passed all filters.
genesis::population::print_sample_counts_filter_category_stats
std::ostream & print_sample_counts_filter_category_stats(std::ostream &os, SampleCountsFilterCategoryStats const &stats, bool verbose)
Definition: sample_counts_filter.cpp:230
genesis::population::SampleCountsFilterTag::kEmpty
@ kEmpty
Zero nucleotide counts, after zeroing out counts based on the min_count and max_count.
genesis::population::SampleCountsFilterTag::kInvalid
@ kInvalid
Generic indicator that the sample is invalid.
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::SampleCountsFilterPolicy::kOnlyPassing
@ kOnlyPassing
genesis::population::SampleCountsFilterTag::kNotPassed
@ kNotPassed
Generic indicator that the sample has not passed a filter.
genesis::population::SampleCountsFilterTag::kEnd
@ kEnd
genesis::population::SampleCountsFilterTag::kNotSnp
@ kNotSnp
Invariant position, not a SNP.
genesis::population::SampleCountsFilterTagCategory::kMasked
@ kMasked
Position is masked.
genesis::population::FilterStats
Counts of how many entries with a particular Filter Tag occured in some data.
Definition: filter_stats.hpp:61
variant.hpp
genesis::population::SampleCountsFilterTagCategory::kEnd
@ kEnd
End of the enum values.
genesis::population::SampleCountsFilterTagCategory::kMissingInvalid
@ kMissingInvalid
Position is missing or otherwise invalid.
genesis::population::SampleCountsFilterTag
SampleCountsFilterTag
Definition: sample_counts_filter.hpp:54
genesis::population::SampleCountsFilterTag::kMaskedPosition
@ kMaskedPosition
Position has been masked out from processing.
genesis::population::SampleCountsFilterTag::kMissing
@ kMissing
Position is missing in the input data.
genesis::population::sample_counts_filter_tag_to_category
SampleCountsFilterTagCategory sample_counts_filter_tag_to_category(SampleCountsFilterTag tag)
For a given tag, return its category tag.
Definition: sample_counts_filter.cpp:62
genesis::population::SampleCountsFilterTag::kNotBiallelicSnp
@ kNotBiallelicSnp
SNP position, but not biallelic, i.e., has more than one alternative.