@fishka/seqalgo

中文文档
1.11.0发布于 2026/08/16Apache-2.0TypeScriptESM + CJS近 30 天下载 6166

Sequence algorithms for bioinformatics — pairwise alignment (Needleman-Wunsch / EMBOSS-compatible) and related sequence analysis utilities

原始使用文档
文档目录5 节
  1. Install
  2. Needleman-Wunsch
  3. Sequence and quality helpers
  4. Alignment and chromatogram helpers
  5. License

@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

版本与发布记录

@fishka/seqalgo 共发布 13 个版本,首次发布于 2026/06/09;过去 12 个月发布了 13 个版本。

版本发布日期距今
1.11.0latest2026/08/162 个月前
1.10.02026/08/152 个月前
1.9.02026/08/123 个月前
1.7.02026/07/173 个月前
1.6.02026/07/134 个月前
1.5.12026/07/054 个月前

关于 @fishka/seqalgo 的常见问题

@fishka/seqalgo 是什么?

Sequence algorithms for bioinformatics — pairwise alignment (Needleman-Wunsch / EMBOSS-compatible) and related sequence analysis utilities

如何安装 @fishka/seqalgo?

在项目目录运行 npm install @fishka/seqalgo,或使用 pnpm add / yarn add / bun add。

@fishka/seqalgo 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fishka/seqalgo 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fishka/seqalgo 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fishka/seqalgo 可以商用吗?

@fishka/seqalgo 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@fishka/seqalgo 的下载量有多少?

根据 npm 官方下载统计,@fishka/seqalgo 在 2026/10/15 – 2026/11/13 这 30 天内被下载 6,166 次,日均约 206 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fishka/seqalgo 还在维护吗?

最新版本 1.11.0 发布于 2026/08/16(2 个月前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/06/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。