Hi,
I am trying to convert a bam file back to fastq files. I have used samtools bam2fq in the past and it has worked well. In this particular case, I want to make sure that the unmapped reads in my bam file are part of the fastq files that are output from samtools bam2fq. I have already confirmed my bam file has unmapped reads. I am just not exactly sure if samtools bam2fastq will take those unmapped reads and put them in the fastq files? I was wondering if anyone had any insight into this? This is the command I typically use. Not to ask too many questions but is there a way to create two fastq files instead of just one?
samtools bam2fq merged.dedup.realn.bam > samtools.bam2fq.fastq
I have been using the following commands to split the fastq file into two
cat input.samtools.bam2fq.fastq | grep '^@.*/1$' -A 3 --no-group-separator > output.samtools.bam2fq_R1.fastq
cat input.samtools.bam2fq.fastq | grep '^@.*/2$' -A 3 --no-group-separator > outout.samtools.bam2fq_R2.fastq
That is fine. Unmapped reads will be converted as any other read.
Why not use following. Be sure to name sort/collate the BAM file.
You can also try SamToFastq from Pircard