More Manipulation of GenBank Files
Here's a script which allows you to display a multi-line entry from a
GenBank file:
#!/usr/bin/perl -w
print "Available Files:\n";
@files = ();
$folder = 'GENBANK';
unless(opendir(FOLDER, $folder)){
print "Cannot open folder\n";
exit;
}
@files = readdir(FOLDER);
closedir(FOLDER);
foreach $f (@files){
print "$f\n";
}
print "Enter name of file: ";
$filename = ;
chomp $filename;
$filename = 'GENBANK/'.$filename;
open(FH, $filename);
@data = ;
close(FH);
$intrans = 0;
$endtrans = 0;
$amino = "";
foreach my $line (@data){
if($line =~ /^\s*\/translation/ ){
$line =~ s/^\s*\/translation="\s*//;
$amino .= $line;
$intrans = 1;
}
elsif($intrans == 1){
$line =~ s/^\s*//;
if( $line =~ /\"$/ ){
$line =~ s/"//;
$endtrans = 1;
}
$amino .= $line;
if($endtrans){
print "$amino\n";
exit;
}
}
}
ASSIGNMENT:
Write a script which displays only the nucleotide sequence. Download an
additional five files so that you have a total of fifteen files in your
GenBank directory.