#!/usr/bin/perl

open(LIST,"v3.1.0.VS.1.73.mappable.domains");

#d1dlwa_ a.1.1.1 1dlwA00 1.10.490.10
#d1uvya_ a.1.1.1 1uvyA00 1.10.490.10




while (<LIST>) {
  @line=split(/\s+/);
  @scop=split(/\./,$line[1]);
  $num_homo{$scop[0].".".$scop[1].".".$scop[2].":".$line[3]}++;
#  print $scop[0].".".$scop[1].".".$scop[2].":".$line[3]."\n";
}
close(LIST);

$same=0;
$diff=0;
foreach $key1 (keys %num_homo) {
  foreach $key2 (keys %num_homo) {
    if ($key1 le $key2) {
      if ($key1 eq $key2) {
          $x=$num_homo{$key1};
          $same+= $x*($x-1)/2;
      }
      else {
          @id1=split(/:/,$key1);
          @id2=split(/:/,$key2);
#         print $id1[0]," ",$id1[1],"\n";
          if (($id1[0] ne $id2[0]) && ($id1[1] ne $id2[1])) {
            $diff+= $num_homo{$key1}*$num_homo{$key2};
          }
      }
    }
  }
}

print $same, " ", $diff," ",$same/($same+$diff),"\n";


        



