Carlos

You are trying to use pattern matching, which is mostly used to find
patterns in strings. In your case, it seems the string consists
exclusively of these characters, and you want to replace all of them.
I would use `map` for this.

function dual(c::Char)
    c=='A' && return 'T'
    c=='C' && return 'G'
    ... etc ...
end

newstring = reverse(map(dual, string))

-erik



On Thu, Mar 3, 2016 at 11:41 AM, 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.



-- 
Erik Schnetter <[email protected]>
http://www.perimeterinstitute.ca/personal/eschnetter/

Reply via email to