
adamjazz1
Novice
Dec 10, 2009, 1:02 PM
Post #4 of 5
(1465 views)
|
Hi, Sorry about my post. I was in a hurry. Here is my script that I have been working on. I have made some changes, and I almost have it figured out... This is what the data looks like. output from showcluster.pl
t.28 385 0 t.2 395 0 t.20 620 0 t.12 685 0 t.7 2820 0 t 9501 49 output from ensfiles.pl
/s3/nh/nh2/1/85/nh2ct2.x 1.716882 /s3/nh/nh2/12/92/nh2ct2.x 1.881869 What I want to do is take the first column "t.###" sorted sorted by the 2nd column. I only need no more than 9. From this t.## I pass this to ensfiles.pl and get "/s3/nh/nh2/1/85/nh2ct2.x 1.716882" I want to make a hash of this data and sort it ascending by the 2nd column of data (the number). I only need the top 3 from the sorted hash. Ideally I would like to have the printout be
"t.## -> /s3/nh/nh2/1/85/nh2ct2.x (without this number though 1.716882)" "t.## -> /s3/nh/nh2/12/92/nh2ct2.x (w/o this number 1.881869)"
#!/usr/bin/perl use strict; use warnings; my $n="nh.ens"; my $tag="nh"; my $dir="/orange/nh/"; my $qq; my @ww=(); my @data=(); my $d; my @f; my $dat; my $key; my %newhash; open INP, "showcluster.pl -dir $dir/$n $tag | sort -k2n | tail |"; while (<INP>) { chomp; #print $_,"\n"; $qq=substr($_,2,4 ); #$qq=~/^t\./g; $qq=~s/\s$//g; push(@ww, $qq); } close INP; for (my $i=0; $i <=8; $i++) { open INP, "ensfiles.pl -cluster $ww[$i] -dir $dir/$n/ $tag | sed q | "; while(<INP>) { chomp; @f=split(/\s/); $dat={}; $dat->{fname}=$f[0]; $dat->{val}=$f[1]; push(@data, $dat); } close INP; open OUT, "| awk '{print $1}' "; for $d ( @data) { $newhash{$d->{val}}=$d->{fname}; } foreach $key (sort (keys %newhash)) { printf OUT "%s -> %s\n", $ww[$i],$newhash{$key}; } close OUT; } Thanks everyone for your help!
|