Changes
From Biolecture.org
no edit summary
<p>Perl foreach loop iterates over a list value and sets the control variable to be each element of the list in turn</p>
<p><font color="#000000">The basic form is like this</font></p>
<p><font color="#000000">foreach</font> var (list) {</p>
<p> </p>
<h3>Perl Script to convert DNA to Protein</h3>
<p>To make a new object and save to a file, write down</p> <p>1. use Bio::Seq;</p> <p> use Bio::SeqIO;</p> <p>When we make a new object, we always have to use this method (method is a function)</p> <p>2. new()</p> <p>3. -> : Method call sign</p> <p>We have to use these arguments to read codon and save it (Argument is a variable to use function or command)</p> <p>4. -seq, -alphabet, -file, -format</p> <p>5. => : To assign argument value<br />
</p>
<p>6. -alphabet argument has one value among dna, rna, and protein.</p> <p> -format argument has 'fasta' or 'genbank' value</p> <p>7. Translation method:</p> <p> $argument name = $object name->translate;</p> <p>8. Print method:</p> <p> Print $argument name ->seq, "\n";</p> <p>Example<sup>2)</sup></p> <p>use Bio::Seq;</p> <p>use Bio::SeqIO;</p> <p>@bases = ("a","t","g","c");</p> <p> foreach $first(@bases){</p> <p> foreach $second(@bases){</p> <p> foreach $third(@bases){</p> <p> $codon = $first.$second.$third;</p> <p> $seq_codon = Bio::Seq -> new(-seq => $codon, -alphabet => 'dna');</p> <p> $aa_letter = $seq_codon -> translate;</p> <p> print "$codon \t", $aa_letter->seq, "\t";</p> <p> }</p> <p> print "\n";</p> <p> }</p> <p>}</p> <p>$seqio_aa = Bio::SeqIO->new(-file => 'aa.fas', -format => 'fasta');</p> <p>$seqio_aa = write_seq($aa_letter);</p> <p>exit;</p> <h3>Reference</h3> <font colorp>1) <a href="#000000http://www.tutorialspoint.com/perl/perl_foreach_loop.htm">Referencehttp://www.tutorialspoint.com/perl/perl_foreach_loop.htm</fonta></h3p>
<p><font color="#000000">12) </font><This code was originally written by Myeong Seo Yoon and I made a href="http://www.tutorialspoint.com/perl/perl_foreach_loop.htm">http://www.tutorialspoint.com/perl/perl_foreach_loop.htm</a>little modification</p>
<p> </p>