UNPKG

cmpstr

Version:

CmpStr is a lightweight, fast and well performing package for calculating string similarity

49 lines (48 loc) 1.95 kB
/** * Smith-Waterman Algorithm * src/metric/SmithWaterman.ts * * @see https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm * * The Smith-Waterman algorithm performs local alignment, finding the best matching * subsequence between two strings. It is commonly used in bioinformatics for local * sequence alignment. Instead of looking at the entire sequence, the Smith–Waterman * algorithm compares segments of all possible lengths and optimizes the similarity * measure. * * @module Metric/SmithWatermanDistance * @author Paul Köhler (komed3) * @license MIT */ import type { MetricInput, MetricOptions, MetricCompute } from '../utils/Types'; import { Metric } from './Metric'; export interface SmithWatermanRaw { score: number; denum: number; } /** * SmithWatermanDistance class extends the Metric class to implement the Smith-Waterman algorithm. */ export declare class SmithWatermanDistance extends Metric<SmithWatermanRaw> { /** * Constructor for the SmithWaterman class. * * Initializes the Smith-Waterman metric with two input strings or * arrays of strings and optional options. * * @param {MetricInput} a - First input string or array of strings * @param {MetricInput} b - Second input string or array of strings * @param {MetricOptions} [opt] - Options for the metric computation */ constructor(a: MetricInput, b: MetricInput, opt?: MetricOptions); /** * Calculates the Smith-Waterman local alignment score between two strings. * * @param {string} a - First string * @param {string} b - Second string * @param {number} m - Length of the first string * @param {number} n - Length of the second string * @return {MetricCompute<SmithWatermanRaw>} - Object containing the similarity result and raw score */ protected compute(a: string, b: string, m: number, n: number): MetricCompute<SmithWatermanRaw>; }