#!/bin/bash

mkdir -p ../t_coffee
mkdir -p ../t_coffee/exit_tcof
mkdir -p ../t_coffee/proteinaambX
mkdir -p ../t_coffee/aln
mkdir -p ../t_coffee/html
mkdir -p ../t_coffee/hits_exon_tcof
mkdir -p ../t_coffee/res_unic_exo
mkdir -p ../t_coffee/exit_tcof/Exonerate
mkdir -p ../t_coffee/proteinaambX/Exonerate
mkdir -p ../t_coffee/aln/Exonerate
mkdir -p ../t_coffee/html/Exonerate

for year_d in ../Exonerate/fastatranslate/*; do {
		year=`basename $year_d`

		mkdir -p ../t_coffee/exit_tcof/Exonerate/$year
		mkdir -p ../t_coffee/proteinaambX/Exonerate/$year
		mkdir -p ../t_coffee/aln/Exonerate/$year
		mkdir -p ../t_coffee/html/Exonerate/$year
		mkdir -p ../t_coffee/hits_exon_tcof/$year
		mkdir -p ../t_coffee/res_unic_exo/$year

for genome_donanom in ../Exonerate/fastatranslate/$year/*; do {
		genome=`basename $genome_donanom`
		
		mkdir -p ../t_coffee/exit_tcof/Exonerate/$year/$genome
		mkdir -p ../t_coffee/proteinaambX/Exonerate/$year/$genome
		mkdir -p ../t_coffee/aln/Exonerate/$year/$genome
		mkdir -p ../t_coffee/html/Exonerate/$year/$genome
		mkdir -p ../t_coffee/hits_exon_tcof/$year/$genome
		mkdir -p ../t_coffee/res_unic_exo/$year/$genome

		for query_donanom in ../Exonerate/fastatranslate/$year/$genome/*; do {
			query=`basename $query_donanom`
				
			mkdir -p ../t_coffee/exit_tcof/Exonerate/$year/$genome/$query
			mkdir -p ../t_coffee/proteinaambX/Exonerate/$year/$genome/$query
			mkdir -p ../t_coffee/aln/Exonerate/$year/$genome/$query
			mkdir -p ../t_coffee/html/Exonerate/$year/$genome/$query
			mkdir -p ../t_coffee/hits_exon_tcof/$year/$genome/$query
			mkdir -p ../t_coffee/res_unic_exo/$year/$genome/$query

				for hit_carpetes in ../Exonerate/fastatranslate/$year/$genome/$query/*; do {
					hitcarpetes=`basename $hit_carpetes`

					mkdir -p ../t_coffee/exit_tcof/Exonerate/$year/$genome/$query/$hitcarpetes
					mkdir -p ../t_coffee/proteinaambX/Exonerate/$year/$genome/$query/$hitcarpetes
					mkdir -p ../t_coffee/aln/Exonerate/$year/$genome/$query/$hitcarpetes
					mkdir -p ../t_coffee/html/Exonerate/$year/$genome/$query/$hitcarpetes
					mkdir -p ../t_coffee/hits_exon_tcof/$year/$genome/$query/$hitcarpetes
					mkdir -p ../t_coffee/res_unic_exo/$year/$genome/$query/$hitcarpetes
	
						for protein_fastatranslate in ../Exonerate/fastatranslate/$year/$genome/$query/$hitcarpetes/*; do {
							fastatranslate=`basename $protein_fastatranslate`
							fasordena=${fastatranslate%.fa}					
	 
perl goexplote.pl < $protein_fastatranslate $year $genome $query $hitcarpetes $fasordena

						} done

						for protein_txatxis in ../t_coffee/hits_exon_tcof/$year/$genome/$query/$hitcarpetes/*; do {
						protein=`basename $protein_txatxis`
						ordena=${protein%.fa}
												
perl foraasterisc.pl < $protein_txatxis > ../t_coffee/proteinaambX/Exonerate/$year/$genome/$query/$hitcarpetes/$protein

t_coffee ../t_coffee/proteinaambX/Exonerate/$year/$genome/$query/$hitcarpetes/$protein ../Exonerate/querysambX/$query.fa > ../t_coffee/exit_tcof/Exonerate/$year/$genome/$query/$hitcarpetes/tcoffee_$protein


	mv $ordena.aln ../t_coffee/aln/Exonerate/$year/$genome/$query/$hitcarpetes/tcoffee_$ordena.aln
	mv $ordena.html ../t_coffee/html/Exonerate/$year/$genome/$query/$hitcarpetes/tcoffee_$ordena.html


} done				
		} done
				} done
		} done
} done

mkdir -p ../t_coffee/hits_gwise_tcof
mkdir -p ../t_coffee/res_unic_gwise
mkdir -p ../t_coffee/exit_tcof/Genewise
mkdir -p ../t_coffee/proteinaambX/Genewise

mkdir -p ../t_coffee/aln_unic_gwise
mkdir -p ../t_coffee/html_unic_gwise

for gyear_d in ../Genewise/genewiseexit/*; do {
		gyear=`basename $gyear_d`

		mkdir -p ../t_coffee/exit_tcof/Exonerate/$gyear
		mkdir -p ../t_coffee/proteinaambX/Exonerate/$gyear
		
		mkdir -p ../t_coffee/hits_gwise_tcof/$gyear
		mkdir -p ../t_coffee/res_unic_gwise/$gyear
		mkdir -p ../t_coffee/aln_unic_gwise/$gyear
		mkdir -p ../t_coffee/html_unic_gwise/$gyear

for genome_Genewise in ../Genewise/genewiseexit/$gyear/*; do {

		gGenewise=`basename $genome_Genewise`

		mkdir -p ../t_coffee/exit_tcof/Genewise/$gyear/$gGenewise
		mkdir -p ../t_coffee/proteinaambX/Genewise/$gyear/$gGenewise
		
		mkdir -p ../t_coffee/hits_gwise_tcof/$gyear/$gGenewise
		mkdir -p ../t_coffee/res_unic_gwise/$gyear/$gGenewise
		mkdir -p ../t_coffee/aln_unic_gwise/$gyear/$gGenewise
		mkdir -p ../t_coffee/html_unic_gwise/$gyear/$gGenewise

		for query_Genewise in ../Genewise/genewiseexit/$gyear/$gGenewise/*; do {

			gquery=`basename $query_Genewise`
	echo $gquery
			mkdir -p ../t_coffee/exit_tcof/Genewise/$gyear/$gGenewise/$gquery
			mkdir -p ../t_coffee/proteinaambX/Genewise/$gyear/$gGenewise/$gquery
			
			mkdir -p ../t_coffee/hits_gwise_tcof/$gyear/$gGenewise/$gquery
			mkdir -p ../t_coffee/res_unic_gwise/$gyear/$gGenewise/$gquery
			mkdir -p ../t_coffee/aln_unic_gwise/$gyear/$gGenewise/$gquery
			mkdir -p ../t_coffee/html_unic_gwise/$gyear/$gGenewise/$gquery

				for ghit_carpetes_d in ../Genewise/genewiseexit/$gyear/$gGenewise/$gquery/*; do {
					
					ghitcarpetes=`basename $ghit_carpetes_d`
				mkdir -p ../t_coffee/exit_tcof/Genewise/$gyear/$gGenewise/$gquery/$ghitcarpetes
			mkdir -p ../t_coffee/proteinaambX/Genewise/$gyear/$gGenewise/$gquery/$ghitcarpetes
			
			mkdir -p ../t_coffee/hits_gwise_tcof/$gyear/$gGenewise/$gquery/$ghitcarpetes
			mkdir -p ../t_coffee/res_unic_gwise/$gyear/$gGenewise/$gquery/$ghitcarpetes
			mkdir -p ../t_coffee/aln_unic_gwise/$gyear/$gGenewise/$gquery/$ghitcarpetes
			mkdir -p ../t_coffee/html_unic_gwise/$gyear/$gGenewise/$gquery/$ghitcarpetes				

				for Genewise_protein in ../Genewise/genewiseexit/$gyear/$gGenewise/$gquery/$ghitcarpetes/*; do {

					gprotein=`basename $Genewise_protein`
					gordena=${gprotein%.fa}		

perl genewisepeltcoffee.pl < $Genewise_protein > ../t_coffee/hits_gwise_tcof/$gyear/$gGenewise/$gquery/$ghitcarpetes/$gprotein
perl foraasterisc.pl < ../t_coffee/hits_gwise_tcof/$gyear/$gGenewise/$gquery/$ghitcarpetes/$gprotein > ../t_coffee/proteinaambX/Genewise/$gyear/$gGenewise/$gquery/$ghitcarpetes/$gprotein


t_coffee  ../t_coffee/proteinaambX/Genewise/$gyear/$gGenewise/$gquery/$ghitcarpetes/$gprotein ../Exonerate/querysambX/$gquery.fa > ../t_coffee/exit_tcof/Genewise/$gyear/$gGenewise/$gquery/$ghitcarpetes/gtcoffee_$gprotein

cp ../t_coffee/exit_tcof/Genewise/$gyear/$gGenewise/$gquery/$ghitcarpetes/gtcoffee_$gprotein ../t_coffee/res_unic_gwise/$gyear/$gGenewise/$gquery/$ghitcarpetes/gtcoffee_$gprotein


	mv ./$gordena.html ../t_coffee/html_unic_gwise/$gyear/$gGenewise/$gquery/$ghitcarpetes/gtcoffee_$gordena.html
	mv ./$gordena.aln ../t_coffee/aln_unic_gwise/$gyear/$gGenewise/$gquery/$ghitcarpetes/gtcoffee_$gordena.aln

				} done
		} done
} done
			
} done

} done

rm ./*.temp
