|
| 1 | +import "protein_translation" |
| 2 | + |
| 3 | +-- Empty RNA sequence results in no proteins |
| 4 | +-- == |
| 5 | +-- input { "" } |
| 6 | +-- output { empty([0][13]u8) } |
| 7 | + |
| 8 | +-- Methionine RNA sequence |
| 9 | +-- == |
| 10 | +-- input { "AUG" } |
| 11 | +-- output { ["Methionine "] } |
| 12 | + |
| 13 | +-- Phenylalanine RNA sequence 1 |
| 14 | +-- == |
| 15 | +-- input { "UUU" } |
| 16 | +-- output { ["Phenylalanine"] } |
| 17 | + |
| 18 | +-- Phenylalanine RNA sequence 2 |
| 19 | +-- == |
| 20 | +-- input { "UUC" } |
| 21 | +-- output { ["Phenylalanine"] } |
| 22 | + |
| 23 | +-- Leucine RNA sequence 1 |
| 24 | +-- == |
| 25 | +-- input { "UUA" } |
| 26 | +-- output { ["Leucine "] } |
| 27 | + |
| 28 | +-- Leucine RNA sequence 2 |
| 29 | +-- == |
| 30 | +-- input { "UUG" } |
| 31 | +-- output { ["Leucine "] } |
| 32 | + |
| 33 | +-- Serine RNA sequence 1 |
| 34 | +-- == |
| 35 | +-- input { "UCU" } |
| 36 | +-- output { ["Serine "] } |
| 37 | + |
| 38 | +-- Serine RNA sequence 2 |
| 39 | +-- == |
| 40 | +-- input { "UCC" } |
| 41 | +-- output { ["Serine "] } |
| 42 | + |
| 43 | +-- Serine RNA sequence 3 |
| 44 | +-- == |
| 45 | +-- input { "UCA" } |
| 46 | +-- output { ["Serine "] } |
| 47 | + |
| 48 | +-- Serine RNA sequence 4 |
| 49 | +-- == |
| 50 | +-- input { "UCG" } |
| 51 | +-- output { ["Serine "] } |
| 52 | + |
| 53 | +-- Tyrosine RNA sequence 1 |
| 54 | +-- == |
| 55 | +-- input { "UAU" } |
| 56 | +-- output { ["Tyrosine "] } |
| 57 | + |
| 58 | +-- Tyrosine RNA sequence 2 |
| 59 | +-- == |
| 60 | +-- input { "UAC" } |
| 61 | +-- output { ["Tyrosine "] } |
| 62 | + |
| 63 | +-- Cysteine RNA sequence 1 |
| 64 | +-- == |
| 65 | +-- input { "UGU" } |
| 66 | +-- output { ["Cysteine "] } |
| 67 | + |
| 68 | +-- Cysteine RNA sequence 2 |
| 69 | +-- == |
| 70 | +-- input { "UGC" } |
| 71 | +-- output { ["Cysteine "] } |
| 72 | + |
| 73 | +-- Tryptophan RNA sequence |
| 74 | +-- == |
| 75 | +-- input { "UGG" } |
| 76 | +-- output { ["Tryptophan "] } |
| 77 | + |
| 78 | +-- STOP codon RNA sequence 1 |
| 79 | +-- == |
| 80 | +-- input { "UAA" } |
| 81 | +-- output { empty([0][13]u8) } |
| 82 | + |
| 83 | +-- STOP codon RNA sequence 2 |
| 84 | +-- == |
| 85 | +-- input { "UAG" } |
| 86 | +-- output { empty([0][13]u8) } |
| 87 | + |
| 88 | +-- STOP codon RNA sequence 3 |
| 89 | +-- == |
| 90 | +-- input { "UGA" } |
| 91 | +-- output { empty([0][13]u8) } |
| 92 | + |
| 93 | +-- Sequence of two protein codons translates into proteins |
| 94 | +-- == |
| 95 | +-- input { "UUUUUU" } |
| 96 | +-- output { ["Phenylalanine", "Phenylalanine"] } |
| 97 | + |
| 98 | +-- Sequence of two different protein codons translates into proteins |
| 99 | +-- == |
| 100 | +-- input { "UUAUUG" } |
| 101 | +-- output { ["Leucine ", "Leucine "] } |
| 102 | + |
| 103 | +-- Translate RNA strand into correct protein list |
| 104 | +-- == |
| 105 | +-- input { "AUGUUUUGG" } |
| 106 | +-- output { ["Methionine ", "Phenylalanine", "Tryptophan "] } |
| 107 | + |
| 108 | +-- Translation stops if STOP codon at beginning of sequence |
| 109 | +-- == |
| 110 | +-- input { "UAGUGG" } |
| 111 | +-- output { empty([0][13]u8) } |
| 112 | + |
| 113 | +-- Translation stops if STOP codon at end of two-codon sequence |
| 114 | +-- == |
| 115 | +-- input { "UGGUAG" } |
| 116 | +-- output { ["Tryptophan "] } |
| 117 | + |
| 118 | +-- Translation stops if STOP codon at end of three-codon sequence |
| 119 | +-- == |
| 120 | +-- input { "AUGUUUUAA" } |
| 121 | +-- output { ["Methionine ", "Phenylalanine"] } |
| 122 | + |
| 123 | +-- Translation stops if STOP codon in middle of three-codon sequence |
| 124 | +-- == |
| 125 | +-- input { "UGGUAGUGG" } |
| 126 | +-- output { ["Tryptophan "] } |
| 127 | + |
| 128 | +-- Translation stops if STOP codon in middle of six-codon sequence |
| 129 | +-- == |
| 130 | +-- input { "UGGUGUUAUUAAUGGUUU" } |
| 131 | +-- output { ["Tryptophan ", "Cysteine ", "Tyrosine "] } |
| 132 | + |
| 133 | +-- Sequence of two non-STOP codons does not translate to a STOP codon |
| 134 | +-- == |
| 135 | +-- input { "AUGAUG" } |
| 136 | +-- output { ["Methionine ", "Methionine "] } |
| 137 | + |
| 138 | +-- Unknown amino acids, not part of a codon, can't translate |
| 139 | +-- == |
| 140 | +-- input { "XYZ" } |
| 141 | +-- error: Error* |
| 142 | + |
| 143 | +-- Incomplete RNA sequence can't translate |
| 144 | +-- == |
| 145 | +-- input { "AUGU" } |
| 146 | +-- error: Error* |
| 147 | + |
| 148 | +-- Incomplete RNA sequence can translate if valid until a STOP codon |
| 149 | +-- == |
| 150 | +-- input { "UUCUUCUAAUGGU" } |
| 151 | +-- output { ["Phenylalanine", "Phenylalanine"] } |
| 152 | + |
| 153 | +local def name (a: amino_acid): [13]u8 = |
| 154 | + match a |
| 155 | + case #methionine -> "Methionine " |
| 156 | + case #phenylalanine -> "Phenylalanine" |
| 157 | + case #leucine -> "Leucine " |
| 158 | + case #serine -> "Serine " |
| 159 | + case #tyrosine -> "Tyrosine " |
| 160 | + case #cysteine -> "Cysteine " |
| 161 | + case #tryptophan -> "Tryptophan " |
| 162 | + |
| 163 | +def main (strand: []u8): [][13]u8 = |
| 164 | + map1 name (proteins strand) |
0 commit comments