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 | 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 (const std::vector< std::string > &filenames)
 reads through all records in a file (vcf or bcf) parsing them into Variant objects More...
 
 VariantReader (const std::string &filename, const std::vector< std::string > &samples, const bool include=true)
 reads through all records in a file (vcf or bcf) parsing them into Variant objects but only including the selected samples. To create a sites only file, simply pass an empty vector of samples. More...
 
 VariantReader (const std::vector< std::string > &filenames, const std::vector< std::string > &samples, const bool include=true)
 reads through all records in a file (vcf or bcf) parsing them into Variant objects but only including the selected samples. To create a sites only file, simply pass an empty vector of samples. More...
 
 VariantReader (const VariantReader &other)=delete
 a VariantReader cannot be copied safely, as it is iterating over a stream. More...
 
VariantReaderoperator= (const VariantReader &other)=delete
 
 VariantReader (VariantReader &&other)=default
 a VariantReader can be moved More...
 
VariantReaderoperator= (VariantReader &&other)=default
 
ITERATOR begin () const
 creates a ITERATOR pointing at the start of the input stream (needed by for-each loop) More...
 
ITERATOR end () const
 creates a ITERATOR with a nullified input stream (needed by for-each loop) More...
 
VariantHeader header () const
 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)
inlineexplicit

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 ( const std::vector< std::string > &  filenames)
inlineexplicit

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

Parameters
filenamesa vector containing a single element: the name of the variant file
template<class ITERATOR >
gamgee::VariantReader< ITERATOR >::VariantReader ( const std::string &  filename,
const std::vector< std::string > &  samples,
const bool  include = true 
)
inline

reads through all records in a file (vcf or bcf) parsing them into Variant objects but only including the selected samples. To create a sites only file, simply pass an empty vector of samples.

Parameters
filenamethe name of the variant file
samplesthe list of samples you want included/excluded from your iteration
includewhether you want these samples to be included or excluded from your iteration. default = true (include)
template<class ITERATOR >
gamgee::VariantReader< ITERATOR >::VariantReader ( const std::vector< std::string > &  filenames,
const std::vector< std::string > &  samples,
const bool  include = true 
)
inline

reads through all records in a file (vcf or bcf) parsing them into Variant objects but only including the selected samples. To create a sites only file, simply pass an empty vector of samples.

Parameters
filenamesa vector containing a single element: the name of the variant file
samplesthe list of samples you want included/excluded from your iteration
includewhether you want these samples to be included or excluded from your iteration. default = true (include)
template<class ITERATOR >
gamgee::VariantReader< ITERATOR >::VariantReader ( const VariantReader< ITERATOR > &  other)
delete

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

template<class ITERATOR >
gamgee::VariantReader< ITERATOR >::VariantReader ( VariantReader< ITERATOR > &&  other)
default

a VariantReader can be moved

Member Function Documentation

template<class ITERATOR >
ITERATOR gamgee::VariantReader< ITERATOR >::begin ( ) const
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 ( ) const
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 ( ) const
inline

returns the variant header of the file being read

template<class ITERATOR >
VariantReader& gamgee::VariantReader< ITERATOR >::operator= ( const VariantReader< ITERATOR > &  other)
delete
template<class ITERATOR >
VariantReader& gamgee::VariantReader< ITERATOR >::operator= ( VariantReader< ITERATOR > &&  other)
default

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