Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: (Golf) RNA Genetic Code Translator

by MeowChow (Vicar)
on Jul 06, 2001 at 02:45 UTC ( [id://94318]=note: print w/replies, xml ) Need Help??


in reply to (Golf) RNA Genetic Code Translator

Here's a swing, strict at 222:
sub f { my@r=qw(UA[AG]|UGA GC. - UG[UC] GA[UC] GA[AG] UU[UC] GG. CA[UC] AU[^ +G] - AA[AG] CU.|UU[AG] AUG AA[UC] - CC. CA[AG] CG.|AG[AG] UC.|AG[UC] AC. - GU. UGG - UA[UC] +); ((my$t=pop)=~s|...|chr 64+(grep$&=~/$r[$_]/,0..25)[0]|eg);$t=~y/@/./ +;$t }
update: I can't count, the one above is actually 232. And as no_slogan points out, it's sometimes helpful to read the spec. 238 chars:
sub f { my@r=qw(UA[AG]|UGA GC. - UG[UC] GA[UC] GA[AG] UU[UC] GG. CA[UC] AU[^ +G] - AA[AG] CU.|UU[AG] AUG AA[UC] - CC. CA[AG] CG.|AG[AG] UC.|AG[UC] +AC. - GU. UGG - UA[UC] ^); ((my$t=pop)=~s|..?.?|chr 64+(grep$&=~/$r[$_]/,0..26)[0]|eg);$t=~y/@Z +/./d;$t }
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: Re: (Golf) RNA Genetic Code Translator
by no_slogan (Deacon) on Jul 06, 2001 at 03:07 UTC
    That's a pretty nifty way to do the encoding. It doesn't eliminate trailing characters that aren't part of a group of three, though.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-25 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found