This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Picard Exception: Illegal Mate State

Hello,

While trying to use Picard's SamToFastq tool I get the following exception:

[Wed Dec 19 17:22:28 PST 2012] Executing as tfunnell@compute-0-2.local on Linux 2.6.18-274.3.1.el5_lustre.g9500ebf amd64; Java HotSpot(TM) 64-Bit Server VM 1.6.0_16-b01; Picard version: 1.59(1062)[Wed Dec 19 17:22:28 PST 2012] net.sf.picard.sam.SamToFastq done. Elapsed time: 0.01 minutes.
Runtime.totalMemory()=9109504Exception in thread "main" net.sf.picard.PicardException: Illegal mate state: HWUSI-EAS627_19:2:43:5028:7313        
at net.sf.picard.sam.SamToFastq.assertPairedMates(SamToFastq.java:299)
at net.sf.picard.sam.SamToFastq.doWork(SamToFastq.java:139)        
at net.sf.picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:177)        
at net.sf.picard.sam.SamToFastq.main(SamToFastq.java:116)

Any thoughts on how I might be able to remove reads with illegal mate states?

Thanks, Tyler

picard

what was the command executed ?

I got the same error, java -Xmx4G -jar /seq/software/picard/current/bin/SamToFastq.jar INPUT=x.bam FASTQ=x.fq1 SECONDENDFASTQ=x.fq2

i think this error means that the input file does not have mate pair.

Thanks, how can I trace back ? we got this BAM file from sequencer. How can I check if your comment is the case and if so, what are the alternatives ? thank you

if you have SAM file try to look at the read HWUSI-EAS627_19:2:43:5028:7313 and try to find its mate read grep 2:43:5028:7313 input.sam. I don't know which tool did you use for the alignment. I got similar kind of error when i trimmed reads using cutadapt and did alignment using bwa. I was unable to solve the issue. But, later i changed adapter trimming program to trimglore and i did not get any problem.

3 answers

I found this error occurring with bam files that contain non-unique read names. i.e. if there are 4 reads with the same name (where there should only be 2 -- representing a single mate pair). bam2fastq checks to make sure that reads with the same name are mates by matching the coordinates of one with the mate coordinates of the other. if these don't match, it will throw this exception. so if you have non-unique read names, this will inevitably occur. so, you need to resolve these mismatches before running bam2fastq... and here's a script to do so. https://github.com/jeff-k/resolvepairs

I am also having this issue, and the recommended resolvepairs did not work for me. Since this is an old post, I reposted with additional info here Picard error Illegal Mate State in converting BAM to Fastq If you have solved this, please respond. thanks

I worked with a pipeline of SNP analysis with GATK, bwa and Picard. When I ran "MarkDuplicates.jar" I found a similar error. I tried to fix with Samtools and others commands but did not work.

I needed to do another alignment compatible with Picard. I eliminated the error when I did:

bwa mem -M .....

-M Mark shorter split hits as secondary (for Picard compatibility).

Log in to answer this question.