# module load singularity

mkdir -p logs
scratch_dir=$(echo $PWD | sed 's/\/data\/ucct\/bi\/scratch_tmp/\/scratch/g')

# Ariba summarise data from several runs. View the results in Phandango by dragging and dropping the files out.summary.phandango.tre and out.summary.phandango.csv into the Phandago window.
# Explanation: 
# 1 - Use the ls in parenthesis to find the reports for a certain db, and xargs to make it into a single line
# 2 - Integrate this into the ariba summary command

cat ../databases.txt | while read in; do echo "srun --chdir $scratch_dir --output logs/ARIBA_SUMMARY_${in}.log --job-name ARIBA_${in} --cpus-per-task 5 --mem 5G --partition short_idx --time 00:30:00 singularity exec -B ${scratch_dir}/../../../../ /data/ucct/bi/pipelines/singularity-images/ariba:2.14.6--py36h4aaaa08_3 ariba summary --cluster_cols ref_seq,match out_summary_${in} $(ls ${scratch_dir}/../run/*/out*_${in}*/*${in}*_report.tsv | xargs) &"; done > _01_ariba_summary_prueba.sh
