Today on #perl6:
<masak> rakudo: subset DNA of Str where { all(.uc.comb) eq any <A C G T> }; my DNA $dna = "gattaca"; say $dna;
<p6eval> rakudo 0e8a86: OUTPUTëgattacaû
<jnthn> rakudo: subset DNA of Str where { all(.uc.comb) eq any <A C G T>}; my DNA $dna = "lolnotdna"; say $dna;
<p6eval> rakudo 0e8a86: OUTPUTëAssignment type check failed [...]
<jnthn> (just checking :-))
<TimToady> course, where not /<-[ACGTactg]>/ might beat all those
<moritz_> but it involves no junction, so it can't be any good :-)
<TimToady> ttaggg &
<masak> halp, TimToady is speaking in DNA bases!
<masak> is my hunch right, and that actually means something as amino acids?
* masak checks
<pyrimidine> yes
<masak> TimToady++
<masak> rakudo: my $dna = "ttaagg"; sub translate($dna) { "FFLLSSSSYY!!CC!WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG".comb[map { :4($_) }, $dna.trans("tcag" => "0123").comb(/.../)] }; say translate($dna)
<p6eval> rakudo 0e8a86: OUTPUTëLRû
<masak> that's what I got too.
<pyrimidine> masak: nice!
<masak> I know! :)
<masak> I should blog about it.
<masak> "The Genetic Code one-liner in Perl 6"
A hyper-short summary of what that one-liner does:
$dna.trans("tcag" => "0123")
.comb(/.../)
map { :4($_) }
Perl 6 feels more like a power tool every day.