Difference between revisions of "2. Make a Perl program translating 'all' combinations of triple bases into amino acids -YJ code:309ir"
imported>Yeong Jae Kim (Created page with "<p>aim . translating triple base codes convert into amino acids</p> <p>strategy.</p> <p>code.</p> <p> </p>") |
imported>Yeong Jae Kim |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<p>aim . translating triple base codes convert into amino acids</p> | <p>aim . translating triple base codes convert into amino acids</p> | ||
− | <p> | + | <p> </p> |
− | <p> | + | <p> </p> |
<p> </p> | <p> </p> | ||
+ | |||
+ | <p>-------------------------------------------------------------------------------------------------------------------------------------</p> | ||
+ | |||
+ | <p>#!/usr/bin/perl<br /> | ||
+ | use strict;<br /> | ||
+ | use warnings;<br /> | ||
+ | #this function is translating 'all' combinations of triple bases into amino acids<br /> | ||
+ | my %basetoaa= (<br /> | ||
+ | "UUU" => "F", "UUC" => "F",<br /> | ||
+ | "UUA" => "L", "UUG" => "L",<br /> | ||
+ | "CUU" => "L", "CUC" => "L",<br /> | ||
+ | "CUA" => "L", "CUG" => "L",<br /> | ||
+ | "AUU" => "I", "AUC" => "I",<br /> | ||
+ | "AUA" => "I", "AUG" => "M",<br /> | ||
+ | "GUU" => "V", "GUC" => "V",<br /> | ||
+ | "GUA" => "V", "GUG" => "V",<br /> | ||
+ | <br /> | ||
+ | "UCU" => "S", "UCC" => "S",<br /> | ||
+ | "UCA" => "S", "UCG" => "S",<br /> | ||
+ | "CCU" => "P", "CCC" => "P",<br /> | ||
+ | "CCA" => "P", "CCG" => "P",<br /> | ||
+ | "ACU" => "T", "ACC" => "T",<br /> | ||
+ | "ACA" => "T", "ACG" => "T",<br /> | ||
+ | "GCU" => "A", "GCC" => "A",<br /> | ||
+ | "GCA" => "A", "GCG" => "A",<br /> | ||
+ | <br /> | ||
+ | "UAU" => "Y", "UAC" => "Y",<br /> | ||
+ | "UAA" => "*", "UAG" => "*",<br /> | ||
+ | "CAU" => "H", "CAC" => "H",<br /> | ||
+ | "CAA" => "Q", "CAG" => "Q",<br /> | ||
+ | "AAU" => "N", "AAC" => "N",<br /> | ||
+ | "AAA" => "K", "AAG" => "K",<br /> | ||
+ | "GAU" => "D", "GAC" => "D",<br /> | ||
+ | "GAA" => "E", "GAG" => "E",<br /> | ||
+ | <br /> | ||
+ | "UGU" => "C", "UGC" => "C",<br /> | ||
+ | "UGA" => "*", "UGG" => "W",<br /> | ||
+ | "CGU" => "R", "CGC" => "R",<br /> | ||
+ | "CGA" => "R", "CGG" => "R",<br /> | ||
+ | "AGU" => "S", "AGC" => "S",<br /> | ||
+ | "AGA" => "R", "AGG" => "R",<br /> | ||
+ | "GGU" => "G", "GGC" => "G",<br /> | ||
+ | "GGA" => "G", "GGG" => "G",<br /> | ||
+ | <br /> | ||
+ | "TTT" => "F", "TTC" => "F",<br /> | ||
+ | "TTA" => "L", "TTG" => "L",<br /> | ||
+ | "CTT" => "L", "CTC" => "L",<br /> | ||
+ | "CTA" => "L", "CTG" => "L",<br /> | ||
+ | "ATT" => "I", "ATC" => "I",<br /> | ||
+ | "ATA" => "I", "ATG" => "M",<br /> | ||
+ | "GTT" => "V", "GTC" => "V",<br /> | ||
+ | "GTA" => "V", "GTG" => "V",<br /> | ||
+ | <br /> | ||
+ | "TCT" => "S", "TCC" => "S",<br /> | ||
+ | "TCA" => "S", "TCG" => "S",<br /> | ||
+ | "CCT" => "P", "CCC" => "P",<br /> | ||
+ | "CCA" => "P", "CCG" => "P",<br /> | ||
+ | "ACT" => "T", "ACC" => "T",<br /> | ||
+ | "ACA" => "T", "ACG" => "T",<br /> | ||
+ | "GCT" => "A", "GCC" => "A",<br /> | ||
+ | "GCA" => "A", "GCG" => "A",<br /> | ||
+ | <br /> | ||
+ | "TAT" => "Y", "TAC" => "Y",<br /> | ||
+ | "TAA" => "*", "TAG" => "*",<br /> | ||
+ | "CAT" => "H", "CAC" => "H",<br /> | ||
+ | "CAA" => "Q", "CAG" => "Q",<br /> | ||
+ | "AAT" => "N", "AAC" => "N",<br /> | ||
+ | "AAA" => "K", "AAG" => "K",<br /> | ||
+ | "GAT" => "D", "GAC" => "D",<br /> | ||
+ | "GAA" => "E", "GAG" => "E",<br /> | ||
+ | <br /> | ||
+ | "TGT" => "C", "TGC" => "C",<br /> | ||
+ | "TGA" => "*", "TGG" => "W",<br /> | ||
+ | "CGT" => "R", "CGC" => "R",<br /> | ||
+ | "CGA" => "R", "CGG" => "R",<br /> | ||
+ | "AGT" => "S", "AGC" => "S",<br /> | ||
+ | "AGA" => "R", "AGG" => "R",<br /> | ||
+ | "GGT" => "G", "GGC" => "G",<br /> | ||
+ | "GGA" => "G", "GGG" => "G",<br /> | ||
+ | "KYJ" => "error"<br /> | ||
+ | );<br /> | ||
+ | print "Guru : ";<br /> | ||
+ | print $basetoaa{"AAA"}; # K<br /> | ||
+ | print $basetoaa{"AUU"}; # I<br /> | ||
+ | print $basetoaa{"AUG"},"\n"; # M</p> | ||
+ | |||
+ | <p>## 변수입력<br /> | ||
+ | my $codon_data;<br /> | ||
+ | my $codon_data_length;<br /> | ||
+ | my @codon_data_split;<br /> | ||
+ | my @three_codon_data;<br /> | ||
+ | my @amino_acid_data;<br /> | ||
+ | my $amino_acid_length;<br /> | ||
+ | my $yorn1, $yorn2, $yorn3, $yorn4, $yorn5;<br /> | ||
+ | my $filename;</p> | ||
+ | |||
+ | <p>## Asking the way of how to input user's data(base).<br /> | ||
+ | print "This is a converting programm.\n\n";<br /> | ||
+ | print "Do you want to input your data using keyboard? [y/n] ";<br /> | ||
+ | # input your choose in yorn.<br /> | ||
+ | $yorn1 = <STDIN>;<br /> | ||
+ | # delete last enter key command <br /> | ||
+ | chomp $yorn1;<br /> | ||
+ | # print $yorn," \n";<br /> | ||
+ | # yes -> using keyboard\ no-> using file\ else-> error\<br /> | ||
+ | if($yorn1 eq "y")<br /> | ||
+ | {<br /> | ||
+ | print "<You want to input your data by using keyboard>\n";<br /> | ||
+ | }<br /> | ||
+ | elsif($yorn1 eq "n")<br /> | ||
+ | {<br /> | ||
+ | print "<You want to input your data by using file>\n";<br /> | ||
+ | }<br /> | ||
+ | else<br /> | ||
+ | {<br /> | ||
+ | print "<Error!>\n<you must input 'y' or 'n'.>\n";<br /> | ||
+ | exit;<br /> | ||
+ | }</p> | ||
+ | |||
+ | <p>#--------------------------------------------------------------------<br /> | ||
+ | ## input by keyboard<br /> | ||
+ | if ($yorn1 eq "y")<br /> | ||
+ | {<br /> | ||
+ | ## input data <br /> | ||
+ | print "<please input your data using keyboard>\n"; #input data in $condon_data<br /> | ||
+ | $codon_data = <STDIN>;<br /> | ||
+ | chomp $codon_data;<br /> | ||
+ | #delete (enter) command. chomp funtion delete last command.<br /> | ||
+ | #because STDIN function memory all of command.<br /> | ||
+ | #if do not use chomp, $codon_data is ([[User:Yeong Jae Kim|Yeong Jae Kim]] 02:02, 27 May 2016 (KST))+(enter key)<br /> | ||
+ | #so you must do it <br /> | ||
+ | } </p> | ||
+ | |||
+ | <p>## input through file.<br /> | ||
+ | elsif($yorn1 eq "n")<br /> | ||
+ | {<br /> | ||
+ | print "---------------------------------------\n<Caution!>\n<You must put on your file in same directory>\n";<br /> | ||
+ | print "<Do not write any word without codon data>\n";<br /> | ||
+ | print "<Please input your file name without filename extension>\n";<br /> | ||
+ | print "<If you want to input BRCA1.txt, just type BRCA1>\n---------------------------------\n";<br /> | ||
+ | print "<Your input file name : ";<br /> | ||
+ | $filename = <STDIN>;<br /> | ||
+ | chomp $filename;<br /> | ||
+ | # $filename = "$filename";<br /> | ||
+ | open(TEXT, "$filename.txt");<br /> | ||
+ | $codon_data = <TEXT>;<br /> | ||
+ | close (TEXT);<br /> | ||
+ | ## convert uppercase(대문자)-uc()<br /> | ||
+ | $codon_data = uc($codon_data);<br /> | ||
+ | # print $codon_data,"\n"; <br /> | ||
+ | }<br /> | ||
+ | #------------------------------------------------------------------------</p> | ||
+ | |||
+ | <p>## confirm data<br /> | ||
+ | print "\nIs it yours?\n-----------------------------------\n$codon_data\n----------------------------------\n";<br /> | ||
+ | <br /> | ||
+ | ## convert uppercase(대문자)-uc()<br /> | ||
+ | $codon_data = uc($codon_data);<br /> | ||
+ | <br /> | ||
+ | ## check data length<br /> | ||
+ | $codon_data_length = length ($codon_data);<br /> | ||
+ | print "Codon length is $codon_data_length.\n";<br /> | ||
+ | # if codon length is not multiply by 3, i notice warning message<br /> | ||
+ | # print $codon_data_length%3;</p> | ||
+ | |||
+ | <p>## warning to data_length<br /> | ||
+ | if ($codon_data_length%3 ne "0")<br /> | ||
+ | {<br /> | ||
+ | print "[warning] your codon length is not multiply by 3."; <br /> | ||
+ | print "Do you want continue? [y/n] ";<br /> | ||
+ | $yorn2 = <STDIN>;<br /> | ||
+ | chomp $yorn2; <br /> | ||
+ | if ($yorn2 eq "n")<br /> | ||
+ | {<br /> | ||
+ | exit; # just stop;<br /> | ||
+ | }<br /> | ||
+ | }<br /> | ||
+ | <br /> | ||
+ | ## split codon_data<br /> | ||
+ | @codon_data_split = split(//, $codon_data);<br /> | ||
+ | # print @codon_data;<br /> | ||
+ | # print $codon_data[0];<br /> | ||
+ | # print $codon_data[1];<br /> | ||
+ | # print $codon_data[3];<br /> | ||
+ | # print @codon_data_split,"\n";<br /> | ||
+ | # my $i =3;<br /> | ||
+ | # print $codon_data_split[$i];<br /> | ||
+ | <br /> | ||
+ | ## check data<br /> | ||
+ | foreach my $i (0..$#codon_data_split)<br /> | ||
+ | {<br /> | ||
+ | ## U,T,C,A,G check<br /> | ||
+ | if ($codon_data_split[$i] eq "U" || <br /> | ||
+ | $codon_data_split[$i] eq "T" || <br /> | ||
+ | $codon_data_split[$i] eq "C"|| <br /> | ||
+ | $codon_data_split[$i] eq "A"|| <br /> | ||
+ | $codon_data_split[$i] eq "G")<br /> | ||
+ | {<br /> | ||
+ | next;<br /> | ||
+ | }<br /> | ||
+ | else<br /> | ||
+ | {<br /> | ||
+ | print "[error]you do not input codon. please check your data\n";<br /> | ||
+ | exit; <br /> | ||
+ | }<br /> | ||
+ | }<br /> | ||
+ | ## divided 3 codons<br /> | ||
+ | for(my $i=0; $i < ($codon_data_length); $i=$i+3) <br /> | ||
+ | {<br /> | ||
+ | # print "this ($i/3) step";<br /> | ||
+ | my $j=$i/3;<br /> | ||
+ | $three_codon_data[$j] = $codon_data_split[$i].$codon_data_split[$i+1].$codon_data_split[$i+2];<br /> | ||
+ | # print $three_codon_data[$j],"\n";<br /> | ||
+ | # print length @three_codon_data;<br /> | ||
+ | # you can't get size of array using length function<br /> | ||
+ | }<br /> | ||
+ | # you just do to define scalar variable which equal array variable<br /> | ||
+ | $amino_acid_length = @three_codon_data;<br /> | ||
+ | # print "test1 = ",$amino_acid_length;<br /> | ||
+ | # print @three_codon_data;<br /> | ||
+ | # print $amino_acid_length;</p> | ||
+ | |||
+ | <p> ## convert codon bases into amino acids<br /> | ||
+ | for (my $i=0; $i < ($amino_acid_length); $i++)<br /> | ||
+ | {<br /> | ||
+ | # print $three_codon_data[$i];<br /> | ||
+ | $amino_acid_data[$i] = $basetoaa{"$three_codon_data[$i]"};<br /> | ||
+ | # print $amino_acid_data[$i],"\n";<br /> | ||
+ | } </p> | ||
+ | |||
+ | <p>#-------------------------------------------------<br /> | ||
+ | ## result<br /> | ||
+ | print "result : ",@amino_acid_data,"\n";</p> | ||
+ | |||
+ | <p> ## alignment<br /> | ||
+ | print "<Do you want alignment?> [y/n] ";<br /> | ||
+ | $yorn3 = <STDIN>;<br /> | ||
+ | chomp $yorn3;<br /> | ||
+ | print "<Do you want see the number?> [y/n] ";<br /> | ||
+ | $yorn4 = <STDIN>;<br /> | ||
+ | chomp $yorn4;<br /> | ||
+ | if ($yorn3 eq "y")<br /> | ||
+ | {<br /> | ||
+ | my $line = int($amino_acid_length/10);<br /> | ||
+ | for (my $i=0; $i <= $line; $i++)<br /> | ||
+ | {<br /> | ||
+ | ## print number<br /> | ||
+ | if ($yorn4 eq "y")<br /> | ||
+ | {<br /> | ||
+ | my $j =10*$i+1;<br /> | ||
+ | print $j; <br /> | ||
+ | print "\n ";<br /> | ||
+ | } <br /> | ||
+ | ## print codon data<br /> | ||
+ | for (my $j=0; $j < 10; $j++)<br /> | ||
+ | {<br /> | ||
+ | print $three_codon_data[10*$i+$j]," ";<br /> | ||
+ | } <br /> | ||
+ | print "\n ";<br /> | ||
+ | ## print amino acid data<br /> | ||
+ | for (my $j=0; $j < 10; $j++)<br /> | ||
+ | {<br /> | ||
+ | my $k = 10*$i+$j+1;<br /> | ||
+ | if ($k == $amino_acid_length && $yorn2 eq "y")<br /> | ||
+ | {<br /> | ||
+ | print " ?", "\n";<br /> | ||
+ | }<br /> | ||
+ | else<br /> | ||
+ | {<br /> | ||
+ | print " ", $amino_acid_data[10*$i+$j], " ";<br /> | ||
+ | } <br /> | ||
+ | }<br /> | ||
+ | print "\n";<br /> | ||
+ | }<br /> | ||
+ | }<br /> | ||
+ | #----------------------------------------------------<br /> | ||
+ | ## make result file<br /> | ||
+ | print "<Do you want make file?> [y/n] ";<br /> | ||
+ | $yorn5 = <STDIN>;<br /> | ||
+ | chomp $yorn5;<br /> | ||
+ | if ($yorn5 eq "y")<br /> | ||
+ | {<br /> | ||
+ | print "<What is the file name?>\n";<br /> | ||
+ | print "<if you want to input BRCA1.txt, just type BRCA1>\n---------------------------------\n";<br /> | ||
+ | print "<Your output file name : ";<br /> | ||
+ | $output_filename = <STDIN>;<br /> | ||
+ | chomp $output_filename;<br /> | ||
+ | while ($filename eq $output_filename)<br /> | ||
+ | {<br /> | ||
+ | print "<This name is same to codon data file name.>\n";<br /> | ||
+ | print "<Please input another name!!!> \n";<br /> | ||
+ | print "<Your output file name : ";<br /> | ||
+ | $output_filename = <STDIN>;<br /> | ||
+ | chomp $output_filename;<br /> | ||
+ | }<br /> | ||
+ | # $output_filename = "$output_filename.txt";<br /> | ||
+ | open (TEXT, ">$output_filename.txt"); <br /> | ||
+ | my $outputdata = join ("", @amino_acid_data);<br /> | ||
+ | # print @amino_acid_data,"\n";<br /> | ||
+ | # print $outputdata;<br /> | ||
+ | print TEXT $outputdata;<br /> | ||
+ | close (TEXT);<br /> | ||
+ | print "Success! check your file";<br /> | ||
+ | exit;<br /> | ||
+ | }<br /> | ||
+ | else <br /> | ||
+ | {<br /> | ||
+ | exit;<br /> | ||
+ | }</p> |
Latest revision as of 02:02, 27 May 2016
aim . translating triple base codes convert into amino acids
-------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
- this function is translating 'all' combinations of triple bases into amino acids
my %basetoaa= (
"UUU" => "F", "UUC" => "F",
"UUA" => "L", "UUG" => "L",
"CUU" => "L", "CUC" => "L",
"CUA" => "L", "CUG" => "L",
"AUU" => "I", "AUC" => "I",
"AUA" => "I", "AUG" => "M",
"GUU" => "V", "GUC" => "V",
"GUA" => "V", "GUG" => "V",
"UCU" => "S", "UCC" => "S",
"UCA" => "S", "UCG" => "S",
"CCU" => "P", "CCC" => "P",
"CCA" => "P", "CCG" => "P",
"ACU" => "T", "ACC" => "T",
"ACA" => "T", "ACG" => "T",
"GCU" => "A", "GCC" => "A",
"GCA" => "A", "GCG" => "A",
"UAU" => "Y", "UAC" => "Y",
"UAA" => "*", "UAG" => "*",
"CAU" => "H", "CAC" => "H",
"CAA" => "Q", "CAG" => "Q",
"AAU" => "N", "AAC" => "N",
"AAA" => "K", "AAG" => "K",
"GAU" => "D", "GAC" => "D",
"GAA" => "E", "GAG" => "E",
"UGU" => "C", "UGC" => "C",
"UGA" => "*", "UGG" => "W",
"CGU" => "R", "CGC" => "R",
"CGA" => "R", "CGG" => "R",
"AGU" => "S", "AGC" => "S",
"AGA" => "R", "AGG" => "R",
"GGU" => "G", "GGC" => "G",
"GGA" => "G", "GGG" => "G",
"TTT" => "F", "TTC" => "F",
"TTA" => "L", "TTG" => "L",
"CTT" => "L", "CTC" => "L",
"CTA" => "L", "CTG" => "L",
"ATT" => "I", "ATC" => "I",
"ATA" => "I", "ATG" => "M",
"GTT" => "V", "GTC" => "V",
"GTA" => "V", "GTG" => "V",
"TCT" => "S", "TCC" => "S",
"TCA" => "S", "TCG" => "S",
"CCT" => "P", "CCC" => "P",
"CCA" => "P", "CCG" => "P",
"ACT" => "T", "ACC" => "T",
"ACA" => "T", "ACG" => "T",
"GCT" => "A", "GCC" => "A",
"GCA" => "A", "GCG" => "A",
"TAT" => "Y", "TAC" => "Y",
"TAA" => "*", "TAG" => "*",
"CAT" => "H", "CAC" => "H",
"CAA" => "Q", "CAG" => "Q",
"AAT" => "N", "AAC" => "N",
"AAA" => "K", "AAG" => "K",
"GAT" => "D", "GAC" => "D",
"GAA" => "E", "GAG" => "E",
"TGT" => "C", "TGC" => "C",
"TGA" => "*", "TGG" => "W",
"CGT" => "R", "CGC" => "R",
"CGA" => "R", "CGG" => "R",
"AGT" => "S", "AGC" => "S",
"AGA" => "R", "AGG" => "R",
"GGT" => "G", "GGC" => "G",
"GGA" => "G", "GGG" => "G",
"KYJ" => "error"
);
print "Guru : ";
print $basetoaa{"AAA"}; # K
print $basetoaa{"AUU"}; # I
print $basetoaa{"AUG"},"\n"; # M
## 변수입력
my $codon_data;
my $codon_data_length;
my @codon_data_split;
my @three_codon_data;
my @amino_acid_data;
my $amino_acid_length;
my $yorn1, $yorn2, $yorn3, $yorn4, $yorn5;
my $filename;
## Asking the way of how to input user's data(base).
print "This is a converting programm.\n\n";
print "Do you want to input your data using keyboard? [y/n] ";
- input your choose in yorn.
$yorn1 = <STDIN>;
- delete last enter key command
chomp $yorn1;
- print $yorn," \n";
- yes -> using keyboard\ no-> using file\ else-> error\
if($yorn1 eq "y")
{
print "<You want to input your data by using keyboard>\n";
}
elsif($yorn1 eq "n")
{
print "<You want to input your data by using file>\n";
}
else
{
print "<Error!>\n<you must input 'y' or 'n'.>\n";
exit;
}
#--------------------------------------------------------------------
- input by keyboard
- input by keyboard
if ($yorn1 eq "y")
{
## input data
print "<please input your data using keyboard>\n"; #input data in $condon_data
$codon_data = <STDIN>;
chomp $codon_data;
#delete (enter) command. chomp funtion delete last command.
#because STDIN function memory all of command.
#if do not use chomp, $codon_data is (Yeong Jae Kim 02:02, 27 May 2016 (KST))+(enter key)
#so you must do it
}
## input through file.
elsif($yorn1 eq "n")
{
print "---------------------------------------\n<Caution!>\n<You must put on your file in same directory>\n";
print "<Do not write any word without codon data>\n";
print "<Please input your file name without filename extension>\n";
print "<If you want to input BRCA1.txt, just type BRCA1>\n---------------------------------\n";
print "<Your input file name : ";
$filename = <STDIN>;
chomp $filename;
# $filename = "$filename";
open(TEXT, "$filename.txt");
$codon_data = <TEXT>;
close (TEXT);
## convert uppercase(대문자)-uc()
$codon_data = uc($codon_data);
# print $codon_data,"\n";
}
- ------------------------------------------------------------------------
## confirm data
print "\nIs it yours?\n-----------------------------------\n$codon_data\n----------------------------------\n";
- convert uppercase(대문자)-uc()
- convert uppercase(대문자)-uc()
$codon_data = uc($codon_data);
- check data length
- check data length
$codon_data_length = length ($codon_data);
print "Codon length is $codon_data_length.\n";
- if codon length is not multiply by 3, i notice warning message
- print $codon_data_length%3;
## warning to data_length
if ($codon_data_length%3 ne "0")
{
print "[warning] your codon length is not multiply by 3.";
print "Do you want continue? [y/n] ";
$yorn2 = <STDIN>;
chomp $yorn2;
if ($yorn2 eq "n")
{
exit; # just stop;
}
}
## split codon_data
@codon_data_split = split(//, $codon_data);
- print @codon_data;
- print $codon_data[0];
- print $codon_data[1];
- print $codon_data[3];
- print @codon_data_split,"\n";
- my $i =3;
- print $codon_data_split[$i];
## check data
foreach my $i (0..$#codon_data_split)
{
## U,T,C,A,G check
if ($codon_data_split[$i] eq "U" ||
$codon_data_split[$i] eq "T" ||
$codon_data_split[$i] eq "C"||
$codon_data_split[$i] eq "A"||
$codon_data_split[$i] eq "G")
{
next;
}
else
{
print "[error]you do not input codon. please check your data\n";
exit;
}
}
## divided 3 codons
for(my $i=0; $i < ($codon_data_length); $i=$i+3)
{
# print "this ($i/3) step";
my $j=$i/3;
$three_codon_data[$j] = $codon_data_split[$i].$codon_data_split[$i+1].$codon_data_split[$i+2];
# print $three_codon_data[$j],"\n";
# print length @three_codon_data;
# you can't get size of array using length function
}
# you just do to define scalar variable which equal array variable
$amino_acid_length = @three_codon_data;
# print "test1 = ",$amino_acid_length;
# print @three_codon_data;
# print $amino_acid_length;
## convert codon bases into amino acids
for (my $i=0; $i < ($amino_acid_length); $i++)
{
# print $three_codon_data[$i];
$amino_acid_data[$i] = $basetoaa{"$three_codon_data[$i]"};
# print $amino_acid_data[$i],"\n";
}
#-------------------------------------------------
## result
print "result : ",@amino_acid_data,"\n";
## alignment
print "<Do you want alignment?> [y/n] ";
$yorn3 = <STDIN>;
chomp $yorn3;
print "<Do you want see the number?> [y/n] ";
$yorn4 = <STDIN>;
chomp $yorn4;
if ($yorn3 eq "y")
{
my $line = int($amino_acid_length/10);
for (my $i=0; $i <= $line; $i++)
{
## print number
if ($yorn4 eq "y")
{
my $j =10*$i+1;
print $j;
print "\n ";
}
## print codon data
for (my $j=0; $j < 10; $j++)
{
print $three_codon_data[10*$i+$j]," ";
}
print "\n ";
## print amino acid data
for (my $j=0; $j < 10; $j++)
{
my $k = 10*$i+$j+1;
if ($k == $amino_acid_length && $yorn2 eq "y")
{
print " ?", "\n";
}
else
{
print " ", $amino_acid_data[10*$i+$j], " ";
}
}
print "\n";
}
}
- ----------------------------------------------------
## make result file
print "<Do you want make file?> [y/n] ";
$yorn5 = <STDIN>;
chomp $yorn5;
if ($yorn5 eq "y")
{
print "<What is the file name?>\n";
print "<if you want to input BRCA1.txt, just type BRCA1>\n---------------------------------\n";
print "<Your output file name : ";
$output_filename = <STDIN>;
chomp $output_filename;
while ($filename eq $output_filename)
{
print "<This name is same to codon data file name.>\n";
print "<Please input another name!!!> \n";
print "<Your output file name : ";
$output_filename = <STDIN>;
chomp $output_filename;
}
# $output_filename = "$output_filename.txt";
open (TEXT, ">$output_filename.txt");
my $outputdata = join ("", @amino_acid_data);
# print @amino_acid_data,"\n";
# print $outputdata;
print TEXT $outputdata;
close (TEXT);
print "Success! check your file";
exit;
}
else
{
exit;
}