local-alignment
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

local-alignment

Performs local sequence alignment between two arrays of arbitrary type using the Smith-Waterman algorithm.

This algorithm is often utilized in bioinformatics to do alignment between two sequenced DNA segments. Local alignment signifies that the algorithm strives to find the largest subsequence in the two arrays that can be aligned subject to a similarity function (versus a global alignment between the entirety of both arrays where large subsegments might vary greatly).

Installation

npm install --save local-alignment

Usage

import { localAlignment } from "local-alignment";
 
function simularity(a: number | undefined, b: number | undefined) {
    if (!|| !|| a !== b) {
        return -1;
    }
 
    return 2;
}
 
const A = [1, 2, 3, 8, 10, 11, 12, 13];
const B = [8, 10];
 
const [alignmentA, alignmentB] = localAlignment(A, B, simularity);
 
// alignmentA is
// {"start":3,"finish":4,"entries":[8,10]}
 
// alignmentB is
// {"start":0,"finish":1,"entries":[8,10]}
 
const A = [7, 8, 9, 10, 11];
const B = [8, 10];
 
const [alignmentA, alignmentB] = localAlignment(A, B, simularity);
 
// alignmentA is
// {"start":1,"finish":3,"entries":[8,9,10]}
 
// alignmentB is
// {"start":0,"finish":1,"entries":[8,null,10]}

For more usage examples, see the tests.

Readme

Keywords

none

Package Sidebar

Install

npm i local-alignment

Weekly Downloads

5

Version

1.0.3

License

MIT

Unpacked Size

25.6 kB

Total Files

17

Last publish

Collaborators

  • tpark