@fishka/seqalgo
v1.9.0
Published
Sequence algorithms for bioinformatics — pairwise alignment (Needleman-Wunsch / EMBOSS-compatible) and related sequence analysis utilities
Maintainers
Readme
@fishka/seqalgo
Part of fishka.bio — free browser-based bioinformatics tools.
Sequence algorithms for browser and Node bioinformatics apps. It is the
algorithmic companion to @fishka/seqio:
seqio reads and writes sequence files, seqalgo analyses the sequences.
Current API:
- Needleman-Wunsch global alignment with EDNAFULL scoring and IUPAC
ambiguity-code support. Scores match EMBOSS
needle. - Sequence utilities: gap removal/counting and IUPAC-aware reverse complement.
- Quality trimming: modified Mott and sliding-window trim ranges.
- Alignment utilities: coordinate conversion, gap-column cleanup, pairwise alignment combination, and gap-filled transforms.
- Chromatogram utilities: reverse-complement traces and inject alignment gaps into chromatograms.
- Pileup: place many reads on one short reference, stack them into columns,
and read verdicts off those columns (coverage, consensus with IUPAC ambiguity,
frequency-threshold variant calling). Reads can come from the built-in aligner
or already placed by a mapper —
placeFromCigarturns SAM/BAM start positions and CIGARs into the same column block, reconciling insertions across reads.
Planned: mutation classification, consensus calling, heteroplasmy detection.
Install
npm install @fishka/seqalgoNeedleman-Wunsch
import { needleAlign } from '@fishka/seqalgo';
const result = needleAlign('GATCACAGGT', 'GATCAGGT');
result.seqA; // aligned reference: "GATCACAGGT"
result.seqB; // aligned read: "GAT--CAGGT"
result.score; // EMBOSS-equivalent scoreneedleAlign(ref, read, {
gapOpen: 10,
gapExtend: 0.5,
gapAnchor: '5-prime',
});gapAnchor only affects where equally-scoring indels land inside
homopolymer/repeat tracts:
'5-prime'(default) matches EMBOSSneedletie-breaking.'3-prime'right-anchors gaps for ISFG forensic mtDNA notation.
Sequence and quality helpers
import { mottTrim, reverseComplement, slidingWindowTrim } from '@fishka/seqalgo';
reverseComplement('ACGTRY'); // "RYACGT"
mottTrim([8, 12, 30, 31, 29, 10], { cutoff: 20 }); // { start, end }
slidingWindowTrim([8, 12, 30, 31, 29, 10], { threshold: 20, windowSize: 3 });Alignment and chromatogram helpers
import {
applyAlignmentGapsToChromatogram,
combineAlignments,
removeColumnsOfGaps,
reverseComplementChromatogram,
} from '@fishka/seqalgo';
const cleaned = removeColumnsOfGaps(['A-C-', '--C-']);
const combined = combineAlignments(pairwiseAlignments);
const rc = reverseComplementChromatogram(chromatogram);
const gappedTrace = applyAlignmentGapsToChromatogram(rc, 'AC-GT');Subpath imports are available for @fishka/seqalgo/needle,
@fishka/seqalgo/sequence, and @fishka/seqalgo/alignment.
License
Apache-2.0
