Skip to content

Commit a80c198

Browse files
add hand-written solution
1 parent 3b086db commit a80c198

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

docs/src/rosalind/08-prot.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,21 @@ codon_table = Dict{String,Char}(
8787
"UUA" => 'L', "UUC" => 'F', "UUG" => 'L', "UUU" => 'F',
8888
)
8989

90-
91-
# check if starts with start codon
92-
93-
# check if string is divisible by three
94-
95-
# separate string into codons, map over with codon table
96-
97-
# dealing with codons not in codon_table
98-
99-
# return amino acid string
90+
function translate_mrna(seq)
91+
# check if starts with start codon
92+
if startswith(seq, "AUG")
93+
warn("this sequence does not start with AUG")
94+
end
95+
# check if string is divisible by three
96+
if seq%3!=0
97+
warn("this sequence is not divisible by 3")
98+
end
99+
# separate string into codons, map over with codon table
100+
codons = (join(chunk) for chunk in Iterators.partition(seq, 3))
101+
102+
protein = join(codon_table[c] for c in codons if haskey(codon_table, c))
103+
104+
# return amino acid string
100105

101106
```
102107

0 commit comments

Comments
 (0)