sketching

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package sketching provides sequence sketching and distance calculation functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Containment

func Containment[T cmp.Ordered](a, b []T) float64

Containment returns a Jaccard-like similarity for the containment of a in b.

func Jaccard

func Jaccard[T cmp.Ordered](a, b []T) float64

Jaccard returns the Jaccard similarity between a and b.

func MyDist

func MyDist[T cmp.Ordered](a, b []T, alen, blen int, k int) float64

MyDist returns a Mash distance with compensation for length difference.

func Sketch

func Sketch[T constraints.Unsigned](seq []byte, k int, scale uint64) []T

Sketch returns a sketch with 1/scale kmer hashes/

Types

type Index

type Index[T constraints.Unsigned] struct {
	// contains filtered or unexported fields
}

Index allows quick lookups for sketches.

func NewIndex

func NewIndex[T constraints.Unsigned](scale int) *Index[T]

NewIndex returns a new index that stores 1/scale of hashes.

func (*Index[T]) Add

func (idx *Index[T]) Add(s []T, i int)

Add adds the given sketch with the given serial number.

func (*Index[T]) Finalize added in v1.1.0

func (idx *Index[T]) Finalize()

Finalize runs final processing after adding data and before using the index.

func (*Index[T]) Search

func (idx *Index[T]) Search(s []T) []int

Search returns serial numbers of sketches that share hashes with the given sketch.

Notes

Bugs

  • Consider making put receive a slice.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL