@gmod/indexedfasta
Version:
read indexed fasta and bgzipped fasta formats
55 lines (54 loc) • 1.93 kB
TypeScript
import type { GenericFilehandle } from 'generic-filehandle2';
interface BaseOpts {
signal?: AbortSignal;
}
interface ParsedIndex {
names: string[];
nameToIndex: Record<string, number>;
offsets: number[];
lengths: number[];
lineLengths: number[];
lineBytes: number[];
sizesCache?: Record<string, number>;
}
export default class IndexedFasta {
fasta: GenericFilehandle;
fai: GenericFilehandle;
indexes?: Promise<ParsedIndex>;
constructor({ fasta, fai, path, faiPath, }: {
fasta?: GenericFilehandle;
fai?: GenericFilehandle;
path?: string;
faiPath?: string;
});
_getIndexes(opts?: BaseOpts): Promise<ParsedIndex>;
/**
* @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 object mapping sequence names to their lengths
*/
getSequenceSizes(opts?: BaseOpts): Promise<Record<string, number>>;
/**
* @returns the length of the given sequence, or undefined if not found
*/
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>;
_fetchFromIndex(offset: number, lineBytes: number, lineLength: number, seqLength: number, min?: number, max?: number, opts?: BaseOpts): Promise<string>;
}
export {};