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 = <STDIN>; chomp $filename; $filename = 'GENBANK/'.$filename; open(FH, $filename); @data = <FH>; close(FH); $output = "<html><body bgcolor=white>\n"; foreach my $line (@data){ if($line =~ /^LOCUS/ ){ $line =~ s/^LOCUS\s*//; $line =~ s/(^.{9}).*/$1/; chomp($line); $output .= "<h2>$line</h2>\n"; } elsif($line =~ /^ACCESSION/ ){ $line =~ s/^ACCESSION\s*//; chomp($line); $output .= "ACCESSION: $line<br>\n"; } elsif($line =~ /^BASE/){ $line =~ s/^BASE COUNT//; $line =~ s/^.{6}//; $output .= "BASE COUNT: $line<br>\n"; } elsif($line =~ /^\/\// ){ $output .= "\n</body></html>\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.