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!
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
sorry, I deleted too much from the inserted command ... I did it properly, like you wrote.
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.
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.
I usually use bam2fq instead of bedtools, did you try the following?
In one line:
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.