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

Utility class to read a SAM/BAM/CRAM file with an appropriate Sam iterator from a stream (e.g. file, stdin, ...) in a for-each loop. More...

#include <sam_reader.h>

Public Member Functions

 SamReader (const std::string &filename)
 reads through all records in a file ( or sam) parsing them into Sam objects More...
 
 SamReader (SamReader &&other)
 
 ~SamReader ()
 closes the file stream if there is one (in case we are reading a sam file) More...
 
 SamReader (const SamReader &)=delete
 a SamReader 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...
 
SamHeader header ()
 

Detailed Description

template<class ITERATOR>
class gamgee::SamReader< ITERATOR >

Utility class to read a SAM/BAM/CRAM file with an appropriate Sam 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 : SamReader<SamIterator>{filename})
do_something_with_sam(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& pair : SamReader<SamPairIterator>{filename})
do_something_with_pair(pair);

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

for (auto& pair : SingleSamReader{filename})
do_something_with_pair(pair);

Constructor & Destructor Documentation

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

reads through all records in a file ( or sam) parsing them into Sam objects

Parameters
filenamethe name of the sam file
template<class ITERATOR >
gamgee::SamReader< ITERATOR >::SamReader ( SamReader< ITERATOR > &&  other)
inline
template<class ITERATOR >
gamgee::SamReader< ITERATOR >::~SamReader ( )
inline

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

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

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

Member Function Documentation

template<class ITERATOR >
ITERATOR gamgee::SamReader< 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::SamReader< 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 >
SamHeader gamgee::SamReader< ITERATOR >::header ( )
inline

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