#!/usr/bin/env perl
# eats the interests ss, 'ResearchInterests-MarianMod.tsv' & counts the 'X's in each column
# to generate the offsets for the links into each interest so the entry points are not single points, 
# but a spread, indicating the number of links into that area of interest.

# the interest headers
my @intname = ("spacer", "brain","skin","blood","breast","immune","intest","lung","stem","prost","tumoruv","metast",
"cellsignal","metab","biomark","dnarepair","virol","obes","rnabio","epigen","tools");


# init the int arry
my @intcnt; for (my $i=0; $i<21; $i++){ $int[$i] = 0; }

while (<>) {
    if ($_ !~ /^#/) {
      chomp;
      my $N = my @A = split(/\t/, $_);
      # count all the Xs in the matrix and plunk into the right el.
      for (my $i=1; $i<21; $i++){ if ($A[$i] eq "X") {$intcnt[$i]++; }}
    }
}

# dump the sorted keys and values for all the PI hashes.
for (my $i=1; $i<21; $i++){
    print "$intname[$i]\t$intcnt[$i]\n";
}

for (my $i=1; $i<21; $i++){
    print "$intcnt[$i],";
}
