Here is one solution:
str = "ACGT"
d = Dict("A"=>"T", "C"=> "G", "G"=>"C", "T"=>"A")
y = replace(str, r"[ACGT]{1}", x->d[x]) # "TGCA"
reverse() is on the top of that
On Thu, Mar 3, 2016 at 3:26 PM Carlos Guzman <[email protected]> wrote:
> I'm relatively new to programming. Started picking up Julia yesterday, and
> am having trouble with something I suspect is very simple to do. I've spent
> some time searching, but haven't been able to get this to work.
>
> I am essentially trying to answer this question here:
> http://rosalind.info/problems/revc/
>
> This isn't homework or related to school in anyway. I am simply trying to
> learn how to write small scripts for various tasks.
>
> I am trying to reverse my string s, and then replace the characters A C G
> T with T G C A. So every 'A' with a 'T' and so on. Here's what i've written
> so far, and after various attempts I don't know how to complete the
> function to get what I want.
>
> # creating complementary strand of DNA
> # reverse the string
> # find the complementary nucleotide
>
>
> s = readall("nt.txt")
>
>
> t = reverse((replace(s, r"[ACGT]", ))) # Not sure what goes here
>
>
> println("$t")
>
> All help is appreciated, and I apologize for the relatively simple
> question.
>