Question: output of bedtools bamtofastq are empty files
0
gravatar for adny
5.4 years ago by
adny50
adny50 wrote:

Hi All,

I would like to convert my bam file to fastq. But after I run bedtools with the sorted bam file, I've got two empty files. What should be wrong? (Or what is the proper way to convert a mapped paired-end bam file to fastq?)

What I tried:

samtools sort -n /pathtothefiles/NA12878.chr1.bam /pathtothefiles/NA12878_chr1.qsort
bedtools bamtofastq -i /pathtothefiles/NA12878_chr1.qsort \
                      -fq aln.end1.fq \
                      -fq2 aln.end2.fq

Thanks in advance!

ADD COMMENTlink modified 14 months ago by gohchengang19940 • written 5.4 years ago by adny50

Samtools doesn't sort files in place, it writes them sorted to a new file. You need something like samtools sort -n foo.bam > name_sorted.bam

ADD REPLYlink written 5.4 years ago by Devon Ryan96k

sorry, I deleted too much from the inserted command ... I did it properly, like you wrote.

ADD REPLYlink written 5.4 years ago by adny50

OK, thanks for the update. I've moved my answer to a comment in hopes that someone more familiar with that particular command will answer.

ADD REPLYlink written 5.4 years ago by Devon Ryan96k

it's fairly possible that you can skip the qsort step, read the file from samtools and execute bedtools next. Also, it's possible that samtools is still running and the files will be available at the end of the run. Do you see the file's size increasing with time? Please edit your post with Code paragraph so we can read more easily. 

ADD REPLYlink written 5.4 years ago by madkitty620

I usually use bam2fq instead of bedtools, did you try the following?

htscmd bamshuf -uOn 128 aln_reads.bam tmp > shuffled_reads.bam 
htscmd bam2fq -a shuffled_reads.bam > interleaved_reads.fq 
gzip interleaved_reads.fq

In one line:

tscmd bamshuf -uOn 128 aln_reads.bam tmp | htscmd bam2fq -a - | gzip > interleaved_reads.fq.gz 
ADD REPLYlink written 5.4 years ago by madkitty620

thanks, I tried, but so far I didn't find a right way to deinterleave the output fastq, or at least the script, which I tried was not correct.

I'm sure that samtools ended before I started to use bedtools, but I try again.

ADD REPLYlink written 5.4 years ago by adny50
0
gravatar for mari.felix5723
2.9 years ago by
mari.felix572310 wrote:

I know this post is old but I had the same issue. I was wondering if my data were paired-end or single-end. To do so I tried Bedtools but the resulting files were empty. So, I tried Picard with the paired-end command and it turned out that all my reads went to the unpaired file. Therefore my dataset was single-end and that's probably why the Bedtools command wouldn't work.

ADD COMMENTlink written 2.9 years ago by mari.felix572310

Please cite your command when you mention one in your solution, so that future users can see and better understand. (picard-tools : which command ? which flags ?)

ADD REPLYlink written 8 weeks ago by mariakondili1310
0
gravatar for gohchengang1994
14 months ago by
gohchengang19940 wrote:

I had the same issue as well. Just found out that the problem stems from sorting. I skipped the sorting step and directly convert the unsorted bam file into fastq file. It worked!

ADD COMMENTlink written 14 months ago by gohchengang19940

I tried what you suggested, it is still empty...

ADD REPLYlink written 4 days ago by w19oody0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1539 users visited in the last hour