bascet 0.4.0

Bascet is a tool to preprocess single-cell data, handling barcode detection, trimming, QC, and managing the execution of custom tools for each cell
Documentation
use core::fmt;
use std::{fmt::Debug, path::PathBuf};

///////////////////////////////
/// Different ways of handling missing files
#[derive(Clone,Debug,Eq,PartialEq,Copy)]
pub enum MissingFileMode {
    Ignore,
    Skip,
    Fail
}
impl fmt::Display for MissingFileMode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{:?}", self)
    }
}



///////////////////////////////
/// Different policys for compressing files generated by mapcell script
#[derive(Clone,Debug,Eq,PartialEq,Copy )]
pub enum CompressionMode {
    Default,
    Uncompressed
}
impl fmt::Display for CompressionMode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{:?}", self)
    }
}


///////////////////////////////
/// A function that mapcell can call
pub trait MapCellFunction where Self: Sync+Send+Debug { 

    fn invoke(
        &self,
        input_dir: &PathBuf,
        output_dir: &PathBuf,
        num_threads: usize
    ) -> anyhow::Result<(bool, String)>;

    fn get_missing_file_mode(&self) -> MissingFileMode;

    fn get_compression_mode(&self, fname: &str) -> CompressionMode;

    fn get_expect_files(&self) -> Vec<String>;

    fn get_recommend_threads(&self) -> usize;
    
    fn preflight_check(&self) -> bool;


}



///////////////////////////////
/// Parse compression mode from string ... TODO expand upon parser trait?
pub fn parse_compression_mode(s: &str) -> anyhow::Result<CompressionMode> {
    match s {
        "default" => Ok(CompressionMode::Default),
        "uncompressed" => Ok(CompressionMode::Uncompressed),
        _ => anyhow::bail!("Cannot parse compression mode")
    }
}

///////////////////////////////
/// Parse missing file mode from string
pub fn parse_missing_file_mode(s: &str) -> anyhow::Result<MissingFileMode> {
    match s {
        "ignore" => Ok(MissingFileMode::Ignore),
        "skip" => Ok(MissingFileMode::Skip),
        "fail" => Ok(MissingFileMode::Fail),
        _ => anyhow::bail!("Cannot parse missing file mode")
    }
}