#include <genesis/sequence/formats/fastq_input_iterator.hpp>
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 (self_type &&)=default | |
FastqInputIterator (self_type const &)=default | |
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 ()=default | |
self_type & | begin () |
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_type & | operator++ () |
self_type | operator++ (int) |
value_type const * | operator-> () const |
self_type & | operator= (self_type &&)=default |
self_type & | operator= (self_type const &)=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 |
|
inline |
Create a default instance, with no input.
Definition at line 109 of file fastq_input_iterator.hpp.
|
inlineexplicit |
Create an instance that reads from an input source, using a default FastqReader.
Definition at line 118 of file fastq_input_iterator.hpp.
|
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.
|
default |
|
default |
|
default |
|
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.
|
inline |
Definition at line 182 of file fastq_input_iterator.hpp.
|
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.
|
inline |
Definition at line 225 of file fastq_input_iterator.hpp.
|
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.
|
inline |
Definition at line 155 of file fastq_input_iterator.hpp.
|
inline |
Definition at line 172 of file fastq_input_iterator.hpp.
|
inline |
Definition at line 212 of file fastq_input_iterator.hpp.
|
inline |
Definition at line 218 of file fastq_input_iterator.hpp.
|
inline |
Definition at line 177 of file fastq_input_iterator.hpp.
|
inline |
Definition at line 150 of file fastq_input_iterator.hpp.
using difference_type = std::ptrdiff_t |
Definition at line 99 of file fastq_input_iterator.hpp.
using iterator_category = std::input_iterator_tag |
Definition at line 100 of file fastq_input_iterator.hpp.
using pointer = value_type* |
Definition at line 97 of file fastq_input_iterator.hpp.
using reference = value_type& |
Definition at line 98 of file fastq_input_iterator.hpp.
using self_type = FastqInputIterator |
Definition at line 95 of file fastq_input_iterator.hpp.
using value_type = Sequence |
Definition at line 96 of file fastq_input_iterator.hpp.