Coder Social home page Coder Social logo

elixirsmithwaterman's Introduction

Smith-Waterman algorithm

SmithWaterman.scoreSW("string1", "string2", match \\ 1, mismatch \\ -1, gap \\ -1)

This local alignment algorithm calculates the score of the most similar alignment of all possible substrings of two strings, including gaps and mismatches. The default scoring scheme is:

  • Match +1
  • Mismatch -1
  • Gap -1

It is optimal, but O(|N| * |M|) in time complexity, and O(|N|) in memory complexity.

The implementation does not provide a traceback of the optimal alignment.

SmithWaterman.score_ratio("string1", "string2", threshold \\ 0.7) 

The SmithWaterman.score_ratio/3 function calculates the highest possible score of two alignments, and if the threshold is achieveable based on the length of the strings, it runs the SmithWaterman.scoreSW/5 function to calculate the ratio of similarity as a number between 0 and 1. If the similarity threshold cannot be achieved due to the lengths of the stings, it just returns 0.

Example usage

SmithWaterman.scoreRatio("my first string", "my second string")
> 0.4666666666666667

SmithWaterman.scoreRatio("my slightly longer string with more information in it", "my slightly longer string with more information in it random chars")
> 1.0

Installation

First add to your dependencies in mix.exs.

def deps do
  [
    {:teiserver, "~> 0.0.5"}
  ]
end

Benchmarking

You can run the benchmarks with mix benchmark.

Possible Improvements

[ ] Compare any two lists of items where the equality operator is supported.

elixirsmithwaterman's People

Contributors

beherith avatar teifion avatar

Watchers

 avatar

Forkers

teifion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.