Skip to main content

cyto_cli/ibu/
sort.rs

1use super::IbuInput;
2
3#[derive(clap::Parser, Debug)]
4pub struct ArgsSort {
5    #[clap(flatten)]
6    pub input: IbuInput,
7
8    /// Output file to write to
9    ///
10    /// Required unless `-p/--pipe` is present.
11    #[clap(short, long, required_unless_present("pipe"))]
12    pub output: Option<String>,
13
14    /// Memory limit for sorting in-memory
15    #[clap(short, long, default_value = "5GiB")]
16    pub memory_limit: String,
17
18    /// Perform the sorting in-memory [default: on-disk merge sort]
19    ///
20    /// This may be faster for small datasets, but will load IBUs fully into memory.
21    #[clap(short, long)]
22    pub in_memory: bool,
23
24    /// Pipe the output to stdout
25    ///
26    /// Due to binary output, this flag is necessary not to flood the terminal with binary.
27    #[clap(short, long, conflicts_with("output"))]
28    pub pipe: bool,
29
30    #[clap(short = 't', long, default_value = "1")]
31    pub num_threads: usize,
32}
33impl ArgsSort {
34    pub fn from_wf_path(
35        path: &str,
36        output: &str,
37        in_memory: bool,
38        memory_limit: String,
39        num_threads: usize,
40    ) -> Self {
41        let input = IbuInput::from_path(path);
42        Self {
43            input,
44            num_threads,
45            output: Some(output.to_string()),
46            pipe: false,
47            in_memory,
48            memory_limit,
49        }
50    }
51}