I align forward and reverse fastq reads to a fasta reference using bwa, then sort the alignment file:

bwa mem -M -t 16 ref_galr2a_AA.fa E01_S49_L001_R1_001.fastq.gz E01_S49_L001_R2_001.fastq.gz | samtools sort > test.bam

Now say I want to convert back this bam to fastq files; I am used to doing:

bedtools bamtofastq -i test.bam -fq  forward.fastq -fq2 reverse.fastq

Then put the result in a gunzip

gzip forward.fastq

It creates file forward.fastq.gz

On macOS, I can typically double-click a file like this, and I'll get the fastq file inside (it uses Archive Utility by default).

However, with this one I get:

Unable to expand "forward.fastq.gz" into "folder".
(Error 79 - Inappropriate file type or format.)

This does not happen if I unzip/put back in a gzip the original fastq directly.

i.e. say I unzip E01_S49_L001_R1_001.fastq.gz by double-clicking it (Archive Utility), then run:

gzip E01_S49_L001_R1_001.fastq

It generates back E01_S49_L001_R1_001.fastq.gz, which I am able to open with Archive Utility.

So that tells me bedtools bamtofastq is not innocent? What is going on?

Source link