rocketperl has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use diagnostics; open PROTEOME,'human_complete_proteome_without_isoforms.fasta'; my @proteome=<PROTEOME>; chomp @proteome; my @aminoacid; my @hold; my $peptide; foreach my $j (@proteome) { if($j!=/^>/) { push @hold,$j; } } print "The proteome is loaded\n"; $peptide= join ('', @hold); undef @hold; @aminoacid=split(//,$peptide); my %count; foreach (@aminoacid) { if(exists $count{$_}) { $count{$_}++; } else { $count{$_}=1; } } print "hash has finished searching the document\n"; foreach (keys %count) { print "$_ \t occurs $count{$_} times \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Count the occurrence of an element in an array
by hdb (Monsignor) on Feb 20, 2014 at 07:10 UTC | |
|
Re: Count the occurrence of an element in an array
by davido (Cardinal) on Feb 20, 2014 at 07:30 UTC | |
|
Re: Count the occurrence of an element in an array
by Laurent_R (Canon) on Feb 20, 2014 at 07:11 UTC | |
|
Re: Count the occurrence of an element in an array
by Discipulus (Canon) on Feb 20, 2014 at 07:54 UTC | |
by robby_dobby (Hermit) on Feb 20, 2014 at 10:59 UTC |