#!/usr/bin/perl -w use strict; open FILE1, ") { chomp; next if(/^\s*$/); my $FastaLine = $_; if ( $FastaLine =~ /^>sp\|(\w+\S+)\|/ ) { $id = $1; } else { $Fasta_split{$id} .= $FastaLine; } } # print header my @header = qw/A B C D E F G H I J K L M N O P Q R S T U V W X Y Z/; print "ID " . join(' ', @header) . "\n"; # print data foreach my $id (sort keys %Fasta_split) { my %words; # count letters $words{$_}++ for split('', $Fasta_split{$id}); printf "%8s ", $id; # print counts foreach my $w (@header) { if (defined $words{$w}) { printf "%2d ", $words{$w}; } else { print ' - '; } } print "\n"; }