'Nested for loop using mapfile

I am trying to do a nested for loop using maple. The first loop takes in all my files that I am analysing (FILE). the second loop takes in different reference genomes (REF) for which each FILE should be analysed against. When running the script below it seems to be stuck in the line starting with bowtie2 --threads 50-... I want to loop each FILE over all the bowtie/samtools commands before for each REF, before starting with a new file.

#!/bin/bash




mapfile -s 1 -t files <  ./samples2/files.txt
echo "${files[@]}"
for FILE in ${files[@]}; do

    

mapfile -s 1 -t files2 <   ./NCBI_FASTA/files.txt
echo "${files2[@]}"
for REF in ${files2[@]}; do
            
        samtools fastq -@40 ./samples/${FILE}.bam   > ${FILE}.fastq
        bowtie2 --threads 50 -x  ./BOWTIE_INDEX_NCBI_FASTA/${REF} -q ${FILE}.fastq -S ${FILE}.sam
        samtools view -@40 -S -b ${FILE}.sam > ${FILE}.bam
        samtools sort -@40 ${FILE}.bam -o ${FILE}.sorted.bam
        samtools index  ${FILE}.sorted.bam
        samtools idxstats ${FILE}.sorted.bam > ${FILE}_${REF}.stats.txt
        samtools mpileup  ${FILE}.sorted.bam | awk -v X="${MIN_COVERAGE_DEPTH}" '$4>=X' | wc -l > ${FILE}_${REF}_MIN_COVERAGE_DEP.txt
        bowtie2-inspect   -s ./BOWTIE_INDEX_NCBI_FASTA/${REF} | awk '{ FS = "\t" } ; BEGIN{L=0}; {L=L+$3}; END{print L}' >  ${FILE};
done;
done


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source