1 #ifndef GENESIS_POPULATION_WINDOW_VCF_WINDOW_H_
2 #define GENESIS_POPULATION_WINDOW_VCF_WINDOW_H_
47 namespace population {
72 template<
class Data,
class Accumulator = EmptyAccumulator>
75 std::string
const& vcf_file,
76 std::function<Data(
VcfRecord const& )> conversion,
77 std::function<
bool(
VcfRecord const& )> condition = {}
79 size_t current_chr_len = 0;
80 for(
auto record = VcfInputStream( vcf_file ); record; ++record ) {
83 if( condition && ! condition( *record )) {
88 auto const rec_chromosome = record->get_chromosome();
93 if( rec_chromosome != generator.
chromosome() ) {
97 current_chr_len = record->header().get_chromosome_length( rec_chromosome );
99 record->header().get_chromosome_values( rec_chromosome ).count(
"length") == 0 ||
101 record->header().get_chromosome_values( rec_chromosome ).at(
"length")
108 if( ! generator.
empty() ) {
116 if( current_chr_len == 0 ) {
125 assert( record->header().get_chromosome_length( rec_chromosome ) == current_chr_len );
129 generator.
enqueue( rec_chromosome, record->get_position(), conversion( *record ));
134 if( current_chr_len == 0 ) {
144 #endif // htslib guard
145 #endif // include guard