UNPKG

@gmod/indexedfasta

Version:

read indexed fasta and bgzipped fasta formats

77 lines (76 loc) 2.62 kB
import type { GenericFilehandle } from 'generic-filehandle2'; interface BaseOpts { signal?: AbortSignal; } interface IndexEntry { offset: number; lineBytes: number; lineLength: number; length: number; } declare function readFAI(fai: GenericFilehandle, opts?: BaseOpts): Promise<{ [k: string]: { readonly name: string; readonly length: number; readonly start: 0; readonly end: number; readonly offset: number; readonly lineLength: number; readonly lineBytes: number; }; }>; export default class IndexedFasta { fasta: GenericFilehandle; fai: GenericFilehandle; indexes?: ReturnType<typeof readFAI>; constructor({ fasta, fai, path, faiPath, }: { fasta?: GenericFilehandle; fai?: GenericFilehandle; path?: string; faiPath?: string; }); _getIndexes(opts?: BaseOpts): Promise<{ [k: string]: { readonly name: string; readonly length: number; readonly start: 0; readonly end: number; readonly offset: number; readonly lineLength: number; readonly lineBytes: number; }; }>; /** * @returns array of string sequence names that are present in the index, in * which the array index indicates the sequence ID, and the value is the * sequence name */ getSequenceNames(opts?: BaseOpts): Promise<string[]>; /** * @returns array of string sequence names that are present in the index, in * which the array index indicates the sequence ID, and the value is the * sequence name */ getSequenceSizes(opts?: BaseOpts): Promise<Record<string, number>>; /** * @returns array of string sequence names that are present in the index, in * which the array index indicates the sequence ID, and the value is the * sequence name */ getSequenceSize(seqName: string, opts?: BaseOpts): Promise<number | undefined>; /** * @param name * * @returns true if the file contains the given reference sequence name */ hasReferenceSequence(name: string, opts?: BaseOpts): Promise<boolean>; /** * @param seqName * @param min * @param max */ getResiduesByName(seqName: string, min: number, max: number, opts?: BaseOpts): Promise<string | undefined>; getSequence(seqName: string, min: number, max: number, opts?: BaseOpts): Promise<string | undefined>; _fetchFromIndexEntry(indexEntry: IndexEntry, min?: number, max?: number, opts?: BaseOpts): Promise<string>; } export {};