Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
gamgee::IndexedVariantIterator Class Reference

#include <indexed_variant_iterator.h>

Inheritance diagram for gamgee::IndexedVariantIterator:
gamgee::VariantIterator

Public Member Functions

 IndexedVariantIterator ()
 creates an empty iterator (used for the end() method) More...
 
 IndexedVariantIterator (const std::shared_ptr< htsFile > &file_ptr, const std::shared_ptr< hts_idx_t > &index_ptr, const std::shared_ptr< bcf_hdr_t > &header_ptr, const std::vector< std::string > &interval_list=all_intervals)
 initializes a new iterator based on a file, an index, a header, and a vector of intervals More...
 
 IndexedVariantIterator (const IndexedVariantIterator &other)=delete
 an IndexedVariantIterator cannot be copied safely, as it is iterating over a stream. More...
 
IndexedVariantIteratoroperator= (const IndexedVariantIterator &other)=delete
 
 IndexedVariantIterator (IndexedVariantIterator &&other)=default
 an IndexedVariantIterator can be moved More...
 
IndexedVariantIteratoroperator= (IndexedVariantIterator &&other)=default
 
bool operator!= (const IndexedVariantIterator &rhs)
 inequality operator (needed by for-each loop) More...
 
- Public Member Functions inherited from gamgee::VariantIterator
 VariantIterator ()=default
 creates an empty iterator (used for the end() method) More...
 
 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, ...) More...
 
 VariantIterator (VariantIterator &&)=default
 a VariantIterator move constructor guarantees all objects will have the same state. More...
 
VariantIteratoroperator= (VariantIterator &&)=default
 a VariantIterator move assignment operator guarantees all objects will have the same state. More...
 
 VariantIterator (const VariantIterator &)=delete
 a VariantIterator cannot be copy-constructed. More...
 
VariantIteratoroperator= (const VariantIterator &)=delete
 a VariantIterator cannot be copied. More...
 
bool operator!= (const VariantIterator &rhs) const
 inequality operator (needed by for-each loop) More...
 
Variantoperator* ()
 dereference operator (needed by for-each loop) More...
 
Variantoperator++ ()
 pre-fetches the next record and tests for end of file More...
 
bool empty () const
 returns whether the iterator has no additional records More...
 

Static Public Attributes

static const std::vector
< std::string > 
all_intervals = {"."}
 

Protected Member Functions

void fetch_next_record () override
 fetches next Variant record into existing htslib memory without making a copy More...
 

Additional Inherited Members

- Protected Attributes inherited from gamgee::VariantIterator
std::shared_ptr< htsFilem_variant_file_ptr
 pointer to the vcf/bcf file More...
 
std::shared_ptr< bcf_hdr_tm_variant_header_ptr
 pointer to the variant header More...
 
std::shared_ptr< bcf1_tm_variant_record_ptr
 pointer to the internal structure of the variant record. Useful to only allocate it once. More...
 
Variant m_variant_record
 temporary record to hold between fetch (operator++) and serve (operator*) More...
 

Constructor & Destructor Documentation

gamgee::IndexedVariantIterator::IndexedVariantIterator ( )

creates an empty iterator (used for the end() method)

gamgee::IndexedVariantIterator::IndexedVariantIterator ( const std::shared_ptr< htsFile > &  file_ptr,
const std::shared_ptr< hts_idx_t > &  index_ptr,
const std::shared_ptr< bcf_hdr_t > &  header_ptr,
const std::vector< std::string > &  interval_list = all_intervals 
)

initializes a new iterator based on a file, an index, a header, and a vector of intervals

Parameters
file_ptrshared pointer to a BCF file opened via the bcf_open() macro from htslib
index_ptrshared pointer to a BCF file index (CSI) created with the bcf_index_load() macro from htslib
header_ptrshared pointer to a BCF file header created with the bcf_hdr_read() macro from htslib
interval_listvector of intervals represented by strings
gamgee::IndexedVariantIterator::IndexedVariantIterator ( const IndexedVariantIterator other)
delete

an IndexedVariantIterator cannot be copied safely, as it is iterating over a stream.

gamgee::IndexedVariantIterator::IndexedVariantIterator ( IndexedVariantIterator &&  other)
default

an IndexedVariantIterator can be moved

Member Function Documentation

void gamgee::IndexedVariantIterator::fetch_next_record ( )
overrideprotectedvirtual

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 from gamgee::VariantIterator.

bool gamgee::IndexedVariantIterator::operator!= ( const IndexedVariantIterator rhs)

inequality operator (needed by for-each loop)

Parameters
rhsthe other IndexedVariantIterator to compare to
Returns
whether or not the two iterators are the same (e.g. have the same input file on the same status and the same intervals)
IndexedVariantIterator& gamgee::IndexedVariantIterator::operator= ( const IndexedVariantIterator other)
delete
IndexedVariantIterator& gamgee::IndexedVariantIterator::operator= ( IndexedVariantIterator &&  other)
default

Member Data Documentation

const std::vector< std::string > gamgee::IndexedVariantIterator::all_intervals = {"."}
static

The documentation for this class was generated from the following files: