Fun With GenBank Files
Okay, so this is not a very useful assignment, but it's kind of neat in a
way. Try the following Perl script:
#!/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);
$inseq = 0;
$nuc = "";
foreach my $line (@data){
if($line =~ /^ORIGIN/ ){
$inseq = 1;
}
elsif($line =~ /\/\// ){
$output = "\n";
$output .= "Colorful Nucleotides
\n";
@nuc = split('',$nuc);
foreach $n (@nuc){
if( $n eq 'c' ){
$output .= "c\n";
}
elsif( $n eq 't' ){
$output .= "t\n";
}
elsif( $n eq 'a' ){
$output .= "a\n";
}
elsif( $n eq 'g' ){
$output .= "g\n";
}
}
$output .= "";
$outputfile = "color_seq.html";
open(CSEQ, ">$outputfile");
print CSEQ "$output";
close(CSEQ);
}
elsif($inseq == 1){
chomp($line);
$nuc .= $line;
}
}
Assignment:
You get to do the same thing for the \translation section of any GenBank
file. You will need to use RGB values to come up with 20 different color
values. Otherwise, this is a pretty simple assignment.