package phylogenetics

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

Source file amino_acid.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
open Base

include Alphabet.Make(struct let card = 20 end)

let chars_of_aa_string = "ACDEFGHIKLMNPQRSTVWY"

let%test "chars_of_aa_string" =
  String.length chars_of_aa_string = card

let to_char i = chars_of_aa_string.[i]

let code_A = Char.to_int 'A'

let aa_of_chars =
  let t = Array.create ~len:26 None in
  for i = 0 to String.length chars_of_aa_string - 1 do
    t.(Char.to_int chars_of_aa_string.[i] - code_A) <- Some i
  done ;
  t

let of_char = function
  | 'A'..'Z' as c -> aa_of_chars.(Char.to_int c - code_A)
  | _ -> None

let%test "of_char" =
  let open Poly in
  of_char (to_char 19) = Some 19
  && of_char 'Z' = None
OCaml

Innovation. Community. Security.