codon

package
v0.0.0-...-eeaf01f Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: GPL-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Package codon is the package for working with codons, codon transition matrices and codon frequencies.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NOCODON is a special number which represents an unknown
	// codon.
	NOCODON = byte(255)
)

Functions

func CreateRateTransitionMatrix

func CreateRateTransitionMatrix(cf Frequency, kappa, omega float64, rates []float64, m *mat64.Dense) (*mat64.Dense, float64)

CreateRateTransitionMatrix creates a transition matrix given the vector of rates.

func CreateTransitionMatrix

func CreateTransitionMatrix(cf Frequency, kappa, omega float64, m *mat64.Dense) (*mat64.Dense, float64)

CreateTransitionMatrix creates a transition matrix.

func PrintQ

func PrintQ(Q *mat64.Dense, gcode bio.GeneticCode)

PrintQ prints a Q or P matrix.

func PrintUnQ

func PrintUnQ(Q *mat64.Dense, gcode bio.GeneticCode)

PrintUnQ prints Q or P matrix without codon names.

func Sum

func Sum(m *mat64.Dense) (s float64)

Sum calculates matrix sum.

Types

type EMatrix

type EMatrix struct {
	// Q is Q-matrix
	Q *mat64.Dense
	// Scale is matrix scale.
	Scale float64
	// CF is codon frequency.
	CF Frequency
	// contains filtered or unexported fields
}

EMatrix stores Q-matrix and it's eigendecomposition to quickly compute e^Qt.

func NewEMatrix

func NewEMatrix(cf Frequency) *EMatrix

NewEMatrix creates a new EMatrix.

func (*EMatrix) Copy

func (m *EMatrix) Copy(recv *EMatrix) *EMatrix

Copy creates a copy of EMatrix while saving eigendecomposition.

func (*EMatrix) Eigen

func (m *EMatrix) Eigen() (err error)

Eigen performs eigendecomposition.

func (*EMatrix) Exp

func (m *EMatrix) Exp(cD *mat64.Dense, t float64, res []float64, tmp []float64) ([]float64, error)

Exp computes P=e^Qt and writes it to cD matrix.

func (*EMatrix) ScaleD

func (m *EMatrix) ScaleD(scale float64)

ScaleD scales matrix after the eigendecomposition.

func (*EMatrix) Set

func (m *EMatrix) Set(Q *mat64.Dense, scale float64)

Set sets Q-matrix and its' scale.

type Frequency

type Frequency struct {
	Freq  []float64
	GCode *bio.GeneticCode
}

Frequency is array (slice) of codon frequencies.

func F0

func F0(cali Sequences) Frequency

F0 returns array (slice) of equal codon frequencies.

func F3X4

func F3X4(cali Sequences) (cf Frequency)

F3X4 computes F3X4-style frequencies based on the alignment.

func ReadFrequency

func ReadFrequency(rd io.Reader, gcode *bio.GeneticCode) (Frequency, error)

ReadFrequency reads codon frequencies from a reader. It should be just a list of numbers in a text format.

func (Frequency) String

func (cf Frequency) String() (s string)

String returns text representation of codon frequencies.

type Sequence

type Sequence struct {
	Name     string
	Sequence []byte
	GCode    *bio.GeneticCode
}

Sequence stores a sequence of codons with the sequence name.

func (Sequence) String

func (seq Sequence) String() (s string)

String returns FASTA representation of the codon sequence.

type Sequences

type Sequences []Sequence

Sequences is an array (slice) of codon sequences with their names. E.g. codon alignment.

func ToCodonSequences

func ToCodonSequences(seqs bio.Sequences, gcode *bio.GeneticCode) (cs Sequences, err error)

ToCodonSequences converts nucleotide bio.Sequences to CodonSequences.

func (Sequences) Fixed

func (seqs Sequences) Fixed() (fixed []bool)

Fixed returns a bool vector, all absolutely conserved (fixed) positions have true value.

func (Sequences) Length

func (seqs Sequences) Length() int

Length returns the length of codon alignment in codons.

func (Sequences) Letters

func (seqs Sequences) Letters() (found [][]int, absent [][]int)

Letters returns a set of present and absent codons at each position of the alignment.

func (Sequences) NAmbiguous

func (seqs Sequences) NAmbiguous() (count int)

NAmbiguous returns number of ambiguous positions in the codon alignment.

func (Sequences) NFixed

func (seqs Sequences) NFixed() (f int)

NFixed calculates number of constant positions in the alignment.

func (Sequences) String

func (seqs Sequences) String() (s string)

String returns all codon sequences in FASTA format.

Jump to

Keyboard shortcuts

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