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.

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";
and right now, it will give me something like this...
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
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 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


In reply to Put multiple values as columns inside a hash by buzzybeewhee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.