RagnarGrootKoerkamp / astar-pairwise-aligner

A pairwise sequence aligner written in Rust
Mozilla Public License 2.0
117 stars 11 forks source link

Use as Rust/C library #14

Closed wdecoster closed 1 year ago

wdecoster commented 2 years ago

Hi,

This looks very interesting. It appears a step is missing in the instructions to get started, probably cloning the repository?

Additionally, I was wondering if it is possible to describe some examples of how to use the library within other rust projects, rather than as a standalone aligner.

Thanks, Wouter

RagnarGrootKoerkamp commented 2 years ago

Hey! Thanks for your interest ))

This looks very interesting. It appears a step is missing in the instructions to get started, probably cloning the repository?

Right, let me explicitly add that.

Additionally, I was wondering if it is possible to describe some examples of how to use the library within other rust projects, rather than as a standalone aligner.

Currently this is more of a research project than an end-user tool, but it's great you want to try it out. I don't expose a proper library interface currently, but it shouldn't be hard to make a small wrapper around the most important functions. I'll get back to you somewhere next week.

RagnarGrootKoerkamp commented 2 years ago

The plan is to make the API look like this:

let params = Params {
  algorithm: AlgorithmsArgs,
  heuristic: HeuristicArgs,
}
let a = b"ACTG";
let b = b"ACGT";
let (cost, cigar) = align(a, b, params);

I'd simply reuse the algorithm and heuristic arguments from the command line interface here, and mark those structs as repr(C). (Or actually that may not be possible given the Options, but I can make equivalent C types.)

I could also add the visualizer arguments so that you can directly visualize things from the C-code, in case you're building with the sdl2 flag.

Is it common to have both a Rust and C api existing next to each other? I need to figure out how to do that cleanly. Either by using separate sub-libraries rust:: and c::, or by pre/suffixing all the c functions.

wdecoster commented 2 years ago

I don't know about API design, and even less about C :)

RagnarGrootKoerkamp commented 1 year ago

Allright, this is finally done :tada:

The main Rust entrypoint is astarpa::astarpa.

I've added a C-wrapper based on block aligner at astarpa-c