36 #include <htslib/hts.h>
37 #include <htslib/vcf.h>
43 namespace population {
49 void VcfInputStream::increment_()
64 char const* cur_chr =
nullptr;
66 if( expect_ordered_ ) {
67 cur_chr = ::bcf_hdr_id2name( record_->header().data(), record_->data()->rid );
68 cur_pos = record_->data()->pos + 1;
72 if( ! record_->read_next( *file_ )) {
78 if( expect_ordered_ ) {
79 assert( cur_chr !=
nullptr );
80 assert( cur_pos > 0 );
83 char const* new_chr = ::bcf_hdr_id2name( record_->header().data(), record_->data()->rid );
84 size_t new_pos = record_->data()->pos + 1;
88 ( strcmp( new_chr, cur_chr ) < 0 ) ||
89 ( strcmp( new_chr, cur_chr ) == 0 && new_pos <= cur_pos )
91 throw std::runtime_error(
92 "Malformed VCF file " + filename_ +
": " +
93 "unordered chromosomes and positions going from " +
94 std::string( cur_chr ) +
":" +
std::to_string( cur_pos ) +
" to " +
104 #endif // htslib guard