Skip to content
Snippets Groups Projects
Commit de67200a authored by Martin Larralde's avatar Martin Larralde
Browse files

Fix striping of empty sequence panicking with AVX2 implementation

parent f4b262b7
No related branches found
No related tags found
No related merge requests found
......@@ -406,6 +406,11 @@ unsafe fn stripe_avx2<A>(
let mut matrix = std::mem::take(striped).into_matrix();
matrix.resize(src_stride);
// Early exit if sequence is too empty (no allocated matrix).
if length == 0 {
return;
}
/// Get a pointer to the matrix
let mut out = matrix[0].as_mut_ptr();
let out_stride = matrix.stride();
......
......@@ -347,6 +347,18 @@ mod test {
use crate::abc::Dna;
use crate::abc::Nucleotide::*;
#[test]
fn test_empty() {
let seq = EncodedSequence::<Dna>::from_str("").unwrap();
let pli = Pipeline::generic();
let striped = <Pipeline<_, _> as Stripe<Dna, U2>>::stripe(&pli, &seq);
assert_eq!(striped.matrix().rows(), 0);
let striped = seq.to_striped();
assert_eq!(striped.matrix().rows(), 0);
}
#[test]
fn test_stripe() {
let pli = Pipeline::generic();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment