pub trait AlphabetCharacter: Into<u8> + TryFrom<u8> {
    const ALPHABET_SIZE: usize;

    // Required methods
    fn index(&self) -> usize;
    fn from_index(index: usize) -> Result<Self, AlphabetError>;
    fn from_index_ref(index: usize) -> Result<&'static Self, AlphabetError>;
    fn complement(&self) -> Self;
}
Expand description

A character in an alphabet.

Required Associated Constants§

source

const ALPHABET_SIZE: usize

The amount of characters in the alphabet.

Required Methods§

source

fn index(&self) -> usize

The index of this character in the alphabet.

source

fn from_index(index: usize) -> Result<Self, AlphabetError>

Constructs the character from the given index, returning None if it is invalid.

source

fn from_index_ref(index: usize) -> Result<&'static Self, AlphabetError>

Constructs the character from the given index, returning None if it is invalid. This method returns a static reference to the character type, so it can only be implemented via lookup in a static table. It is required to create an implementation of std::ops::Index for genome sequence types that do not store the characters in plain format.

source

fn complement(&self) -> Self

Constructs the complement of this character.

Implementors§