I have mapped PE reads to a custom build genome using bwa and converted the sam output to bam and filtered out unpaired reads and reads that didnt align. I then converted the filtered bam to sam and tried to convert the sam to fastq but got the error

Exception in thread "main" net.sf.picard.PicardException: Found 1014 unpaired mates
at net.sf.picard.sam.SamToFastq.doWork(SamToFastq.java:158)
at net.sf.picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:175)
at net.sf.picard.sam.SamToFastq.main(SamToFastq.java:116)

The same sam file runs OK in cufflinks. I want the fastq files to attempt de novo assembly of the mapped on velvet because the reads were mapped to variant genes with some homology but are predicted to have recombined into novel arrangements.

Update: I failed to read this fully. You are working with unmapped sequences. BWA does not report these individually - but Tophat2 will, as an advanced option ("Write unaligned reads to seperate file(s)"). To my knowledge SAM->Fastq will unmapped from any SAM. But do not attempt to convert SAM->Interval, as there will be no "mappings to report (not useful for assembly, but info many aid someone else reading).

-- original ->

This tool requires the sam header lines. Filtering steps will usually remove these, as will converting BAM->SAM without selecting the option to include headers. If needed, Picard has a tool for replacing headers from a donor dataset. Please give this a try.