#!/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) SPS(hit1) TR(hit1)"
samples="DI1(hit1)"
for sample in $samples
do

	cd $sample

	contig=$(cut -d ':' -f1 $sample.exon.gff | uniq) #identificador del contig
	
	echo ">$sample($contig)" >> ~/Escritorio/$sample.txt
	
	counter=1

	linecount=$(wc $sample.exon.gff -l $f | cut -f1 -d' ')

	while [ $counter -le $linecount ] 
		do		

		a=$(cut -d '(' -f2 $sample.exon.gff | cut -d ',' -f1 | uniq) #start we gave to the fastasubseq
		
		b=$(cut -f4 $sample.exon.gff | awk NR==$counter) #relative start in the fastasubseq

		c=$(cut -f5 $sample.exon.gff | awk NR==$counter) #relative end in the fastasubseq

		d=$(($a+$b)) #abolute start of the exon in the contig

		e=$(($a+$c)) #abolute end of the exon in the contig
		
		echo "exon$counter	start:$d	end:$e" >> ~/Escritorio/$sample.txt
		
		counter=$(($counter + 1))

		echo $counter

		done

	counter=1
	cd $PATH_resultsred

done




