Question: How to fix the BAM file (SAM validation error)
0
gravatar for bzg
15 months ago by
bzg40
Brazil
bzg40 wrote:

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 • 706 views
ADD COMMENTlink modified 15 months ago by Pierre Lindenbaum122k • written 15 months ago by bzg40

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

ADD REPLYlink written 15 months ago by Devon Ryan91k
0
gravatar for h.mon
15 months ago by
h.mon26k
Brazil
h.mon26k wrote:

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

ADD COMMENTlink written 15 months ago by h.mon26k

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 REPLYlink modified 15 months ago • written 15 months ago by bzg40
0
gravatar for Pierre Lindenbaum
15 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum122k wrote:

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 COMMENTlink modified 15 months ago • written 15 months ago by Pierre Lindenbaum122k
1

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 REPLYlink written 15 months ago by bzg40
1

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

ADD REPLYlink written 15 months ago by Pierre Lindenbaum122k
1

I updated my answer.

ADD REPLYlink written 15 months ago by Pierre Lindenbaum122k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1329 users visited in the last hour