#!/use/bin/perl

use warnings;
use strict;
use Data::Dumper;

my %data = ();
my $missed_ids = 0;
my $found_ids  = 0;
my %found_ids  = ();

my $mart_fh = './input/mart_export_short.txt.gz';

open MART, "zcat $mart_fh |" or die "can t open pipe to $mart_fh";
while(<MART>){
  chomp;
  next if (m/^$/);
  my @F=split"\t",$_;
  if($data{$F[0]}){
    next;
  }
  elsif ( $F[0] && $F[2] ){
    $data{$F[0]} = $F[2];
  }  
}
close MART;

while(<>){
  chomp;
  if( defined($data{$_}) ){
    $found_ids{$data{$_}}++;
    $found_ids++;
  }
  else{
    $missed_ids++;
  }
}

print "$_\n" for (sort keys %found_ids);
#printf STDERR "ensemble2uniprot.pl: No uniprot ID for %d out of %d genes\n", $missed_ids, $missed_ids + $found_ids;
   
