This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Sam Validation Error: Error: Record 8404072, Read Name Srx020270.6546275, Mapq Should Be 0 For Unmapped Read

Hi, I had a error message when I use picard to replace read groups in a BAM file, like this:

$ java -jar AddOrReplaceReadGroups.jar I=SRX020270.sorted.bam O=SRX020270.resorted.bam SORTORDER=coordinate RGID=SRX020270 RGLB=bar RGPL=illumina RGSM=SRX020270 RGPU='run barcode' CREATEINDEX=True

[Sat Nov 19 13:17:11 CST 2011] net.sf.picard.sam.AddOrReplaceReadGroups INPUT=SRX020270.sorted.bam OUTPUT=SRX020270.resorted.bam SORTORDER=coordinate RGID=SRX020270 RGLB=bar RGPL=illumina RGPU=run barcode RGSM=SRX020270 CREATEINDEX=true TMPDIR=/tmp/ludongsheng VERBOSITY=INFO QUIET=false VALIDATIONSTRINGENCY=STRICT COMPRESSIONLEVEL=5 MAXRECORDSINRAM=500000 CREATEMD5FILE=false

INFO 2011-11-19 13:17:11 AddOrReplaceReadGroups Created read group ID=SRX020270 PL=illumina LB=bar SM=SRX020270

[Sat Nov 19 13:18:34 CST 2011] net.sf.picard.sam.AddOrReplaceReadGroups done. Elapsed time: 1.39 minutes. Runtime.totalMemory()=5798559744 Exception in thread "main" java.lang.RuntimeException: SAM validation error: ERROR: Record 8404072, Read name SRX020270.6546275, MAPQ should be 0 for unmapped read. at net.sf.samtools.SAMUtils.processValidationErrors(SAMUtils.java:334) at net.sf.samtools.BAMFileReader$BAMFileIterator.advance(BAMFileReader.java:469) at net.sf.samtools.BAMFileReader$BAMFileIterator.next(BAMFileReader.java:450) at net.sf.samtools.BAMFileReader$BAMFileIterator.next(BAMFileReader.java:417) at net.sf.samtools.SAMFileReader$AssertableIterator.next(SAMFileReader.java:629) at net.sf.samtools.SAMFileReader$AssertableIterator.next(SAMFileReader.java:607) at net.sf.picard.sam.AddOrReplaceReadGroups.doWork(AddOrReplaceReadGroups.java:91) at net.sf.picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:158) at net.sf.picard.cmdline.CommandLineProgram.instanceMainWithExit(CommandLineProgram.java:118) at net.sf.picard.sam.AddOrReplaceReadGroups.main(AddOrReplaceReadGroups.java:61)

I was told that read name SRX020270.6546275 was an unmapped read, so I checked out the entry for this read, and also the head line in SRX020270.sorted.bam.

$ samtools view SRX020270.sorted.bam | grep "SRX020270.6546275"

SRX020270.6546275 4 GL000198.1 90085 37 43M1D37M * 0 0 AGAATTCTTCAAAGAGTTCCAGATATCCACAGGCAGATTCTACAAATAAGTGTTTCAATACTGCTCTATCAAAAGACGTA BABA@?B?@BBBA@A@;?BBB@A<A?A@B@A>?AAA?>?@>@@?>A>@@@7@;;@?>@>@?:>A>@=<=@@=?@??>?;@ XT:A:U NM:i:4 X0:i:1 X1:i:0 XM:i:3 XO:i:1 XG:i:1 MD:Z:0C42^A3G29T3

$ samtools view -H SRX020270.sorted.bam

@SQ SN:1 LN:249250621

@SQ SN:2 LN:243199373

............

@SQ SN:GL000241.1 LN:42152

@SQ SN:GL000243.1 LN:43341

@SQ SN:GL000242.1 LN:43523

@SQ SN:GL000230.1 LN:43691

@SQ SN:GL000237.1 LN:45867

@SQ SN:GL000233.1 LN:45941

@SQ SN:GL000204.1 LN:81310

@SQ SN:GL000198.1 LN:90085

@SQ SN:GL000208.1 LN:92689

@SQ SN:GL000191.1 LN:106433

@SQ SN:GL000227.1 LN:128374

@SQ SN:GL000228.1 LN:129120

@SQ SN:GL000214.1 LN:137718

.....

@PG ID:bwa PN:bwa VN:0.5.9-r16

So, my question is, is there a way to fix this problem?

picard bwa sam

1 answer

Yes, there is and actually this is not a problem.

This is a BWA "feature". What you must keep in mind is that the only way to know if a read is unmapped is to check the flag. You may have a seq name or/and a mapQ>0, if the flag says it is unmapped, it is.

A simple solution to your problem is to set VALIDATION_STRINGENCY to LENIENT (you will be just warn) or SILENT (totally ignore) in your Picard commands.

Thank you so much, finally I've done with it.

Log in to answer this question.