hello,
I am using the pipeline
samtools view -f 12 -F 256 aligned-sorted-deduplicated.bam | samtools sort -n - | samtools fastq -1 paired1.fq -2 paired2.fq -0 /dev/null -s /dev/null -N -
to generate fastq files but I get empty fastq files. Yet I got the sequence:
aligned-sorted-deduplicated.bam 65 Gb
unmapped.bam 7 Kb
unmapped-sorted 3 Kb
paired1.fq 0 By
Why is that? If there are data (not much, but still 3 Kb) in the sorted file, why there is nothing in the fast files? Thanks
1 answer
My best guess is that the first command produces a headerless SAM file (because -h and/or -b is missing), therefore sort considers this an invalid file, hence doesn't do anything (3kb is nothing), so fastq doesn't get any data. This is a least what happens on my machine with a random bam file:
$ samtools view random.bam | samtools sort -n > /dev/null
[E::sam_parse1] no SQ lines present in the header
samtools sort: truncated file. Aborting
Check your log files for this error. Add -u to the first view command, this will return an uncompressed BAM that sort can read with no further time wasted on decompression.
Log in to answer this question.