#!/bin/bash
#$ -cwd
#$ -j y
#$ -t 1:500
set -x
set -o
SGE_TASK_ID=1
# Define varibles
WD="/bioinf/projects/megx/UNKNOWNS/chiara/Clusters_data/2016_11/multi_PFAM/"
CL_FILES="${WD}/clusters_splits"
CL_FILE="${CL_FILES}/CLUSTERS_${SGE_TASK_ID}"
INDXER="/bioinf/projects/megx/UNKNOWNS/chiara/Clusters_data/2016_11/multi_PFAM/tarindexer.py"
TAR="${WD}/ergm1_aln.tar"
INDEX="${WD}/ergm1_aln.index"
OUTDIR="/bioinf/projects/megx/UNKNOWNS/chiara/Clusters_data/2016_11/multi_PFAM/results/${SGE_TASK_ID}"
if [[ -d "${OUTDIR}" ]]; then
find "${OUTDIR}" -delete -print
mkdir -p "${OUTDIR}"
else
mkdir -p "${OUTDIR}"
fi
cd "${OUTDIR}"
awk '{print $3".aln.id.filt.m8"}' "${CL_FILE}" | parallel --progress -j 10 "${INDXER}" -l "${TAR}" "${INDEX}" {} ">" {}