#!/bin/bash 

PATH_resultsgreen="~/Escriptori/vipera/green_proteins/resultsgreen/"

cd $PATH_resultsgreen

samples="eEFsec(1)(hit1) MsrA(hit5) SecS(hit1) SelR3(hit1) eEFsec(2)(hit1) GPx(hit1) Sel0(1)(hit1) Sel0(2)(hit1) eEFsec(3)(hit1) MsrA(hit1) PSTK(hit1) SelU2(hit1) GPx4(hit1) MsrA(hit2) SBP2(1)(hit1) SPS1(hit1) MsrA(hit3) SBP2(2)(hit1) SelI(hit1) SPS1(hit2) GPx8(hit1) MsrA(hit4) SECp43(hit1) SelR2(hit1) GPx8(hit2)"

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
	d=$(($a+$b)) #absolute start of the gene in the contig
	e=$(($a+$c)) #absolute end of the gene in the contig	
	f=$(cut -d ':' -f1 $sample.exon.gff | uniq) #contig's ID

	echo "$sample	$f	start:$d	end:$e" >> ~/Escriptori/vipera/coordenades/resultats_coordenades/green_coordenades_gens.txt

	cd $PATH_resultsgreen
done


