mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-11-10 01:24:41 +00:00
Implement k-mer distance metrics and constrained generation
Adds support for Hamming distance, constrained k-mer generation, and optimized Longest Common Subsequence (LCS) calculations using scalar, batch, and SIMD methods. This includes new methods for k-mer distance calculation, structures for k-mer constraints, and SIMD-based batch processing for LCS to improve performance and correctness.
This commit is contained in:
1 parent
0012a55cad
commit
a0d8187fd6
11 files changed
+601
-19
No files matched your search
@@ -0,0 +1,31 @@
|
||||
//go:build goexperiment.simd && arm64
|
||||
|
||||
package obikmer
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestKmerLCSBatchNEONMatchesReference(t *testing.T) {
|
||||
rng := rand.New(rand.NewSource(5))
|
||||
for _, k := range []int{1, 2, 5, 11, 21, 31} {
|
||||
for _, n := range []int{0, 1, 7, 8, 9, 100} {
|
||||
query := randomKmer(rng, k)
|
||||
partners := make([]uint64, n)
|
||||
for i := range partners {
|
||||
partners[i] = randomKmer(rng, k)
|
||||
}
|
||||
out := make([]KmerLCSResult, n)
|
||||
kmerLCSBatchNEON(query, partners, k, out)
|
||||
for i, p := range partners {
|
||||
if want := KmerLCS(query, p, k); out[i] != want {
|
||||
t.Fatalf("k=%d n=%d partner %d: got %+v, want %+v", k, n, i, out[i], want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkKmerLCSNEON21(b *testing.B) { benchBatch(b, 21, kmerLCSBatchNEON) }
|
||||
func BenchmarkKmerLCSNEON11(b *testing.B) { benchBatch(b, 11, kmerLCSBatchNEON) }
|
||||
Reference in new issue
Block a user