Hello All,
I am running bwa-mem
with compressed paired-end input files using an array. I am trying to make sorted bam files as well. I am using this array:
INPUT=$(ls -1 input/*_1.fq.gz | sed -n ${RUN}p)
SAMPLE=$(basename "$INPUT" | sed 's/_1.fq.gz//')
bwa mem GENOME ${SAMPLE}_1.fq.gz ${SAMPLE}_2.fq.gz | samtools sort -o ${SAMPLE}_sorted.bam
However, at some point it stops running with an error:
[E::hts_open_format] fail to open file 'sorted.bam.tmp.0000.bam'
[bam_sort_core] failed to create temporary file "sorted.bam.tmp.0000.bam": File exists
I used the same array for uncompressed files before and there was no error. I am trying to save some space by using compressed files.
I will appreciate any input. Thanks!
basename
takes a parameter to trim, you don't need the sed. Even without that, you could use${INPUT/%_1.fq.gz/}
You ran this command, or similar, before in this directory. These temporary files need to be removed first.
Thank you! I tried this. I removed the temporary files from previous runs. I also tried running it after making a new directory. But it always gives the same error.