smarco/WFA2-lib

rust crate libwfa

hangsuUNC opened this issue · 11 comments

Hi,

I was trying to use libwfa for a rust code, but failed to compile. The error message suggests stderr value is not found in the scope of the file affine_wavefront.rs (affine_wavefront.rs at line 187. The compiler suggests importing stderr from std::io::stderr). Is this an easy fix or is this crate totally out of maintenance?

Best,

Hang

Have you tried using the existing rust wrapper? That one should work without issues.
https://github.com/pairwise-alignment/rust-wfa2

Currently not, but you can add it as a git dependency. I suppose we can also push it to crates.io if you prefer

Currently not, but you can add it as a git dependency. I suppose we can also push it to crates.io if you prefer

I add it as a git dependency, however the crate stucture is different from the examples in your manual. Can you provide an example how to calculate the alignment score from your crate?

Best,

Hang

This example usage should get you going: https://github.com/pairwise-alignment/pa-bench/blob/main/pa-wrapper/src/wrappers/wfa.rs
Thank you!

Here is my code below:

let alignment_scope = rust_wfa2::aligner::AlignmentScope::Alignment;
 let memory_model = rust_wfa2::aligner::MemoryModel::MemoryHigh;
let mut aligner = rust_wfa2::aligner::WFAligner::new(alignment_scope, memory_model);
 let status = aligner.align_end_to_end(target.as_bytes(), pseq.as_bytes());
let score = aligner.score();

However, I got an error with 40460 segmentation fault ...

Do you have any suggestions how's it going?

Thanks

I got WFAlignerGapAffine working. Thanks so much!
Will this continue being developed? Could be really useful!

Ah, you'll probably want to use the Memory::UltraLow variant which corresponds to BiWFA and is faster and uses much less memory.

The rust crate is simply a wrapper around the code in this rep; not much development is needed I'd say. Possibly the submodule could be updated to the latest version, but Santiago would know better if there are relevant recent changes (bug fixes and/or breaking API changes) here.

Thanks, @RagnarGrootKoerkamp, for the help.

There are no major changes in the library (just a few bug fixes). However, the development continues, and it is our aim to keep improving the library in the near future with new features and optimizations.

just noticing the comment about memory mode and BiWFA. Maybe the Readme could be updated to clarify?

The WFA2 library implements various memory modes: wavefront_memory_high, wavefront_memory_med, wavefront_memory_low, and , wavefront_memory_ultralow. These modes allow regulating the overall memory consumption at the expense of execution time. The standard WFA algorithm, which stores explicitly all wavefronts in memory, correspond to the mode wavefront_memory_high. The other methods progressively reduce memory usage at the expense of slightly larger alignment times. These memory modes can be used transparently with other alignment options and generate identical results. Note that this option does not affect the score-only alignment mode (it already uses a minimal memory footprint of O(s)).

The phrase at the expense of slightly larger alignment times is a bit misleading here, because bidirectional WFA is an exception to that rule.

Yes, indeed. You are right. I should rewrite this part.