smithwaterman

package
v0.0.0-...-c65180b Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchMismatch

type MatchMismatch struct {
	// Match represents the score of equal character substitutions.
	Match float64

	// Mismatch represents the score of unequal character substitutions.
	Mismatch float64
}

MatchMismatch represents a substitution function which returns the match or mismatch value depeding on the equality of the compared characters. The match value must be greater than the mismatch value.

func (MatchMismatch) Compare

func (m MatchMismatch) Compare(a []rune, idxA int, b []rune, idxB int) float64

Compare returns the match value if a[idxA] is equal to b[idxB] or the mismatch value otherwise.

func (MatchMismatch) Max

func (m MatchMismatch) Max() float64

Max returns the match value.

func (MatchMismatch) Min

func (m MatchMismatch) Min() float64

Min returns the mismatch value.

type SmithWatermanGotoh

type SmithWatermanGotoh struct {
	// CaseSensitive specifies if the string comparison is case sensitive.
	CaseSensitive bool

	// GapPenalty defines a score penalty for character insertions or deletions.
	// For relevant results, the gap penalty should be a non-positive number.
	GapPenalty float64

	// Substitution represents a substitution function which is used to
	// calculate a score for character substitutions.
	Substitution Substitution
}

SmithWatermanGotoh represents the Smith-Waterman-Gotoh metric for measuring the similarity between sequences.

For more information see https://en.wikipedia.org/wiki/Smith-Waterman_algorithm.

func NewSmithWatermanGotoh

func NewSmithWatermanGotoh() *SmithWatermanGotoh

NewSmithWatermanGotoh returns a new Smith-Waterman-Gotoh string metric.

Default options:

CaseSensitive: true
GapPenalty: -0.5
Substitution: MatchMismatch{
	Match:    1,
	Mismatch: -2,
},

func (*SmithWatermanGotoh) Compare

func (m *SmithWatermanGotoh) Compare(a, b string) float64

Compare returns the Smith-Waterman-Gotoh similarity of a and b. The returned similarity is a number between 0 and 1. Larger similarity numbers indicate closer matches.

type Substitution

type Substitution interface {
	// Compare returns the substitution score of characters a[idxA] and b[idxB].
	Compare(a []rune, idxA int, b []rune, idxB int) float64

	// Returns the maximum score of a character substitution operation.
	Max() float64

	// Returns the minimum score of a character substitution operation.
	Min() float64
}

Substitution represents a substitution function which is used to calculate a score for character substitutions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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