Skip to content

Commit 6708eb1

Browse files
jeromekelleherbenjeffery
authored andcommitted
Rename icf module to vcf
1 parent 598c95f commit 6708eb1

8 files changed

+192
-186
lines changed

bio2zarr/cli.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import numcodecs
99
import tabulate
1010

11-
from . import icf as icf_mod
1211
from . import plink, provenance, vcf_utils
12+
from . import vcf as vcf_mod
1313

1414
logger = logging.getLogger(__name__)
1515

@@ -197,7 +197,7 @@ def check_partitions(num_partitions):
197197
def get_compressor(cname):
198198
if cname is None:
199199
return None
200-
config = icf_mod.ICF_DEFAULT_COMPRESSOR.get_config()
200+
config = vcf_mod.ICF_DEFAULT_COMPRESSOR.get_config()
201201
config["cname"] = cname
202202
return numcodecs.get_codec(config)
203203

@@ -236,7 +236,7 @@ def explode(
236236
"""
237237
setup_logging(verbose)
238238
check_overwrite_dir(icf_path, force)
239-
icf_mod.explode(
239+
vcf_mod.explode(
240240
icf_path,
241241
vcfs,
242242
worker_processes=worker_processes,
@@ -276,7 +276,7 @@ def dexplode_init(
276276
setup_logging(verbose)
277277
check_overwrite_dir(icf_path, force)
278278
check_partitions(num_partitions)
279-
work_summary = icf_mod.explode_init(
279+
work_summary = vcf_mod.explode_init(
280280
icf_path,
281281
vcfs,
282282
target_num_partitions=num_partitions,
@@ -304,7 +304,7 @@ def dexplode_partition(icf_path, partition, verbose, one_based):
304304
setup_logging(verbose)
305305
if one_based:
306306
partition -= 1
307-
icf_mod.explode_partition(icf_path, partition)
307+
vcf_mod.explode_partition(icf_path, partition)
308308

309309

310310
@click.command
@@ -315,7 +315,7 @@ def dexplode_finalise(icf_path, verbose):
315315
Final step for distributed conversion of VCF(s) to intermediate columnar format.
316316
"""
317317
setup_logging(verbose)
318-
icf_mod.explode_finalise(icf_path)
318+
vcf_mod.explode_finalise(icf_path)
319319

320320

321321
@click.command
@@ -326,7 +326,7 @@ def inspect(path, verbose):
326326
Inspect an intermediate columnar format or Zarr path.
327327
"""
328328
setup_logging(verbose)
329-
data = icf_mod.inspect(path)
329+
data = vcf_mod.inspect(path)
330330
click.echo(tabulate.tabulate(data, headers="keys"))
331331

332332

@@ -345,7 +345,7 @@ def mkschema(icf_path, variants_chunk_size, samples_chunk_size, local_alleles):
345345
err=True,
346346
)
347347
stream = click.get_text_stream("stdout")
348-
icf_mod.mkschema(
348+
vcf_mod.mkschema(
349349
icf_path,
350350
stream,
351351
variants_chunk_size=variants_chunk_size,
@@ -384,7 +384,7 @@ def encode(
384384
"""
385385
setup_logging(verbose)
386386
check_overwrite_dir(zarr_path, force)
387-
icf_mod.encode(
387+
vcf_mod.encode(
388388
icf_path,
389389
zarr_path,
390390
schema_path=schema,
@@ -438,7 +438,7 @@ def dencode_init(
438438
setup_logging(verbose)
439439
check_overwrite_dir(zarr_path, force)
440440
check_partitions(num_partitions)
441-
work_summary = icf_mod.encode_init(
441+
work_summary = vcf_mod.encode_init(
442442
icf_path,
443443
zarr_path,
444444
target_num_partitions=num_partitions,
@@ -466,7 +466,7 @@ def dencode_partition(zarr_path, partition, verbose, one_based):
466466
setup_logging(verbose)
467467
if one_based:
468468
partition -= 1
469-
icf_mod.encode_partition(zarr_path, partition)
469+
vcf_mod.encode_partition(zarr_path, partition)
470470

471471

472472
@click.command
@@ -478,7 +478,7 @@ def dencode_finalise(zarr_path, verbose, progress):
478478
Final step for distributed conversion of ICF to VCF Zarr.
479479
"""
480480
setup_logging(verbose)
481-
icf_mod.encode_finalise(zarr_path, show_progress=progress)
481+
vcf_mod.encode_finalise(zarr_path, show_progress=progress)
482482

483483

484484
@click.command(name="convert")
@@ -507,7 +507,7 @@ def convert_vcf(
507507
"""
508508
setup_logging(verbose)
509509
check_overwrite_dir(zarr_path, force)
510-
icf_mod.convert(
510+
vcf_mod.convert(
511511
vcfs,
512512
zarr_path,
513513
variants_chunk_size=variants_chunk_size,
File renamed without changes.

tests/test_cli.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class TestWithMocks:
8484
vcf_path = "tests/data/vcf/sample.vcf.gz"
8585

8686
@pytest.mark.parametrize(("progress", "flag"), [(True, "-P"), (False, "-Q")])
87-
@mock.patch("bio2zarr.icf.explode")
87+
@mock.patch("bio2zarr.vcf.explode")
8888
def test_vcf_explode(self, mocked, tmp_path, progress, flag):
8989
icf_path = tmp_path / "icf"
9090
runner = ct.CliRunner(mix_stderr=False)
@@ -101,7 +101,7 @@ def test_vcf_explode(self, mocked, tmp_path, progress, flag):
101101
mocked.assert_called_once_with(str(icf_path), (self.vcf_path,), **args)
102102

103103
@pytest.mark.parametrize("compressor", ["lz4", "zstd"])
104-
@mock.patch("bio2zarr.icf.explode")
104+
@mock.patch("bio2zarr.vcf.explode")
105105
def test_vcf_explode_compressor(self, mocked, tmp_path, compressor):
106106
icf_path = tmp_path / "icf"
107107
runner = ct.CliRunner(mix_stderr=False)
@@ -124,7 +124,7 @@ def test_vcf_explode_compressor(self, mocked, tmp_path, compressor):
124124
)
125125

126126
@pytest.mark.parametrize("compressor", ["lz4", "zstd"])
127-
@mock.patch("bio2zarr.icf.explode_init")
127+
@mock.patch("bio2zarr.vcf.explode_init")
128128
def test_vcf_dexplode_init_compressor(self, mocked, tmp_path, compressor):
129129
icf_path = tmp_path / "icf"
130130
runner = ct.CliRunner(mix_stderr=False)
@@ -148,7 +148,7 @@ def test_vcf_dexplode_init_compressor(self, mocked, tmp_path, compressor):
148148
)
149149

150150
@pytest.mark.parametrize("compressor", ["LZ4", "asdf"])
151-
@mock.patch("bio2zarr.icf.explode")
151+
@mock.patch("bio2zarr.vcf.explode")
152152
def test_vcf_explode_bad_compressor(self, mocked, tmp_path, compressor):
153153
runner = ct.CliRunner(mix_stderr=False)
154154
icf_path = tmp_path / "icf"
@@ -161,7 +161,7 @@ def test_vcf_explode_bad_compressor(self, mocked, tmp_path, compressor):
161161
assert "Invalid value for '-C'" in result.stderr
162162
mocked.assert_not_called()
163163

164-
@mock.patch("bio2zarr.icf.explode")
164+
@mock.patch("bio2zarr.vcf.explode")
165165
def test_vcf_explode_multiple_vcfs(self, mocked, tmp_path):
166166
icf_path = tmp_path / "icf"
167167
runner = ct.CliRunner(mix_stderr=False)
@@ -178,7 +178,7 @@ def test_vcf_explode_multiple_vcfs(self, mocked, tmp_path):
178178
)
179179

180180
@pytest.mark.parametrize("response", ["y", "Y", "yes"])
181-
@mock.patch("bio2zarr.icf.explode")
181+
@mock.patch("bio2zarr.vcf.explode")
182182
def test_vcf_explode_overwrite_icf_confirm_yes(self, mocked, tmp_path, response):
183183
icf_path = tmp_path / "icf"
184184
icf_path.mkdir()
@@ -197,7 +197,7 @@ def test_vcf_explode_overwrite_icf_confirm_yes(self, mocked, tmp_path, response)
197197
)
198198

199199
@pytest.mark.parametrize("response", ["y", "Y", "yes"])
200-
@mock.patch("bio2zarr.icf.encode")
200+
@mock.patch("bio2zarr.vcf.encode")
201201
def test_vcf_encode_overwrite_zarr_confirm_yes(self, mocked, tmp_path, response):
202202
icf_path = tmp_path / "icf"
203203
icf_path.mkdir()
@@ -218,7 +218,7 @@ def test_vcf_encode_overwrite_zarr_confirm_yes(self, mocked, tmp_path, response)
218218
)
219219

220220
@pytest.mark.parametrize("force_arg", ["-f", "--force"])
221-
@mock.patch("bio2zarr.icf.explode")
221+
@mock.patch("bio2zarr.vcf.explode")
222222
def test_vcf_explode_overwrite_icf_force(self, mocked, tmp_path, force_arg):
223223
icf_path = tmp_path / "icf"
224224
icf_path.mkdir()
@@ -236,7 +236,7 @@ def test_vcf_explode_overwrite_icf_force(self, mocked, tmp_path, force_arg):
236236
)
237237

238238
@pytest.mark.parametrize("force_arg", ["-f", "--force"])
239-
@mock.patch("bio2zarr.icf.encode")
239+
@mock.patch("bio2zarr.vcf.encode")
240240
def test_vcf_encode_overwrite_icf_force(self, mocked, tmp_path, force_arg):
241241
icf_path = tmp_path / "icf"
242242
icf_path.mkdir()
@@ -257,7 +257,7 @@ def test_vcf_encode_overwrite_icf_force(self, mocked, tmp_path, force_arg):
257257
**DEFAULT_ENCODE_ARGS,
258258
)
259259

260-
@mock.patch("bio2zarr.icf.explode")
260+
@mock.patch("bio2zarr.vcf.explode")
261261
def test_vcf_explode_missing_vcf(self, mocked, tmp_path):
262262
icf_path = tmp_path / "icf"
263263
runner = ct.CliRunner(mix_stderr=False)
@@ -272,7 +272,7 @@ def test_vcf_explode_missing_vcf(self, mocked, tmp_path):
272272
mocked.assert_not_called()
273273

274274
@pytest.mark.parametrize("response", ["n", "N", "No"])
275-
@mock.patch("bio2zarr.icf.explode")
275+
@mock.patch("bio2zarr.vcf.explode")
276276
def test_vcf_explode_overwrite_icf_confirm_no(self, mocked, tmp_path, response):
277277
icf_path = tmp_path / "icf"
278278
icf_path.mkdir()
@@ -287,7 +287,7 @@ def test_vcf_explode_overwrite_icf_confirm_no(self, mocked, tmp_path, response):
287287
assert "Aborted" in result.stderr
288288
mocked.assert_not_called()
289289

290-
@mock.patch("bio2zarr.icf.explode")
290+
@mock.patch("bio2zarr.vcf.explode")
291291
def test_vcf_explode_missing_and_existing_vcf(self, mocked, tmp_path):
292292
icf_path = tmp_path / "icf"
293293
runner = ct.CliRunner(mix_stderr=False)
@@ -302,7 +302,7 @@ def test_vcf_explode_missing_and_existing_vcf(self, mocked, tmp_path):
302302
mocked.assert_not_called()
303303

304304
@pytest.mark.parametrize(("progress", "flag"), [(True, "-P"), (False, "-Q")])
305-
@mock.patch("bio2zarr.icf.explode_init", return_value=FakeWorkSummary(5))
305+
@mock.patch("bio2zarr.vcf.explode_init", return_value=FakeWorkSummary(5))
306306
def test_vcf_dexplode_init(self, mocked, tmp_path, progress, flag):
307307
runner = ct.CliRunner(mix_stderr=False)
308308
icf_path = tmp_path / "icf"
@@ -324,7 +324,7 @@ def test_vcf_dexplode_init(self, mocked, tmp_path, progress, flag):
324324
)
325325

326326
@pytest.mark.parametrize("num_partitions", ["-1", "0", "asdf", "1.112"])
327-
@mock.patch("bio2zarr.icf.explode_init", return_value=5)
327+
@mock.patch("bio2zarr.vcf.explode_init", return_value=5)
328328
def test_vcf_dexplode_init_bad_num_partitions(
329329
self, mocked, tmp_path, num_partitions
330330
):
@@ -339,7 +339,7 @@ def test_vcf_dexplode_init_bad_num_partitions(
339339
assert "Invalid value for '-n'" in result.stderr
340340
mocked.assert_not_called()
341341

342-
@mock.patch("bio2zarr.icf.explode_init", return_value=5)
342+
@mock.patch("bio2zarr.vcf.explode_init", return_value=5)
343343
def test_vcf_dexplode_init_no_partitions(self, mocked, tmp_path):
344344
runner = ct.CliRunner(mix_stderr=False)
345345
icf_path = tmp_path / "icf"
@@ -352,7 +352,7 @@ def test_vcf_dexplode_init_no_partitions(self, mocked, tmp_path):
352352
assert "-n/--num-partitions must currently be specified" in result.stderr
353353
mocked.assert_not_called()
354354

355-
@mock.patch("bio2zarr.icf.explode_partition")
355+
@mock.patch("bio2zarr.vcf.explode_partition")
356356
def test_vcf_dexplode_partition(self, mocked, tmp_path):
357357
runner = ct.CliRunner(mix_stderr=False)
358358
icf_path = tmp_path / "icf"
@@ -369,7 +369,7 @@ def test_vcf_dexplode_partition(self, mocked, tmp_path):
369369
str(icf_path), 1, **DEFAULT_DEXPLODE_PARTITION_ARGS
370370
)
371371

372-
@mock.patch("bio2zarr.icf.explode_partition")
372+
@mock.patch("bio2zarr.vcf.explode_partition")
373373
def test_vcf_dexplode_partition_one_based(self, mocked, tmp_path):
374374
runner = ct.CliRunner(mix_stderr=False)
375375
icf_path = tmp_path / "icf"
@@ -386,7 +386,7 @@ def test_vcf_dexplode_partition_one_based(self, mocked, tmp_path):
386386
str(icf_path), 0, **DEFAULT_DEXPLODE_PARTITION_ARGS
387387
)
388388

389-
@mock.patch("bio2zarr.icf.explode_partition")
389+
@mock.patch("bio2zarr.vcf.explode_partition")
390390
def test_vcf_dexplode_partition_missing_dir(self, mocked, tmp_path):
391391
runner = ct.CliRunner(mix_stderr=False)
392392
icf_path = tmp_path / "icf"
@@ -401,7 +401,7 @@ def test_vcf_dexplode_partition_missing_dir(self, mocked, tmp_path):
401401
mocked.assert_not_called()
402402

403403
@pytest.mark.parametrize("partition", ["-- -1", "asdf", "1.112"])
404-
@mock.patch("bio2zarr.icf.explode_partition")
404+
@mock.patch("bio2zarr.vcf.explode_partition")
405405
def test_vcf_dexplode_partition_bad_partition(self, mocked, tmp_path, partition):
406406
runner = ct.CliRunner(mix_stderr=False)
407407
icf_path = tmp_path / "icf"
@@ -416,7 +416,7 @@ def test_vcf_dexplode_partition_bad_partition(self, mocked, tmp_path, partition)
416416
assert len(result.stdout) == 0
417417
mocked.assert_not_called()
418418

419-
@mock.patch("bio2zarr.icf.explode_finalise")
419+
@mock.patch("bio2zarr.vcf.explode_finalise")
420420
def test_vcf_dexplode_finalise(self, mocked, tmp_path):
421421
runner = ct.CliRunner(mix_stderr=False)
422422
result = runner.invoke(
@@ -427,7 +427,7 @@ def test_vcf_dexplode_finalise(self, mocked, tmp_path):
427427
assert len(result.stderr) == 0
428428
mocked.assert_called_once_with(str(tmp_path))
429429

430-
@mock.patch("bio2zarr.icf.inspect")
430+
@mock.patch("bio2zarr.vcf.inspect")
431431
def test_inspect(self, mocked, tmp_path):
432432
runner = ct.CliRunner(mix_stderr=False)
433433
result = runner.invoke(
@@ -438,7 +438,7 @@ def test_inspect(self, mocked, tmp_path):
438438
assert len(result.stderr) == 0
439439
mocked.assert_called_once_with(str(tmp_path))
440440

441-
@mock.patch("bio2zarr.icf.mkschema")
441+
@mock.patch("bio2zarr.vcf.mkschema")
442442
def test_mkschema(self, mocked, tmp_path):
443443
runner = ct.CliRunner(mix_stderr=False)
444444
result = runner.invoke(
@@ -455,7 +455,7 @@ def test_mkschema(self, mocked, tmp_path):
455455
mocked.assert_called_once()
456456

457457
@pytest.mark.parametrize(("progress", "flag"), [(True, "-P"), (False, "-Q")])
458-
@mock.patch("bio2zarr.icf.encode")
458+
@mock.patch("bio2zarr.vcf.encode")
459459
def test_encode(self, mocked, tmp_path, progress, flag):
460460
icf_path = tmp_path / "icf"
461461
icf_path.mkdir()
@@ -478,7 +478,7 @@ def test_encode(self, mocked, tmp_path, progress, flag):
478478
)
479479

480480
@pytest.mark.parametrize(("progress", "flag"), [(True, "-P"), (False, "-Q")])
481-
@mock.patch("bio2zarr.icf.encode_init", return_value=FakeWorkSummary(10))
481+
@mock.patch("bio2zarr.vcf.encode_init", return_value=FakeWorkSummary(10))
482482
def test_dencode_init(self, mocked, tmp_path, progress, flag):
483483
icf_path = tmp_path / "icf"
484484
icf_path.mkdir()
@@ -501,7 +501,7 @@ def test_dencode_init(self, mocked, tmp_path, progress, flag):
501501
**args,
502502
)
503503

504-
@mock.patch("bio2zarr.icf.encode_init", return_value=5)
504+
@mock.patch("bio2zarr.vcf.encode_init", return_value=5)
505505
def test_vcf_dencode_init_no_partitions(self, mocked, tmp_path):
506506
runner = ct.CliRunner(mix_stderr=False)
507507
icf_path = tmp_path / "icf"
@@ -516,7 +516,7 @@ def test_vcf_dencode_init_no_partitions(self, mocked, tmp_path):
516516
assert "-n/--num-partitions must currently be specified" in result.stderr
517517
mocked.assert_not_called()
518518

519-
@mock.patch("bio2zarr.icf.encode_partition")
519+
@mock.patch("bio2zarr.vcf.encode_partition")
520520
def test_vcf_dencode_partition(self, mocked, tmp_path):
521521
runner = ct.CliRunner(mix_stderr=False)
522522
zarr_path = tmp_path / "zarr"
@@ -533,7 +533,7 @@ def test_vcf_dencode_partition(self, mocked, tmp_path):
533533
str(zarr_path), 1, **DEFAULT_DENCODE_PARTITION_ARGS
534534
)
535535

536-
@mock.patch("bio2zarr.icf.encode_partition")
536+
@mock.patch("bio2zarr.vcf.encode_partition")
537537
def test_vcf_dencode_partition_one_based(self, mocked, tmp_path):
538538
runner = ct.CliRunner(mix_stderr=False)
539539
zarr_path = tmp_path / "zarr"
@@ -551,7 +551,7 @@ def test_vcf_dencode_partition_one_based(self, mocked, tmp_path):
551551
)
552552

553553
@pytest.mark.parametrize(("progress", "flag"), [(True, "-P"), (False, "-Q")])
554-
@mock.patch("bio2zarr.icf.encode_finalise")
554+
@mock.patch("bio2zarr.vcf.encode_finalise")
555555
def test_vcf_dencode_finalise(self, mocked, tmp_path, progress, flag):
556556
runner = ct.CliRunner(mix_stderr=False)
557557
result = runner.invoke(
@@ -567,7 +567,7 @@ def test_vcf_dencode_finalise(self, mocked, tmp_path, progress, flag):
567567
mocked.assert_called_once_with(str(tmp_path), **args)
568568

569569
@pytest.mark.parametrize(("progress", "flag"), [(True, "-P"), (False, "-Q")])
570-
@mock.patch("bio2zarr.icf.convert")
570+
@mock.patch("bio2zarr.vcf.convert")
571571
def test_convert_vcf(self, mocked, progress, flag):
572572
runner = ct.CliRunner(mix_stderr=False)
573573
result = runner.invoke(
@@ -587,7 +587,7 @@ def test_convert_vcf(self, mocked, progress, flag):
587587
)
588588

589589
@pytest.mark.parametrize("response", ["n", "N", "No"])
590-
@mock.patch("bio2zarr.icf.convert")
590+
@mock.patch("bio2zarr.vcf.convert")
591591
def test_vcf_convert_overwrite_zarr_confirm_no(self, mocked, tmp_path, response):
592592
zarr_path = tmp_path / "zarr"
593593
zarr_path.mkdir()
@@ -617,7 +617,7 @@ def test_convert_plink(self, mocked, progress, flag):
617617
mocked.assert_called_once_with("in", "out", **args)
618618

619619
@pytest.mark.parametrize("response", ["y", "Y", "yes"])
620-
@mock.patch("bio2zarr.icf.convert")
620+
@mock.patch("bio2zarr.vcf.convert")
621621
def test_vcf_convert_overwrite_zarr_confirm_yes(self, mocked, tmp_path, response):
622622
zarr_path = tmp_path / "zarr"
623623
zarr_path.mkdir()

0 commit comments

Comments
 (0)