alphabet

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package alphabet provides structs for defining biological sequence alphabets.

Index

Constants

This section is empty.

Variables

View Source
var (
	DNA     = NewAlphabet([]string{"A", "C", "G", "T"})
	RNA     = NewAlphabet([]string{"A", "C", "G", "U"})
	Protein = NewAlphabet([]string{"A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y"})
)

Functions

This section is empty.

Types

type Alphabet

type Alphabet struct {
	// contains filtered or unexported fields
}

Alphabet is a struct that holds a list of symbols and a map of symbols to their index in the list.

func NewAlphabet

func NewAlphabet(symbols []string) *Alphabet

NewAlphabet creates a new alphabet from a list of symbols.

func (*Alphabet) Decode

func (alphabet *Alphabet) Decode(code interface{}) (string, error)

Decode returns the symbol at a given index in the alphabet.

func (*Alphabet) Encode

func (alphabet *Alphabet) Encode(symbol interface{}) (int, error)

Encode returns the index of a symbol in the alphabet.

func (*Alphabet) Extend

func (alphabet *Alphabet) Extend(symbols []string) *Alphabet

Extend returns a new alphabet that is the original alphabet extended with a list of symbols.

func (*Alphabet) Symbols

func (alphabet *Alphabet) Symbols() []string

Symbols returns the list of symbols in the alphabet.

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is an error type that is returned when a symbol is not in the alphabet.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message for AlphabetError.

Jump to

Keyboard shortcuts

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