Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: mismatching characters in dna sequence

by choroba (Cardinal)
on Dec 30, 2011 at 01:11 UTC ( [id://945580]=note: print w/replies, xml ) Need Help??


in reply to Re^2: mismatching characters in dna sequence
in thread mismatching characters in dna sequence

If you apply binary xor (exclusive-or) on the strings, you get another string as a result. This string contains the null character in places where the two strings were identical, and various other characters in positions where the two strings were different. For each tuple of letters, the result is different.
  • Comment on Re^3: mismatching characters in dna sequence

Replies are listed 'Best First'.
Re^4: mismatching characters in dna sequence
by Eliya (Vicar) on Dec 30, 2011 at 01:31 UTC
    For each tuple of letters, the result is different.

    A problem might be (depending on what exactly the OP needs) that "A" ^ "T" is the same as "T" ^ "A" (etc.), so the direction of the change (i.e. A->T or T->A) would be lost with this simple approach.

Re^4: mismatching characters in dna sequence
by prbndr (Acolyte) on Dec 30, 2011 at 01:47 UTC
    yes, i need to know the direction of change.
      You can get the information back from the strings if needed:
      use warnings; use strict; my $source="ATTCCGGG"; print "source: $source\n"; for my $str ( "ATTGCGGG", "ATACCGGC", "ACTGCGGT" , "ATCGGGGG" ) { print "string: $str\n"; my @res = unpack "c*", $source ^ $str; for my $i (grep $res[$_], 0 .. $#res) { print "$i: ", substr($source, $i, 1), "->", substr($str, $i, 1), "\n"; } }
      I am not sure how fast this is compared to the PDL solution.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://945580]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found