Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: need help comparing DNA compliments

by broquaint (Abbot)
on Mar 17, 2003 at 16:01 UTC ( [id://243671]=note: print w/replies, xml ) Need Help??


in reply to need help comparing DNA compliments

If you're just comparing 2 strings then this should do the trick
my @pairs = ( [qw/ATCG TAGC/], [qw/ACTG TGAT/] ); print "@$_: ", (dna_compare(@$_) ? "matched" : "didn't matched"), $/ for @pairs; sub dna_compare { my($dna, $comp) = @_; return !scalar grep { (substr($dna, $_, 1).substr($comp, $_, 1)) !~ m< ^ (?: AT | TA | GC | CG ) \z >x; } 0 .. (length($dna) - 1); } __output__ ATCG TAGC: matched ACTG TGAT: didn't matched

HTH

_________
broquaint

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2024-04-18 08:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found