1 #ifndef gamgee__variant_reader__
2 #define gamgee__variant_reader__
8 #include "htslib/vcf.h"
43 template<
class ITERATOR>
54 m_variant_file_ptr {bcf_open(filename.empty() ?
"-" : filename.c_str(),
"r")},
62 m_variant_file_ptr {std::move(other.m_variant_file_ptr)},
63 m_variant_header_ptr {std::move(other.m_variant_header_ptr)}
70 bcf_close(m_variant_file_ptr);
85 return ITERATOR{m_variant_file_ptr, m_variant_header_ptr};
103 vcfFile* m_variant_file_ptr;
104 const std::shared_ptr<bcf_hdr_t> m_variant_header_ptr;
VariantReader(VariantReader &&other)
VariantReader should never be copied, but it can be moved around.
Definition: variant_reader.h:61
shared_ptr< bcf_hdr_t > make_shared_variant_header(bcf_hdr_t *bcf_hdr_ptr)
wraps a pre-allocated bcf_hdr_t in a shared_ptr with correct deleter
Definition: hts_memory.cpp:38
VariantHeader header()
returns the variant header of the file being read
Definition: variant_reader.h:100
~VariantReader()
closes the file stream if there is one (in case we are reading a variant file)
Definition: variant_reader.h:69
Utility class to read a VCF/BCF file with an appropriate Variant iterator from a stream (e...
Definition: variant_reader.h:44
ITERATOR end()
creates a ITERATOR with a nullified input stream (needed by for-each loop)
Definition: variant_reader.h:93
ITERATOR begin()
creates a ITERATOR pointing at the start of the input stream (needed by for-each loop) ...
Definition: variant_reader.h:84
VariantReader(const std::string &filename)
reads through all records in a file (vcf or bcf) parsing them into Variant objects ...
Definition: variant_reader.h:53