#include <genesis/sequence/formats/fastq_writer.hpp>
Write Fastq data.
This class provides simple facilities for writing Fastq data.
Exemplary usage:
std::string outfile = "path/to/file.fastq"; SequenceSet sequence_set; FastqWriter().write( sequence_set, utils::to_file( outfile ));
See FastqReader for a description of the Fastq format. Sequences are written to Fastq format, using the Sanger encoding (phred score plus offset 33), see also quality_encode_from_phred_score().
We expect Sequences to have a phred quality score by default, and throw an exception otherwise. To change this behaviour, and instead fill Sequences without quality scores with a constant quality score value, use fill_missing_quality( unsigned char ).
Definition at line 79 of file fastq_writer.hpp.
Public Member Functions | |
FastqWriter ()=default | |
FastqWriter (FastqWriter &&)=default | |
FastqWriter (FastqWriter const &)=default | |
~FastqWriter ()=default | |
unsigned char | fill_missing_quality () const |
Get the current value to fill missing phred quality scores. More... | |
FastqWriter & | fill_missing_quality (unsigned char value) |
Set the value to fill the quality scores of sequences that do not have a phread score assigned to them. More... | |
size_t | line_length () const |
Get the current line length. More... | |
FastqWriter & | line_length (size_t value) |
Set the line length, which determines after how many chars (Sequence sites) lines breaks are inserted when writing the Fastq file. More... | |
FastqWriter & | operator= (FastqWriter &&)=default |
FastqWriter & | operator= (FastqWriter const &)=default |
bool | repeat_label () const |
Get whether the setting to repeat the sequence identifier (label) on the third line is set. More... | |
FastqWriter & | repeat_label (bool value) |
Set whether to repeat the sequence identifier (label) on the third line of each sequence. More... | |
void | write (Sequence const &sequence, std::shared_ptr< utils::BaseOutputTarget > target) const |
Write a single Sequence to an output target, using the Fastq format. More... | |
void | write (Sequence const &sequence, std::string const &quality, std::shared_ptr< utils::BaseOutputTarget > target) const |
Write a single Sequence to an output target, using the Fastq format. More... | |
void | write (SequenceSet const &sequence_set, std::shared_ptr< utils::BaseOutputTarget > target) const |
Write a SequenceSet to an output target, using the Fastq format. More... | |
|
default |
|
default |
|
default |
|
default |
|
inline |
Get the current value to fill missing phred quality scores.
Definition at line 212 of file fastq_writer.hpp.
|
inline |
Set the value to fill the quality scores of sequences that do not have a phread score assigned to them.
By default, we do not accept sequences without phred scores assigned to them. If such a sequence occurs while writing, an exception is thrown. To change that behaviour, set the value to fill all sites of sequences that are missing their phread scores with this function. All values in the range [0, 254]
are valid, but the encoding used in Fastq only ranges from 0
to 93
- all values above that are clamped to be 93
. See quality_encode_from_phred_score() for details.
Lastly, in order to restore the original behaviour (that is, throw an exception if a sequence is missing phred scores), set this function to the magic value 255
.
Definition at line 203 of file fastq_writer.hpp.
|
inline |
Get the current line length.
See the setter line_length( size_t ) for details.
Definition at line 184 of file fastq_writer.hpp.
|
inline |
Set the line length, which determines after how many chars (Sequence sites) lines breaks are inserted when writing the Fastq file.
Default is 0
, which means, no line breaks are inserted. This is because many other parsing tools are implemented lazily and expect sequences in Fastq format to be on one line, so we use this by default. If set to any value greater than zero, line breaks are inserted into both the sequence and the quality score lines so that the do not exceed the specified length.
The functions returns the FastqWriter object to allow fluent interfaces.
Definition at line 173 of file fastq_writer.hpp.
|
default |
|
default |
|
inline |
Get whether the setting to repeat the sequence identifier (label) on the third line is set.
Definition at line 236 of file fastq_writer.hpp.
|
inline |
Set whether to repeat the sequence identifier (label) on the third line of each sequence.
Fastq allows the third line (starting with a +
char) to either only contain that char, or to repeat the label of the first line (for whatever reason...). By default, we do not write the label again, to save a bit of storage space. Use this function to change that behaviour.
Definition at line 226 of file fastq_writer.hpp.
void write | ( | Sequence const & | sequence, |
std::shared_ptr< utils::BaseOutputTarget > | target | ||
) | const |
Write a single Sequence to an output target, using the Fastq format.
See the output target convenience functions utils::to_file(), utils::to_stream(), and utils::to_string() for examples of how to obtain a suitable output target.
Definition at line 114 of file fastq_writer.cpp.
void write | ( | Sequence const & | sequence, |
std::string const & | quality, | ||
std::shared_ptr< utils::BaseOutputTarget > | target | ||
) | const |
Write a single Sequence to an output target, using the Fastq format.
This overload additionally takes the quality string as input, for cases where this is not stored in the sequence itself. The provided quality string has to be either of the same length as the sequece itself, or empty, in which case this function behaves according to fill_missing_quality(). If the sequence itself already has a phred score, an exception is thrown.
See the output target convenience functions utils::to_file(), utils::to_stream(), and utils::to_string() for examples of how to obtain a suitable output target.
Definition at line 144 of file fastq_writer.cpp.
void write | ( | SequenceSet const & | sequence_set, |
std::shared_ptr< utils::BaseOutputTarget > | target | ||
) | const |
Write a SequenceSet to an output target, using the Fastq format.
See the output target convenience functions utils::to_file(), utils::to_stream(), and utils::to_string() for examples of how to obtain a suitable output target.
Definition at line 171 of file fastq_writer.cpp.