Skip to content

Repository files navigation

@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 — placeFromCigar turns SAM/BAM start positions and CIGARs into the same column block, reconciling insertions across reads.
  • Consensus: two callers over the same block. buildConsensus is the frequency vote a deep pileup wants; buildBayesianConsensus weighs every read by its own phred score with the reference as a prior, so one clean read outweighs two doubtful ones — the right answer for capillary work — and reports a confidence per column.

Planned: mutation classification, consensus calling, heteroplasmy detection.

Install

npm install @fishka/seqalgo

Needleman-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 score
needleAlign(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 EMBOSS needle tie-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

About

Sequence algorithms for bioinformatics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages