npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nucleotide-sequence

v2.0.0

Published

A JavaScript/TypeScript library for manipulating and analyzing DNA and RNA sequences.

Readme

nucleotide-sequence

NPM Version License: MIT

nucleotide-sequence is a JavaScript/TypeScript library for Node.js and the Browser that provides functions for manipulating and analyzing DNA and RNA sequences. It uses Uint8Array to represent sequences internally.

Installation

npm install nucleotide-sequence

Basic Usage

import { Seq, Translation, Alignment } from 'nucleotide-sequence';

// Initialize and read a sequence
const dna = new Seq('DNA').read('ATGCGTACGTTAG');

// Reverse Complement
const revComp = dna.reverseComplement();
console.log(revComp.sequence());

// Translation to Amino Acids (NCBI Table 1)
const protein = Translation.translate(dna);

// Pairwise Sequence Alignment (Smith-Waterman)
const ref = new Seq().read('ATGCGTACGT');
const result = Alignment.smithWaterman(dna, ref, { match: 2, mismatch: -1 });
console.log(`Alignment Score: ${result.score}`);

API Reference

Seq

The core class for wrapping and manipulating nucleotide sequences.

  • read(sequence: string): Parses a string into a Uint8Array sequence, ignoring whitespace.
  • static readFASTA(content: string): Parses a FASTA string and returns an array of Seq objects. Loads all records into memory; not suitable for gigabyte-scale genomic assemblies.
  • static readFASTQ(content: string): Parses a FASTQ string and returns an array of Seq objects.
  • reverseComplement(): Returns a new Seq object containing the reverse complement, supporting IUPAC degenerate bases.
  • kmers(k: number): Returns a Generator yielding Uint8Array subarrays of length k. Yields strand-specific, overlapping substrings (not canonical k-mers).
  • gcContent(): Computes the global GC percentage (0.0 to 1.0) based on exact G/C/S bases. Degenerate bases like 'N' are ignored.
  • gcSkew(windowSize?: number): Calculates (G-C)/(G+C) across sliding windows.
  • hammingDistance(other: Seq): Computes the Hamming distance between two sequences of equal length.
  • meltingTemperatureNN(naConc?, kConc?, trisConc?, mgConc?, dNTPs?, seqConc?): Computes primer Melting Temperature (Tm) using the SantaLucia (1998) Nearest-Neighbor parameters. Corrects for monovalent cations (Na, K, Tris). The Mg²⁺ formula is a generic proxy coefficient and NOT the rigorous Owczarzy 2008 correction.
  • molecularWeight({ phosphorylated?: boolean }): Computes mass using explicit exact IUPAC atomic masses (C, H, N, O, P). Perfectly mirrors Biopython's molecular weight algorithm for 5'-phosphorylated DNA/RNA, and provides exactly derived $HPO_3$ analytical subtraction for 5'-OH sequences.

Parsers

  • static parseFASTAStream(stream: AsyncIterable<Buffer> | ReadableStream): Parses FASTA asynchronously, emitting Sequence events. O(chunk-size) memory bound.
  • static parseFASTQEvents(stream: AsyncIterable<Buffer> | ReadableStream): Parses FASTQ asynchronously, validating strict sequence vs quality length bounds immediately. O(chunk-size) memory bound.

Translation

  • static translate(seq: Seq, tableId?: number): Translates a DNA/RNA sequence into an amino acid string using NCBI Translation Tables. Supports Standard (1), Vertebrate Mitochondrial (2), and Bacterial/Archaeal/Plant Plastid (11).
  • static findOpenReadingFrames(seq: Seq, minCodons?: number, tableId?: number): Scans all 6 biological reading frames (1, 2, 3 and -1, -2, -3) extracting nested structural ORFs. Supports alternative initiation codons under appropriate tables.

Alignment

  • static smithWaterman(query: Seq, reference: Seq, options?: AlignmentOptions): Performs local pairwise sequence alignment. Memory scales $O(\min(m, n))$ during score-only operations, allowing extreme sequence disparities.
  • static needlemanWunsch(query: Seq, reference: Seq, options?: AlignmentOptions): Performs global pairwise sequence alignment via dynamic programming. Note: Alignments utilize configurable integer match/mismatch scores and affine gap penalties.

CrisprScoring

  • static findSpacers(seq: Seq, pam?: string, spacerLength?: number): Identifies structural Protospacer Adjacent Motifs (PAMs) on both strands via regex. Does not evaluate chromatin accessibility.
  • static calculateOnTargetScoreProxy(spacer: string): Calculates an on-target efficiency score proxy based on a simplified positional weight matrix. This is NOT a published Rule Set 2/Azimuth score.
  • static calculateCFDScoreProxy(guide: string, offTarget: string): Calculates an off-target cutting proxy using static positional penalties. This is NOT the published Doench CFD model.

SubstringSearch

  • constructor(query: Seq, reference: Seq): Initializes an exact substring search tool.
  • top(limit?: number): Returns ungapped matches tolerant to N wildcards using an $O(M \times N)$ sliding window. Highly optimal for short amplicons and plasmids, but intractable for mapping short reads to whole genomes.

FormatSAM

  • static parse(samContent: string): Parses Sequence Alignment/Map (SAM) text into an array of structured SAMRecord objects. Extracts standard fields but does not process bitwise FLAG semantics or CIGAR clipping operations.

Parallel

Requires the optional peer dependency zeroworker.

  • static align(query: Seq, references: Seq[], options?: AlignmentOptions): Distributes pairwise alignments across a multithreaded Web Worker pool using zeroworker.
  • static kmerCount(seq: Seq, k: number, chunks?: number): Computes k-mer frequencies using a Web Worker pool.

License

MIT License