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::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 (const std::vector< std::string > &filenames)
 reads through all records in a file ( or sam) parsing them into Sam objects More...
 
 SamReader (const SamReader &other)=delete
 no copy construction/assignment allowed for iterators and readers More...
 
SamReaderoperator= (const SamIterator &)=delete
 
 SamReader (SamReader &&)=default
 a SamReader move constructor guarantees all objects will have the same state. More...
 
SamReaderoperator= (SamReader &&)=default
 
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 defined 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 ( const std::vector< std::string > &  filenames)
inline

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

Parameters
filenamesa vector containing a single element: the name of the sam file
template<class ITERATOR >
gamgee::SamReader< ITERATOR >::SamReader ( const SamReader< ITERATOR > &  other)
delete

no copy construction/assignment allowed for iterators and readers

template<class ITERATOR >
gamgee::SamReader< ITERATOR >::SamReader ( SamReader< ITERATOR > &&  )
default

a SamReader move constructor guarantees all objects will have the same state.

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
template<class ITERATOR >
SamReader& gamgee::SamReader< ITERATOR >::operator= ( const SamIterator )
delete
template<class ITERATOR >
SamReader& gamgee::SamReader< ITERATOR >::operator= ( SamReader< ITERATOR > &&  )
default

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