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::MultipleVariantReader< ITERATOR > Class Template Reference

Utility class to read multiple VCF/BCF files with an appropriate iterator in a for-each loop. More...

#include <multiple_variant_reader.h>

Public Member Functions

 MultipleVariantReader (const std::vector< std::string > &filenames, const bool validate_headers=true)
 enables reading records in multiple files (vcf or bcf) More...
 
 MultipleVariantReader (const std::vector< std::string > &filenames, const bool validate_headers, const std::vector< std::string > &samples, const bool include=true)
 enables reading records in multiple files (vcf or bcf) More...
 
void init_reader (const std::vector< std::string > &filenames, const bool validate_headers)
 helper function for constructors More...
 
 MultipleVariantReader (MultipleVariantReader &&other)=default
 MultipleVariantReader should never be copied, but it can be moved. More...
 
MultipleVariantReaderoperator= (MultipleVariantReader &&other)=default
 
 MultipleVariantReader (const MultipleVariantReader &)=delete
 a MultipleVariantReader cannot be copied safely, as it is iterating over streams. More...
 
MultipleVariantReaderoperator= (const MultipleVariantReader &other)=delete
 
ITERATOR begin () const
 creates an ITERATOR pointing at the start of the input streams (needed by for-each loop) More...
 
ITERATOR end () const
 creates a default ITERATOR (needed by for-each loop) More...
 
const VariantHeader combined_header () const
 returns a combined header for the files being read More...
 
InputOrderedVariantHeaderMergerget_variant_header_merger ()
 return VariantHeaderMerger object More...
 
const std::vector
< std::shared_ptr< bcf_hdr_t > > & 
get_input_vcf_headers () const
 return vector of input VCF headers More...
 

Detailed Description

template<class ITERATOR>
class gamgee::MultipleVariantReader< ITERATOR >

Utility class to read multiple VCF/BCF files with an appropriate iterator in a for-each loop.

Note
result vectors will be ordered arbitrarily per location. There is no guarantee or expectation that the vector will be in the same order (or have the same number) as the inputs. In the common case where all files have exactly the same sites, it is recommended to use a zip iterator over SingleVariantReaders. This will produce a deterministic ordering and will be faster than MultipleVariantReader.

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

for (auto& vector : MultipleVariantReader<MultipleVariantIterator>{filenames})
do_something_with_vector(vector);

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

for (auto& vector : MultipleVariantReader<MultipleVariantIterator>{filename1, stream2})
do_something_with_vector(vector);

Constructor & Destructor Documentation

template<class ITERATOR >
gamgee::MultipleVariantReader< ITERATOR >::MultipleVariantReader ( const std::vector< std::string > &  filenames,
const bool  validate_headers = true 
)
inlineexplicit

enables reading records in multiple files (vcf or bcf)

Parameters
filenamesthe names of the variant files
validate_headersshould we validate that the header files have identical chromosomes? default = true
template<class ITERATOR >
gamgee::MultipleVariantReader< ITERATOR >::MultipleVariantReader ( const std::vector< std::string > &  filenames,
const bool  validate_headers,
const std::vector< std::string > &  samples,
const bool  include = true 
)
inline

enables reading records in multiple files (vcf or bcf)

Parameters
filenamesthe names of the variant files
validate_headersshould we validate that the header files have identical chromosomes? (must specify if using this constructor)
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::MultipleVariantReader< ITERATOR >::MultipleVariantReader ( MultipleVariantReader< ITERATOR > &&  other)
default

MultipleVariantReader should never be copied, but it can be moved.

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

a MultipleVariantReader cannot be copied safely, as it is iterating over streams.

Member Function Documentation

template<class ITERATOR >
ITERATOR gamgee::MultipleVariantReader< ITERATOR >::begin ( ) const
inline

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

Returns
an ITERATOR ready to start parsing the files
template<class ITERATOR >
const VariantHeader gamgee::MultipleVariantReader< ITERATOR >::combined_header ( ) const
inline

returns a combined header for the files being read

Returns
a VariantHeader object constructed by combining the headers of the incmoing files
template<class ITERATOR >
ITERATOR gamgee::MultipleVariantReader< ITERATOR >::end ( ) const
inline

creates a default ITERATOR (needed by for-each loop)

Returns
an ITERATOR that will match the end status of the iterator at the end of the streams
template<class ITERATOR >
const std::vector<std::shared_ptr<bcf_hdr_t> >& gamgee::MultipleVariantReader< ITERATOR >::get_input_vcf_headers ( ) const
inline

return vector of input VCF headers

Returns
vector of input VCF headers
template<class ITERATOR >
InputOrderedVariantHeaderMerger& gamgee::MultipleVariantReader< ITERATOR >::get_variant_header_merger ( )
inline

return VariantHeaderMerger object

Returns
VariantHeaderMerger object for the headers of the vcf files being considered
template<class ITERATOR >
void gamgee::MultipleVariantReader< ITERATOR >::init_reader ( const std::vector< std::string > &  filenames,
const bool  validate_headers 
)
inline

helper function for constructors

Parameters
filenamesthe names of the variant files
validate_headersshould we validate that the header files have identical chromosomes?
template<class ITERATOR >
MultipleVariantReader& gamgee::MultipleVariantReader< ITERATOR >::operator= ( MultipleVariantReader< ITERATOR > &&  other)
default
template<class ITERATOR >
MultipleVariantReader& gamgee::MultipleVariantReader< ITERATOR >::operator= ( const MultipleVariantReader< ITERATOR > &  other)
delete

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