How to fix the BAM file (SAM validation error)
2
0
Entering edit mode
6.5 years ago

I get the following error when I try to build the index of my BAM file:

Exception in thread "main" htsjdk.samtools.SAMFormatException: SAM validation error: ERROR: Record 3009, Read name M00918:82:000000000-BMF6N:1:1101:10112:22298, bin field of BAM record does not equal value computed based on alignment start and end, and length of sequence to which read is aligned
at htsjdk.samtools.SAMUtils.processValidationErrors(SAMUtils.java:439)
at htsjdk.samtools.BAMFileReader$BAMFileIterator.advance(BAMFileReader.java:644)
at htsjdk.samtools.BAMFileReader$BAMFileIterator.next(BAMFileReader.java:629)
at htsjdk.samtools.BAMFileReader$BAMFileIterator.next(BAMFileReader.java:599)
at htsjdk.samtools.BAMFileReader$BAMQueryFilteringIterator.advance(BAMFileReader.java:832)
at htsjdk.samtools.BAMFileReader$BAMQueryFilteringIterator.next(BAMFileReader.java:822)
at htsjdk.samtools.BAMFileReader$BAMQueryFilteringIterator.next(BAMFileReader.java:788)
at htsjdk.samtools.SamReader$AssertingIterator.next(SamReader.java:544)
at htsjdk.samtools.SamReader$AssertingIterator.next(SamReader.java:518)

The command is:

java -jar picard.jar BuildBamIndex I=myfile.bam

I know I can set VALIDATION_STRINGENCY=LENIENTE, but I want to fix my BAM file because it is another program that is calling it (Astrolabe, which I don't have the source).

I also could revert the Astrolabe classes to java file and try to debug and change, but if someone could suggest me an quickier solution, I would appreciate.

alignment • 4.3k views
ADD COMMENT
0
Entering edit mode

Just use samtools index instead, it likely won't complain about this.

ADD REPLY
0
Entering edit mode
6.5 years ago
h.mon 35k

See SAM bin field error for the GATK run for possible solutions.

ADD COMMENT
0
Entering edit mode

Thanks for the link: I will try the solution: java -cp /path/to/picard/bin/htsjdk-1.133.jar htsjdk.samtools.FixBAMFile source.bam fixed.bam (EDIT: it worked. Thank you so much! You saved me a lot of time)

ADD REPLY
0
Entering edit mode
6.5 years ago

another solution

https://github.com/broadinstitute/picard/blob/b2a6985ed1cdbbbb03930e40cf7b077e487aba6a/src/main/java/picard/cmdline/CommandLineProgram.java#L104

change

 public ValidationStringency VALIDATION_STRINGENCY = ValidationStringency.DEFAULT_STRINGENCY;

to

 public ValidationStringency VALIDATION_STRINGENCY = ValidationStringency.LENIENT;

recompile/re-install picard (see https://github.com/broadinstitute/picard for instruction )


add the following option

VALIDATION_STRINGENCY=LENIENT

see https://broadinstitute.github.io/picard/command-line-overview.html "Standard Options"

ADD COMMENT
1
Entering edit mode

Dear Pierre, thanks very much for your answer, but, as I said in the question, I aware of that I can set VALIDATION_STRINGENCY=LENIENTE, but I want to fix my BAM file because it is another program that is calling it (Astrolabe, which I don't have the source).

ADD REPLY
1
Entering edit mode

ah yes, sorry, my bad, I didn't take the time to read the whole question....

ADD REPLY
1
Entering edit mode

I updated my answer.

ADD REPLY

Login before adding your answer.

Traffic: 2280 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