Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
ksw2rs
ksw2rs is a native Rust port of ksw2, focused on preserving ksw2 behavior and performance characteristics as directly as possible.
Building for optimal performance
ksw2rs uses runtime feature detection to dispatch to the best available SIMD backend (AVX2, SSE4.1, or NEON). However, to ensure the compiler can generate optimal code for all backends, you should compile with native target CPU support:
RUSTFLAGS="-C target-cpu=native"
Alternatively, add this to your project's .cargo/config.toml:
[]
= ["-C", "target-cpu=native"]
This ensures the compiler is aware of all SIMD instruction sets your CPU supports, enabling the best runtime dispatch path. Without this, the compiler may not emit AVX2 or other advanced instruction variants even though the runtime detection selects them.
This project is closely related to minimap2, where ksw2 is used as a core alignment component.
Scope
At this time, ksw2rs implements only the ksw2_extz2_sse variant (ported to stable Rust with scalar + SIMD backends).
This is intentional: the current primary client is bramble-rs, and this is the specific kernel variant required there.
Additional ksw2 variants may be added in the future.
Design goal
The guiding goal is not to redesign the algorithm, but to make a faithful, direct Rust port of the original C kernel:
- preserve scoring and traceback semantics,
- preserve anti-diagonal DP structure,
- preserve SIMD-oriented data flow,
- support stable Rust and modern SIMD backends.
Provenance
This codebase was produced almost entirely via automated conversion and iterative optimization using an AI agen (Codex 5.3), with human review and direction.
Usage
ksw2rs expects sequences encoded in the same compact DNA5 alphabet used by ksw2:
A=0C=1G=2T=3N/other=4
One-shot alignment
use ;
let query = vec!;
let target = query.clone;
let mat = dna5_mat;
let input = Extz2Input ;
let mut ez = default;
extz2;
println!;
High-throughput API (Aligner)
For repeated alignments, prefer Aligner. It reuses both DP scratch buffers and the result object to reduce per-call overhead.
use ;
let mat = dna5_mat;
let mut aligner = new;
for in
Manual workspace reuse
If you prefer functional-style calls, you can reuse Workspace directly:
use ;
let query = vec!;
let target = vec!;
let mat = ;
let input = Extz2Input ;
let mut ws = default;
let mut ez = default;
extz2_with_workspace;
License
This project is licensed under the BSD 3-Clause License. See LICENSE.