Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POA panics on some sets of sequences #572

Open
davidlougheed opened this issue Feb 7, 2024 · 8 comments · May be fixed by #575
Open

POA panics on some sets of sequences #572

davidlougheed opened this issue Feb 7, 2024 · 8 comments · May be fixed by #575

Comments

@davidlougheed
Copy link

I've written a wrapper function to calculate consensus sequences from POA alignments using rust-bio. Some sets of sequences panic where I wouldn't expect them too; for example, see the following:

>>> seqs = ('GTGTGTGTGTGTATATGTTGTAGAA', 'GTGTGTGTGTGTGTGTGTTGT', 'GTGTGTGTGTGTGTGTGTTGT', 'GTGTGTGTGTGTGTGTTGTG', 'GTGTGTGTGTGTGTGTTGTG', 'GTGTGTGTGTGTGTTGTG', 'TGTGAGTGTGTGTGTGTGTGTGTTGT', 'TGTGGTGTGTGTGTGTTGT')
>>> seqs
('GTGTGTGTGTGTATATGTTGTAGAA', 'GTGTGTGTGTGTGTGTGTTGT', 'GTGTGTGTGTGTGTGTGTTGT', 'GTGTGTGTGTGTGTGTTGTG', 'GTGTGTGTGTGTGTGTTGTG', 'GTGTGTGTGTGTGTTGTG', 'TGTGAGTGTGTGTGTGTGTGTGTTGT', 'TGTGGTGTGTGTGTGTTGT')
>>> strkit_rust_ext.consensus_seq(seqs)
thread '<unnamed>' panicked at /Users/davidlougheed/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bio-1.5.0/src/alignment/poa.rs:439:28:
index out of bounds: the len is 31 but the index is 31
stack backtrace:
   0: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_bounds_check
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:190:5
   3: bio::alignment::poa::Aligner<F>::consensus
   4: std::panicking::try
   5: strkit_rust_ext::strkit::consensus::_::<impl strkit_rust_ext::strkit::consensus::consensus_seq::MakeDef>::DEF::trampoline
   6: _cfunction_vectorcall_FASTCALL_KEYWORDS
   7: _call_function
   8: __PyEval_EvalFrameDefault
   9: __PyEval_Vector
  10: _PyEval_EvalCode
  11: _run_eval_code_obj
  12: _run_mod
  13: _PyRun_InteractiveOneObjectEx
  14: __PyRun_InteractiveLoopObject
  15: __PyRun_AnyFileObject
  16: _PyRun_AnyFileExFlags
  17: _pymain_run_stdin
  18: _Py_RunMain
  19: _Py_BytesMain
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@davidlougheed
Copy link
Author

this might be a duplicate of #549 ... any chance of the PR open for that being merged soon?

@lorewar2
Copy link
Member

lorewar2 commented Feb 7, 2024

The PR with the fix has been merged, is this issue fixed now?

@davidlougheed
Copy link
Author

I'll test when there's a new version released, thanks for the update!

@davidlougheed
Copy link
Author

davidlougheed commented Feb 8, 2024

@lorewar2 ok I tested - the latest PR does not fix all forms of this problem. For example, the following sequences still cause a panic with rust_bio https://github.com/rust-bio/rust-bio.git?rev=440cb1c#440cb1ce:

('ACACACACACACACACACACACACACACACACACACACACACAC', 'ACACACACACACACACACACACACACACACACACACACACACACACACACAC', 'ACACACACACACACACACACACACACACACACACACACACACACACACACACTT', 'ACACACACACACACATTACTGCACACACACACACACACACACACACACACAC', 'CACACACACACACACACACACACACACACACACACACACACACACACACACAC', 'CATACACACACACACACACACACACACACACACACACACACACACACAC')

results in:

thread '<unnamed>' panicked at /Users/davidlougheed/.cargo/git/checkouts/rust-bio-d51470571d61aed1/440cb1c/src/alignment/poa.rs:550:28:
index out of bounds: the len is 59 but the index is 59
stack backtrace:
   0:        0x100b43110 - std::backtrace_rs::backtrace::libunwind::trace::h2966c6fbfac9d426
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:        0x100b43110 - std::backtrace_rs::backtrace::trace_unsynchronized::h8a5f4aefe890b7c5
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x100b43110 - std::sys_common::backtrace::_print_fmt::h7574dd98fd39c257
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
   3:        0x100b43110 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h298c9ab285ff3934
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x100b57b64 - core::fmt::rt::Argument::fmt::hf9661447f7b99899
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
   5:        0x100b57b64 - core::fmt::write::h4e276abdb6d0c2a1
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
   6:        0x100b41b84 - std::io::Write::write_fmt::hd421848f5f0bf9d0
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
   7:        0x100b42f4c - std::sys_common::backtrace::_print::h09e653c6686dbd70
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x100b42f4c - std::sys_common::backtrace::print::hd8bd9ecab1f94b94
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x100b44148 - std::panicking::default_hook::{{closure}}::h520eeb743fc98fb4
  10:        0x100b43e90 - std::panicking::default_hook::ha6550ffe49b63df1
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
  11:        0x100b44570 - std::panicking::rust_panic_with_hook::hddb0e884a202de7c
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:779:13
  12:        0x100b44470 - std::panicking::begin_panic_handler::{{closure}}::hd2798398a2fd9077
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
  13:        0x100b43578 - std::sys_common::backtrace::__rust_end_short_backtrace::h9201cc364dbb8a23
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  14:        0x100b4420c - rust_begin_unwind
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  15:        0x100b64e98 - core::panicking::panic_fmt::h4d5168028d4c43c7
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  16:        0x100b64fdc - core::panicking::panic_bounds_check::h17fa693e54374598
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:190:5
  17:        0x100ac7244 - bio::alignment::poa::Aligner<F>::consensus::hde9245f33981f8bd
                               at /Users/davidlougheed/.cargo/git/checkouts/rust-bio-d51470571d61aed1/440cb1c/src/alignment/poa.rs:550:28
  18:        0x100ac1a70 - strkit_rust_ext::strkit::consensus::consensus_seq::{{closure}}::{{closure}}::he58e26ad547fc66c
...

@lorewar2
Copy link
Member

lorewar2 commented Feb 8, 2024

I ran the same sequences and worked fine for me, this could be the same issue mentioned in #549
Is it possible to provide the graph for this?
e.g
let graph = aligner.graph(); println!("{:?}", Dot::new(&graph.map(|_, n| (*n) as char, |_, e| *e)));
Thank you for your help in debugging.

@davidlougheed
Copy link
Author

here is the output:

digraph {
    0 [ label = "'C'" ]
    1 [ label = "'A'" ]
    2 [ label = "'T'" ]
    3 [ label = "'A'" ]
    4 [ label = "'C'" ]
    5 [ label = "'A'" ]
    6 [ label = "'C'" ]
    7 [ label = "'A'" ]
    8 [ label = "'C'" ]
    9 [ label = "'A'" ]
    10 [ label = "'C'" ]
    11 [ label = "'A'" ]
    12 [ label = "'C'" ]
    13 [ label = "'A'" ]
    14 [ label = "'C'" ]
    15 [ label = "'A'" ]
    16 [ label = "'C'" ]
    17 [ label = "'A'" ]
    18 [ label = "'C'" ]
    19 [ label = "'A'" ]
    20 [ label = "'C'" ]
    21 [ label = "'A'" ]
    22 [ label = "'C'" ]
    23 [ label = "'A'" ]
    24 [ label = "'C'" ]
    25 [ label = "'A'" ]
    26 [ label = "'C'" ]
    27 [ label = "'A'" ]
    28 [ label = "'C'" ]
    29 [ label = "'A'" ]
    30 [ label = "'C'" ]
    31 [ label = "'A'" ]
    32 [ label = "'C'" ]
    33 [ label = "'A'" ]
    34 [ label = "'C'" ]
    35 [ label = "'A'" ]
    36 [ label = "'C'" ]
    37 [ label = "'A'" ]
    38 [ label = "'C'" ]
    39 [ label = "'A'" ]
    40 [ label = "'C'" ]
    41 [ label = "'A'" ]
    42 [ label = "'C'" ]
    43 [ label = "'A'" ]
    44 [ label = "'C'" ]
    45 [ label = "'A'" ]
    46 [ label = "'C'" ]
    47 [ label = "'A'" ]
    48 [ label = "'C'" ]
    49 [ label = "'A'" ]
    50 [ label = "'C'" ]
    51 [ label = "'A'" ]
    52 [ label = "'C'" ]
    53 [ label = "'T'" ]
    54 [ label = "'T'" ]
    55 [ label = "'T'" ]
    56 [ label = "'T'" ]
    57 [ label = "'T'" ]
    58 [ label = "'G'" ]
    0 -> 1 [ label = "6" ]
    1 -> 2 [ label = "1" ]
    2 -> 3 [ label = "1" ]
    3 -> 4 [ label = "4" ]
    4 -> 5 [ label = "6" ]
    5 -> 6 [ label = "6" ]
    6 -> 7 [ label = "6" ]
    7 -> 8 [ label = "6" ]
    8 -> 9 [ label = "6" ]
    9 -> 10 [ label = "6" ]
    10 -> 11 [ label = "6" ]
    11 -> 12 [ label = "6" ]
    12 -> 13 [ label = "6" ]
    13 -> 14 [ label = "6" ]
    14 -> 15 [ label = "6" ]
    15 -> 16 [ label = "5" ]
    16 -> 17 [ label = "5" ]
    17 -> 18 [ label = "6" ]
    18 -> 19 [ label = "5" ]
    19 -> 20 [ label = "5" ]
    20 -> 21 [ label = "6" ]
    21 -> 22 [ label = "6" ]
    22 -> 23 [ label = "6" ]
    23 -> 24 [ label = "6" ]
    24 -> 25 [ label = "6" ]
    25 -> 26 [ label = "6" ]
    26 -> 27 [ label = "6" ]
    27 -> 28 [ label = "6" ]
    28 -> 29 [ label = "6" ]
    29 -> 30 [ label = "6" ]
    30 -> 31 [ label = "6" ]
    31 -> 32 [ label = "6" ]
    32 -> 33 [ label = "6" ]
    33 -> 34 [ label = "6" ]
    34 -> 35 [ label = "6" ]
    35 -> 36 [ label = "6" ]
    36 -> 37 [ label = "6" ]
    37 -> 38 [ label = "6" ]
    38 -> 39 [ label = "6" ]
    39 -> 40 [ label = "6" ]
    40 -> 41 [ label = "6" ]
    41 -> 42 [ label = "6" ]
    42 -> 43 [ label = "6" ]
    43 -> 44 [ label = "6" ]
    44 -> 45 [ label = "6" ]
    45 -> 46 [ label = "6" ]
    46 -> 47 [ label = "5" ]
    47 -> 48 [ label = "5" ]
    1 -> 4 [ label = "2" ]
    49 -> 0 [ label = "3" ]
    1 -> 50 [ label = "3" ]
    50 -> 3 [ label = "3" ]
    48 -> 51 [ label = "4" ]
    51 -> 52 [ label = "4" ]
    52 -> 53 [ label = "1" ]
    53 -> 54 [ label = "1" ]
    15 -> 55 [ label = "1" ]
    55 -> 56 [ label = "1" ]
    56 -> 17 [ label = "1" ]
    18 -> 57 [ label = "1" ]
    57 -> 58 [ label = "1" ]
    58 -> 20 [ label = "1" ]
    4 -> 0 [ label = "1" ]
}

I'm pretty sure I'm using master since I specified bio = { git = "https://github.com/rust-bio/rust-bio.git", rev = "440cb1c" } in my Cargo.toml

@lorewar2
Copy link
Member

lorewar2 commented Feb 8, 2024

Okay, I see a reverse edge on the graph, this is the same as the #549, I need to debug this.

@davidlougheed
Copy link
Author

in both cases it involves short tandem repeats too, interesting...

@lorewar2 lorewar2 linked a pull request Feb 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants