#levenshtein

seqalign

Sequence alignment using edit operations

5 releases

0.2.3 Aug 22, 2022
0.2.2 May 11, 2020
0.2.1 May 19, 2018
0.1.1 Mar 18, 2018
0.1.0 Mar 9, 2018

#20 in #levenshtein

Download history 175/week @ 2024-06-12 177/week @ 2024-06-19 171/week @ 2024-06-26 75/week @ 2024-07-03 157/week @ 2024-07-10 87/week @ 2024-07-17 166/week @ 2024-07-24 131/week @ 2024-07-31 154/week @ 2024-08-07 144/week @ 2024-08-14 142/week @ 2024-08-21 178/week @ 2024-08-28 171/week @ 2024-09-04 100/week @ 2024-09-11 133/week @ 2024-09-18 224/week @ 2024-09-25

647 downloads per month
Used in 11 crates (3 directly)

MIT/Apache

36KB
857 lines

crates.io docs.rs Travis CI

seqalign

Introduction

This crate implements commonly-used sequence alignment methods based on edit operations. There are multiple crates available to compute edit distances. However, to my knowledge there was no crate that supports all of the following seqalign features:

  • Works on slices of any type.
  • Can return both the edit distance and the edit script/alignment.
  • Can be extended with new measures.

Example

use seqalign::Align;
use seqalign::measures::LevenshteinDamerau;

let incorrect = &['t', 'p', 'y', 'o'];
let correct = &['t', 'y', 'p', 'o', 's'];

let measure = LevenshteinDamerau::new(1, 1, 1, 1);
let alignment = measure.align(incorrect, correct);

// Get the edit distance
assert_eq!(2, alignment.distance());

// Get the edit script.
use seqalign::measures::LevenshteinDamerauOp;
use seqalign::op::IndexedOperation;

assert_eq!(vec![
  	IndexedOperation::new(LevenshteinDamerauOp::Match, 0, 0),
  	IndexedOperation::new(LevenshteinDamerauOp::Transpose(1), 1, 1),
  	IndexedOperation::new(LevenshteinDamerauOp::Match, 3, 3),
  	IndexedOperation::new(LevenshteinDamerauOp::Insert(1), 4, 4)
  ], alignment.edit_script());

No runtime deps