pjedge / longshot

diploid SNV caller for error-prone reads
MIT License
191 stars 26 forks source link

thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', src/main.rs:750:13 #105

Open BioWilko opened 3 months ago

BioWilko commented 3 months ago

Hi I'm getting this error on testdata in a dev version of fieldbioinformatics with clair3 called data (attached), I've confirmed that this occurs with version 0.4.5 and 1.0.0 full traceback below.

longshot --min_mapq 20 -P 0 -F --max_cov 200000 --no_haps --bam MT007544.primertrimmed.rg.sorted.bam --ref /home/ubuntu/fieldbioinformatics/test-data/primer-schemes/artic-sars-cov-2/400/v1.0.0/reference.fasta --out MT007544.longshot.vcf --potential_variants MT007544.merged.vcf.gz

2024-08-17 12:46:17 Min read coverage set to 6.
2024-08-17 12:46:17 Max read coverage set to 200000.
2024-08-17 12:46:17 Estimating alignment parameters...
2024-08-17 12:46:17 Done estimating alignment parameters.

                    Transition Probabilities:
                    match -> match:          0.966
                    match -> insertion:      0.010
                    match -> deletion:       0.024
                    deletion -> match:       0.390
                    deletion -> deletion:    0.610
                    insertion -> match:      0.672
                    insertion -> insertion:  0.328

                    Emission Probabilities:
                    match (equal):           0.982
                    match (not equal):       0.006
                    insertion:               1.000
                    deletion:                1.000

2024-08-17 12:46:17 Reading potential variants from input VCF...
2024-08-17 12:46:17 10 potential variants identified.
2024-08-17 12:46:17 Generating haplotype fragments from reads...
2024-08-17 12:46:17    100% of variants processed.
2024-08-17 12:46:17 Calling initial genotypes using pair-HMM realignment...
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', src/main.rs:750:13
stack backtrace:
   0:     0x55d6d493aada - std::backtrace_rs::backtrace::libunwind::trace::ha9053a9a07ca49cb
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55d6d493aada - std::backtrace_rs::backtrace::trace_unsynchronized::h9c2852a457ad564e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55d6d493aada - std::sys_common::backtrace::_print_fmt::h457936fbfaa0070f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x55d6d493aada - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5779d7bf7f70cb0c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55d6d495bbae - core::fmt::write::h5a4baaff1bcd3eb5
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:1232:17
   5:     0x55d6d4938285 - std::io::Write::write_fmt::h4bc1f301cb9e9cce
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/io/mod.rs:1684:15
   6:     0x55d6d493a8a5 - std::sys_common::backtrace::_print::h5fcdc36060f177e8
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x55d6d493a8a5 - std::sys_common::backtrace::print::h54ca9458b876c8bf
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x55d6d493beff - std::panicking::default_hook::{{closure}}::hbe471161c7664ed6
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:271:22
   9:     0x55d6d493bc3b - std::panicking::default_hook::ha3500da57aa4ac4f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:290:9
  10:     0x55d6d493c4a8 - std::panicking::rust_panic_with_hook::h50c09d000dc561d2
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:692:13
  11:     0x55d6d493c3a9 - std::panicking::begin_panic_handler::{{closure}}::h9e2b2176e00e0d9c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:583:13
  12:     0x55d6d493af46 - std::sys_common::backtrace::__rust_end_short_backtrace::h5739b8e512c09d02
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:150:18
  13:     0x55d6d493c0b2 - rust_begin_unwind
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:579:5
  14:     0x55d6d45c5cb3 - core::panicking::panic_fmt::hf33a1475b4dc5c3e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:64:14
  15:     0x55d6d45c5e22 - core::panicking::panic_bounds_check::haf06fefb23eba82d
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:159:5
  16:     0x55d6d45f2c34 - longshot::run::ha5892bd923080708
  17:     0x55d6d45ec87e - longshot::main::hfc320f1dc091f743
  18:     0x55d6d45d4bf3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h83f82c13b8b880f7
  19:     0x55d6d45d27b9 - std::rt::lang_start::{{closure}}::h97457b920ea3a05c
  20:     0x55d6d493369c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hd6efcd3bec896f2c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:287:13
  21:     0x55d6d493369c - std::panicking::try::do_call::hce04e543bb1f4cbb
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:487:40
  22:     0x55d6d493369c - std::panicking::try::h3342dd4e1f680968
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:451:19
  23:     0x55d6d493369c - std::panic::catch_unwind::h148ce1e59ac0cee7
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panic.rs:140:14
  24:     0x55d6d493369c - std::rt::lang_start_internal::{{closure}}::h25f9dda2057a67fe
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:48
  25:     0x55d6d493369c - std::panicking::try::do_call::h7caaaeaf9401650b
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:487:40
  26:     0x55d6d493369c - std::panicking::try::he7d15285746cbbc2
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:451:19
  27:     0x55d6d493369c - std::panic::catch_unwind::h89fb4f50c0301fe0
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panic.rs:140:14
  28:     0x55d6d493369c - std::rt::lang_start_internal::h078acd489417d3c1
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:20
  29:     0x55d6d45f3625 - main
  30:     0x7fd365560d90 - <unknown>
  31:     0x7fd365560e40 - __libc_start_main
  32:     0x55d6d45c62e5 - <unknown>

MT007544.merged.vcf.gz MT007544.primertrimmed.rg.sorted.bam.gz reference.fasta.gz

vibansal commented 3 months ago

Thanks for providing the input files to reproduce this error. The input VCF file contains multiple variants without an alternate allele. While this is a valid VCF specification, Longshot expects each potential variant to have at least one alternate allele. If you filter out such variants, the error goes away. It should not be difficult to add a check for such variants in the longshot code.