just a meditation about printing in descending order...

use strict; use warnings; my $ncol; while (<DATA>){ my ($id,@acgt)=split; my (%count,@reports); # -- count ACGT $count{$_}++ for (@acgt) ; # -- print in descending order while( my ($marker,$number) = each %count ) { push @reports, "$number $marker"; } print "Column :",$ncol++,"\n"; no warnings "numeric"; print join ("\t",sort {$b <=>$a} @reports),"\n"; } __DATA__ 3851 A A G G T T A A C C 3854 A A G G T T A A C C 3871 A A G G T T A A G G

OUTPUT:

Column :0 4 A 2 T 2 C 2 G Column :1 4 A 2 T 2 C 2 G Column :2 4 A 4 G 2 T

Cheers Rolf


In reply to Re: Count # of occurrences per column by LanX
in thread Count # of occurrences per column by Renyulb28

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.