#!/bin/bash 

PATH_resultsred="~/Escritorio/vipera/red_proteins/resultsred"

cd $PATH_resultsred

#samples="DI1(hit1) DI1(hit3) DI2(hit2) GPx3(hit1) GPx(hit2) Sel15(hit1) SelI(hit1) SelP1(hit1) SelR1(hit1) SelU1(hit1) TR3(hit1)
#DI1(hit2) DI2(hit1) GPx2(hit1) GPx(hit1) GPx(hit3) SelH(hit1) SelN(hit1) SelP2(hit1) SelT(hit1) TR(hit1) SPS(hit1)"
samples="SPS(hit1)"
for sample in $samples
do

	cd $sample

	a=$(cut -d '(' -f2 $sample.exon.gff | cut -d ',' -f1 | uniq) #start we gave to the fastasubseq	
	b=$(egrep -m1 gene $sample.exonerate.gff | cut -f4 | uniq) #relative start in the fastasubseq
	c=$(egrep -m1 gene $sample.exonerate.gff | cut -f5 | uniq) #relative end in the fastasubseq
	echo "$sample a: $a b: $b c: $c"
	d=$(($a+$b)) #abolute start of the gene in the contig
	e=$(($a+$c)) #abolute end of the gene in the contig	
	f=$(cut -d ':' -f1 $sample.exon.gff | uniq) #identificador del contig
	echo "$sample	$f	start:$d	end:$e" >> ~/Escritorio/coordenades_absolutes.txt
#	echo "$sample a: $a b: $b c: $c d: $d e: $e f:$f"
	cd $PATH_resultsred
done


