Sorry, I didn't include all my code, because it is long and not very good!

Just in case you think I am not trying to do it myself see the attached

#!/usr/bin/perl use strict; use warnings; use HBV; my $machine="PC"; my ($inputDataPath, $outputDataPath,$inPathForScript,$outPathForScript +) = HBV::PathFinder($machine); my $origfile = $outputDataPath. qw(individualAlleles\HLA-A-1_HBe_Analy +sis.txt); # HLA-A-1_HBe_Analysis.txt open (IN, $origfile) or die "cannot open $origfile"; my @columns; my $count = 0; my @genotypeAndAllele; my @binders; my @lineCount; my $bitBinder; my @bitBinder; my @copybinders; while (my $line = <IN>){ chomp $line; if ($line =~/^([A-Z]{9}).*(IOH.{7}).*([1-9].?).*(HLA.{8})/){ push @genotypeAndAllele,$4.' '.$2; push @lineCount,$3; } if ($line =~/^([A-Z]{9})/){ push @binders, $1; @copybinders = @binders; } } foreach my $el (@lineCount){ for (my $i=0; $i <$el; $i++){ my $bit = $binders[$i]; $bitBinder .= $bit." "; } push @bitBinder, $bitBinder; $bitBinder=''; splice @binders,0,$el; } my %alleleProtein; foreach my $item (@genotypeAndAllele){ $alleleProtein{$item}++; } my %bindersHash; foreach my $item (@copybinders){ $bindersHash{$item}++; } my %genoBinderAlleleHash; @genoBinderAlleleHash{@genotypeAndAllele} = +@bitBinder; foreach my $keys (sort {$a cmp $b} keys (%genoBinderAlleleHash)){ print "$keys \($alleleProtein{$keys}\) = $genoBinderAlleleHash{$keys}\ +n"; } foreach my $keys (sort {$bindersHash{$b} <=> $bindersHash{$a}} (keys ( +%bindersHash))){ print "$keys = $bindersHash{$keys}\n"; }

Sorry to have bothered you


In reply to Re^4: Sort array using a ranking system from separate hash by Sandy_Bio_Perl
in thread Sort array using a ranking system from separate hash by Sandy_Bio_Perl

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.