use crate::quant::{ResolutionStrategy, SplicedAmbiguityModel};
use clap;
use std::path::{Path, PathBuf};
impl clap::ValueEnum for ResolutionStrategy {
fn value_variants<'a>() -> &'a [Self] {
&[
Self::Trivial,
Self::CellRangerLike,
Self::CellRangerLikeEm,
Self::ParsimonyEm,
Self::Parsimony,
Self::ParsimonyGeneEm,
Self::ParsimonyGene,
]
}
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
match self {
Self::Trivial => Some(clap::builder::PossibleValue::new("trivial")),
Self::CellRangerLike => Some(clap::builder::PossibleValue::new("cr-like")),
Self::CellRangerLikeEm => Some(clap::builder::PossibleValue::new("cr-like-em")),
Self::ParsimonyEm => Some(clap::builder::PossibleValue::new("parsimony-em")),
Self::Parsimony => Some(clap::builder::PossibleValue::new("parsimony")),
Self::ParsimonyGeneEm => Some(clap::builder::PossibleValue::new("parsimony-gene-em")),
Self::ParsimonyGene => Some(clap::builder::PossibleValue::new("parsimony-gene")),
}
}
}
impl clap::ValueEnum for SplicedAmbiguityModel {
fn value_variants<'a>() -> &'a [Self] {
&[Self::PreferAmbiguity, Self::WinnerTakeAll]
}
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
match self {
Self::PreferAmbiguity => Some(clap::builder::PossibleValue::new("prefer-ambig")),
Self::WinnerTakeAll => Some(clap::builder::PossibleValue::new("winner-take-all")),
}
}
}
pub fn pathbuf_file_exists_validator(v: &str) -> Result<PathBuf, String> {
if !Path::new(v).exists() {
Err(String::from("No valid file was found at this path."))
} else {
Ok(PathBuf::from(v))
}
}
pub fn pathbuf_directory_exists_validator(v: &str) -> Result<PathBuf, String> {
if !Path::new(v).is_dir() {
Err(String::from("No valid directory was found at this path."))
} else {
Ok(PathBuf::from(v))
}
}