Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
gamgee::VariantReader< ITERATOR > Class Template Reference

Utility class to read a VCF/BCF file with an appropriate Variant iterator from a stream (e.g. file, stdin, ...) in a for-each loop. More...

#include <variant_reader.h>

Public Member Functions

 VariantReader (const std::string &filename)
 reads through all records in a file (vcf or bcf) parsing them into Variant objects More...
 
 VariantReader (VariantReader &&other)
 VariantReader should never be copied, but it can be moved around. More...
 
 ~VariantReader ()
 closes the file stream if there is one (in case we are reading a variant file) More...
 
 VariantReader (const VariantReader &)=delete
 a VariantReader cannot be copied safely, as it is iterating over a stream. More...
 
ITERATOR begin ()
 creates a ITERATOR pointing at the start of the input stream (needed by for-each loop) More...
 
ITERATOR end ()
 creates a ITERATOR with a nullified input stream (needed by for-each loop) More...
 
VariantHeader header ()
 returns the variant header of the file being read More...
 

Detailed Description

template<class ITERATOR>
class gamgee::VariantReader< ITERATOR >

Utility class to read a VCF/BCF file with an appropriate Variant iterator from a stream (e.g. file, stdin, ...) in a for-each loop.

This class is designed to parse the file in for-each loops with the following signature:

for (auto& record : VariantReader<VariantIterator>{filename})
do_something_with_record(record);

You can also use it with the stdin or any other stream by using the default constructor or passing in an empty string for a filename, like so:

for (auto& record : VariantReader<VariantIterator>{filename})
do_something_with_record(record);

Most iterators have aliases defined by this module so you can use it like so:

for (auto& record : SingleVariantReader{filename})
do_something_with_record(record);

Constructor & Destructor Documentation

template<class ITERATOR >
gamgee::VariantReader< ITERATOR >::VariantReader ( const std::string &  filename)
inline

reads through all records in a file (vcf or bcf) parsing them into Variant objects

Parameters
filenamethe name of the variant file
template<class ITERATOR >
gamgee::VariantReader< ITERATOR >::VariantReader ( VariantReader< ITERATOR > &&  other)
inline

VariantReader should never be copied, but it can be moved around.

template<class ITERATOR >
gamgee::VariantReader< ITERATOR >::~VariantReader ( )
inline

closes the file stream if there is one (in case we are reading a variant file)

template<class ITERATOR >
gamgee::VariantReader< ITERATOR >::VariantReader ( const VariantReader< ITERATOR > &  )
delete

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

Member Function Documentation

template<class ITERATOR >
ITERATOR gamgee::VariantReader< ITERATOR >::begin ( )
inline

creates a ITERATOR pointing at the start of the input stream (needed by for-each loop)

Returns
a ITERATOR ready to start parsing the file
template<class ITERATOR >
ITERATOR gamgee::VariantReader< ITERATOR >::end ( )
inline

creates a ITERATOR with a nullified input stream (needed by for-each loop)

Returns
a ITERATOR that will match the end status of the iterator at the end of the stream
template<class ITERATOR >
VariantHeader gamgee::VariantReader< ITERATOR >::header ( )
inline

returns the variant header of the file being read


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