dna-sequence-tools
v1.2.0
Published
Small utilities for working with nucleotide sequences: reverse complement, GC content, transcription and codon translation.
Maintainers
Readme
dna-sequence-tools
Tiny, dependency-free helpers for manipulating DNA and RNA strings.
Nothing here talks to a network or reads a file — it's just pure functions
over A/C/G/T (and U for RNA). IUPAC ambiguity codes (N, R, Y, ...)
are deliberately unsupported so the complement table stays unambiguous.
Install
npm install dna-sequence-toolsUsage
import {
reverseComplement,
gcContent,
transcribe,
translate,
} from 'dna-sequence-tools';
reverseComplement('ATGC'); // 'GCAT'
gcContent('ATATGC'); // 0.3333...
transcribe('ATGCTT'); // 'AUGCUU'
translate('ATGAAATAAGGG'); // 'MK' (stops at TAA)
translate('ATGTAA', { keepStop: true }); // 'M*'API
| Function | Description |
| --- | --- |
| complement(seq) | DNA complement, 5'→3' order preserved |
| reverseComplement(seq) | Opposite strand read 5'→3' |
| gcContent(seq) | Fraction of G+C bases, in [0, 1] |
| transcribe(seq) | Coding DNA → mRNA (T→U) |
| rnaComplement(seq) | RNA complement (A↔U, G↔C) |
| translate(seq, opts) | DNA → protein using NCBI table 1 |
| countBases(seq) | { A, C, G, T } tallies |
Input is case-insensitive; output is upper-case. Invalid bases throw.
The codon table is NCBI translation table 1 (the standard code). Alternate codes are out of scope for now.
License
MIT
