SeungWon Lee Perl HW

From Biolecture.org
Revision as of 02:22, 29 November 2015 by imported>Seung won lee
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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