A library for working with phylogenetic and population genetic data.
v0.32.0
variant_filter.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_POPULATION_FILTER_VARIANT_FILTER_H_
2 #define GENESIS_POPULATION_FILTER_VARIANT_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 <iosfwd>
40 #include <stdexcept>
41 #include <string>
42 #include <vector>
43 
44 namespace genesis {
45 namespace population {
46 
47 // =================================================================================================
48 // Variant Filter Tag
49 // =================================================================================================
50 
72 {
76  kPassed = 0,
77 
78  // -------------------------------------------
79  // Position
80  // -------------------------------------------
81 
93 
100 
101  // -------------------------------------------
102  // Missing and Invalid
103  // -------------------------------------------
104 
108  kMissing,
109 
115  kNotPassed,
116 
122  kInvalid,
123 
124  // -------------------------------------------
125  // Sample
126  // -------------------------------------------
127 
135 
145 
146  // -------------------------------------------
147  // Numeric
148  // -------------------------------------------
149 
155  kEmpty,
156 
163 
170 
177 
178  // -------------------------------------------
179  // SNP vs Invariant
180  // -------------------------------------------
181 
191  kNotSnp,
192 
202 
216 
225 
234 
235  // -------------------------------------------
236  // Special
237  // -------------------------------------------
238 
247  kEnd
248 };
249 
250 // =================================================================================================
251 // Variant Filter Tag Categories
252 // =================================================================================================
253 
262 {
266  kPassed = 0,
267 
271  kMasked,
272 
277 
282 
286  kNumeric,
287 
291  kInvariant,
292 
296  kEnd
297 };
298 
299 // =================================================================================================
300 // Variant Filter Stats
301 // =================================================================================================
302 
307 
315 
320 
333  VariantFilterStats const& stats
334 );
335 
340  VariantFilterStats const& stats, VariantFilterTagCategory category
341 );
342 
343 // =================================================================================================
344 // Filter Functions
345 // =================================================================================================
346 
347 // --------------------------------------------------------------------------------------
348 // Print variant stats
349 // --------------------------------------------------------------------------------------
350 
354 std::ostream& print_variant_filter_stats(
355  std::ostream& os,
356  VariantFilterStats const& stats,
357  bool verbose = false
358 );
359 
363 std::string print_variant_filter_stats(
364  VariantFilterStats const& stats,
365  bool verbose = false
366 );
367 
368 // --------------------------------------------------------------------------------------
369 // Print category stats
370 // --------------------------------------------------------------------------------------
371 
373  std::ostream& os,
374  VariantFilterCategoryStats const& stats,
375  bool verbose = false
376 );
377 
379  VariantFilterCategoryStats const& stats,
380  bool verbose = false
381 );
382 
384  std::ostream& os,
385  VariantFilterStats const& stats,
386  bool verbose = false
387 ) {
389  os, variant_filter_stats_category_counts( stats ), verbose
390  );
391 }
392 
394  VariantFilterStats const& stats,
395  bool verbose = false
396 ) {
398  variant_filter_stats_category_counts( stats ), verbose
399  );
400 }
401 
402 } // namespace population
403 } // namespace genesis
404 
405 #endif // include guard
genesis::population::VariantFilterTag::kAboveSnpMaxCount
@ kAboveSnpMaxCount
Sum of nucleotides is above VariantFilterNumericalParams::snp_max_count.
genesis::population::VariantFilterTag::kMaskedPosition
@ kMaskedPosition
Position has been masked out from processing.
genesis::population::VariantFilterTagCategory::kNumeric
@ kNumeric
Any of the numeric variant filters failed.
genesis::population::VariantFilterTag::kBelowMinAlleleFreq
@ kBelowMinAlleleFreq
Did not reach minimum allele frequency.
genesis::population::VariantFilterTagCategory::kSamplesFailed
@ kSamplesFailed
Either all or some of the samples failed their respetive filters.
genesis::population::VariantFilterTag::kInvalid
@ kInvalid
Generic indicator that the Variant is invalid.
genesis::population::VariantFilterTag::kNotPassed
@ kNotPassed
Generic indicator that the Variant has not passed a filter.
genesis::population::VariantFilterTagCategory
VariantFilterTagCategory
List of filter categories for a Variant.
Definition: variant_filter.hpp:261
genesis::population::VariantFilterTag::kNotBiallelicSnp
@ kNotBiallelicSnp
SNP position, but not biallelic, i.e., has more than one alternative.
genesis::population::variant_filter_stats_category_counts
VariantFilterCategoryStats variant_filter_stats_category_counts(VariantFilterStats const &stats)
Generate summary counts for a VariantFilterStats counter.
Definition: variant_filter.cpp:103
genesis::population::VariantFilterTagCategory::kInvariant
@ kInvariant
Postion is not a SNP according to the SNP filters.
sample_counts.hpp
genesis::population::VariantFilterTag::kMaskedRegion
@ kMaskedRegion
Position is part of a masked region.
genesis::population::VariantFilterTag::kEmpty
@ kEmpty
All counts across all samples are zero.
genesis::population::VariantFilterTagCategory::kMissingInvalid
@ kMissingInvalid
Position is missing or otherwise invalid.
genesis::population::VariantFilterTagCategory::kPassed
@ kPassed
Variant has passed all filters.
genesis::population::FilterStatus::IntType
uint32_t IntType
Definition: filter_status.hpp:69
filter_stats.hpp
genesis::population::VariantFilterTag::kNotSnp
@ kNotSnp
Invariant position, not a SNP.
filter_status.hpp
genesis::population::VariantFilterTagCategory::kEnd
@ kEnd
End of the enum values.
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::VariantFilterTag::kBelowMinReadDepth
@ kBelowMinReadDepth
Sum of counts across all samples is below the min read depth threshold.
genesis::population::VariantFilterTag::kAboveDeletionsCountLimit
@ kAboveDeletionsCountLimit
Too many deletions at the position.
genesis::population::VariantFilterTag::kNoSamplePassed
@ kNoSamplePassed
None of the SampleCounts of the Variant passed their filters.
genesis::population::VariantFilterTag
VariantFilterTag
List of filters that we apply to a Variant, to indicate whether the Variant passed or not.
Definition: variant_filter.hpp:71
genesis::population::VariantFilterTag::kMissing
@ kMissing
Position is missing in the input data.
genesis::population::VariantFilterTag::kEnd
@ kEnd
End of the enum values.
genesis::population::VariantFilterTagCategory::kMasked
@ kMasked
Position is masked.
genesis::population::print_variant_filter_category_stats
std::ostream & print_variant_filter_category_stats(std::ostream &os, VariantFilterCategoryStats const &stats, bool verbose)
Definition: variant_filter.cpp:269
genesis::population::VariantFilterTag::kNotAllSamplesPassed
@ kNotAllSamplesPassed
Some of the SampleCounts of the Variant did not pass their filters.
genesis::population::print_variant_filter_stats
std::ostream & print_variant_filter_stats(std::ostream &os, VariantFilterStats const &stats, bool verbose)
Print a textual representation of the counts collected.
Definition: variant_filter.cpp:193
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::variant_filter_tag_to_category
VariantFilterTagCategory variant_filter_tag_to_category(VariantFilterTag tag)
For a given tag, return its category tag.
Definition: variant_filter.cpp:63
genesis::population::VariantFilterTag::kBelowSnpMinCount
@ kBelowSnpMinCount
Sum of nucleotides is below VariantFilterNumericalParams::snp_min_count.
genesis::population::VariantFilterTag::kAboveMaxReadDepth
@ kAboveMaxReadDepth
Sum of counts across all samples is above the max read depth threshold.
genesis::population::VariantFilterTag::kPassed
@ kPassed
Variant has passed all filters.