#!/usr/bin/perl -w 

$genome='Sbay';

open(IF,"$genome/$genome.tab");

#Sbay_89.1	283	504	1	222	1	0	0		0		1e+100	1e+100	1e+100	1e+100	0	-1e+100	-1e+100	1e+100	NNNN	GAP	
#Sbay_5.1	2428	2913	1	486	1	2	0	YEL066W	0	Anc_8.697	0.0026	3e-72	1e+100	1e+100	0	-1e+100	-1e+100	1e+100	AA	REAL	YEL066W
while($a=<IF>){
@b=split(/\t/,$a);
$this=$b[0];
$that = $b[8];
$lu{$this} = $that;
}
close(IF);


open(IF,"cdnafilt.bed");
open(OF,">base2.bed");
open(OF0,">base02.bed");
#chr1	846	2184	Sbay_1.1	1000	-	846	2184	0	1	1338,	0,
while($a=<IF>){
@b=split(/\t/,$a);
$score=$b[4];
if($score>950){
print OF0 $a;
$this = $b[3];
if($lu{$this}){
$that=$lu{$this};
$a =~ s/$this/$that/;
print OF $a;
}
else{print OF $a;}
}}


