smith-walterman-score

1.0.3 • Public • Published

Smith-Walterman Scoring

Build Status XO code style

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 }*/

Package Sidebar

Install

npm i smith-walterman-score

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

6.47 kB

Total Files

8

Last publish

Collaborators

  • a1c0