It seems that replace does not yet make translations, like, say, tr in Bash. Instead, here are a couple of approaches using word matching (the BioJulia package also seems to use similar dictionaries):
compliments = Dict('A' => 'T', 'C' => 'G', 'G' => 'C', 'T' => 'A')
Then, if str = "AAAACCCGGT" , you can use join as follows:
julia> join([compliments[c] for c in str]) "TTTTGGGCCA"
Another approach might be to use a function and map :
function translate(c) compliments[c] end
Then:
julia> map(translate, str) "TTTTGGGCCA"
Strings are exterminated objects in Julia; each of these approaches reads one character, in turn, c and passes it to the dictionary to return a free character. A new line is created from these free characters.
Julia strings are also immutable: you cannot change characters around, but you need to create a new string.
source share