Convert Bam To Fastq With Pe & Se Reads
3
5
Entering edit mode
12.6 years ago
Pasta ★ 1.3k

Hi there,

EDIT

I filtered my PE reads based on quality. Filtering generated 3 kind of files:

  • 1 file with PE of good quality
  • 1 file with discarded reads,
  • 1 file with orphan PE reads of good quality(unpaired PE).

I concatenated good quality reads, and submitted my reads to BWA to generate a SAM file. So basically, all my reads "look like" PE reads, even though I have unpaired reads.

!EDIT

I would like to convert a BAM/SAM file to FASTQ. The thing is that my BAM file contains Paired-end reads and Single-end reads, and I'd like a tool that will generate 3 files :

  • 1 file with paired end reads #1
  • 1 file with paired end reads #2
  • 1 file with single end reads (unpaired)

I tried Picard and Bam2Fastq but this option doesnt exist. Any idea ?

Thanks

fastq bam next-gen sequencing • 8.8k views
ADD COMMENT
3
Entering edit mode
12.6 years ago
Swbarnes2 ★ 1.6k

You could use samtools view to filter the .bam into three files; reads that are read 1, reads that are read 2, and reads from SE experiments. Picard can sort each .bam by read name, before you convert them to fastq.

ADD COMMENT
2
Entering edit mode

What's so onerous about running samtools view 3 times to split up the .bam into those three groups?

samtools view -bf 64 mixed.bam > read1.bam samtools view -bf 128 mixed.bam > read2.bam samtools view -bF 1 mixed.bam > SE.bam

Then run bam2fastq on each of those files.

ADD REPLY
0
Entering edit mode

Question edited with more details

ADD REPLY
3
Entering edit mode
8.1 years ago
Shicheng Guo ★ 9.5k

Swbarnes2 method is quite right. three Step:

1, Get all the reads belong to read1 (paired-end). With -f 64, you can get all the reads including 64, such as 65, 193 and so on

samtools view -bf 64 mixed.bam > read1.bam

2, Get all the reads belong to read2 (paired-end). With -f 128, you can get all the reads including 128, such as 129, 177 and so on

samtools view -bf 128 mixed.bam > read2.bam

3, Get all the reads belong to single-end. With -F 1, you can exclude all the pair-end reads.

samtools view -bF 1 mixed.bam > SE.bam
ADD COMMENT
0
Entering edit mode
12.6 years ago

Is this thread what you are looking for?

ADD COMMENT
0
Entering edit mode

Thanks. I read this thread already but I need to sort PE and SE while converting to fastq

ADD REPLY
0
Entering edit mode

Do the read ids contain information on pairing? If so there are easy ways to do what you want. Can you provide a few read ids?

ADD REPLY

Login before adding your answer.

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