A library for working with phylogenetic and population genetic data.
v0.32.0
variant_input_stream_sources.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_POPULATION_STREAM_VARIANT_INPUT_STREAM_SOURCES_H_
2 #define GENESIS_POPULATION_STREAM_VARIANT_INPUT_STREAM_SOURCES_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 
46 
47 #include <cassert>
48 #include <functional>
49 #include <stdexcept>
50 #include <string>
51 #include <unordered_map>
52 #include <vector>
53 
54 namespace genesis {
55 namespace population {
56 
57 // =================================================================================================
58 // vector
59 // =================================================================================================
60 
72  std::vector<Variant> const& variants
73 );
74 
75 // =================================================================================================
76 // SAM/BAM/CRAM
77 // =================================================================================================
78 
79 // Only available if compiled with htslib
80 #ifdef GENESIS_HTSLIB
81 
97  std::string const& filename,
98  SamVariantInputStream const& reader = SamVariantInputStream{}
99 );
100 
101 #endif // GENESIS_HTSLIB
102 
103 // =================================================================================================
104 // Pileup
105 // =================================================================================================
106 
113  std::string const& filename,
114  SimplePileupReader const& reader = SimplePileupReader{}
115 );
116 
131  std::string const& filename,
132  std::vector<size_t> const& sample_indices,
133  bool inverse_sample_indices = false,
134  SimplePileupReader const& reader = SimplePileupReader{}
135 );
136 
144  std::string const& filename,
145  std::vector<bool> const& sample_filter,
146  SimplePileupReader const& reader = SimplePileupReader{}
147 );
148 
149 // =================================================================================================
150 // Sync
151 // =================================================================================================
152 
158  std::string const& filename
159 );
160 
174  std::string const& filename,
175  std::vector<size_t> const& sample_indices,
176  bool inverse_sample_indices = false
177 );
178 
187  std::string const& filename,
188  std::vector<bool> const& sample_filter
189 );
190 
191 // =================================================================================================
192 // Frequency Table
193 // =================================================================================================
194 
202  std::string const& filename,
203  char separator_char = '\t',
204  FrequencyTableInputStream const& reader = FrequencyTableInputStream{}
205 );
206 
218  std::string const& filename,
219  std::vector<std::string> const& sample_names_filter,
220  bool inverse_sample_names_filter = false,
221  char separator_char = '\t',
222  FrequencyTableInputStream const& reader = FrequencyTableInputStream{}
223 );
224 
225 // =================================================================================================
226 // VCF
227 // =================================================================================================
228 
229 // Only available if compiled with htslib
230 #ifdef GENESIS_HTSLIB
231 
254 {
255  // Types of records to use or discard.
256  bool only_snps = false;
257  bool only_biallelic_snps = false;
258  bool only_filter_pass = false;
259 
260  // Subset the samples.
261  std::vector<std::string> sample_names;
262  bool inverse_sample_names = false;
263 };
264 
280  std::string const& filename,
282 );
283 
295  std::string const& filename,
296  VariantInputStreamFromVcfParams const& params = VariantInputStreamFromVcfParams{},
297  bool use_allelic_depth = false
298 );
299 
300 #endif // GENESIS_HTSLIB
301 
302 } // namespace population
303 } // namespace genesis
304 
305 #endif // include guard
genesis::population::VariantInputStreamFromVcfParams::only_snps
bool only_snps
Definition: variant_input_stream_sources.hpp:256
genesis::population::VariantInputStreamFromVcfParams::only_filter_pass
bool only_filter_pass
Definition: variant_input_stream_sources.hpp:258
genesis::population::VariantInputStreamFromVcfParams::sample_names
std::vector< std::string > sample_names
Definition: variant_input_stream_sources.hpp:261
genesis::population::make_variant_input_stream_from_sam_file
VariantInputStream make_variant_input_stream_from_sam_file(std::string const &filename, SamVariantInputStream const &reader)
Create a VariantInputStream to iterate the contents of a SAM/BAM/CRAM file as Variants.
Definition: variant_input_stream_sources.cpp:188
genesis::population::make_variant_input_stream_from_sync_file
VariantInputStream make_variant_input_stream_from_sync_file(std::string const &filename)
Create a VariantInputStream to iterate the contents of a PoPoolation2 sync file as Variants.
Definition: variant_input_stream_sources.cpp:381
sync_reader.hpp
sync_input_stream.hpp
frequency_table_input_stream.hpp
sample_counts.hpp
simple_pileup_input_stream.hpp
genesis::population::make_variant_input_stream_from_vector
VariantInputStream make_variant_input_stream_from_vector(std::vector< Variant > const &variants)
Create a VariantInputStream to iterate the contents of std::vector containing Variants.
Definition: variant_input_stream_sources.cpp:147
sequence_dict.hpp
generic_input_stream.hpp
reference_genome.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::VariantInputStreamFromVcfParams
Parameters to use when streaming through a VCF file as Variants.
Definition: variant_input_stream_sources.hpp:253
genesis::population::make_variant_input_stream_from_pileup_file
VariantInputStream make_variant_input_stream_from_pileup_file(std::string const &filename, SimplePileupReader const &reader)
Create a VariantInputStream to iterate the contents of a (m)pileup file as Variants.
Definition: variant_input_stream_sources.cpp:302
genesis::population::make_variant_input_stream_from_pool_vcf_file
VariantInputStream make_variant_input_stream_from_pool_vcf_file(std::string const &filename, VariantInputStreamFromVcfParams const &params)
Create a VariantInputStream to iterate the contents of a VCF file as Variants, treating each sample a...
Definition: variant_input_stream_sources.cpp:582
genesis::population::VariantInputStreamFromVcfParams::inverse_sample_names
bool inverse_sample_names
Definition: variant_input_stream_sources.hpp:262
sam_variant_input_stream.hpp
variant_input_stream.hpp
genesis::population::VariantInputStream
utils::GenericInputStream< Variant, VariantInputStreamData > VariantInputStream
Iterate Variants, using a variety of input file formats.
Definition: stream/variant_input_stream.hpp:108
variant.hpp
genesis::population::make_variant_input_stream_from_individual_vcf_file
VariantInputStream make_variant_input_stream_from_individual_vcf_file(std::string const &filename, VariantInputStreamFromVcfParams const &params, bool use_allelic_depth)
Create a VariantInputStream to iterate the contents of a VCF file as Variants, treating each sample a...
Definition: variant_input_stream_sources.cpp:591
vcf_input_stream.hpp
genesis::utils::GenericInputStream
Type erasure for iterators, using std::function to eliminate the underlying input type.
Definition: generic_input_stream.hpp:163
genesis::population::make_variant_input_stream_from_frequency_table_file
VariantInputStream make_variant_input_stream_from_frequency_table_file(std::string const &filename, char separator_char, FrequencyTableInputStream const &reader)
Create a VariantInputStream to iterate the contents of a frequency table file as Variants.
Definition: variant_input_stream_sources.cpp:412
genesis::population::VariantInputStreamFromVcfParams::only_biallelic_snps
bool only_biallelic_snps
Definition: variant_input_stream_sources.hpp:257