UNPKG

generic-sequence-panel

Version:

read feature and sequence data and produce highlighted fasta

23 lines (22 loc) 1.03 kB
import { RemoteFile } from "generic-filehandle2"; import { BgzipIndexedFasta } from "@gmod/indexedfasta"; export async function accessFasta(refseq, start, end, fastaURL, upDownBp) { const fastaFilehandle = new RemoteFile(fastaURL); const faiFilehandle = new RemoteFile(fastaURL + ".fai"); const gziFilehandle = new RemoteFile(fastaURL + ".gzi"); const t = new BgzipIndexedFasta({ fasta: fastaFilehandle, fai: faiFilehandle, gzi: gziFilehandle, }); const upstreamstart = Math.max(0, start - upDownBp); const downstreamend = end + upDownBp; const seq = await t.getSequence(refseq, start, end); const upstream = await t.getSequence(refseq, upstreamstart, start); const downstream = await t.getSequence(refseq, end, downstreamend); return { seq: seq !== null && seq !== void 0 ? seq : "", upstream: upstream !== null && upstream !== void 0 ? upstream : "", downstream: downstream !== null && downstream !== void 0 ? downstream : "", }; }