When running the capacitor with BAM input files, I get the following error:

[ERROR] Exception creating BAM index for record IPMHD:09324:09018 78b aligned read.
net.sf.samtools.SAMException: Exception creating BAM index for record IPMHD:09324:09018 78b aligned read.
        at net.sf.samtools.BAMIndexer.processAlignment(BAMIndexer.java:94)
        at barna.io.sam.SAMReader.createIndex(SAMReader.java:190)
        at barna.io.sam.SAMReader.isApplicable(SAMReader.java:143)
        at barna.flux.capacitor.reconstruction.FluxCapacitor.fileInit(FluxCapacitor.java:2744)
        at barna.flux.capacitor.reconstruction.FluxCapacitor.call(FluxCapacitor.java:1795)
        at barna.flux.capacitor.reconstruction.FluxCapacitor.call(FluxCapacitor.java:74)
        at barna.commons.launcher.Flux.main(Flux.java:198)
Caused by: net.sf.samtools.SAMException: Unexpected reference 4 when constructing index for 18 for record IPMHD:09324:09018 78b aligned read.
        at net.sf.samtools.BAMIndexer$BAMIndexBuilder.processAlignment(BAMIndexer.java:198)
        at net.sf.samtools.BAMIndexer.processAlignment(BAMIndexer.java:92)
        ... 6 more

What is going wrong?

  • No labels

1 Comment

  1. The error is not very self-explanatory, but it comes from the 3rd party SAMtools library we are using. What SAMtools wants to say tell us with that error is that the BAM file has to be sorted for the (necessary) indexing. To sort your bam file, use the command:

    samtools sort aln.bam aln.sorted