Giter VIP home page Giter VIP logo

asmukk's Introduction

asmukk

Implementation of Ukkonen's approximate string matching algorithm using fixed mismatch and gap cost.

The straight forward dynamic programming algorithm for approximate string alignment (ASM) takes O(N*M) time and O(N*M) space, where N and M are the lengths of the strings to compare. Though there's good reason to think that this is optimal, often the strings we want to compare are very similar and the straight forward dynamic programming solution does a lot of extra work, considering paths that are far from optimal.

This was noticed by Ukkonen and led to an "output sensitive" algorithm that runs in O( max{N,M) * d ), where d is the edit distance between the two strings.

Note that Hirschberg's algorithm only takes O( max{N,M} ) space but still requires the full O(N*M) time.

Though Ukkonen's approximate string matching algorithm is well known, I found it difficult to find an accessible implementation of it.

Quick Start

$ git clone https://github.com/abeconnelly/asmukk
$ cd asmukk
$ make
$ echo -e "cute\ncat\n" | ./asm_ukk
5
cute
cat-

The mismatch cost is fixed as is the gap cost. By default, the mismatch cost is set to 3 and the gap cost is set to 2.

Examples

C

// gcc asm_ukk.o main.cpp -o main
#include <stdio.h>
#include <stdio.h>
#include "asm_ukk.h"

int main(int argc, char **argv) {
  char *x = "cute", *y = "cat";
  char *X=NULL, *Y=NULL;
  int score;

  int mismatch = 3, gap = 2;
  char gap_char = '-';

  score = asm_ukk_align2(&X, &Y, x, y, mismatch, gap, gap_char);

  printf("got score: %d\n", score);
  printf("orig x: %5s, aligned x: %s\n", x, X);
  printf("orig y: %5s, aligned y: %s\n", y, Y);

  free(X);
  free(Y);
}

References

License

Copyright Curoverse, Inc, AGPLv3. See the LICENSE file for more details.

asmukk's People

Contributors

abeconnelly avatar

Watchers

 avatar  avatar

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.