Do I need to sort a .bam to convert it to fastq?
1
0
Entering edit mode
2.8 years ago
bio_elle ▴ 10

I need to get a .fq file and I have bam files, I am following a code that I found online that sorts it at first

samtools sort -n file.bam > sorted.bam

and then converts it to fastq

samtools fastq sorted.bam > file.fq

Is the sort needed? I think in this case it was used because the data had paired-end reads and sorting by read name makes it so that the files have the mates in the same order, and that can make things easier when using the fastq files (I think???)

But is it needed in single-end data?

samtools fastq bam • 830 views
ADD COMMENT
1
Entering edit mode
2.8 years ago

samtools sort -n file.bam > sorted.bam and then converts it to fastq samtools fastq sorted.bam > file.fq

use "samtools collate" and pipe it into "samtools fastq"

But is it needed in single-end data?

no

ADD COMMENT
0
Entering edit mode

So with paired-end I can avoid the sort and use

samtools collate file.bam | samtools fastq > file.fq

while with single end I can directly convert to fastq?

ADD REPLY

Login before adding your answer.

Traffic: 2239 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