use strict; use warnings; use bio::seqIO; my @tracked_proteins = qw( A C D E F G H I K L M N P Q R S T V W Y ); # Protein output file: my $output_file = 'countaa'; open my $OUT, '>', $output_file or die "Can't open file $output_file for output.\n$!"; my $proteinio = Bio::SeqIO->new( -file => "ec 1.1.1.fasta", -format => 'fasta' ); while ( my $seq = $proteinio->next_seq ) { foreach my $protein_seq ( $seq->seq ) { my %counts; @counts{@tracked_proteins} = (); my @protein = split //, $protein_seq; foreach my $protein_alpha (@protein) { next unless exists $counts{$protein_alpha}; $counts{$protein_alpha}++; } } print $OUT "$_ " for @counts{@tracked_proteins}; print $OUT "\n"; } close $OUT or die $!;