Skip to content

Commit e19455b

Browse files
Merge pull request #246 from jeromekelleher/no-progress-flag
Add progress/no-progress flag to CLI
2 parents b054efa + 5f91469 commit e19455b

File tree

4 files changed

+99
-40
lines changed

4 files changed

+99
-40
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.1.0 2024-06-10
2+
3+
- Add -Q/--no-progress flag to CLI
4+
15
# 0.0.10 2024-05-15
26
- Change output format of dexplode-init and dencode-init
37
- Bugfix for mac progress, and change of multiprocessing startup strategy.

bio2zarr/cli.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ def list_commands(self, ctx):
5858
help="Force overwriting of existing directories",
5959
)
6060

61+
progress = click.option(
62+
"-P /-Q",
63+
"--progress/--no-progress",
64+
default=True,
65+
help="Show progress bars (default: show)",
66+
)
67+
6168
one_based = click.option(
6269
"--one-based",
6370
is_flag=True,
@@ -190,9 +197,17 @@ def show_work_summary(work_summary, json):
190197
@verbose
191198
@column_chunk_size
192199
@compressor
200+
@progress
193201
@worker_processes
194202
def explode(
195-
vcfs, icf_path, force, verbose, column_chunk_size, compressor, worker_processes
203+
vcfs,
204+
icf_path,
205+
force,
206+
verbose,
207+
column_chunk_size,
208+
compressor,
209+
progress,
210+
worker_processes,
196211
):
197212
"""
198213
Convert VCF(s) to intermediate columnar format
@@ -205,7 +220,7 @@ def explode(
205220
worker_processes=worker_processes,
206221
column_chunk_size=column_chunk_size,
207222
compressor=get_compressor(compressor),
208-
show_progress=True,
223+
show_progress=progress,
209224
)
210225

211226

@@ -218,6 +233,7 @@ def explode(
218233
@compressor
219234
@json
220235
@verbose
236+
@progress
221237
@worker_processes
222238
def dexplode_init(
223239
vcfs,
@@ -228,6 +244,7 @@ def dexplode_init(
228244
compressor,
229245
json,
230246
verbose,
247+
progress,
231248
worker_processes,
232249
):
233250
"""
@@ -243,7 +260,7 @@ def dexplode_init(
243260
column_chunk_size=column_chunk_size,
244261
worker_processes=worker_processes,
245262
compressor=get_compressor(compressor),
246-
show_progress=True,
263+
show_progress=progress,
247264
)
248265
show_work_summary(work_summary, json)
249266

@@ -310,6 +327,7 @@ def mkschema(icf_path):
310327
@samples_chunk_size
311328
@max_variant_chunks
312329
@max_memory
330+
@progress
313331
@worker_processes
314332
def encode(
315333
icf_path,
@@ -321,6 +339,7 @@ def encode(
321339
samples_chunk_size,
322340
max_variant_chunks,
323341
max_memory,
342+
progress,
324343
worker_processes,
325344
):
326345
"""
@@ -337,7 +356,7 @@ def encode(
337356
max_variant_chunks=max_variant_chunks,
338357
worker_processes=worker_processes,
339358
max_memory=max_memory,
340-
show_progress=True,
359+
show_progress=progress,
341360
)
342361

343362

@@ -351,6 +370,7 @@ def encode(
351370
@samples_chunk_size
352371
@max_variant_chunks
353372
@json
373+
@progress
354374
@verbose
355375
def dencode_init(
356376
icf_path,
@@ -362,6 +382,7 @@ def dencode_init(
362382
samples_chunk_size,
363383
max_variant_chunks,
364384
json,
385+
progress,
365386
verbose,
366387
):
367388
"""
@@ -387,7 +408,7 @@ def dencode_init(
387408
variants_chunk_size=variants_chunk_size,
388409
samples_chunk_size=samples_chunk_size,
389410
max_variant_chunks=max_variant_chunks,
390-
show_progress=True,
411+
show_progress=progress,
391412
)
392413
show_work_summary(work_summary, json)
393414

@@ -413,12 +434,13 @@ def dencode_partition(zarr_path, partition, verbose, one_based):
413434
@click.command
414435
@zarr_path
415436
@verbose
416-
def dencode_finalise(zarr_path, verbose):
437+
@progress
438+
def dencode_finalise(zarr_path, verbose, progress):
417439
"""
418440
Final step for distributed conversion of ICF to VCF Zarr.
419441
"""
420442
setup_logging(verbose)
421-
vcf2zarr.encode_finalise(zarr_path, show_progress=True)
443+
vcf2zarr.encode_finalise(zarr_path, show_progress=progress)
422444

423445

424446
@click.command(name="convert")
@@ -428,6 +450,7 @@ def dencode_finalise(zarr_path, verbose):
428450
@variants_chunk_size
429451
@samples_chunk_size
430452
@verbose
453+
@progress
431454
@worker_processes
432455
def convert_vcf(
433456
vcfs,
@@ -436,6 +459,7 @@ def convert_vcf(
436459
variants_chunk_size,
437460
samples_chunk_size,
438461
verbose,
462+
progress,
439463
worker_processes,
440464
):
441465
"""
@@ -448,7 +472,7 @@ def convert_vcf(
448472
zarr_path,
449473
variants_chunk_size=variants_chunk_size,
450474
samples_chunk_size=samples_chunk_size,
451-
show_progress=True,
475+
show_progress=progress,
452476
worker_processes=worker_processes,
453477
)
454478

@@ -481,6 +505,7 @@ def vcf2zarr_main():
481505
@click.argument("in_path", type=click.Path())
482506
@click.argument("zarr_path", type=click.Path())
483507
@worker_processes
508+
@progress
484509
@verbose
485510
@variants_chunk_size
486511
@samples_chunk_size
@@ -489,6 +514,7 @@ def convert_plink(
489514
zarr_path,
490515
verbose,
491516
worker_processes,
517+
progress,
492518
variants_chunk_size,
493519
samples_chunk_size,
494520
):
@@ -499,7 +525,7 @@ def convert_plink(
499525
plink.convert(
500526
in_path,
501527
zarr_path,
502-
show_progress=True,
528+
show_progress=progress,
503529
worker_processes=worker_processes,
504530
samples_chunk_size=samples_chunk_size,
505531
variants_chunk_size=variants_chunk_size,

docs/vcf2zarr/tutorial.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ rm -fR sample_noHQ.vcz
168168
```
169169

170170
```{code-cell}
171-
vcf2zarr encode sample.icf -s sample_noHQ.schema.json sample_noHQ.vcz
171+
vcf2zarr encode sample.icf -Qs sample_noHQ.schema.json sample_noHQ.vcz
172172
```
173+
:::{tip}
174+
Use the ``-Q/--no-progress`` flag to suppress progress bars.
175+
:::
176+
173177
We can then ``inspect`` to see that there is no ``call_HQ`` array in the output:
174178

175179
```{code-cell}
@@ -210,7 +214,7 @@ Let's go through the example above using the distributed commands. First, we
210214
rm -fR sample-dist.icf
211215
```
212216
```{code-cell}
213-
vcf2zarr dexplode-init sample.vcf.gz sample-dist.icf 5
217+
vcf2zarr dexplode-init sample.vcf.gz sample-dist.icf -Q 5
214218
```
215219

216220
Here we asked ``dexplode-init`` to set up an ICF store in which the data
@@ -227,9 +231,9 @@ granularity). You should be careful to use this value in your scripts
227231
Once ``dexplode-init`` is done and we know how many partitions we have,
228232
we need to call ``dexplode-partition`` this number of times.
229233

230-
<!-- ```{code-cell} -->
231-
<!-- vcf2zarr dexplode-partition sample-dist.icf 0 -->
232-
<!-- vcf2zarr dexplode-partition sample-dist.icf 1 -->
233-
<!-- vcf2zarr dexplode-partition sample-dist.icf 2 -->
234-
<!-- ``` -->
234+
```{code-cell}
235+
vcf2zarr dexplode-partition sample-dist.icf 0
236+
vcf2zarr dexplode-partition sample-dist.icf 1
237+
vcf2zarr dexplode-partition sample-dist.icf 2
238+
```
235239

0 commit comments

Comments
 (0)