1crate::ix!();
2
3#[derive(Getters,StructOpt, Debug)]
5#[structopt(name = "crate-activity")]
6pub struct CrateActivityCli {
7
8 #[structopt(long, help = "Enable all analyses at once")]
10 #[getset(get = "pub")]
11 all: bool,
12
13 #[structopt(long, short = "c", help = "Display correlation analysis")]
15 #[getset(get = "pub")]
16 show_correlations: bool,
17
18 #[structopt(long, short = "p", help = "Perform PCA analysis")]
20 #[getset(get = "pub")]
21 perform_pca: bool,
22
23 #[structopt(long, short = "h", help = "Perform hierarchical clustering")]
25 #[getset(get = "pub")]
26 perform_hierarchical_clustering: bool,
27
28 #[structopt(long, short = "n", help = "Perform correlation network analysis")]
30 #[getset(get = "pub")]
31 correlation_network: bool,
32
33 #[structopt(long, default_value = "0.7", help = "Correlation threshold for network edges")]
35 #[getset(get = "pub")]
36 network_threshold: f64,
37
38 #[structopt(long, short = "g", help = "Target number of communities for Girvan–Newman")]
40 #[getset(get = "pub")]
41 girvan_newman: Option<usize>,
42
43 #[structopt(long, short = "b", help = "Compute betweenness centrality and display top nodes")]
45 #[getset(get = "pub")]
46 compute_betweenness: bool,
47
48 #[structopt(long, short = "s", help = "Print a summary of the network graph")]
50 #[getset(get = "pub")]
51 print_summary: bool,
52
53 #[structopt(long, short = "t", help = "Compute time-lagged correlations")]
55 #[getset(get = "pub")]
56 time_lag_correlations: bool,
57
58 #[structopt(long, default_value = "7", help = "Maximum lag (in days) to consider for time-lag correlations")]
60 #[getset(get = "pub")]
61 max_lag: i32,
62
63 #[structopt(long, default_value = "24.0", help = "Z-score threshold for outlier detection")]
65 #[getset(get = "pub")]
66 outlier_z_threshold: f64,
67
68 #[structopt(long, help = "Downweight outliers instead of removing them")]
70 #[getset(get = "pub")]
71 downweight_outliers: bool,
72
73 #[structopt(long, default_value = "0.1", help = "Downweight factor for outliers")]
75 #[getset(get = "pub")]
76 outlier_weight: f64,
77
78 #[structopt(long, help = "Disable outlier detection and handling")]
80 disable_outlier_handling: bool,
81}
82
83impl CrateActivityCli {
84
85 pub fn read_command_line() -> Self {
86 let mut cli = CrateActivityCli::from_args();
87 cli.apply_all_flag();
88 cli
89 }
90
91 pub fn disable_outlier_handling(&self) -> bool {
92
93 #[cfg(test)]
94 let disable_outliers_override = true; #[cfg(not(test))]
97 let disable_outliers_override = false;
98
99 let disable_outliers = self.disable_outlier_handling || disable_outliers_override;
100
101 disable_outliers
102 }
103
104 pub fn apply_all_flag(&mut self) {
106 if self.all {
107 self.show_correlations = true;
108 self.perform_pca = true;
109 self.perform_hierarchical_clustering = true;
110 self.correlation_network = true;
111 self.compute_betweenness = true;
112 self.print_summary = true;
113 self.time_lag_correlations = true;
114 }
116 }
117}