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

    Class FastaParser

    Streaming FASTA parser with comprehensive validation

    Designed for memory efficiency - processes sequences one at a time without loading entire files into memory. Handles real-world FASTA file messiness including wrapped sequences, comments, and malformed headers.

    const parser = new FastaParser();
    for await (const sequence of parser.parseString(fastaData)) {
    console.log(`${sequence.id}: ${sequence.length} bp`);
    }
    const parser = new FastaParser({
    skipValidation: false,
    maxLineLength: 1000000,
    onError: (error, lineNumber) => console.error(`Line ${lineNumber}: ${error}`)
    });

    Hierarchy

    Index

    Constructors

    • Create a new FASTA parser with specified options and interrupt support

      Parameters

      • options: FastaParserOptions = {}

        FASTA parser configuration options including AbortSignal

      Returns FastaParser

    Methods

    • Parse FASTA sequences from a string

      Parameters

      • data: string

        Raw FASTA format string data

      Returns AsyncIterable<FastaSequence>

      FastaSequence objects as they are parsed from the input

      When FASTA format is invalid

      When sequence data is malformed

      const fastaData = '>seq1\nATCG\n>seq2\nGGGG';
      for await (const sequence of parser.parseString(fastaData)) {
      console.log(`${sequence.id}: ${sequence.sequence}`);
      }
    • Parse FASTA sequences from a file using streaming I/O

      Parameters

      • filePath: string

        Path to FASTA file to parse

      • Optionaloptions: FileReaderOptions

        File reading options for performance tuning

      Returns AsyncIterable<FastaSequence>

      FastaSequence objects as they are parsed from the file

      When file cannot be read

      When FASTA format is invalid

      When sequence data is malformed

      const parser = new FastaParser();
      for await (const sequence of parser.parseFile('/path/to/genome.fasta')) {
      console.log(`${sequence.id}: ${sequence.length} bp`);
      }
    • Parse FASTA sequences from a ReadableStream

      Parameters

      • stream: ReadableStream<Uint8Array<ArrayBufferLike>>

        Stream of binary data containing FASTA format text

      Returns AsyncIterable<FastaSequence>

      FastaSequence objects as they are parsed from the stream

      When FASTA format is invalid

      When sequence data is malformed

      const response = await fetch('genome.fasta');
      for await (const sequence of parser.parse(response.body!)) {
      console.log(`Processing ${sequence.id}...`);
      }