Genotype API Documentation - v0.1.0
    Preparing search index...

    Class FastqWriter

    FASTQ format writer with quality encoding conversion support

    Provides symmetry with the FastqParser for round-trip compatibility. Uses the same validation infrastructure and quality handling as the parser.

    const writer = new FastqWriter({ qualityEncoding: 'phred33' });
    const formatted = writer.formatSequence(sequence);
    const writer = new FastqWriter({
    qualityEncoding: 'phred33',
    validateOutput: true,
    validationLevel: 'full'
    });
    const formatted = writer.formatSequence(sequence);
    // Output is validated using the same rules as the parser
    const writer = new FastqWriter({
    preservePlatformFormat: true,
    outputStrategy: 'auto'
    });
    // Automatically detects and preserves Illumina/PacBio/Nanopore formats
    Index

    Constructors

    Methods

    • Format a single FASTQ sequence as string

      This is the primary method for writing FASTQ data, symmetric to the parser's parse methods.

      Parameters

      Returns string

      Formatted FASTQ string with header, sequence, separator, and quality

      ValidationError if validateOutput is true and output is invalid

      O(n) where n is sequence length

      O(n) for the formatted output string

      const formatted = writer.formatSequence({
      format: 'fastq',
      id: 'seq1',
      sequence: 'ATCG',
      quality: 'IIII',
      qualityEncoding: 'phred33',
      length: 4
      });
    • Format multiple sequences as string

      Parameters

      Returns string

      Formatted FASTQ string with all sequences

      Symmetric to the parser's ability to parse multiple sequences. Memory consideration: For large datasets, use writeToStream instead.

      ValidationError if validateOutput is true and any output is invalid

      O(n*m) where n is number of sequences, m is average sequence length

      O(n*m) - accumulates all formatted sequences in memory

      const formatted = writer.formatSequences([seq1, seq2, seq3]);
      // Returns multi-sequence FASTQ file content
    • Format sequences as an async iterable stream

      Memory-efficient streaming output for large datasets, symmetric to the parser's async iteration support.

      Parameters

      • sequences: AsyncIterable<FastqSequence>

        Async iterable of sequences to format

      Returns AsyncGenerator<string>

      Formatted FASTQ strings

      for await (const chunk of writer.formatStream(sequences)) {
      await writeToFile(chunk);
      }
    • Write sequences to a WritableStream

      Provides full streaming support symmetric to the parser's streaming capabilities.

      Parameters

      • sequences: AsyncIterable<FastqSequence>

        Async iterable of FASTQ sequences

      • stream: WritableStream<Uint8Array<ArrayBufferLike>>

        Writable stream to write to

      Returns Promise<void>