#!/usr/bin/perl -w 

system("ls ../3_output_bin30/ > fl");


open(IF,"fl");
$fn=0;
while($f=<IF>){
chomp($f);
$farray[$fn] = $f; $fn++;
open(IF2,"../3_output_bin30/$f");
$head = <IF2>;
while($aa = <IF2>){
chomp($aa);
@bb = split(/\t/,$aa);
$gene = $bb[0];
$data{$gene}{$f} = $bb[1];
$genehash{$gene}++;
}
close(IF2);
}
close(IF);

print "gene";
for($i=0;$i<$fn;$i++){print " $farray[$i]";}
print "\n";

foreach $gene (sort keys %genehash){

print "$gene";

for($i=0;$i<$fn;$i++){
$f = $farray[$i];
if(exists $data{$gene}{$f}){print " $data{$gene}{$f}";}
else{print " NA";}
}
print "\n";
}


