Skip to main content

cyto_cli/ibu/
count.rs

1use std::path::Path;
2
3use super::IbuInput;
4
5#[derive(clap::Parser, Debug)]
6pub struct ArgsCount {
7    #[clap(flatten)]
8    pub input: IbuInput,
9
10    /// Output file to write to [default=stdout]
11    #[clap(short, long)]
12    pub output: Option<String>,
13
14    /// Output mtx format.
15    /// Will treat `output` as a directory and create 3 files:
16    ///
17    /// (1) barcodes.txt.gz
18    /// (2) features.txt.gz
19    /// (3) matrix.mtx.gz
20    #[clap(long, requires = "output", requires = "features")]
21    pub mtx: bool,
22
23    /// Number of threads to use in counting
24    #[clap(short = 't', long, default_value = "1")]
25    pub num_threads: usize,
26
27    /// Keep the barcode values 2bit compressed in the output
28    #[clap(short = 'e', long = "compressed")]
29    pub compressed: bool,
30
31    /// File containing the index features
32    ///
33    /// If this is provided the index features names will be output instead of their index values
34    #[clap(short = 'f', long)]
35    pub features: Option<String>,
36
37    /// The column in the feature table to aggregate reads over - skips aggregation if this is zero
38    #[clap(short = 'C', long, default_value_t = 1)]
39    pub feature_col: usize,
40
41    /// Suffix to append to cell barcodes
42    ///
43    /// example: {barcode}-{suffix}
44    #[clap(short = 's', long, requires = "features")]
45    pub suffix: Option<String>,
46}
47impl ArgsCount {
48    pub fn from_wf_path<P: AsRef<Path>>(
49        sort_path: &str,
50        out_path: P,
51        features_path: P,
52        num_threads: usize,
53        mtx: bool,
54        suffix: Option<String>,
55    ) -> Self {
56        Self {
57            input: IbuInput::from_path(sort_path),
58            output: Some(out_path.as_ref().to_str().unwrap().to_string()),
59            features: Some(features_path.as_ref().to_str().unwrap().to_string()),
60            mtx,
61            compressed: false,
62            feature_col: 1,
63            num_threads,
64            suffix,
65        }
66    }
67}