buzzybeewhee has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I'm currently trying to match the different frequency of occurrences for each month to my key itself. I have this perl script which has a key, and the different frequency of occurrences for different months as values. Its multiple value to one key.
and right now, it will give me something like this...my %mutperc; while (<FILE>) { chomp; $countentry++; ($acc, $freq, $perc) = split ("\t"); $accession = $acc; push @{$mutperc{$accession}}, $perc; $" = "\t"; } close (FILE); foreach my $accession (sort {$mutperc{$b} <=> $mutperc{$a}} (keys %mut +perc)) { if(grep $_ > 10 , @{$mutperc{$accession}}) { print "$accession\t@{$mutperc{$accession}}\n"; $countprint++; } } print "$countentry\t$countprint\n";
but then the problem right now is that I actually have 5 months, but the occurrence rate for some months is actually 0, so the perl script does not give me the values matched to the months. In other words, I'm looking for 5 columns (for my 5 months) and the frequency of occurrences for each month should be matched to the column number. (e.g. if the frequency of occurrence in April is 4.67%, 4.67 should appear in the 4th column) If the occurrence rate for that month is 0, a 0 should appear in that column, instead of moving the next few occurrence rates for the following months in front. The end product I'm looking for is:T373I 24.3902439 16.36363636 7.142857143 9.090909091 V100I 36.58536585 61.81818182 85.71428571 96.66666667 1 +00 L122Q 97.56097561 100 100 100
T373I 24.3902439 16.36363636 7.142857143 9.090909091 0 V100I 36.58536585 61.81818182 85.71428571 96.66666667 1 +00 L122Q 0 97.56097561 100 100 100
I'm so sorry that I'm asking so much >< but I truly need this script to be working...to save my life because I have around 250 such files to sort through and its almost impossible to do it manually! Please help!~ Many thanks and appreciation! :D Best Regards, Buzzybee
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Put multiple values as columns inside a hash
by spazm (Monk) on Jun 18, 2010 at 04:18 UTC | |
by buzzybeewhee (Initiate) on Jun 18, 2010 at 05:58 UTC | |
by almut (Canon) on Jun 18, 2010 at 09:47 UTC | |
|
Re: Put multiple values as columns inside a hash
by aquarium (Curate) on Jun 18, 2010 at 06:23 UTC | |
by buzzybeewhee (Initiate) on Jun 18, 2010 at 07:10 UTC | |
by aquarium (Curate) on Jun 25, 2010 at 04:13 UTC | |
|
Re: Put multiple values as columns inside a hash
by almut (Canon) on Jun 18, 2010 at 05:28 UTC |