A library for working with phylogenetic and population genetic data.
v0.32.0
FastxInputStream< Reader > Class Template Reference

#include <genesis/sequence/formats/fastx_input_stream.hpp>

Detailed Description

template<class Reader>
class genesis::sequence::FastxInputStream< Reader >

Stream through an input source and parse it as Fasta or Fastq sequences.

This class allows to iterate over an input source, interpreting it as Fasta or Fastq sequences, and yielding one such sequence per iteration step. This is useful for processing large files without having to keep them fully in memory.

Example:

for( auto const& s : FastaInputStream( from_file( "/path/to/large_file.fastq" ))) {
    std::cout << s.length() << "\n";
}

Use functions such as utils::from_file() and utils::from_string() to conveniently get an input source that can be used here.

See FastaReader and FastqReader for a description of the expected formats. In order to change the reading behaviour, a reader object can be handed over from which the settings are copied. The reader instance can also be modified before starting the iteration, if needed.

Thread safety: No thread safety. The common use case for this iterator is to loop over a file. Thus, guarding induces unnecessary overhead. If multiple threads read from this iterator, both dereferencing and incrementing need to be guarded.

Definition at line 55 of file fastx_input_stream.hpp.

Public Member Functions

 FastxInputStream ()
 Create a default instance, with no input. More...
 
 FastxInputStream (self_type &&)=default
 
 FastxInputStream (self_type const &)=default
 
 FastxInputStream (std::shared_ptr< utils::BaseInputSource > source)
 Create an instance that reads from an input source, using a default FastaReader or FastqReader. More...
 
 FastxInputStream (std::shared_ptr< utils::BaseInputSource > source, Reader const &reader)
 Create an instance that reads from an input source, using the settings of a given FastaReader oder FastqReader. More...
 
 ~FastxInputStream ()=default
 
Iterator begin () const
 
Iterator end () const
 
std::shared_ptr< utils::BaseInputSourceinput_source () const
 
self_typeoperator= (self_type &&)=default
 
self_typeoperator= (self_type const &)=default
 
Reader & reader ()
 
Reader const & reader () const
 

Public Types

using difference_type = std::ptrdiff_t
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type *
 
using reference = value_type &
 
using self_type = FastxInputStream
 
using value_type = Sequence
 

Classes

class  Iterator
 Internal iterator over the sequences. More...
 

Constructor & Destructor Documentation

◆ FastxInputStream() [1/5]

FastxInputStream ( )
inline

Create a default instance, with no input.

Definition at line 279 of file fastx_input_stream.hpp.

◆ FastxInputStream() [2/5]

FastxInputStream ( std::shared_ptr< utils::BaseInputSource source)
inlineexplicit

Create an instance that reads from an input source, using a default FastaReader or FastqReader.

Definition at line 288 of file fastx_input_stream.hpp.

◆ FastxInputStream() [3/5]

FastxInputStream ( std::shared_ptr< utils::BaseInputSource source,
Reader const &  reader 
)
inline

Create an instance that reads from an input source, using the settings of a given FastaReader oder FastqReader.

Definition at line 299 of file fastx_input_stream.hpp.

◆ ~FastxInputStream()

~FastxInputStream ( )
default

◆ FastxInputStream() [4/5]

FastxInputStream ( self_type const &  )
default

◆ FastxInputStream() [5/5]

FastxInputStream ( self_type &&  )
default

Member Function Documentation

◆ begin()

Iterator begin ( ) const
inline

Definition at line 319 of file fastx_input_stream.hpp.

◆ end()

Iterator end ( ) const
inline

Definition at line 324 of file fastx_input_stream.hpp.

◆ input_source()

std::shared_ptr<utils::BaseInputSource> input_source ( ) const
inline

Definition at line 333 of file fastx_input_stream.hpp.

◆ operator=() [1/2]

self_type& operator= ( self_type &&  )
default

◆ operator=() [2/2]

self_type& operator= ( self_type const &  )
default

◆ reader() [1/2]

Reader& reader ( )
inline

Definition at line 338 of file fastx_input_stream.hpp.

◆ reader() [2/2]

Reader const& reader ( ) const
inline

Definition at line 343 of file fastx_input_stream.hpp.

Member Typedef Documentation

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 101 of file fastx_input_stream.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 102 of file fastx_input_stream.hpp.

◆ pointer

using pointer = value_type*

Definition at line 99 of file fastx_input_stream.hpp.

◆ reference

Definition at line 100 of file fastx_input_stream.hpp.

◆ self_type

Definition at line 97 of file fastx_input_stream.hpp.

◆ value_type

Definition at line 98 of file fastx_input_stream.hpp.


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