Samtools bam2fq converting bam file to fastq. What happens to unmapped reads?
0
0
Entering edit mode
3.2 years ago

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
Assembly alignment sequencing next-gen • 6.2k views
ADD COMMENT
2
Entering edit mode

That is fine. Unmapped reads will be converted as any other read.

ADD REPLY
0
Entering edit mode

Why not use following. Be sure to name sort/collate the BAM file.

samtools fastq -1 paired1.fq -2 paired2.fq -0 /dev/null -s single.fq -n in.bam
ADD REPLY
0
Entering edit mode

You can also try SamToFastq from Pircard

java -jar picard.jar SamToFastq I=merged.dedup.realn.bam FASTQ=output.samtools.bam2fq_R1.fastq --SECOND_END_FASTQ=outout.samtools.bam2fq_R2.fastq
ADD REPLY

Login before adding your answer.

Traffic: 2609 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6