1use clap::{Args, Parser, Subcommand};
2
3use crate::{
4 ordering::OrderingMethod,
5 weights::{InferenceMethod, active_set_weights::NNLSParams},
6};
7
8#[derive(Parser, Debug)]
9#[command(version, about, long_about = None)]
10pub struct ProgramArgs {
11 #[command(subcommand)]
12 pub subcommand: ProgramSubcommand,
13 #[arg(
14 short,
15 long,
16 default_value = "1",
17 global = true,
18 help = "Number of threads to use."
19 )]
20 pub threads: usize,
21 #[arg(
22 short,
23 long,
24 default_value = "false",
25 conflicts_with = "quiet",
26 global = true
27 )]
28 pub verbose: bool,
29 #[arg(
30 short,
31 long,
32 default_value = "false",
33 conflicts_with = "verbose",
34 global = true
35 )]
36 pub quiet: bool,
37 #[arg(
38 short = 'd',
39 long,
40 default_value = "output",
41 global = true,
42 help = "Output directory"
43 )]
44 pub output_directory: String,
45}
46
47#[derive(Subcommand, Debug)]
48pub enum ProgramSubcommand {
49 #[clap(
50 name = "neighbour_net",
51 about = "Build a NeighbourNet split network from a distance matrix",
52 long_about = "Build a NeighbourNet split network (Bryant & Moulton, 2004) from a \
53distance matrix. Produces an implicit split network with a 2-D equal-angle \
54layout, written to a Nexus file."
55 )]
56 NeighborNet(NeighbourNetArgs),
57}
58
59#[derive(Args, Debug)]
60pub struct NeighbourNetArgs {
61 #[arg(short, long, help = "Input distance matrix file path", required = true)]
63 pub input: String,
64 #[arg(
65 short,
66 long,
67 help = "Output prefix for result files",
68 default_value = "output"
69 )]
70 pub output_prefix: String,
71 #[arg(
72 short = 'O',
73 long,
74 help = "The ordering algorithm to use to get splits cycle",
75 default_value = "multiway"
76 )]
77 pub ordering: OrderingMethod,
78 #[arg(
79 long,
80 help = "Split-weight inference algorithm",
81 default_value = "active-set"
82 )]
83 pub inference: InferenceMethod,
84 #[clap(flatten)]
85 pub nnls_params: NNLSParams,
86}
87
88impl Default for NeighbourNetArgs {
89 fn default() -> Self {
90 Self {
91 input: String::new(),
92 output_prefix: String::from("output"),
93 ordering: OrderingMethod::Multiway,
94 inference: InferenceMethod::ActiveSet,
95 nnls_params: NNLSParams::default(),
96 }
97 }
98}