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)
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.
2 answers
See SAM bin field error for the GATK run for possible solutions.
another solution
- checkout picard, https://github.com/broadinstitute/picard
- change src/main/java/picard/cmdline/CommandLineProgram.java on line
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"
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).
Log in to answer this question.
Just use
samtools indexinstead, it likely won't complain about this.