Skip to content

Commit

Permalink
Merge pull request #96 from COMBINE-lab/clap_v4
Browse files Browse the repository at this point in the history
Clap v4
  • Loading branch information
rob-p committed Jan 12, 2023
2 parents 113e49a + 788d5c3 commit 129559a
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 98 deletions.
66 changes: 34 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ csv = "1.1.6"
mimalloc = { version = "0.1.34", default-features = false }
num-format = "0.4.4"
num_cpus = "1.15.0"
bio-types = "0.13.0"
bio-types = { version = "0.13.0", default-features = true, features = ["serde"] }
itertools = "0.10.5"
thiserror = "1.0.38"
statrs = "0.16.0"
Expand All @@ -79,7 +79,7 @@ sce = { git = "https://github.com/parazodiac/SingleCellExperiment", version = "0

# no shenanigans; clap makes breaking "fixes" too often to allow variability
# in the version different from what we tested with
clap = { version = "=3.2.23", features = ["derive", "wrap_help", "cargo"] }
clap = { version = "=4.0.32", features = ["derive", "wrap_help", "cargo", "help", "usage", "string", "error-context"] }

[profile.release]
#debug = true
Expand Down
15 changes: 11 additions & 4 deletions src/cellfilter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use libradicl::rad_types;
use libradicl::BarcodeLookupMap;
use needletail::bitkmer::*;
use num_format::{Locale, ToFormattedString};
use serde::Serialize;
use serde_json::json;
use std::cmp;
use std::collections::HashMap;
Expand All @@ -32,7 +33,7 @@ use std::io::{BufWriter, Write};
use std::path::{Path, PathBuf};
use std::time::Instant;

#[derive(Debug)]
#[derive(Clone, Debug, Serialize)]
pub enum CellFilterMethod {
// cut off at this cell in
// the frequency sorted list
Expand Down Expand Up @@ -230,6 +231,7 @@ fn process_unfiltered(
velo_mode: bool,
cmdline: &str,
log: &slog::Logger,
gpl_opts: &GenPermitListOpts,
) -> anyhow::Result<u64> {
let parent = std::path::Path::new(output_dir);
std::fs::create_dir_all(&parent)
Expand Down Expand Up @@ -418,7 +420,8 @@ fn process_unfiltered(
"version_str" : version,
"max-ambig-record" : max_ambiguity_read,
"cmd" : cmdline,
"permit-list-type" : "unfiltered"
"permit-list-type" : "unfiltered",
"gpl_options" : &gpl_opts
});

let m_path = parent.join("generate_permit_list.json");
Expand Down Expand Up @@ -451,6 +454,7 @@ fn process_filtered(
velo_mode: bool,
cmdline: &str,
log: &slog::Logger,
gpl_opts: &GenPermitListOpts,
) -> anyhow::Result<u64> {
let valid_bc: Vec<u64>;
let mut freq: Vec<u64> = hm.values().cloned().collect();
Expand Down Expand Up @@ -557,7 +561,8 @@ fn process_filtered(
"version_str" : version,
"max-ambig-record" : max_ambiguity_read,
"cmd" : cmdline,
"permit-list-type" : "filtered"
"permit-list-type" : "filtered",
"gpl_options" : &gpl_opts
});

let m_path = parent.join("generate_permit_list.json");
Expand Down Expand Up @@ -586,7 +591,7 @@ fn process_filtered(
pub fn generate_permit_list(gpl_opts: GenPermitListOpts) -> anyhow::Result<u64> {
let rad_dir = gpl_opts.input_dir;
let output_dir = gpl_opts.output_dir;
let filter_meth = gpl_opts.fmeth;
let filter_meth = gpl_opts.fmeth.clone();
let expected_ori = gpl_opts.expected_ori;
let version = gpl_opts.version;
let velo_mode = gpl_opts.velo_mode;
Expand Down Expand Up @@ -728,6 +733,7 @@ pub fn generate_permit_list(gpl_opts: GenPermitListOpts) -> anyhow::Result<u64>
velo_mode,
cmdline,
log,
&gpl_opts,
)
} else {
Ok(0)
Expand Down Expand Up @@ -757,6 +763,7 @@ pub fn generate_permit_list(gpl_opts: GenPermitListOpts) -> anyhow::Result<u64>
velo_mode,
cmdline,
log,
&gpl_opts,
)
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/cmd_parse_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ impl clap::ValueEnum for ResolutionStrategy {
]
}

fn to_possible_value<'a>(&self) -> Option<clap::PossibleValue<'a>> {
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
match self {
Self::Trivial => Some(clap::PossibleValue::new("trivial")),
Self::CellRangerLike => Some(clap::PossibleValue::new("cr-like")),
Self::CellRangerLikeEm => Some(clap::PossibleValue::new("cr-like-em")),
Self::ParsimonyEm => Some(clap::PossibleValue::new("parsimony-em")),
Self::Parsimony => Some(clap::PossibleValue::new("parsimony")),
Self::ParsimonyGeneEm => Some(clap::PossibleValue::new("parsimony-gene-em")),
Self::ParsimonyGene => Some(clap::PossibleValue::new("parsimony-gene")),
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")),
}
}
}
Expand All @@ -33,10 +33,10 @@ impl clap::ValueEnum for SplicedAmbiguityModel {
&[Self::PreferAmbiguity, Self::WinnerTakeAll]
}

fn to_possible_value<'a>(&self) -> Option<clap::PossibleValue<'a>> {
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
match self {
Self::PreferAmbiguity => Some(clap::PossibleValue::new("prefer-ambig")),
Self::WinnerTakeAll => Some(clap::PossibleValue::new("winner-take-all")),
Self::PreferAmbiguity => Some(clap::builder::PossibleValue::new("prefer-ambig")),
Self::WinnerTakeAll => Some(clap::builder::PossibleValue::new("winner-take-all")),
}
}
}
Expand Down

0 comments on commit 129559a

Please sign in to comment.