polaranges 0.3.2

Rust-first genomic range operations on top of Polars DataFrames
Documentation
use polars_core::prelude::PolarsError;
use thiserror::Error;

pub type Result<T> = std::result::Result<T, RangeFrameError>;

#[derive(Debug, Error)]
pub enum RangeFrameError {
    #[error(transparent)]
    Polars(#[from] PolarsError),

    #[error("missing required column `{0}`")]
    MissingColumn(String),

    #[error("column `{column}` contains null values")]
    NullValues { column: String },

    #[error("column `{column}` must be an integer dtype, found `{dtype}`")]
    InvalidCoordinateDtype { column: String, dtype: String },

    #[error("range frame contains negative coordinates in `{column}`")]
    NegativeCoordinate { column: String },

    #[error("range frame contains empty or negative intervals (`{start}` >= `{end}`)")]
    InvalidIntervals { start: String, end: String },

    #[error("match_by column `{0}` does not exist in both frames")]
    MissingMatchBy(String),

    #[error("unsupported match_by dtype `{dtype}` in column `{column}`")]
    UnsupportedKeyDtype { column: String, dtype: String },

    #[error("match_by column `{column}` contains null values")]
    NullKeyValue { column: String },

    #[error("nearest requires k >= 1, found {k}")]
    InvalidNearestK { k: usize },

    #[error("missing required strand column `{column}`")]
    MissingStrandColumn { column: String },

    #[error("can only do {behavior} strand operations when both frames have valid strand info")]
    InvalidStrandBehavior { behavior: String },

    #[error("upstream/downstream nearest requires valid strand info on both frames")]
    DirectionalNearestRequiresStrand,

    #[error("frame height {len} exceeds supported row-id capacity (`u32::MAX`)")]
    TooManyRows { len: usize },
}