WFA icon indicating copy to clipboard operation
WFA copied to clipboard

rust crate libwfa

Open hangsuUNC opened this issue 1 year ago • 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

hangsuUNC avatar Jul 29 '24 18:07 hangsuUNC

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

RagnarGrootKoerkamp avatar Jul 29 '24 19:07 RagnarGrootKoerkamp

Can I found this wrapper on crate.io?

Thanks,

Hang

On Mon, Jul 29, 2024 at 3:38 PM Ragnar Groot Koerkamp < @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/smarco/WFA2-lib/issues/98#issuecomment-2256755333, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6ZVY2HIOYBGPFTEG6FP7ULZO2K4ZAVCNFSM6AAAAABLU2JMKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJWG42TKMZTGM . You are receiving this because you authored the thread.Message ID: @.***>

hangsuUNC avatar Jul 29 '24 20:07 hangsuUNC

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

RagnarGrootKoerkamp avatar Jul 29 '24 20:07 RagnarGrootKoerkamp

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

hangsuUNC avatar Jul 30 '24 20:07 hangsuUNC

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

RagnarGrootKoerkamp avatar Jul 30 '24 21:07 RagnarGrootKoerkamp

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

hangsuUNC avatar Jul 30 '24 23:07 hangsuUNC

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

hangsuUNC avatar Jul 30 '24 23:07 hangsuUNC

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.

RagnarGrootKoerkamp avatar Jul 31 '24 00:07 RagnarGrootKoerkamp

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.

smarco avatar Jul 31 '24 07:07 smarco

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.

rlorigro avatar Aug 09 '24 16:08 rlorigro

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

smarco avatar Aug 09 '24 19:08 smarco