File: Alphabet.hs

package info (click to toggle)
bali-phy 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,392 kB
  • sloc: cpp: 120,442; xml: 13,966; haskell: 9,975; python: 2,936; yacc: 1,328; perl: 1,169; lex: 912; sh: 343; makefile: 26
file content (74 lines) | stat: -rw-r--r-- 2,414 bytes parent folder | download
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module Bio.Alphabet where

import Foreign.String -- For CPPString
import Data.Text (Text)
import qualified Data.Text as T

data Alphabet

data GeneticCode

-- This should only take a Triplets or Codons!
foreign import bpcall "Alphabet:" getNucleotides :: Alphabet -> Alphabet

-- This should only take a Triplets or Codons!
foreign import bpcall "Alphabet:" getAminoAcids :: Alphabet -> Alphabet

foreign import bpcall "Alphabet:" alphabetSize :: Alphabet -> Int

foreign import bpcall "Alphabet:alphabet_letters" builtin_letters :: Alphabet -> EVector CPPString
getLetters a = map listFromString (vectorToList (builtin_letters a) )

foreign import bpcall "Alphabet:find_letter" builtin_find_letter :: Alphabet -> CPPString -> Int
findLetter a letter = builtin_find_letter a (list_to_string letter)

foreign import bpcall "Alphabet:" translate :: Alphabet -> Int -> Int

foreign import bpcall "Alphabet:" mkDoublets :: Alphabet -> Alphabet

foreign import bpcall "Alphabet:" mkRNAEdits :: Alphabet -> Alphabet

foreign import bpcall "Alphabet:" mkTriplets :: Alphabet -> Alphabet

foreign import bpcall "Alphabet:" mkCodons :: Alphabet -> GeneticCode -> Alphabet

foreign import bpcall "Alphabet:dna" builtin_dna :: () -> Alphabet
dna = builtin_dna ()

foreign import bpcall "Alphabet:rna" builtin_rna :: () -> Alphabet
rna = builtin_rna ()

foreign import bpcall "Alphabet:aa" builtin_aa  :: () -> Alphabet
aa  = builtin_aa  ()
amino_acids = builtin_aa

foreign import bpcall "Alphabet:aaWithStop" builtin_aaWithStop :: () -> Alphabet
aaWithStop = builtin_aaWithStop ()
amino_acids_with_stop = builtin_aaWithStop ()

foreign import bpcall "Alphabet:" mkNumeric :: Int -> Alphabet

-- https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi
foreign import bpcall "Alphabet:" geneticCodeByNumber :: Int -> GeneticCode
foreign import bpcall "Alphabet:" geneticCodeRaw :: CPPString -> GeneticCode
geneticCode name = geneticCodeRaw (pack_cpp_string name)

standard_code = geneticCodeByNumber 1

foreign import bpcall "Alphabet:" sequenceToTextRaw :: Alphabet -> EVector Int -> CPPString
sequenceToText a s = T.fromCppString $ sequenceToTextRaw a s

class HasAlphabet x where
    getAlphabet :: x -> Alphabet

gapCharIndex = -1 :: Int

missingCharIndex = -2 :: Int

type SMap = EVector Int

class HasAlphabet x => HasSMap x where
    getSMap :: x -> SMap

instance Show Alphabet where
    show a = show (getLetters a)