Converting GenBank Files to Web Pages
Here is a file which displays selected lines from a GenBank file in a web
page format:
#!/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);
$output = "\n";
foreach my $line (@data){
if($line =~ /^LOCUS/ ){
$line =~ s/^LOCUS\s*//;
$line =~ s/(^.{9}).*/$1/;
chomp($line);
$output .= "$line
\n";
}
elsif($line =~ /^ACCESSION/ ){
$line =~ s/^ACCESSION\s*//;
chomp($line);
$output .= "ACCESSION: $line
\n";
}
elsif($line =~ /^BASE/){
$line =~ s/^BASE COUNT//;
$line =~ s/^.{6}//;
$output .= "BASE COUNT: $line
\n";
}
elsif($line =~ /^\/\// ){
$output .= "\n\n";
$outputfile = "gbweb.html";
open(CSEQ, ">$outputfile");
print CSEQ "$output";
close(CSEQ);
}
}
Assignment:
Add code to include VERSION, SOURCE, and DEFINITION to your web page.
DEFINITION is often more than one line so you will have to deal with this.