Utility class to enable for-each style iteration in the VariantReader class.
More...
#include <variant_iterator.h>
Utility class to enable for-each style iteration in the VariantReader class.
gamgee::VariantIterator::VariantIterator |
( |
| ) |
|
|
default |
creates an empty iterator (used for the end() method)
gamgee::VariantIterator::VariantIterator |
( |
const std::shared_ptr< htsFile > & |
variant_file_ptr, |
|
|
const std::shared_ptr< bcf_hdr_t > & |
variant_header_ptr |
|
) |
| |
initializes a new iterator based on an input stream (e.g. a vcf/bcf file, stdin, ...)
- Parameters
-
variant_file_ptr | shared pointer to a vcf/bcf file opened via the bcf_open() macro from htslib |
variant_header_ptr | shared pointer to a vcf/bcf file header created with the bcf_hdr_read() macro from htslib |
a VariantIterator move constructor guarantees all objects will have the same state.
bool gamgee::VariantIterator::empty |
( |
| ) |
const |
returns whether the iterator has no additional records
- Returns
- true if the the iterator has no additional records
void gamgee::VariantIterator::fetch_next_record |
( |
| ) |
|
|
protectedvirtual |
fetches next Variant record into existing htslib memory without making a copy
pre-fetches the next variant record
- Warning
- we're reusing the existing htslib memory, so users should be aware that all objects from the previous iteration are now stale unless a deep copy has been performed
Reimplemented in gamgee::IndexedVariantIterator.
bool gamgee::VariantIterator::operator!= |
( |
const VariantIterator & |
rhs | ) |
const |
inequality operator (needed by for-each loop)
- Parameters
-
- Returns
- whether or not the two iterators are the same (e.g. have the same input stream on the same status)
Variant & gamgee::VariantIterator::operator* |
( |
| ) |
|
dereference operator (needed by for-each loop)
- Returns
- a persistent Variant object independent from the iterator (a copy of the iterator's object)
Variant & gamgee::VariantIterator::operator++ |
( |
| ) |
|
pre-fetches the next record and tests for end of file
- Returns
- a reference to the object (it can be const& because this return value should only be used by the for-each loop to check for the eof)
a VariantIterator move assignment operator guarantees all objects will have the same state.
std::shared_ptr<htsFile> gamgee::VariantIterator::m_variant_file_ptr |
|
protected |
pointer to the vcf/bcf file
std::shared_ptr<bcf_hdr_t> gamgee::VariantIterator::m_variant_header_ptr |
|
protected |
pointer to the variant header
Variant gamgee::VariantIterator::m_variant_record |
|
protected |
temporary record to hold between fetch (operator++) and serve (operator*)
std::shared_ptr<bcf1_t> gamgee::VariantIterator::m_variant_record_ptr |
|
protected |
pointer to the internal structure of the variant record. Useful to only allocate it once.
The documentation for this class was generated from the following files: