#!/usr/bin/perl


my $resultfile  = $ARGV[0];
my $fname       = $ARGV[1];
my $outfile     = $fname."_mod";

open( RESFILE, $resultfile )         or die "Cannot open: $!";
open( INFILE,  $fname)               or die "Cannot open: $!";
open( OUTFILE, ">$outfile" )         or die "Cannot write to file: $!";


%name2CP;

while ( <RESFILE> )
{
  $a = $_;
  if( $a =~ /_/ )
    {
      @parts = split " ", $a;
      $parts[5] =~ s/uORF//g;
      $parts[5] =~ s/x/\-/g;
      my $name = "Scer_".$parts[5];
#      print $name."\n";
      $name2CF{ $name } = $parts[10];
    }
}


while( <INFILE> )
  {
    @parts = split " ", $_;
    $a = $_;
    $a =~ s/\n//g;
    my $CF = $name2CF{ $parts[0] };
    if( $CF eq "" )
      {
	print OUTFILE "$a $CF -1.0\n";
      }
    else
      {
	print OUTFILE "$a $CF\n";
      }
  }
