Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: need help comparing DNA compliments

by benn (Vicar)
on Mar 17, 2003 at 16:00 UTC ( [id://243670]=note: print w/replies, xml ) Need Help??


in reply to need help comparing DNA compliments

Looks suspiciouly like a homework assignment to me, but as you've actually posted code, here goes...:)

The first two lines stuff the arrays with the individual letters - it's not obvious from your code whether this is initially the case or not.

The '%pairs' hash demonstrates one way of avoiding large numbers of 'if' statements.
my @dna = split("","ATCTGCG"); my @comp = split("","TCTGCAA"); my %pairs = qw(A T T A G C C G); foreach (0..$#dna) { my $d = $dna[$_]; my $c = $comp[$_]; print "$_: $d - $c is a mispair\n" unless ($pairs{$d} eq $c); }
Hope this helps.

Update ROFLMAO! Marvellous how so many people can come up with the same routine written so many ways in 5 minutes :) Go monks! :)

Log In?
Username:
Password:

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

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

    No recent polls found