Difference between revisions of "Perl change codon to AA"

From Biolecture.org
imported>Park SeongWan
(Created page with "<p>#!/usr/bin/perl<br /> use strict;<br /> use warnings;</p> <p><br /> my @bases=("u","c","a","g");<br /> my @AA=("F","F&q...")
 
imported>Park SeongWan
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
<p><strong>CODE&nbsp;</strong></p>
 +
 +
<hr />
 
<p>#!/usr/bin/perl<br />
 
<p>#!/usr/bin/perl<br />
 
use strict;<br />
 
use strict;<br />
Line 9: Line 12:
 
&nbsp;&nbsp;&quot;V&quot;,&quot;V&quot;,&quot;V&quot;,&quot;V&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;D&quot;,&quot;D&quot;,&quot;E&quot;,&quot;E&quot;,&quot;G&quot;,&quot;G&quot;,&quot;G&quot;,&quot;G&quot;);</p>
 
&nbsp;&nbsp;&quot;V&quot;,&quot;V&quot;,&quot;V&quot;,&quot;V&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;A&quot;,&quot;D&quot;,&quot;D&quot;,&quot;E&quot;,&quot;E&quot;,&quot;G&quot;,&quot;G&quot;,&quot;G&quot;,&quot;G&quot;);</p>
  
<p><br />
+
<p>my %codon;<br />
for (my $i=0;$i&lt;4;$i++) {<br />
+
my $var;<br />
 +
my %result;</p>
 +
 
 +
<p>for (my $i=0;$i&lt;4;$i++) {<br />
 
for (my $j=0;$j&lt;4;$j++) {<br />
 
for (my $j=0;$j&lt;4;$j++) {<br />
for (my $k=0;$k&lt;4;$k++) {</p>
+
for (my $k=0;$k&lt;4;$k++) {<br />
 +
&nbsp;$var=$bases[$i]. $bases[$j]. $bases[$k];<br />
 +
&nbsp;$codon{$var} = $AA[16*($i)+4*($j)+($k)];</p>
 +
 
 +
<p>}}}</p>
  
 
<p><br />
 
<p><br />
&nbsp;print $bases[$i], $bases[$j], $bases[$k], &quot; &quot;,&nbsp; $AA[16*($i)+4*($j)+($k)], &quot;&nbsp; &quot;;<br />
+
print %codon , &quot;\n&quot;;</p>
}}<br />
+
 
print &quot;\n&quot;;}</p>
+
<p>print $codon{&quot;uuu&quot;};</p>
  
 
<p>&nbsp;</p>
 
<p>&nbsp;</p>
  
<p>uuu F&nbsp; uuc F&nbsp; uua L&nbsp; uug L&nbsp; ucu S&nbsp; ucc S&nbsp; uca S&nbsp; ucg S&nbsp; uau Y&nbsp; uac Y&nbsp; uaa .&nbsp; uag .&nbsp; ugu C&nbsp; ugc C&nbsp; uga .&nbsp; ugg W<br />
+
<p><strong>Result</strong></p>
cuu L&nbsp; cuc L&nbsp; cua L&nbsp; cug L&nbsp; ccu P&nbsp; ccc P&nbsp; cca P&nbsp; ccg P&nbsp; cau H&nbsp; cac H&nbsp; caa Q&nbsp; cag Q&nbsp; cgu R&nbsp; cgc R&nbsp; cga R&nbsp; cgg R<br />
+
 
auu I&nbsp; auc I&nbsp; aua I&nbsp; aug M&nbsp; acu T&nbsp; acc T&nbsp; aca T&nbsp; acg T&nbsp; aau N&nbsp; aac N&nbsp; aaa K&nbsp; aag K&nbsp; agu S&nbsp; agc S&nbsp; aga R&nbsp; agg R<br />
+
<hr />
guu V&nbsp; guc V&nbsp; gua V&nbsp; gug V&nbsp; gcu A&nbsp; gcc A&nbsp; gca A&nbsp; gcg A&nbsp; gau D&nbsp; gac D&nbsp; gaa E&nbsp; gag E&nbsp; ggu G&nbsp; ggc G&nbsp; gga G&nbsp; ggg G</p>
+
<p>gggGuucFgguGaugMccaPauuIaacNccuPggaGacuTucuSgcuAcuuLcguRuuuFguuVgccAcuaLaucIggcGgagE</p>
 +
 
 +
<p>aauNcugLgauDaccTaagKuga.cgaRgcgAuuaLuaa.acgTgugVcauHuguCgcaAgucVuccSuacYagcSuauYucaS</p>
 +
 
 +
<p>acaTuugLauaIccgPcacHgaaEgacDcagQcggRcccPaggRaguSuag.cgcRguaVuggWugcCucgSagaRcucLaaaKcaaQ</p>
 +
 
 +
<p>F</p>
  
 
<p>&nbsp;</p>
 
<p>&nbsp;</p>

Latest revision as of 18:57, 23 May 2016

CODE 


#!/usr/bin/perl
use strict;
use warnings;


my @bases=("u","c","a","g");
my @AA=("F","F","L","L","S","S","S","S","Y","Y",".",".","C","C",".","W","L","L","L","L","P","P","P","P",
  "H","H","Q","Q","R","R","R","R","I","I","I","M","T","T","T","T","N","N","K","K","S","S","R","R",
  "V","V","V","V","A","A","A","A","D","D","E","E","G","G","G","G");

my %codon;
my $var;
my %result;

for (my $i=0;$i<4;$i++) {
for (my $j=0;$j<4;$j++) {
for (my $k=0;$k<4;$k++) {
 $var=$bases[$i]. $bases[$j]. $bases[$k];
 $codon{$var} = $AA[16*($i)+4*($j)+($k)];

}}}


print %codon , "\n";

print $codon{"uuu"};

 

Result


gggGuucFgguGaugMccaPauuIaacNccuPggaGacuTucuSgcuAcuuLcguRuuuFguuVgccAcuaLaucIggcGgagE

aauNcugLgauDaccTaagKuga.cgaRgcgAuuaLuaa.acgTgugVcauHuguCgcaAgucVuccSuacYagcSuauYucaS

acaTuugLauaIccgPcacHgaaEgacDcagQcggRcccPaggRaguSuag.cgcRguaVuggWugcCucgSagaRcucLaaaKcaaQ

F