Picard Exception: Illegal Mate State
3
6
Entering edit mode
11.3 years ago
Tyler ▴ 60

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 • 9.0k views
ADD COMMENT
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

what was the command executed ?

ADD REPLY
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Try bedtools bamtofastq.

Also check this link http://seqanswers.com/forums/showthread.php?t=40117

Deeps

ADD REPLY
3
Entering edit mode
11.2 years ago
Jamie ▴ 30

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

ADD COMMENT
0
Entering edit mode
9.6 years ago
trakhtenberg ▴ 160

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

ADD COMMENT
0
Entering edit mode
9.6 years ago
RafaelMP ▴ 120

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).

ADD COMMENT
0
Entering edit mode

This doesn't help.

ADD REPLY

Login before adding your answer.

Traffic: 2699 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6