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.
Just use
samtools index
instead, it likely won't complain about this.