any suggestions on good programs or scripts to convert a BAM file back to a fastq? I have found some scripts but wanted to ask for advice before I go too far down the wrong path.
Do you know the rules for identifying mate pairs? I used bowtie to align some paired end reads into a sam format file and was able to use various picard methods to process it. I made a file with duplicates removed and SamToFastq throws an exception:
Exception in thread "main" net.sf.picard.PicardException: Illegal mate state: HWUSI-EAS614_1:1:12:4379:1523:0:2:1
I assume because the read ID is not HWUSI-EAS614_1:1:12:4379:1523/2
Have you any had any problems like this?
I have not. Maybe you should ask this as an independent question to have more people view and potentially offer assistance.
Mike, Did you find a way around it? Im facing the same problem.
Teja, please ask your problem as a separate question for detailed response.
use SamToFastq : http://picard.sourceforge.net/command-line-overview.shtml#SamToFastq
hu ? I wonder why someone flagged this as negative ???!! :-/
There is a bam2fastx utility bundled with tophat:
bam2fastx [--fasta|-a|--fastq|-q] <in.bam>
Works really really well for me:
bam2fastx --fastq -M -o S1_mapped.fastq -N S1.sort.grp.md.bam
Here it adds the /1 and /2 suffix for paired reads and doesn't complain if mate is missing (some of my reads are single ended and don't have a mate). Bam2Fastq would complain about missing mates and wouldn't export single ended reads unless extra precautions were taken.
There is also one in the Hydra package. It's called bamToFastq.
Here is another tool that saves the transition into sam format and converts bam directly into fastq: bam2fastq
By the way, the URL changed to https://gsl.hudsonalpha.org/information/software/bam2fastq, but the software is deprecated in favour of Picard.
Bedtools - for converting bam to fastq
You can use Picard
java -jar picard.jar SamToFASTQ \
FYI, if you're directly copying this answer, you should use camel case: SamToFastq for the program name. Thanks for the answer!
Login before adding your answer.