Skip to main content

bixverse_rs/
lib.rs

1//! Highly optimised code for computational biology: statistics, enrichment,
2//! graphs, matrix factorisation, a single cell suite and GPU backends.
3//!
4//! This crate is a facade. The code lives in the `bixverse-*` crates; this one
5//! re-exports them under the module paths the crate has always had, so a
6//! consumer that wants everything only needs one dependency and a consumer
7//! that wants one layer can depend on that crate directly.
8//!
9//! ## Feature flags
10#![doc = document_features::document_features!()]
11
12pub use bixverse_core::{VERSION, core, ml, utils};
13pub use bixverse_methods::{enrichment, graph, methods, ontology};
14
15/// The error enums of every crate compiled in. Each upper enum wraps the ones
16/// below it, so `?` converts upwards.
17pub mod errors {
18    pub use bixverse_core::errors::*;
19    #[cfg(feature = "gpu")]
20    pub use bixverse_gpu::errors::*;
21    pub use bixverse_methods::errors::*;
22    #[cfg(feature = "mlx")]
23    pub use bixverse_mlx::errors::*;
24    #[cfg(feature = "single-cell")]
25    pub use bixverse_sc::errors::*;
26    #[cfg(feature = "single-cell")]
27    pub use bixverse_sc_data::errors::*;
28    #[cfg(feature = "sc-gpu")]
29    pub use bixverse_sc_gpu::errors::*;
30}
31
32/// The union of the preludes of every crate compiled in.
33///
34/// Each upper prelude already re-exports the ones below it, so some of these
35/// globs are redundant for a given feature set.
36#[allow(unused_imports)]
37pub mod prelude {
38    #[cfg(feature = "gpu")]
39    pub use bixverse_gpu::prelude::*;
40    pub use bixverse_methods::prelude::*;
41    #[cfg(feature = "single-cell")]
42    pub use bixverse_sc::prelude::*;
43    #[cfg(feature = "sc-gpu")]
44    pub use bixverse_sc_gpu::prelude::*;
45}
46
47/// Single cell and metacell analysis.
48#[cfg(feature = "single-cell")]
49pub mod single_cell {
50    pub use bixverse_sc::*;
51    pub use bixverse_sc_data as sc_data;
52    pub use bixverse_sc_data::{CELL_BATCH_SIZE, sc_traits};
53}
54
55/// GPU methods via cubecl.
56#[cfg(feature = "gpu")]
57pub mod gpu {
58    pub use bixverse_gpu::*;
59    #[cfg(feature = "sc-gpu")]
60    pub use bixverse_sc_gpu as sc_gpu;
61}
62
63#[cfg(feature = "mlx")]
64pub use bixverse_mlx as mlx;
65
66/// Whether the MLX backend was compiled in: the `mlx` feature is on and the
67/// build script found `libmlxc`.
68#[cfg(feature = "mlx")]
69pub const MLX_AVAILABLE: bool = bixverse_mlx::MLX_AVAILABLE;
70/// Whether the MLX backend was compiled in: the `mlx` feature is on and the
71/// build script found `libmlxc`.
72#[cfg(not(feature = "mlx"))]
73pub const MLX_AVAILABLE: bool = false;