Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>#!/usr/bin/perl %p=qw/UUU F UUC F UUA L UUG L UCU S UCC S UCA S UCG S UAU Y UAC Y UGU C UGC C UGG W CUU L CUC L CUA L CUG L CCU P CCC P CCA P CCG P CAU H CAC H CAA Q CAG Q CGU R CGC R CGA R CGG R AUU I AUC I AUA I AUG M ACU T ACC T ACA T ACG T AAU N AAC N AAA K AAG K AGU S AGC S AGA R AGG R GUU V GUC V GUA V GUG V GCU A GCC A GCA A GCG A GAU D GAC D GAA E GAG E GGU G GGC G GGA G GGG G/; $_=uc&lt;DATA&gt;;y/GCTA/CGAU/;map{print if$_=$p{$_}}/(...)/g __DATA__ TCATAATACGTTTTGTATTCGCCAGCGCTTCGGTGT </code></pre> <p>Phew. Best I can come up with, at least this quickly. If you're sure the input is always already in uppercase, you can also drop the <code>uc</code> saving another two characters. Or if the input is always the same, you could assign it to <code>$_</code> straight away instead of reading it from anywhere.</p> <p>I guess I don't need to say that this code should <strong>not</strong> be used in production environments or anywhere else other than pure fun. When doing actual programming, readability almost always wins over compactness.</p> <p>A few other versions I mentioned in the comments:</p> <p>Reading %p and the DNA from files:</p> <pre><code>#!/usr/bin/perl open A,"&lt;p.txt";map{map{/(...)/;$p{$1}=chop}/(... .)/g}&lt;A&gt;; open B,"&lt;dna.txt";$_=uc&lt;B&gt;;y/GCTA/CGAU/;map{print if$_=$p{$_}}/(...)/g </code></pre> <p>From shell with <code>perl -e</code>:</p> <pre><code>perl -e 'open A,"&lt;p.txt";map{map{/(...)/;$p{$1}=chop}/(... .)/g}&lt;A&gt;;open B,"&lt;dna.txt";$_=uc&lt;B&gt;;y/GCTA/CGAU/;map{print if$_=$p{$_}}/(...)/g' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload