More Parsing of PROSITE Files


This sample PERL script will list one entire PROSITE record as identified by the user using an accession number: #!/usr/bin/perl -w use strict; use util; my $filename = "prosite.dat"; my @file = get_file_data("$filename"); print "Enter Accession Number: "; my $input = <STDIN>; chomp $input; my $hold = " "; my $keep = 0; my $output = " "; foreach my $line (@file){ if( $line =~ /^\/\/\n/ ){ if( $keep == 1) { $output = $hold; last; } $hold = " "; } $hold .= $line; if( $line =~ /^AC/ ){ $line =~ s/^AC\s*//; $line =~ s/;//; chomp $line; if($line eq $input){ $keep = 1; } } } print $output; exit; Basically, every line in the PROSITE file is stored in the $hold string. The $hold string gets flushed every time a line beginning with // is encountered. If the accession number entered by the user is found, the contents of $hold get dumped into $output and the foreach loop is terminated.
ASSIGNMENT:
You will write a PERL script which lists only the lines which begin with ID, AC, DT, DE, PA, and RU for one entry selected by the user based on accession number.