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

rust crate libwfa #98

Open
hangsuUNC opened this issue Jul 29, 2024 · 11 comments
Open

rust crate libwfa #98

hangsuUNC opened this issue Jul 29, 2024 · 11 comments

Comments

@hangsuUNC
Copy link

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

@RagnarGrootKoerkamp
Copy link
Contributor

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

@hangsuUNC
Copy link
Author

hangsuUNC commented Jul 29, 2024 via email

@RagnarGrootKoerkamp
Copy link
Contributor

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

@hangsuUNC
Copy link
Author

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

@RagnarGrootKoerkamp
Copy link
Contributor

RagnarGrootKoerkamp commented Jul 30, 2024

@hangsuUNC
Copy link
Author

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
Copy link
Author

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

@RagnarGrootKoerkamp
Copy link
Contributor

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.

@smarco
Copy link
Owner

smarco commented Jul 31, 2024

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.

@rlorigro
Copy link
Contributor

rlorigro commented Aug 9, 2024

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.

@smarco
Copy link
Owner

smarco commented Aug 9, 2024

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

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

No branches or pull requests

4 participants