GenoType's goal is to fill a gap in the TypeScript ecosystem by providing a fully type-safe, performant, idiomatic library for parsing and processing genomic data in any of the major bioinformatic data formats. It's built with an obsession with developer experience and enables users to compose their own pipelines of sequence transformations in a fluent DSL. For example, the following "pipeline", mirroring a Unix pipeline of operations from the excellent Seqkit command line interface, can be composed in TypeScript like so:
import { seqops } from "@genotype-ts/core";
await seqops(genomeSequences)
.grep({ pattern: /^chr\d+/, target: "id" }) // Find chromosome sequences
.filter({ minLength: 100, maxGC: 60 }) // Filter by length and GC content
.sample({ n: 1000, strategy: "reservoir" }) // Statistical sampling
.sort({ by: "length", order: "desc" }) // Sort longest first
.rmdup({ by: "sequence", caseSensitive: false, exact: true }) // Remove duplicates
.writeFasta("analyzed_genome.fasta");GenoType brings familiar SeqKit-style operations into TypeScript and adds tools that fit naturally in a library, such as typed k-mer set algebra and composable predicates.
Where possible, GenoType delegates sequence operations to SIMD-accelerated code written in Rust. Rust compiles to both native addons and WebAssembly, so the same engine can run on the server or in the browser.
GenoType uses Effect as its internal standard library for file I/O, engine management, and runtime control such as interruption. This architecture keeps GenoType runtime-agnostic: you write the same fluent pipeline while GenoType handles the platform-specific work.
GenoType was designed with scripting in mind. TypeScript is a good fit for the small, reusable scripts that make up much of data science and bioinformatics. With Node.js 26, you can install your npm dependencies and run a TypeScript workflow directly with node workflow.ts, without a separate build step. See the runnable examples for complete scripts.
Whether you're doing bioinformatics in the browser, writing a portable script, or processing data on a server, GenoType's goal is the same: let you compose high-throughput genomic workflows in a type-safe DSL without requiring a separate bioinformatics CLI.
Start with the core package:
npm install @genotype-ts/core| Package | Use it for |
|---|---|
@genotype-ts/core |
FASTA, FASTQ, and alignment I/O; fluent sequence operations |
@genotype-ts/tabular |
Sequence metrics, table pipelines, and CSV, TSV, or JSON export |
@genotype-ts/parquet |
Parquet export, column projection, and sequence round trips |
Install the extensions you need, then import them to register their fluent methods. For example, import "@genotype-ts/tabular" enables .toTabular(); importing @genotype-ts/parquet also registers the tabular methods.
| Environment | First release |
|---|---|
| Node.js 26, ESM | All three packages |
| macOS arm64 and Linux x64 GNU | Native backend. Linux requires AVX2 and glibc 2.34 or newer. |
| Other Node targets | WASM for supported core operations; Linux x64 musl is tested. |
| Browser ESM | Core with WASM |
GenoType's first release is 0.1.0. Expect API changes during the 0.x series. See GitHub Releases for release notes and assets once available.
For runnable scripts, see examples/. Those examples are kept as standalone Node.js programs with small synthetic fixtures so they can double as both documentation and smoke tests for real workflows.
- Sort FASTQ larger than memory, or keep the best duplicate instead of the first.
- Query sequence metrics in DuckDB, or round-trip FASTQ through Parquet.
- Compare genetic codes and reading frames, or look for novel k-mer occurrences.
Problem: You've received Illumina sequencing data from a collaborator. As always, it needs quality control before analysis.
import { seqops, FastqParser } from "@genotype-ts/core";
// Parse FASTQ with quality encoding specification (or automatic detection)
const parser = new FastqParser({
qualityEncoding: "phred33", // Specify encoding, or omit for automatic detection
parseQualityScores: true, // Enable quality score parsing for QC
});
const reads = parser.parseFile("SRR12345678.fastq.gz");
// Build a comprehensive QC pipeline
const qcStats = await seqops(reads)
// Step 1: Trim low-quality tails and filter by mean Phred score
.quality({
minScore: 20, // Mean Phred score threshold after trimming
trim: true, // Enable quality trimming
trimThreshold: 20, // Sliding window quality
trimWindow: 4, // Window size
})
// Step 2: Length filtering (post-trimming)
.filter({
minLength: 35, // Minimum read length
maxLength: 151, // Remove anomalously long reads
})
// Step 3: Keep reads that contain only standard DNA bases
.filter((read) => /^[ACGT]+$/i.test(read.sequence.toString()))
// Step 4: Calculate statistics
.stats({ detailed: true });
console.log(`
QC Report:
- Sequences: ${qcStats.numSequences}
- Total length: ${qcStats.totalLength}
- Mean quality: ${qcStats.avgQuality?.toFixed(1) ?? "N/A"}
- N50: ${qcStats.n50}
- GC content: ${((qcStats.gcContent ?? 0) * 100).toFixed(1)}%
`);Problem: You need to extract specific amplicon regions from sequencing data using PCR primers, with support for long reads and sequence validation.
import { primer, seqops } from "@genotype-ts/core";
// Define primers with compile-time validation and IUPAC support
const forwardPrimer = primer.literal("TCGTCGGCAGCGTCAGATGTGTATAAGAGACAG"); // Nextera adapter
const reversePrimer = primer.literal("GTCTCGTGGGCTCGGAGATGTGTATAAGAGACAG"); // Nextera adapter
// Simple amplicon extraction
await seqops(reads)
.amplicon(forwardPrimer, reversePrimer) // Extract between primers
.filter({ minLength: 100, maxLength: 500 }) // Keep amplicons in the target length range
.writeFasta("extracted_amplicons.fasta");
// Advanced workflow with performance optimization for long reads
await seqops(nanoporeReads)
.quality({ minScore: 10 }) // Nanopore quality threshold
.amplicon(forwardPrimer, reversePrimer, {
maxMismatches: 2, // Allow sequencing errors
searchWindow: { forward: 200, reverse: 200 }, // Limit the primer search to the ends of each read
flanking: false, // Inner region only (exclude primers)
outputMismatches: true, // Include debugging info
})
.filter({ minLength: 200, maxLength: 800 }) // Target region length
.rmdup({ by: "sequence", exact: true }) // Keep one record per identical sequence
.validate({ sequenceType: "dna", action: "reject" }) // Reject invalid DNA
.writeFasta("validated_amplicons.fasta");
// Summarize product lengths for a synthetic control
const controlStats = await seqops(controlReads)
.quality({ minScore: 20, trim: true })
.amplicon(controlForwardPrimer, controlReversePrimer)
.validate({ sequenceType: "dna", action: "reject" })
.stats({ detailed: true });
console.log(`Found ${controlStats.numSequences} control amplicons`);Problem: Two sets of sequences can have similar overall GC content but different local patterns. Compare the k-mers they contain.
const backgroundKmers = await seqops(background)
.kmers(5) // Collect a typed set of distinct background 5-mers
.collectSet();
await seqops(candidates)
.kmers(5) // Keep the position of each candidate window
.filterBySet(backgroundKmers, { exclude: true }) // Drop windows found in the background
.writeFasta("novel-windows.fasta");Problem: RNA-seq data needs preprocessing before differential expression analysis.
await seqops(rnaseqReads)
// Trim low-quality tails before checking read length
.quality({ trim: true, trimThreshold: 20, trimWindow: 4 })
// Filter reads by length and base ambiguity without collapsing read counts
.filter({ minLength: 35, hasAmbiguous: false })
// Normalize case before writing FASTQ for the next tool
.transform({ upperCase: true })
.writeFastq("processed_rnaseq.fastq");Problem: Screen a draft assembly for short contigs and invalid base symbols, then summarize what passes. This is an input QC step, not a completeness check.
const validationReport = await seqops(assemblies)
// Exclude contigs below the reporting cutoff
.filter({
minLength: 500,
})
// Validate sequence content
.validate({
sequenceType: "dna",
allowAmbiguous: true, // Accept IUPAC ambiguity codes
action: "reject", // Reject invalid sequences
})
// Summarize the remaining contigs
.stats({ detailed: true });
console.log(`${validationReport.numSequences} contigs passed QC`);
console.log(
`N50: ${validationReport.n50}, GC: ${((validationReport.gcContent ?? 0) * 100).toFixed(1)}%`
);Install mise, rustup, and a native compiler toolchain (Xcode Command Line Tools on macOS or a C/C++ compiler and linker on Linux). From a clean checkout:
mise trust
mise install
mise run bootstrap
mise run validate-fullRun mise tasks to list the shared local and CI commands. After building, mise run docs generates TypeDoc and mise run build-publish-artifacts stages npm artifacts without publishing them.
Builds and typechecks use TypeScript 7. TypeDoc and type-coverage still use the TypeScript 6 compiler API, so their copy is scoped to tools/typescript-legacy. For Effect diagnostics without patching the installed compiler, run mise exec -- pnpm -C packages/core exec effect-tsgo tsc --noEmit -p tsconfig.test.json.