cuDDL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
cuddl::detail::fastx_fastq_reader Class Reference

FASTQ parser over a contiguous in-memory buffer. More...

#include <fastx_sequence_file.hpp>

Public Member Functions

 fastx_fastq_reader (std::string_view data, std::string source_name="<buffer>")
 Constructs a reader over a contiguous in-memory FASTQ buffer.
 
Result< bool > append_next_record (std::string &sequence)
 Appends the next record's sequence bytes to sequence.
 

Detailed Description

FASTQ parser over a contiguous in-memory buffer.

Accumulates multiline sequence lines and validates multiline qualities against the sequence length, exactly as the FASTA path's record scan excludes header bytes: only sequence bytes reach the caller. The first header fixes the format; a later header of the other kind is a mixed-format error.

Definition at line 455 of file fastx_sequence_file.hpp.

Constructor & Destructor Documentation

◆ fastx_fastq_reader()

cuddl::detail::fastx_fastq_reader::fastx_fastq_reader ( std::string_view  data,
std::string  source_name = "<buffer>" 
)
inlineexplicit

Constructs a reader over a contiguous in-memory FASTQ buffer.

Parameters
dataEntire file or decompressed payload.
source_nameLabel used in parse error messages.

Definition at line 463 of file fastx_sequence_file.hpp.

464 : data_(data), source_name_(std::move(source_name)) {}

Member Function Documentation

◆ append_next_record()

Result< bool > cuddl::detail::fastx_fastq_reader::append_next_record ( std::string &  sequence)
inline

Appends the next record's sequence bytes to sequence.

Returns
false at end-of-buffer, true when a record was read, or an error.

Definition at line 471 of file fastx_sequence_file.hpp.

471 {
472 auto header = CUDDL_TRY(read_header_line());
473 if (header.empty()) {
474 return false;
475 }
476
477 char const tag = header.front();
478 if (format_ == fastx_format::unknown) {
479 if (tag == '>') {
480 format_ = fastx_format::fasta;
481 } else if (tag == '@') {
482 format_ = fastx_format::fastq;
483 } else {
484 return Err(parse_error("expected FASTA or FASTQ header"));
485 }
486 }
487
488 char const expected = format_ == fastx_format::fasta ? '>' : '@';
489 if (tag != expected) {
490 return Err(parse_error("mixed FASTA and FASTQ records are not supported"));
491 }
492 if (format_ != fastx_format::fastq) {
493 return Err(parse_error("mixed FASTA and FASTQ records are not supported"));
494 }
495 auto const base = sequence.size();
496 CUDDL_TRY(read_fastq_sequence(sequence, base));
497 return true;
498 }
#define CUDDL_TRY(expr)
Propagates a cuddl::Result failure from the enclosing function (GNU statement expression).
Definition error.hpp:225
@ fasta
FASTA (> headers).
@ fastq
FASTQ (@ headers).
@ unknown
Format not yet determined from the first header.
cuda::std::unexpected< Error > Err(Error error)
Failure return; converts to any Result<T> via cuda::std::unexpected.
Definition error.hpp:176
Here is the call graph for this function:
Here is the caller graph for this function:

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