Biological Alphabets#

Base#

class pyhmmer.easel.Alphabet#

A biological alphabet, including additional marker symbols.

This type is used to share an alphabet to several objects in the easel and plan7 modules. Reference counting helps sharing the same instance everywhere, instead of reallocating memory every time an alphabet is needed.

Use the factory class methods to obtain a default Alphabet for one of the three standard biological alphabets:

>>> dna = Alphabet.dna()
>>> rna = Alphabet.rna()
>>> aa  = Alphabet.amino()
classmethod amino()#

Create a default amino-acid alphabet.

Returns:

pyhmmer.easel.AA – A new amino-acid alphabet object.

decode(sequence)#

Decode a raw digital sequence into its textual representation.

Parameters:

sequence (object, buffer-like) – A raw sequence in digital format. Any object implementing the buffer protocol (like bytearray, VectorU8, etc.) may be given.

Returns:

str – A raw sequence in textual format.

Example

>>> alphabet = easel.Alphabet.amino()
>>> dseq = easel.VectorU8([0, 4, 2, 17, 3, 13, 0, 0, 5])
>>> alphabet.decode(dseq)
'AFDVEQAAG'

Added in version 0.6.3.

classmethod dna()#

Create a default DNA alphabet.

Returns:

pyhmmer.easel.DNA – A new DNA alphabet object.

encode(sequence)#

Encode a raw text sequence into its digital representation.

Parameters:

sequence (str) – A raw sequence in text format.

Returns:

VectorU8 – A raw sequence in digital format.

Example

>>> alphabet = easel.Alphabet.dna()
>>> alphabet.encode("ACGT")
VectorU8([0, 1, 2, 3])

Added in version 0.6.3.

is_amino()#

Check whether the Alphabet object is a protein alphabet.

is_dna()#

Check whether the Alphabet object is a DNA alphabet.

is_nucleotide()#

Check whether the Alphabet object is a nucleotide alphabet.

is_rna()#

Check whether the Alphabet object is a RNA alphabet.

classmethod rna()#

Create a default RNA alphabet.

Returns:

pyhmmer.easel.RNA – A new RNA alphabet object.

K#

The alphabet size, counting only actual alphabet symbols.

Example

>>> Alphabet.dna().K
4
>>> Alphabet.amino().K
20
Type:

int

Kp#

The complete alphabet size, including marker symbols.

Example

>>> Alphabet.dna().Kp
18
>>> Alphabet.amino().Kp
29
Type:

int

gap_index#

The alphabet gap index.

Added in version 0.11.1.

Type:

int

gap_symbol#

The alphabet gap symbol.

Added in version 0.11.1.

Type:

str

symbols#

The symbols composing the alphabet.

Example

>>> Alphabet.dna().symbols
'ACGT-RYMKSWHBVDN*~'
>>> Alphabet.rna().symbols
'ACGU-RYMKSWHBVDN*~'
Type:

str

type#

The alphabet type, as a short string.

Example

>>> Alphabet.dna().type
'DNA'
>>> Alphabet.amino().type
'amino'

Added in version 0.8.2.

Type:

str

Nucleotide alphabets#

class pyhmmer.easel.DNA#
class pyhmmer.easel.RNA#

Protein alphabet#

class pyhmmer.easel.AA#