|
18 | 18 | * and numbers of crossovers, etc.., from being entered |
19 | 19 | * on the command line. |
20 | 20 | */ |
21 | | -use clap::{value_t, App, Arg}; |
| 21 | +use clap::{App, Arg}; |
22 | 22 | use rand::rngs::StdRng; |
23 | 23 | use rand::Rng; |
24 | 24 | use rand::SeedableRng; |
@@ -67,73 +67,75 @@ impl SimParams { |
67 | 67 |
|
68 | 68 | let matches = App::new("forward_simulation") |
69 | 69 | .arg( |
70 | | - Arg::with_name("popsize") |
71 | | - .short("N") |
| 70 | + Arg::new("popsize") |
| 71 | + .short('N') |
72 | 72 | .long("popsize") |
73 | 73 | .help("Diploid population size. Default = 1,000.") |
74 | 74 | .takes_value(true), |
75 | 75 | ) |
76 | 76 | .arg( |
77 | | - Arg::with_name("nsteps") |
78 | | - .short("n") |
| 77 | + Arg::new("nsteps") |
| 78 | + .short('n') |
79 | 79 | .long("nsteps") |
80 | 80 | .help("Number of birth steps to simulate. For non-overlapping generations, this is the number of generations to simulate. Default = 1,000.") |
81 | 81 | .takes_value(true), |
82 | 82 | ) |
83 | 83 | .arg( |
84 | | - Arg::with_name("xovers") |
85 | | - .short("x") |
| 84 | + Arg::new("xovers") |
| 85 | + .short('x') |
86 | 86 | .long("xovers") |
87 | 87 | .help("Mean number of crossovers per meiosis. The number of crossovers is Poisson-distributed with this value. Default = 0.0.") |
88 | 88 | .takes_value(true), |
89 | 89 | ) |
90 | 90 | .arg( |
91 | | - Arg::with_name("genome_length") |
92 | | - .short("L") |
| 91 | + Arg::new("genome_length") |
| 92 | + .short('L') |
93 | 93 | .long("genome_length") |
94 | 94 | .help("Genome length (continuous units). Default = 1e6.") |
95 | 95 | .takes_value(true), |
96 | 96 | ) |
97 | 97 | .arg( |
98 | | - Arg::with_name("simplification_interval") |
99 | | - .short("s") |
| 98 | + Arg::new("simplification_interval") |
| 99 | + .short('s') |
100 | 100 | .long("simplify") |
101 | 101 | .help("Number of birth steps between simplifications. Default = 100.") |
102 | 102 | .takes_value(true), |
103 | 103 | ) |
104 | 104 | .arg( |
105 | | - Arg::with_name("treefile") |
106 | | - .short("t") |
| 105 | + Arg::new("treefile") |
| 106 | + .short('t') |
107 | 107 | .long("treefile") |
108 | 108 | .help("Name of output file. The format is a tskit \"trees\" file. Default = \"treefile.trees\".") |
109 | 109 | .takes_value(true), |
110 | 110 | ) |
111 | 111 | .arg( |
112 | | - Arg::with_name("seed") |
113 | | - .short("S") |
| 112 | + Arg::new("seed") |
| 113 | + .short('S') |
114 | 114 | .long("seed") |
115 | 115 | .help("Random number seed. Default = 0.") |
116 | 116 | .takes_value(true), |
117 | 117 | ) |
118 | 118 | .arg( |
119 | | - Arg::with_name("psurvival") |
120 | | - .short("P") |
| 119 | + Arg::new("psurvival") |
| 120 | + .short('P') |
121 | 121 | .long("psurvival") |
122 | 122 | .help("Survival probability. A value of 0.0 is the Wright-Fisher model of non-overlapping generations. Values must b 0.0 <= p < 1.0. Default = 0.0.") |
123 | 123 | .takes_value(true), |
124 | 124 | ) |
125 | 125 | .get_matches(); |
126 | 126 |
|
127 | | - params.popsize = value_t!(matches.value_of("popsize"), u32).unwrap_or(params.popsize); |
128 | | - params.nsteps = value_t!(matches.value_of("nsteps"), u32).unwrap_or(params.nsteps); |
129 | | - params.xovers = value_t!(matches.value_of("xovers"), f64).unwrap_or(params.xovers); |
130 | | - params.genome_length = |
131 | | - value_t!(matches.value_of("genome_length"), f64).unwrap_or(params.genome_length); |
132 | | - params.simplification_interval = value_t!(matches.value_of("simplification_interval"), u32) |
| 127 | + params.popsize = matches.value_of_t("popsize").unwrap_or(params.popsize); |
| 128 | + params.nsteps = matches.value_of_t("nsteps").unwrap_or(params.nsteps); |
| 129 | + params.xovers = matches.value_of_t("xovers").unwrap_or(params.xovers); |
| 130 | + params.genome_length = matches |
| 131 | + .value_of_t("genome_length") |
| 132 | + .unwrap_or(params.genome_length); |
| 133 | + params.simplification_interval = matches |
| 134 | + .value_of_t("simplification_interval") |
133 | 135 | .unwrap_or(params.simplification_interval); |
134 | | - params.seed = value_t!(matches.value_of("seed"), u64).unwrap_or(params.seed); |
135 | | - params.psurvival = value_t!(matches.value_of("psurvival"), f64).unwrap_or(params.psurvival); |
136 | | - params.treefile = value_t!(matches.value_of("treefile"), String).unwrap_or(params.treefile); |
| 136 | + params.seed = matches.value_of_t("seed").unwrap_or(params.seed); |
| 137 | + params.psurvival = matches.value_of_t("psurvival").unwrap_or(params.psurvival); |
| 138 | + params.treefile = matches.value_of_t("treefile").unwrap_or(params.treefile); |
137 | 139 |
|
138 | 140 | params |
139 | 141 | } |
|
0 commit comments