15
15
16
16
logger = logging .getLogger (__name__ )
17
17
18
+
18
19
class NaturalOrderGroup (click .Group ):
19
20
"""
20
21
List commands in the order they are provided in the help text.
@@ -29,12 +30,27 @@ def list_commands(self, ctx):
29
30
"vcfs" , nargs = - 1 , required = True , type = click .Path (exists = True , dir_okay = False )
30
31
)
31
32
32
- icf_path = click .argument ("icf_path" , type = click .Path (file_okay = False , dir_okay = True ))
33
+ new_icf_path = click .argument (
34
+ "icf_path" , type = click .Path (file_okay = False , dir_okay = True )
35
+ )
36
+
37
+ icf_path = click .argument (
38
+ "icf_path" , type = click .Path (exists = True , file_okay = False , dir_okay = True )
39
+ )
40
+
41
+ new_zarr_path = click .argument (
42
+ "zarr_path" , type = click .Path (file_okay = False , dir_okay = True )
43
+ )
33
44
34
45
verbose = click .option ("-v" , "--verbose" , count = True , help = "Increase verbosity" )
35
46
36
- force = click .option ("-f" , "--force" , is_flag = True , flag_value = True ,
37
- help = "Force overwriting of existing directories" )
47
+ force = click .option (
48
+ "-f" ,
49
+ "--force" ,
50
+ is_flag = True ,
51
+ flag_value = True ,
52
+ help = "Force overwriting of existing directories" ,
53
+ )
38
54
39
55
version = click .version_option (version = f"{ provenance .__version__ } " )
40
56
@@ -84,7 +100,10 @@ def check_overwrite_dir(path, force):
84
100
path = pathlib .Path (path )
85
101
if path .exists ():
86
102
if not force :
87
- click .confirm (f"Do you want to overwrite { path } ? (use --force to skip this check)" )
103
+ click .confirm (
104
+ f"Do you want to overwrite { path } ? (use --force to skip this check)" ,
105
+ abort = True ,
106
+ )
88
107
# These trees can be mondo-big and on slow file systems, so it's entirely
89
108
# feasible that the delete would fail or be killed. This makes it less likely
90
109
# that partially deleted paths are mistaken for good paths.
@@ -96,7 +115,7 @@ def check_overwrite_dir(path, force):
96
115
97
116
@click .command
98
117
@vcfs
99
- @icf_path
118
+ @new_icf_path
100
119
@force
101
120
@verbose
102
121
@worker_processes
@@ -118,8 +137,8 @@ def explode(vcfs, icf_path, force, verbose, worker_processes, column_chunk_size)
118
137
119
138
@click .command
120
139
@vcfs
121
- @icf_path
122
- @click .argument ("num_partitions" , type = int )
140
+ @new_icf_path
141
+ @click .argument ("num_partitions" , type = click . IntRange ( min = 1 ) )
123
142
@force
124
143
@column_chunk_size
125
144
@verbose
@@ -146,7 +165,7 @@ def dexplode_init(
146
165
147
166
@click .command
148
167
@icf_path
149
- @click .argument ("partition" , type = int )
168
+ @click .argument ("partition" , type = click . IntRange ( min = 0 ) )
150
169
@verbose
151
170
def dexplode_partition (icf_path , partition , verbose ):
152
171
"""
@@ -193,7 +212,8 @@ def mkschema(icf_path):
193
212
194
213
@click .command
195
214
@icf_path
196
- @click .argument ("zarr_path" , type = click .Path ())
215
+ @new_zarr_path
216
+ @force
197
217
@verbose
198
218
@click .option ("-s" , "--schema" , default = None , type = click .Path (exists = True ))
199
219
@variants_chunk_size
@@ -220,6 +240,7 @@ def mkschema(icf_path):
220
240
def encode (
221
241
icf_path ,
222
242
zarr_path ,
243
+ force ,
223
244
verbose ,
224
245
schema ,
225
246
variants_chunk_size ,
@@ -232,10 +253,11 @@ def encode(
232
253
Encode intermediate columnar format (see explode) to vcfzarr.
233
254
"""
234
255
setup_logging (verbose )
256
+ check_overwrite_dir (zarr_path , force )
235
257
vcf .encode (
236
258
icf_path ,
237
259
zarr_path ,
238
- schema ,
260
+ schema_path = schema ,
239
261
variants_chunk_size = variants_chunk_size ,
240
262
samples_chunk_size = samples_chunk_size ,
241
263
max_v_chunks = max_variant_chunks ,
@@ -247,7 +269,7 @@ def encode(
247
269
248
270
@click .command (name = "convert" )
249
271
@vcfs
250
- @click . argument ( "zarr_path" , type = click . Path ())
272
+ @new_zarr_path
251
273
@variants_chunk_size
252
274
@samples_chunk_size
253
275
@verbose
0 commit comments