lindenb / jvarkit

Java utilities for Bioinformatics
https://jvarkit.readthedocs.io/
Other
482 stars 133 forks source link

sam2tsv: Errormessage: Index 0 out of bounds for length 0 #133

Closed joachimwolff closed 5 years ago

joachimwolff commented 5 years ago

Hi,

I try to run sam2tsv with the version install via conda: https://anaconda.org/hcc/jvarkit-sam2tsv running on Ubuntu 18.04, version 1.0 of sam2tsv.

To create the data I am following the README of EpiNano: https://github.com/Huanle/EpiNano

I am running the commands:

minimap2 -ax map-ont mrna.fa non-spike-in.U2T.fastq | samtools view -bhS -o non-spike-in.bam
samtools sort -@ 6 non-spike-in.bam -o non-spike-in_sorted.bam
samtools index non-spike-in_sorted.bam
samtools faidx mrna.fa
picard CreateSequenceDictionary R=mrna.fa O=mrna.dict
sam2tsv -r mrna.fa non-spike_mapped.bam  > non-spike.bam.tsv

I am expecting to get a tsv file for the sam file, however I only get a tsv file with the size of 56 kbyte and an error message of sam2tsv:

[SEVERE][Sam2Tsv]scan error:
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.printAln(Sam2Tsv.java:323)
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.scan(Sam2Tsv.java:465)
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.doWork(Sam2Tsv.java:501)
 at com.github.lindenb.jvarkit.util.jcommander.Launcher.instanceMain(Launcher.java:1156)
 at com.github.lindenb.jvarkit.util.jcommander.Launcher.instanceMainWithExit(Launcher.java:1342)
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.main(Sam2Tsv.java:525)
[SEVERE][Sam2Tsv]Index 0 out of bounds for length 0
java.lang.RuntimeException: Index 0 out of bounds for length 0
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.scan(Sam2Tsv.java:473)
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.doWork(Sam2Tsv.java:501)
 at com.github.lindenb.jvarkit.util.jcommander.Launcher.instanceMain(Launcher.java:1156)
 at com.github.lindenb.jvarkit.util.jcommander.Launcher.instanceMainWithExit(Launcher.java:1342)
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.main(Sam2Tsv.java:525)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.printAln(Sam2Tsv.java:323)
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.scan(Sam2Tsv.java:465)
 ... 4 more
[INFO][Launcher]sam2tsv Exited with failure (-1)

The mrna.fa file I got from: http://hgdownload.cse.ucsc.edu/goldenPath/mm10/bigZips/mrna.fa.gz All other data is available via: https://drive.google.com/open?id=1HJRrk0QQ54UOk3vZGXRyeWsCihCAGFN3

The error message is similar to this issue but I do not see how the solution there helps me: https://github.com/lindenb/jvarkit/issues/122

Thanks a lot for your help.

Best,

Joachim

lindenb commented 5 years ago

thank you for the bug report ad the files, I'm going to explore this.

lindenb commented 5 years ago

I'm sorry but for now, when I'm trying to download the file from google, firefox says: "The page isn’t redirecting properly"

lindenb commented 5 years ago

ok, got it...

lindenb commented 5 years ago

I run my program with you parameters, I got no problem.

java -jar ~/src/jvarkit-git/dist/sam2tsv.jar -r ~/mrna.fa ~/jeter.bam > /dev/null (...) [WARN][Sam2Tsv]Ignoring read without sequence: 6fc050d4-1d8b-41b8-bddf-b2979d8a538a [WARN][Sam2Tsv]Ignoring read without sequence: cd2aa681-1816-4681-8f83-b805337dacdc [WARN][Sam2Tsv]Ignoring read without sequence: 1720d701-8ce9-40f7-ba75-d2d8e136d388 [WARN][Sam2Tsv]Ignoring read without sequence: 813434d4-756e-4a06-bc67-52fa50a3dae9 [WARN][Sam2Tsv]Ignoring read without sequence: 6818e5d6-dab4-4a7f-9307-0572ff2938a1 [WARN][Sam2Tsv]Ignoring read without sequence: 08d0b34d-3036-4fec-b5aa-31e3491cad8b [WARN][Sam2Tsv]Ignoring read without sequence: ed707e18-e60d-472c-8870-00026ff13002 [WARN][Sam2Tsv]Ignoring read without sequence: d6871be5-b766-4200-a5fe-15f1236a40d8 [WARN][Sam2Tsv]Ignoring read without sequence: 6fc050d4-1d8b-41b8-bddf-b2979d8a538a [INFO][Sam2Tsv]. Completed. N=21,721. That took:7 seconds

furthermore, you're error says

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
 at com.github.lindenb.jvarkit.tools.sam2tsv.Sam2Tsv.printAln(Sam2Tsv.java:323)

but there is no code throwing such exception at 323

https://github.com/lindenb/jvarkit/blob/master/src/main/java/com/github/lindenb/jvarkit/tools/sam2tsv/Sam2Tsv.java#L323

I strongly think that you're using an old version of this tool.

joachimwolff commented 5 years ago

Hi,

Thanks for the help, a git clone with the master branch version helped to fix the issue.

Best,

Joachim