aspartik.data

class DNANucleotide:

#

DNA nucleotide bases and their combinations

This class only supports DNA, so it has thymine, but not uracil. Aside from the core 4 bases it also supports all of their permutations (e.g. Weak for adenine or thymine). See IUPAC codes for the full list. Finally, it also has two special values: Any, which encodes an arbitrary base, and Gap, which is used in alignments.

Protocols

DnaNucleotide implements the __contains__ protocol for testing which combinations of nucleotides are supersets of others. For example:

>>> DNANucleotide.Adenine in DNANucleotide.Weak
True
>>> DNANucleotide.Pyrimidine in DNANucleotide.NotGuanine
True
>>> DNANucleotide.Cytosine in DNANucleotide.NotCytosine
False

Any includes all other states, including Gap.

Adenine

#

Cytosine

#

Guanine

#

Thymine

#

Weak

#

Strong

#

Amino

#

Ketone

#

Purine

#

Pyrimidine

#

NotAdenine

#

NotCytosine

#

NotGuanine

#

NotThymine

#

Any

#

Gap

#

def complement(self, /)

#

The complementary pair of the nucleotide base

For combined states the combination of all possible complements will be returned. The complement of Weak is Strong, for NotGuanine it is NotCytosine, and so on. And Any and Gap will return themselves.

class DNASeq:

#

An immutable DNA sequence

This sequence cannot be mutated. Instead, its methods can be used for various transformations which will return new sequences.

def complement(self, /)

#

A complementary strand

See DNANucleotide.complement for notes on how combined states such as DNANucleotide.Weak and gaps are handled.

def reverse_complement(self, /)

#

Reversed complementary strand

class Phred:

#

The Phred quality score

A Phred score estimates the probability that a given base has been assigned correctly. It is primarily used in the FASTQ format.

def accuracy(self, /)

#

The chance that a base has been assigned correctly

def probability_incorrect(self, /)

#

The chance that there has been an error in a base assignment

Equals 1 - self.accuracy().