A toolkit for working with phylogenetic data.
v0.24.0
FastqInputIterator Class Reference

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

Detailed Description

Iterate an input source and parse it as Fastq sequences.

This class allows to iterate over an input source, interpreting it as 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 : FastqInputIterator( from_file( "/path/to/large_file.fastq" ))) {
    std::cout << s.length() << "\n";
}

Alternatively, the following also works:

auto it = FastqInputIterator( from_file( "/path/to/large_file.fastq" ));
while( it ) {
    std::cout << it->length() << "\n";
    ++it;
}

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

See FastqReader for a description of the expected format. In order to change the reading behaviour, a FastqReader object can be handed over from which the settings are copied.

The copy constructur copies a pointer to the underlying source. Thus, when advancing the copy to the next Sequence, the original "skips" this Sequence, as the source then is at the next one.

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 87 of file fastq_input_iterator.hpp.

Public Member Functions

 FastqInputIterator ()
 Create a default instance, with no input. More...
 
 FastqInputIterator (std::shared_ptr< utils::BaseInputSource > source)
 Create an instance that reads from an input source, using a default FastqReader. More...
 
 FastqInputIterator (std::shared_ptr< utils::BaseInputSource > source, FastqReader const &settings)
 Create an instance that reads from an input source, using the settings of a given FastqReader. More...
 
 FastqInputIterator (self_type const &)=default
 
 FastqInputIterator (self_type &&)=default
 
 ~FastqInputIterator ()=default
 
self_typebegin ()
 Beginning of the iterator. More...
 
value_type const & dereference () const
 
self_type end ()
 End of the iterator. More...
 
void increment ()
 
 operator bool () const
 Return true iff dereferencing is valid, i.e., iff there is a Sequence available. More...
 
bool operator!= (self_type const &other) const
 
value_type const & operator* () const
 
self_typeoperator++ ()
 
self_type operator++ (int)
 
value_type const * operator-> () const
 
self_typeoperator= (self_type const &)=default
 
self_typeoperator= (self_type &&)=default
 
bool operator== (self_type const &other) 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 = FastqInputIterator
 
using value_type = Sequence
 

Constructor & Destructor Documentation

◆ FastqInputIterator() [1/5]

FastqInputIterator ( )
inline

Create a default instance, with no input.

Definition at line 109 of file fastq_input_iterator.hpp.

◆ FastqInputIterator() [2/5]

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

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

Definition at line 118 of file fastq_input_iterator.hpp.

◆ FastqInputIterator() [3/5]

FastqInputIterator ( std::shared_ptr< utils::BaseInputSource source,
FastqReader const &  settings 
)
inline

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

Definition at line 130 of file fastq_input_iterator.hpp.

◆ ~FastqInputIterator()

~FastqInputIterator ( )
default

◆ FastqInputIterator() [4/5]

FastqInputIterator ( self_type const &  )
default

◆ FastqInputIterator() [5/5]

FastqInputIterator ( self_type &&  )
default

Member Function Documentation

◆ begin()

self_type& begin ( )
inline

Beginning of the iterator.

This is a bit uncommon, as the iterator provides its own begin() and end() functions. We do this to allow the easy use case that is explained above.

Definition at line 197 of file fastq_input_iterator.hpp.

◆ dereference()

value_type const& dereference ( ) const
inline

Definition at line 182 of file fastq_input_iterator.hpp.

◆ end()

self_type end ( )
inline

End of the iterator.

Beginning of the iterator. This is a bit uncommon, as the iterator provides its own begin() and end() functions. We do this to allow the easy use case that is explained above.

Definition at line 207 of file fastq_input_iterator.hpp.

◆ increment()

void increment ( )
inline

Definition at line 225 of file fastq_input_iterator.hpp.

◆ operator bool()

operator bool ( ) const
inlineexplicit

Return true iff dereferencing is valid, i.e., iff there is a Sequence available.

Definition at line 163 of file fastq_input_iterator.hpp.

◆ operator!=()

bool operator!= ( self_type const &  other) const
inline

Definition at line 155 of file fastq_input_iterator.hpp.

◆ operator*()

value_type const& operator* ( ) const
inline

Definition at line 172 of file fastq_input_iterator.hpp.

◆ operator++() [1/2]

self_type& operator++ ( )
inline

Definition at line 212 of file fastq_input_iterator.hpp.

◆ operator++() [2/2]

self_type operator++ ( int  )
inline

Definition at line 218 of file fastq_input_iterator.hpp.

◆ operator->()

value_type const* operator-> ( ) const
inline

Definition at line 177 of file fastq_input_iterator.hpp.

◆ operator=() [1/2]

self_type& operator= ( self_type const &  )
default

◆ operator=() [2/2]

self_type& operator= ( self_type &&  )
default

◆ operator==()

bool operator== ( self_type const &  other) const
inline

Definition at line 150 of file fastq_input_iterator.hpp.

Member Typedef Documentation

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 99 of file fastq_input_iterator.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 100 of file fastq_input_iterator.hpp.

◆ pointer

using pointer = value_type&

Definition at line 97 of file fastq_input_iterator.hpp.

◆ reference

Definition at line 98 of file fastq_input_iterator.hpp.

◆ self_type

Definition at line 95 of file fastq_input_iterator.hpp.

◆ value_type

Definition at line 96 of file fastq_input_iterator.hpp.


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