@@ -71,7 +71,7 @@ rna = "AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA"
7171
7272# note: this can be created by hand
7373# or it can be accessed from the BioSequences package (see link above)
74- codon_table = Dict {String,Char} (
74+ codon_table = Dict (
7575 " AAA" => ' K' , " AAC" => ' N' , " AAG" => ' K' , " AAU" => ' N' ,
7676 " ACA" => ' T' , " ACC" => ' T' , " ACG" => ' T' , " ACU" => ' T' ,
7777 " AGA" => ' R' , " AGC" => ' S' , " AGG" => ' R' , " AGU" => ' S' ,
@@ -101,13 +101,14 @@ function translate_mrna(seq, codon_table)
101101 @warn " this sequence is not divisible by 3"
102102 end
103103 # separate string into codons
104+ # this makes a generator, which allocates less memory than a vector
104105 codons = (join (chunk) for chunk in Iterators. partition (seq, 3 ))
105106
106107 # map over codons with codon table, return X if not in codon_table
107108 aa_string = join (get (codon_table, c, " X" ) for c in codons)
108109
109110 # return amino acid string
110- return ( aa_string)
111+ return aa_string
111112
112113end
113114
@@ -123,7 +124,7 @@ established function from the BioSequences package in BioJulia.
123124``` julia
124125using BioSequences
125126
126- rna = ( " AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA" )
127+ rna = " AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA"
127128
128129translate (rna " AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA" )
129130
0 commit comments