@gmod/faidx
v3.0.1
Published
create indexed fasta files
Readme
Install
$ npm install --save @gmod/faidxUsage
Accepts a ReadableStream<Uint8Array> (FASTA file) and a
WritableStream<Uint8Array> (FAI output).
Node.js — write index to a .fai file:
import fs from 'fs'
import { Readable, Writable } from 'stream'
import { generateFastaIndex } from '@gmod/faidx'
await generateFastaIndex(
Writable.toWeb(fs.createWriteStream('genome.fa.fai')),
Readable.toWeb(fs.createReadStream('genome.fa')),
)Browser — get the FAI index as a string from a File input:
import { generateFastaIndex } from '@gmod/faidx'
const { readable, writable } = new TransformStream()
const [fai] = await Promise.all([
new Response(readable).text(),
generateFastaIndex(writable, file.stream()),
])
// fai is the FAI index as a stringFastaIndexTransform is also exported if you want the
TransformStream<Uint8Array, string> on its own.
The input is scanned as bytes, never buffered as text, so memory stays flat regardless of how long the sequence lines are.
Academic Use
This package was written with funding from the NHGRI as part of the JBrowse project. If you use it in an academic project that you publish, please cite the most recent JBrowse paper, which will be linked from jbrowse.org.
License
MIT © Colin Diesh
Publishing
Trusted publishing via GitHub Actions.
pnpm version patch # or minor/major