#!/usr/bin/perl -w use strict; use Getopt::Std; my $TITLE = <$sc)?$dcount{$d}:$sc; } $scores{$dbid}=$sc; } return %scores; } ##################################################################### sub readfasta #($filename) { my $fname=shift; my %seqs=(); my $header = "NIX"; my $line; my $seq = ""; open FASTA,"<$fname" or die "Cannot open $fname!"; while (!($header =~ /^>/)) { $header = ; } chomp($header); $header=~s/^>//; while() { chomp; $line=$_; if ($line =~ /^>/) { $seqs{$header}=$seq; $header = $line; $header=~s/^>//; $seq=""; } else { $seq .= $line; } } $seqs{$header}=$seq; close FASTA; return %seqs; } #################################################################### ## MAIN #################################################################### my %options; my $sname=''; my $q=2; my %db; my %seqs; my %scores; my ($key,$k); my $l; $TITLE =~ s/\#( )?//g; $USAGE =~ s/\#( )?//g; $USAGE =~ s/\n//; print STDERR $TITLE; getopts("hs:q:", \%options); if ($options{h} || (!@ARGV)) { print STDERR $USAGE; exit;} if ($options{s}) { $sname=$options{s}; } else { $sname=$ARGV[0]; } if ($options{q}) { $q=$options{q}; } %db=readfasta($ARGV[0]); %seqs=readfasta($sname); foreach $key (sort keys %seqs) { $l=length($seqs{$key}); %scores = fastascores($seqs{$key},$q,\%db); printf "FASTA-Scores for Sequence '$key' (length $l):\n"; foreach $k (sort keys %scores) { print " $k => $scores{$k}\n"; } printf "\n"; } ####################################################################