smith-walterman-score
v1.0.3
Published
This algorithm allows us to compute the alignment of two strings.
Downloads
10
Maintainers
Readme
Smith-Walterman Scoring
This module is based on the Smith–Waterman algorithm. This algorithm allows us to compute the alignment of two arrays of elements.
The origin source is here
Install
$ yarn add smith-walterman-score
or
$ npm install smith-walterman-score
Usage
const smtihWaltermanScore = require('smith-walterman-score');
const options = {gap: -1, mismatch: -2, match: 2};
// example to compare two words
const test1A = 'Hello'.split('');
const test1B = 'Helo'.split('');
const result1 = smtihWaltermanScore(test1A, test1B, options);
console.log(result1);
/*=> { finalQ: [ 'H', 'e', 'l', 'l', 'o' ],
finalP: [ 'H', 'e', {}, 'l', 'o' ], // {} is a gap
score: 7 }*/
// example to compare two sentences
const test2A = 'I\'m a little boy'.split(' ');
const test2B = 'I\'m a big boy'.split(' ');
const result2 = smtihWaltermanScore(test2A, test2B, options);
console.log(result2);
/*=> { finalQ: [ "I'm", 'a' ],
finalP: [ "I'm", 'a' ],
score: 4 }*/