7
7
from . import plink
8
8
from . import provenance
9
9
10
+ class NaturalOrderGroup (click .Group ):
11
+ """
12
+ List commands in the order they are provided in the help text.
13
+ """
14
+
15
+ def list_commands (self , ctx ):
16
+ return self .commands .keys ()
17
+
18
+
10
19
# Common arguments/options
11
20
verbose = click .option ("-v" , "--verbose" , count = True , help = "Increase verbosity" )
12
21
22
+ version = click .version_option (version = f"{ provenance .__version__ } " )
23
+
13
24
worker_processes = click .option (
14
25
"-p" , "--worker-processes" , type = int , default = 1 , help = "Number of worker processes"
15
26
)
19
30
"--column-chunk-size" ,
20
31
type = int ,
21
32
default = 64 ,
22
- help = "Size of exploded column chunks" ,
33
+ help = "Approximate uncompressed size of exploded column chunks in MiB " ,
23
34
)
24
35
25
36
# Note: -l and -w were chosen when these were called "width" and "length".
26
37
# possibly there are better letters now.
27
- # TODO help text
28
38
variants_chunk_size = click .option (
29
39
"-l" ,
30
40
"--variants-chunk-size" ,
41
51
help = "Chunk size in the samples dimension" ,
42
52
)
43
53
44
- version = click .version_option (version = f"{ provenance .__version__ } " )
45
-
46
54
47
- # Note: logging hasn't been implemented in the code at all, this is just
48
- # a first pass to try out some ways of doing things to see what works.
49
55
def setup_logging (verbosity ):
50
56
level = "WARNING"
51
57
if verbosity == 1 :
52
58
level = "INFO"
53
59
elif verbosity >= 2 :
54
60
level = "DEBUG"
55
61
# NOTE: I'm not that excited about coloredlogs, just trying it out
56
- # as it is installed by cyvcf2 anyway. We will have some complicated
57
- # stuff doing on with threads and processes, to logs might not work
58
- # so well anyway.
62
+ # as it is installed by cyvcf2 anyway.
59
63
coloredlogs .install (level = level )
60
64
61
65
@@ -78,13 +82,14 @@ def explode(vcfs, out_path, verbose, worker_processes, column_chunk_size):
78
82
show_progress = True ,
79
83
)
80
84
85
+
81
86
@click .command
82
87
@click .argument ("vcfs" , nargs = - 1 , required = True )
83
88
@click .argument ("out_path" , type = click .Path ())
84
89
@click .option ("-n" , "--target-num-partitions" , type = int , required = True )
85
90
@verbose
86
91
@worker_processes
87
- def explode_init (vcfs , out_path , target_num_partitions , verbose , worker_processes ):
92
+ def dexplode_init (vcfs , out_path , target_num_partitions , verbose , worker_processes ):
88
93
"""
89
94
Initial step for parallel conversion of VCF(s) to columnar intermediate format
90
95
"""
@@ -97,13 +102,15 @@ def explode_init(vcfs, out_path, target_num_partitions, verbose, worker_processe
97
102
show_progress = True ,
98
103
)
99
104
105
+
100
106
@click .command
101
107
@click .argument ("path" , type = click .Path ())
102
- def explode_partition_count (path ):
108
+ def dexplode_partition_count (path ):
103
109
"""
104
110
Count the actual number of partitions in a parallel conversion of VCF(s) to columnar intermediate format
105
111
"""
106
- print (vcf .explode_partition_count (path ))
112
+ click .echo (vcf .explode_partition_count (path ))
113
+
107
114
108
115
@click .command
109
116
@click .argument ("path" , type = click .Path (), required = True )
@@ -112,7 +119,7 @@ def explode_partition_count(path):
112
119
@verbose
113
120
@worker_processes
114
121
@column_chunk_size
115
- def explode_slice (path , start , end , verbose , worker_processes , column_chunk_size ):
122
+ def dexplode_slice (path , start , end , verbose , worker_processes , column_chunk_size ):
116
123
"""
117
124
Convert VCF(s) to columnar intermediate format
118
125
"""
@@ -126,22 +133,24 @@ def explode_slice(path, start, end, verbose, worker_processes, column_chunk_size
126
133
show_progress = True ,
127
134
)
128
135
136
+
129
137
@click .command
130
138
@click .argument ("path" , type = click .Path (), required = True )
131
139
@verbose
132
- def explode_finalise (path , verbose ):
140
+ def dexplode_finalise (path , verbose ):
133
141
"""
134
142
Final step for parallel conversion of VCF(s) to columnar intermediate format
135
143
"""
136
144
setup_logging (verbose )
137
145
vcf .explode_finalise (path )
138
146
147
+
139
148
@click .command
140
149
@click .argument ("if_path" , type = click .Path ())
141
150
@verbose
142
151
def inspect (if_path , verbose ):
143
152
"""
144
- Inspect an intermediate format file
153
+ Inspect an intermediate format or Zarr path.
145
154
"""
146
155
setup_logging (verbose )
147
156
data = vcf .inspect (if_path )
@@ -248,21 +257,21 @@ def validate(vcfs, out_path):
248
257
249
258
250
259
@version
251
- @click .group ()
260
+ @click .group (cls = NaturalOrderGroup )
252
261
def vcf2zarr ():
253
262
pass
254
263
255
264
256
265
# TODO figure out how to get click to list these in the given order.
266
+ vcf2zarr .add_command (convert_vcf )
257
267
vcf2zarr .add_command (explode )
258
- vcf2zarr .add_command (explode_init )
259
- vcf2zarr .add_command (explode_partition_count )
260
- vcf2zarr .add_command (explode_slice )
261
- vcf2zarr .add_command (explode_finalise )
262
268
vcf2zarr .add_command (inspect )
263
269
vcf2zarr .add_command (mkschema )
264
270
vcf2zarr .add_command (encode )
265
- vcf2zarr .add_command (convert_vcf )
271
+ vcf2zarr .add_command (dexplode_init )
272
+ vcf2zarr .add_command (dexplode_partition_count )
273
+ vcf2zarr .add_command (dexplode_slice )
274
+ vcf2zarr .add_command (dexplode_finalise )
266
275
vcf2zarr .add_command (validate )
267
276
268
277
0 commit comments