Skip to content

Commit

Permalink
Allow empty sequences in Fastx Input View Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
lczech committed Dec 12, 2024
1 parent 6969edd commit 6bafda4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/genesis/sequence/formats/fastx_input_view_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class FastxInputViewStream
sequence_view_[2].remove_prefix( 1 );

// Basic check of sequence and quality length.
if( sequence_view_[1].empty() ) {
if( ! parent_->allow_empty_seqs_ && sequence_view_[1].empty() ) {
throw std::runtime_error(
"Malformed fastq " + input_stream_->source_name() + ": Expecting a " +
"sequence sites line after the first label line near line "
Expand Down Expand Up @@ -517,6 +517,22 @@ class FastxInputViewStream
// Settings
// -------------------------------------------------------------------------

/**
* @brief Set whether to allow empty sequences (default), or not.
*
* By default, we allow empty sequences in the files. However, we might want to fail in that
* case as well, which can be done by setting this to `false`.
*/
void allow_empty_seqs( bool value )
{
allow_empty_seqs_ = value;
}

bool allow_empty_seqs() const
{
return allow_empty_seqs_;
}

std::shared_ptr<utils::BaseInputSource> input_source() const
{
return input_source_;
Expand All @@ -529,6 +545,8 @@ class FastxInputViewStream
private:

std::shared_ptr<utils::BaseInputSource> input_source_;
bool allow_empty_seqs_ = true;

};

} // namespace sequence
Expand Down

0 comments on commit 6bafda4

Please sign in to comment.