Daniel-Liu-c0deb0t / block-aligner

SIMD-accelerated library for computing global and X-drop affine gap penalty sequence-to-sequence or sequence-to-profile alignments using an adaptive block-based algorithm.
https://crates.io/crates/block_aligner
MIT License
124 stars 7 forks source link

Custom AAMatrix from C API? #10

Closed smarco closed 2 years ago

smarco commented 2 years ago

Hi,

I was wondering if it is possible to define a custom AAMatrix from C API?

Thanks,

Daniel-Liu-c0deb0t commented 2 years ago

Unfortunately that API does not exist right now. The C API only includes core features right now. Do you need this feature?

smarco commented 2 years ago

I would not say strictly "need", but I would like to benchmark your awesome library (speed/accuracy) using a Match/Mismatch penalty model.

Daniel-Liu-c0deb0t commented 2 years ago

This feature exists on the Rust side. I can probably easily expose some sort of API for match/mismatch penalties.

Daniel-Liu-c0deb0t commented 2 years ago

Added a basic interface for this for now: https://github.com/Daniel-Liu-c0deb0t/block-aligner/blob/main/src/ffi.rs#L32

Note that match scores must be positive and mismatch scores must be negative.

smarco commented 2 years ago

Awesome, thanks. Now, I need to solve how to properly use it. From the C interface perspective, AAMatrix is an incomplete type. For example:

AAMatrix m_matrix = block_new_simple_aamatrix(1,-4);

Gives a error: storage size of ‘m_matrix’ isn’t known

How can I resolve this without hacking into your lib?

Thank you very much,

Daniel-Liu-c0deb0t commented 2 years ago

Ah the binding generator library was not correctly generating the full struct declaration. I worked around this by allocating the struct on the heap. The same function can be used to create a pointer to an AAMatrix, but it needs to be freed later: https://github.com/Daniel-Liu-c0deb0t/block-aligner/blob/main/src/ffi.rs#L32

smarco commented 2 years ago

Sorry for the delay in answering. I got to test it properly today and it works flawlessly. Thank you very much.