Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/exercises/protein-translation/.meta/example.om # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / exercises / protein-translation / .meta / example.om` 105 lines ยท 1920 bytes Raw Blame History 1 note Exercism-style exercise "protein-translation": https://exercism.org/tracks/python/exercises/protein-translation 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note proteins translates the RNA strand codon by codon into o, protein names joined by commas: 4 note AUG Methionine; UUU UUC Phenylalanine; UUA UUG Leucine; UCU UCC UCA UCG Serine; UAU UAC 5 note Tyrosine; UGU UGC Cysteine; UGG Tryptophan; UAA UAG UGA stop translation. Returns the number 6 note of bytes written, or -1 when a codon before the first stop is invalid or incomplete. 7 note Check it with: sh exercise.sh exercises/protein-translation 8 om2 9 text pn0 "Methionine" 10 text pn1 "Phenylalanine" 11 text pn2 "Leucine" 12 text pn3 "Serine" 13 text pn4 "Tyrosine" 14 text pn5 "Cysteine" 15 text pn6 "Tryptophan" 16 fn app o edit uchar * p ulong s view uchar * to ulong 17 q = p 18 for i ulong len s 19 put o q get s i 20 q = add q 1 21 end 22 ret q 23 end 24 note codon id: 0 .. 6 a protein as in pn0 .. pn6, 7 stop, 8 invalid 25 fn codon a uchar b uchar c uchar to ulong 26 if and and eq a 65 eq b 85 eq c 71 27 ret 0 28 end 29 if ne a 85 30 ret 8 31 end 32 if not or or or eq c 85 eq c 67 eq c 65 eq c 71 33 ret 8 34 end 35 if eq b 85 36 if or eq c 85 eq c 67 37 ret 1 38 end 39 ret 2 40 end 41 if eq b 67 42 ret 3 43 end 44 if eq b 65 45 if or eq c 85 eq c 67 46 ret 4 47 end 48 ret 7 49 end 50 if eq b 71 51 if or eq c 85 eq c 67 52 ret 5 53 end 54 if eq c 71 55 ret 6 56 end 57 ret 7 58 end 59 ret 8 60 end 61 fn appname o edit uchar * p ulong k ulong to ulong 62 if eq k 0 63 ret app o p pn0 64 end 65 if eq k 1 66 ret app o p pn1 67 end 68 if eq k 2 69 ret app o p pn2 70 end 71 if eq k 3 72 ret app o p pn3 73 end 74 if eq k 4 75 ret app o p pn4 76 end 77 if eq k 5 78 ret app o p pn5 79 end 80 ret app o p pn6 81 end 82 fn proteins strand view uchar * o edit uchar * to long 83 p = ulong 0 84 i = ulong 0 85 n = len strand 86 while lt i n bound 999999 87 if gt add i 3 n 88 ret -1 89 end 90 k = codon get strand i get strand add i 1 get strand add i 2 91 if eq k 8 92 ret -1 93 end 94 if eq k 7 95 break 96 end 97 if gt p 0 98 put o p 44 99 p = add p 1 100 end 101 p = appname o p k 102 i = add i 3 103 end 104 ret long p 105 end