package phylogenetics

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Phylogenetics.CodonSource

Abstract representations of codons and genetic codes

Codons are triplets of nucleotides that encode amino acids in a coding sequence. The correspondance between codons and amino acids is called a genetic code and several have been observed in living beings.

This module includes an implementation for the universal genetic code as well as functions to work with genetic codes specified by the NCBI (this NCBI page).

The module also defines types and functions to manipulate codons and nucleotides.

Sourcemodule type S = sig ... end
Sourcetype genetic_code

A type representing a genetic code

This type represents a genetic code as specified this NCBI page.

Each genetic code is identified by a unique integer identifier and has a label describing its origin. It is associated with a string representing the amino acids encoded by the codons.

Sourceval genetic_codes : genetic_code list

List of genetic codes specified by the NCBI.

The list contains tuples with the following components:

  • Genetic code identifier (integer)
  • Genetic code label (string)
  • String representation of the amino acids encoded by the codons
Sourceval transl_table : genetic_code -> int

Translation table of a genetic code to its identifier

Sourceval label_of_genetic_code : genetic_code -> string
include S
include Alphabet.S_int
include Alphabet.S with type t = private int and type vector = private Linear_algebra.vec and type matrix = private Linear_algebra.mat and type 'a table = private 'a array
Sourcetype t = private int
Sourcetype vector = private Linear_algebra.vec
Sourcetype matrix = private Linear_algebra.mat
Sourcetype 'a table = private 'a array
Sourceval equal : t -> t -> bool
Sourceval compare : t -> t -> int
Sourceval all : t list
Sourceval card : int
Sourceval to_int : t -> int
Sourceval counts : t Core.Sequence.t -> int table
Sourcemodule Table : sig ... end
Sourcemodule Vector : sig ... end
Sourceval flat_profile : unit -> vector
Sourceval random_profile : Gsl.Rng.t -> float -> vector
Sourcemodule Matrix : sig ... end
Sourceval (.%()) : vector -> t -> float
Sourceval (.%()<-) : vector -> t -> float -> unit
Sourceval (.%{}) : matrix -> (t * t) -> float
Sourceval (.%{}<-) : matrix -> (t * t) -> float -> unit
Sourceval of_int : int -> t option
Sourceval of_int_exn : int -> t
Sourceval to_string : t -> string

to_string c returns a string representation of codon c

Example:

  let codon_option = Codon.of_string "ATG" in
  match codon_option with
  | Some codon -> assert (Codon.to_string codon = "ATG")
  | None -> failwith "Invalid codon string"

In this example, the codon is converted to its string representation. The string representation is then compared to the expected value.

Sourceval of_string : string -> t option

of_string s tries tp build a codon from a string representation. It returns None if the string is not a valid codon

Sourceval neighbours : t -> t -> (int * Nucleotide.t * Nucleotide.t) option

neighbours p q tests if codons p and q are neighbors that is, if they differ by exactly one nucleotide. If so, the function returns the index of the differing nucleotide and the nucleotides themselves; it returns None if the codons are not neighbors.

Example:

  let codon_p = Codon.of_string "ATA" in
  let codon_q = Codon.of_string "ATG" in
  match Codon.neighbours codon_p codon_q with
  | Some (index, nucleotide_p, nucleotide_q) ->
    assert (index = 2);
    assert (nucleotide_p = Nucleotide.A);
    assert (nucleotide_q = Nucleotide.G)
  | None -> failwith "Codons are not neighbors"

In this example, the codons are compared to find the index of the differing nucleotide and the nucleotides themselves. The index and nucleotides are then compared to the expected values.

nucleotides c returns the triplet of nucleotides of c

Example :

  let codon_option = Codon.of_string "ATG" in
  match codon_option with
  | None -> failwith "Invalid codon string"
  | Some codon ->
    let (n1, n2, n3) = Codon.nucleotides codon in
    assert (n1 = Nucleotide.A);
    assert (n2 = Nucleotide.T);
    assert (n3 = Nucleotide.G)

In this example, the nucleotides of the codon are extracted and compared to the expected values.

Sourcemodule type Genetic_code = sig ... end

Universal genetic code module.

Sourceval genetic_code_impl : genetic_code -> (module Genetic_code)

Get the implementation module for a genetic code.

  let module Genetic_code = Codon.genetic_code_impl genetic_code in
  let stop_codons = Genetic_code.stop_codons in
  assert (List.length stop_codons = 3)
OCaml

Innovation. Community. Security.