Java Error when attempting to load BAM file

452 views
Skip to first unread message

Michael Ruesch

unread,
Jan 27, 2023, 8:58:46 AM1/27/23
to igv-help
Hello all,

I'm new to IGV and have been trying to navigate some single cell RNA-seq data that I've recently gathered. However, whenever I attempt to upload any of the 4 BAM files I have to IGV, it gives me this error:

"Error encountered querying alignments: java.lang.StringIndexOutOfBoundsException: String index out of range: 1"

I'm not sure how to navigate this, so any help would be much appreciated.

Best,
Michael

igv-help

unread,
Jan 27, 2023, 12:44:39 PM1/27/23
to igv-help
Hi Michael,

All BAM files need a corresponding index file. IGV assumes the index file is in the some folder as the bam file, and is named the same as the BAM file but with a .bai suffix.  For example mybamfile.bam and mybamfile.bai (or mybamfile.bam.bai).
From your description it sounds like you have an index file (since IGV didn't complain about not finding an index file) but that there's something wrong with it.  If you received it from someone else, contact them to verify you have the correct file. Or if you can run samtools (found here, but this tutorial might be helpful), recreate the index and make sure the bam file is first sorted.

Helga

Michael Ruesch

unread,
Jan 28, 2023, 1:33:15 PM1/28/23
to igv-help
Hi Helga,

Thanks for your help. I talked to a collaborator on this and they mentioned that they have IGC v2.12 on their desktop and they were able to use it fine. I went ahead and tried downloading the same version as them and I'm not getting the same error and I'm getting all the reads. 

Michael

Michael Ruesch

unread,
Jan 30, 2023, 1:58:55 PM1/30/23
to igv-...@googlegroups.com
I’ve been using v2.16.0.
I believe it’s the most recent version.

On Mon, Jan 30, 2023 at 10:50 AM Helga Thorvaldsdottir <he...@broadinstitute.org> wrote:

Hi Michael,

Thanks for letting us know. Out of curiosity, which version were you using when you had the problem?

Helga

--

---
You received this message because you are subscribed to a topic in the Google Groups "igv-help" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/igv-help/A-17es3DO98/unsubscribe.
To unsubscribe from this group and all its topics, send an email to igv-help+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/igv-help/67bf3fc8-cf65-41dc-a7ef-3ee4be768712n%40googlegroups.com.

igv-help

unread,
Feb 8, 2023, 3:42:08 PM2/8/23
to igv-help
We'll need to see your igv log file to investigate this further.   Its located in an igv folder under the home directory.    There might be several logs there with names like "igv0.log",  just send the most recent one.   If you would prefer to do this privately email it to igvteam (at) broadinstitute.org

Soo Lee

unread,
Jun 27, 2023, 2:40:12 PM6/27/23
to igv-help
Hi Helga and Jim,

"Error encountered querying alignments: java.lang.StringIndexOutOfBoundsException: String index out of range: 1"

I'm seeing the same error reported above with IGV-2.16.1. I can load the BAM but when I navigate to a gene locus, the error pops up. I am using the BAM and BAI from a 10x Genomics public data set at https://www.10xgenomics.com/resources/datasets/5k-human-pbmcs-3-v3-1-chromium-controller-3-1-standard. Scroll down on the page for the BAM and BAI download links. The data reflects a recent 10x cellranger version (v7.0.1), where the BAM is always sorted.

When I use IGV-v2.12.0, the error is absent. I regenerated the index with `samtools index` and the error persists.

A customer wrote into 10x Support about the error. I hope this can be fixed for future IGV releases.

Hope you are both well!

Best,
Soo Hee

James Robinson

unread,
Jun 27, 2023, 3:08:02 PM6/27/23
to igv-...@googlegroups.com
Could we see your igv log file?  10X has been introducing some out-of-spec tags, specifically MM and/or ML tags, that are reserved.    It's really a 10X issue.   However we need to confirm thai is the problem.   Your igv.log might help,   Also, some exact steps to reproduce would be helpful.   Load exactly which file,  jump to exactly which locus, and anything else needed.  

Do you have a reference to the customer who wrote to 10X,  if I can add a comment to the ticket I will.

Soo Lee

unread,
Jun 27, 2023, 3:39:14 PM6/27/23
to igv-help
Hi Jim,

The igv0.log stacktrace for the error I recapitulate is as follows for v2.16.1.
```
SEVERE [Jun 27,2023 15:35] [AlignmentTileLoader] Error loading alignment data
SEVERE [Jun 27,2023 15:35] [AlignmentTileLoader] java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.base/java.lang.StringLatin1.charAt(Unknown Source)
at java.base/java.lang.String.charAt(Unknown Source)
at org.igv/org.broad.igv.sam.mods.BaseModificationUtils.getBaseModificationSets(BaseModificationUtils.java:76)
at org.igv/org.broad.igv.sam.SAMAlignment.getBaseModificationSets(SAMAlignment.java:338)
at org.igv/org.broad.igv.sam.mods.BaseModificationCounts.incrementCounts(BaseModificationCounts.java:81)
at org.igv/org.broad.igv.sam.BaseAlignmentCounts.incCounts(BaseAlignmentCounts.java:132)
at org.igv/org.broad.igv.sam.AlignmentTileLoader$AlignmentTile.addRecord(AlignmentTileLoader.java:494)
at org.igv/org.broad.igv.sam.AlignmentTileLoader.loadTile(AlignmentTileLoader.java:245)
at org.igv/org.broad.igv.sam.AlignmentDataManager.loadInterval(AlignmentDataManager.java:391)
at org.igv/org.broad.igv.sam.AlignmentDataManager.load(AlignmentDataManager.java:338)
at org.igv/org.broad.igv.sam.CoverageTrack.load(CoverageTrack.java:186)
at org.igv/org.broad.igv.ui.IGV.lambda$repaint$16(IGV.java:2267)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
```
Let me know if you need anything else. I will ask the customer if I may bring you into the ongoing conversation.

Best,
Soo Hee

Soo Lee

unread,
Jun 27, 2023, 3:45:28 PM6/27/23
to igv-help
For 

> Load exactly which file,  jump to exactly which locus, and anything else needed.  

I load the BAM I linked from the 10x website, then type in TP53 to the search box. That's when the error message pops up.

Again, I am using the BAM and BAI from a 10x Genomics public data set at https://www.10xgenomics.com/resources/datasets/5k-human-pbmcs-3-v3-1-chromium-controller-3-1-standard. Scroll down on the page for the BAM and BAI download links. 

James Robinson

unread,
Jun 27, 2023, 4:19:00 PM6/27/23
to igv-...@googlegroups.com
I can't access the BAMs you reference from the 10X site, it looks like you need an account.  However the log is enough to confirm the problem. This is caused by 10X using a reserved sam tag (MM and or ML) for some other purpose, the file in other words is an out-of-spec BAM.     The tags in question are specified here (base modification section):  https://samtools.github.io/hts-specs/SAMtags.pdf.

Base modifications aside, it is not legal for any capitalized tag to be introduced that is not specifically defined in the SAM specification.   This is a non-trivial issue,  any tool that supports base modification tags are likely to fail on these files.

Regardless, I've created a patch in IGV that should allow these files to be read.   It is not released yet but is available in the "snapshot" IGV.




James Robinson

unread,
Jun 27, 2023, 4:35:10 PM6/27/23
to igv-...@googlegroups.com
I signed up to get access, it is the MM tag.   I also confirmed that the snapshot build will load these files, so they will be loadable in the next release,  which should be by the end of July.

A00836:523:HJH22DSXY:1:2575:3839:4601 16 chr11 118996807 255 1S76M13S * 0 0 GTATTTTTAGTAGAGACGGGGTTTCACCATGTTAGCCAGGCTGGTCCTGAACTCCTGACCTCAGGTGATCCACCTTCACATCCACCATGG FFF:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF CB:Z:AAACGCTAGGATTACA-1 UB:Z:AAACTCAACCTA RE:A:E RG:Z:SC3pv3_GEX_Human_PBMC:0:1:HJH22DSXY:1 NH:i:5 HI:i:5 MM:i:1 nM:i:2 GN:Z:CCDC84-DT CR:Z:AAACGCTAGGATTACA UR:Z:AAACTCAACCTA AS:i:70 GX:Z:ENSG00000255121 TX:Z:ENST00000526453,+671,13S76M1S CY:Z:FFFFFFFFFFFFFFFF UY:Z:FFFFFFFFFFFF xf:i:19 fx:Z:ENSG00000255121
Reply all
Reply to author
Forward
0 new messages