I have a file which is tab delimited(a hit from a DB). I would like to first store say the first and tenth item on each(row) as well as the entire row in a hash. And then build an array of hashes from 2nd,3rd,...... rows respectively. I would then sort each of the rows by score and ID(which are the first and 10th elements of each row) and print the row with the best score.
I have tried this out and it seems I was just able to pick only one row:
my program seem to be processing only the first row. I need hints/snippets!my @CHIMP = <CBLAT>;#CBLAT hold the file to be processed</p> my %hITS; my $score; my @bestHITS; if(!@CHIMP){</p> my $nm = "no_match"; next} my $cblast = shift @CHIMP;#process blat output lines(r +ows)</p> my @row = split(/\t/,$cblast);</p> unshift @{$hITS{$score}},{MATCH=>$row[0],qID=>$row[9], +cLINE=>$cblast};#keep score,query id and whole lines in hash</p> @{$hITS{$score}} = sort {$b->{MATCH} <=> $a->{MATCH} | +| $a->{qID} cmp $b->{qID}} </p>@{$hITS{$score}};#sort by match score/ +query ID</p> foreach my $key (@{$hITS{$score}}){ my $hits = $key->{cLINE}; push @bestHITS, $hits;#keep sorted lines in ar +ray last;}
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |