Skip to content

Commit 2d54bc9

Browse files
fix bugs in warnings
1 parent 3ebe9c3 commit 2d54bc9

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

Project.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/src/rosalind/08-prot.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Now that we have established an approach,
6363
let's turn this into code!
6464

6565
```julia
66+
using Test
6667

6768
rna = "AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA"
6869

@@ -87,23 +88,28 @@ codon_table = Dict{String,Char}(
8788
"UUA" => 'L', "UUC" => 'F', "UUG" => 'L', "UUU" => 'F',
8889
)
8990

90-
function translate_mrna(seq)
91+
function translate_mrna(seq, codon_table)
92+
9193
# check if starts with start codon
92-
if startswith(seq, "AUG")
93-
warn("this sequence does not start with AUG")
94+
if ! startswith(seq, "AUG")
95+
@warn "this sequence does not start with AUG"
9496
end
9597
# check if string is divisible by three
96-
if seq%3!=0
97-
warn("this sequence is not divisible by 3")
98+
if rem(length(seq), 3) != 0
99+
@warn "this sequence is not divisible by 3"
98100
end
99101
# separate string into codons
100102
codons = (join(chunk) for chunk in Iterators.partition(seq, 3))
101103

102-
# map over codons with codon table
104+
# map over codons with codon table, return X if not in codon_table
103105
aa_string = join(get(codon_table, c, "X") for c in codons)
104106

105107
# return amino acid string
106108
return(aa_string)
109+
110+
end
111+
112+
translate_mrna(rna, codon_table)
107113
```
108114

109115

0 commit comments

Comments
 (0)