spoa_sys/
lib.rs

1#[cxx::bridge(namespace = "spoa")]
2pub mod ffi {
3    /// Enumerates the possible alignment types
4    #[repr(u32)]
5    enum AlignmentType {
6        /// Smith-Waterman alignment
7        kSW,
8        /// Needleman-Wunsch alignment
9        kNW,
10        /// Overlap alignment
11        kOV,
12    }
13
14    unsafe extern "C++" {
15        include!("spoa-sys/include/bindings.hpp");
16
17        type Alignment;
18        type AlignmentEngine;
19        type AlignmentType;
20        type Graph;
21
22        fn create_graph() -> UniquePtr<Graph>;
23        /// # Safety
24        /// this function is unsafe because cxx says pointer arguments are unsafe
25        unsafe fn add_alignment_with_qual(
26            graph: Pin<&mut Graph>,
27            alignment: &Alignment,
28            sequence: *const c_char,
29            sequence_len: u32,
30            quality: *const c_char,
31            quality_len: u32,
32        );
33        unsafe fn add_alignment(
34            graph: Pin<&mut Graph>,
35            alignment: &Alignment,
36            sequence: *const c_char,
37            sequence_len: u32,
38            weight: u32,
39        );
40        fn generate_consensus(graph: Pin<&mut Graph>) -> UniquePtr<CxxString>;
41        fn generate_multiple_sequence_alignment(
42            graph: Pin<&mut Graph>,
43            include_consensus: bool,
44        ) -> UniquePtr<CxxVector<CxxString>>;
45        fn graph_clear(graph: Pin<&mut Graph>);
46
47        fn create_alignment_engine(
48            typ: AlignmentType,
49            m: i8,
50            n: i8,
51            g: i8,
52            e: i8,
53            q: i8,
54            c: i8,
55        ) -> UniquePtr<AlignmentEngine>;
56        /// # Safety
57        /// this function is unsafe because cxx says pointer arguments are unsafe
58        unsafe fn align(
59            alignment_engine: Pin<&mut AlignmentEngine>,
60            sequence: *const c_char,
61            sequence_len: u32,
62            graph: &Graph,
63        ) -> UniquePtr<Alignment>;
64    }
65}