Skip to content

A1c0/smith-waterman-scoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A Node.JS function to compare two arrays with the smith-waterman Algorithm

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published