Difference between revisions of "SeungWon Lee Perl HW"

From Biolecture.org
imported>Seung won lee
(Created page with "<p>Q.write a simple program to open and write a FASTA file with the content<br /> below:<br /> <br /> >Your_fi...")
 
imported>Seung won lee
 
Line 12: Line 12:
 
<p>A1. the perl code</p>
 
<p>A1. the perl code</p>
  
<p><textarea cols="30" name="code" rows="20">
+
<blockquote>
use warnings;
+
<p>use warnings;<br />
use strict;
+
use strict;</p>
  
open my $fh, &#39;&gt;&#39;, &#39;fasta.txt&#39;;
+
<p>open my $fh, &#39;&gt;&#39;, &#39;fasta.txt&#39;;</p>
  
print &quot;enter your fasta file name\n&quot;;
+
<p>print &quot;enter your fasta file name\n&quot;;<br />
my $seqname = &lt;&gt;;
+
my $seqname = &lt;&gt;;<br />
print $fh &#39;&gt;&#39;. &quot;$seqname&quot;;
+
print $fh &#39;&gt;&#39;. &quot;$seqname&quot;;</p>
  
print &quot;enter your fasta sequence(to end inputing sequence, hit 0 and enter)\n&quot;;
+
<p>print &quot;enter your fasta sequence(to end inputing sequence, hit 0 and enter)\n&quot;;<br />
while (my $line = &lt;STDIN&gt;) {
+
while (my $line = &lt;STDIN&gt;) {<br />
    last if $line =~ &#39;^0$&#39;;
+
&nbsp; &nbsp; last if $line =~ &#39;^0$&#39;;<br />
    print $fh $line;
+
&nbsp; &nbsp; print $fh $line;<br />
}
+
}</p>
  
close $fh;
+
<p>close $fh;</p>
  
print &quot;done\n&quot;;</textarea></p>
+
<p>print &quot;done\n&quot;;</p>
 +
</blockquote>
 +
 
 +
<p>&nbsp;</p>
 +
 
 +
<p>download the code&nbsp;<a href="/ckfinder/userfiles/files/fasta_code.txt">/ckfinder/userfiles/files/fasta_code.txt</a></p>
 +
 
 +
<p>the .pl format can&#39;t upload, so I change pl to txt. when you open the file, you have to save as .pl</p>
  
 
<p>A2. Running in consol</p>
 
<p>A2. Running in consol</p>
Line 38: Line 45:
 
<p>A3. result file</p>
 
<p>A3. result file</p>
  
<p><textarea cols="20" rows="20">&gt;Your_first_seq
+
<blockquote>&gt;Your_first_seq<br />
 +
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA<br />
 +
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA<br />
 +
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA<br />
 
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
 
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
+
<p>&nbsp;</p>
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
+
</blockquote>
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
+
 
</textarea></p>
+
<p>the file name is fasta.txt (format is txt)&nbsp;</p>
  
<p>the file name is fasta.txt (format is txt)</p>
+
<p>download file :&nbsp;<a href="/ckfinder/userfiles/files/fasta.txt">/ckfinder/userfiles/files/fasta.txt</a></p>

Latest revision as of 02:22, 29 November 2015

Q.write a simple program to open and write a FASTA file with the content
below:

>Your_first_seq
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA

 

A1. the perl code

use warnings;
use strict;

open my $fh, '>', 'fasta.txt';

print "enter your fasta file name\n";
my $seqname = <>;
print $fh '>'. "$seqname";

print "enter your fasta sequence(to end inputing sequence, hit 0 and enter)\n";
while (my $line = <STDIN>) {
    last if $line =~ '^0$';
    print $fh $line;
}

close $fh;

print "done\n";

 

download the code /ckfinder/userfiles/files/fasta_code.txt

the .pl format can't upload, so I change pl to txt. when you open the file, you have to save as .pl

A2. Running in consol

A3. result file

>Your_first_seq

ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA
ATATATATATATATATAATATATATATATATATAATATATATATATATATAATATATATATATATATA

 

the file name is fasta.txt (format is txt) 

download file : /ckfinder/userfiles/files/fasta.txt