Skip to content

Commit fbb0d79

Browse files
committed
Add partition count command
1 parent c3b1ef1 commit fbb0d79

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

bio2zarr/cli.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def explode(vcfs, out_path, verbose, worker_processes, column_chunk_size):
8181
@click.command
8282
@click.argument("vcfs", nargs=-1, required=True)
8383
@click.argument("out_path", type=click.Path())
84-
@click.argument("num_partitions", type=int, required=True)
84+
@click.option("-n", "--target_num_partitions", type=int, required=True)
8585
@verbose
8686
@worker_processes
8787
def explode_init(vcfs, out_path, num_partitions, verbose, worker_processes):
@@ -98,19 +98,27 @@ def explode_init(vcfs, out_path, num_partitions, verbose, worker_processes):
9898
)
9999

100100
@click.command
101-
@click.argument("out_path", type=click.Path(), required=True)
102-
@click.argument("start", type=int, required=True)
103-
@click.argument("end", type=int, required=True)
101+
@click.argument("path", type=click.Path())
102+
def explode_partition_count(path):
103+
"""
104+
Count the actual number of partitions in a parallel conversion of VCF(s) to columnar intermediate format
105+
"""
106+
print(vcf.explode_partition_count(path))
107+
108+
@click.command
109+
@click.argument("path", type=click.Path(), required=True)
110+
@click.option("-s", "--start", type=int, required=True)
111+
@click.option("-e", "--end", type=int, required=True)
104112
@verbose
105113
@worker_processes
106114
@column_chunk_size
107-
def explode_slice(out_path, start, end, verbose, worker_processes, column_chunk_size):
115+
def explode_slice(path, start, end, verbose, worker_processes, column_chunk_size):
108116
"""
109117
Convert VCF(s) to columnar intermediate format
110118
"""
111119
setup_logging(verbose)
112120
vcf.explode_slice(
113-
out_path,
121+
path,
114122
start,
115123
end,
116124
worker_processes=worker_processes,
@@ -119,14 +127,14 @@ def explode_slice(out_path, start, end, verbose, worker_processes, column_chunk_
119127
)
120128

121129
@click.command
122-
@click.argument("out_path", type=click.Path(), required=True)
130+
@click.argument("path", type=click.Path(), required=True)
123131
@verbose
124-
def explode_finalise(out_path, verbose):
132+
def explode_finalise(path, verbose):
125133
"""
126134
Final step for parallel conversion of VCF(s) to columnar intermediate format
127135
"""
128136
setup_logging(verbose)
129-
vcf.explode_finalise(out_path)
137+
vcf.explode_finalise(path)
130138

131139
@click.command
132140
@click.argument("if_path", type=click.Path())
@@ -248,6 +256,7 @@ def vcf2zarr():
248256
# TODO figure out how to get click to list these in the given order.
249257
vcf2zarr.add_command(explode)
250258
vcf2zarr.add_command(explode_init)
259+
vcf2zarr.add_command(explode_partition_count)
251260
vcf2zarr.add_command(explode_slice)
252261
vcf2zarr.add_command(explode_finalise)
253262
vcf2zarr.add_command(inspect)

bio2zarr/vcf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,10 @@ def explode_init(vcfs, out_path, *, num_partitions=1, worker_processes=1, show_p
11231123
show_progress=show_progress,
11241124
)
11251125

1126+
def explode_partition_count(out_path):
1127+
pcvcf = PickleChunkedVcf.load(out_path)
1128+
return pcvcf.num_partitions
1129+
11261130

11271131
def explode_slice(out_path, start, stop, *, worker_processes=1, show_progress=False, column_chunk_size=16):
11281132
pcvcf = PickleChunkedVcf.load(out_path)

0 commit comments

Comments
 (0)