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

    Class BAIWriter

    BAI writer class for generating BAM index files

    Supports both batch index generation from complete BAM files and streaming index generation for real-time processing.

    const writer = new BAIWriter('/path/to/output.bam.bai');
    const index = await writer.generateIndex('/path/to/input.bam');
    await writer.writeIndex(index);
    const writer = new BAIWriter('/path/to/output.bam.bai', { streamingMode: true });

    // Process alignments one by one
    for (const alignment of bamAlignments) {
    await writer.addAlignment(alignment, virtualOffset);
    }

    const index = await writer.finalize();
    Index

    Constructors

    Methods

    • Generate complete BAI index from a BAM file

      Parameters

      • bamFilePath: string

        Path to input BAM file

      • OptionalreferenceNames: string[]

        Array of reference sequence names (optional)

      Returns Promise<BAIIndex>

      Promise resolving to generated BAI index

      If BAM file cannot be processed

    • Calculate bin number for genomic coordinate range (convenience method)

      Parameters

      • start: number

        Start coordinate (0-based, inclusive)

      • end: number

        End coordinate (0-based, exclusive)

      Returns BAIBinNumber

      BAI bin number

    • Set reference sequence names for the index

      Parameters

      • names: string[]

        Array of reference sequence names

      Returns void

    • Get current indexing statistics

      Returns {
          totalAlignments: number;
          referencesWithData: number;
          totalBins: number;
          totalChunks: number;
          isFinalized: boolean;
      }

      Statistics about current index state