Acid rules!

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{--

You have the following 20 amino acids defined in acids.defs

a: gct gcc gca gcg
c: tgt tgc
d: gat gac
e: gaa gag
f: ttt ttc
g: ggt ggc gga ggg
h: cat cac
i: att atc ata
k: aaa aag
l: tta ttg ctt ctc cta ctg
m: atg
n: aat aac
p: cct ccc cca ccg
q: caa cag
r: cgt cgc cga cgg aga agg
s: tct tcc tca tcg agt agc
t: act acc acg
v: gtt gtc gta gtg
w: tgg
y: tat tac

That is, amino acids are defined by various sets of nucleotide triples,
so, for example, the amino acid y is either the nucleotide triple tat OR 
it is the nucleotide triple tac.

For the purpose of this exercise, the above definitions are fixed, or
static.

Hm.

1. Recall the declaration of the bases from the last exercise:

 --}

data Base = A | T | C | G
   deriving (Eq, Ord, Show, Read)

{--

Declare a data type for amino acids. Read in the above definitions and
verify that each nucleotide triple uniquely defines an amino acid. Than is, an
amino acid may be represented by more than one nucleotide triple, but not
the other way around, am I right? ... or am I wrong? Confirm. 

2. Or, put another way, given the data types you declare for NucleotideTriple
and AminoAcid, and the definitions of the amino acids:

 --}

data NucleotideTriple = SomethingOrOtherComposedEntirelyOfBases
   deriving (Eq, Ord)

data AminoAcid = PairedAcidNameToNucleotideTripleSets
   deriving (Eq, Ord)

data AminoAcidDefinitions = SetOfAminoAcidDefinitions

{--

(AminoAcidDefinitions could be construed (or constructed as) a type-synonym)

define the following function:

 --}

acid :: NucleotideTriple -> AminoAcidDefintions -> [AminoAcid]
acid triple defs = undefined

{--

Verify that the number of solutions for any nucleotide triple is at most one,
given the acids.defs file provided above.

If that be the case, is there a better result type for the function acid?
What is it?

3. What are the total number of all possible nucleotide triples, given that 
a nucleotide triple is composed of three bases defined above?

4. How many representations for the acid kmspdw are there? Write a function:

 --}

target :: String -> AminoAcidDefinitions -> [[NucleotideTriple]]
target aminoAcid defs = undefined

{--

That gives you a list of all possible NucleotideTriple sequences from a given
amino acid target.

Notice something, incidentally, for both the acid and the target functions:
list is used to represent nondeterminism, but it's also used to represent
a string, or an 'ordered sequence,' of elements. This is a strength of List a,
right? that it can be used so nonspecifically; its strength and its weakness.

Thought: what is a better data type to represent nondeterminism (that is:
a function may have none, one, or many solutions from a given input)? What is
a better data type to represent an (rigidly?) ordered input or output sequence
of elements?

Your thoughts and experiences on this?

Citation for this problem statement: I found the article upon which this 
problem was based, all these years ago. The acid definitions and the KMSPDW
sequence was from a puzzle set in Doctor Dobb's Journal. 

link: http://www.drdobbs.com/dr-eccos-omniheurist-corner/184405008

 --}

-- a solution is provided at: http://lpaste.net/107069