Skip to content

Commit

Permalink
add test of chunked output
Browse files Browse the repository at this point in the history
  • Loading branch information
aryarm authored Dec 21, 2024
1 parent ade0eb1 commit 78ec92d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/commands/simgenotype.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ If speed is important, it's generally faster to use PGEN files than VCFs.
.. warning::
Writing PGEN files will require more memory than writing VCFs. The memory will depend on the number of simulated samples and variants.
You can reduce the memory required by this step by writing the variants in chunks. Just specify a ``--chunk-size`` value.
You can reduce the memory required for this step by writing the variants in chunks. Just specify a ``--chunk-size`` value.

All files used in these examples are described :doc:`here </project_info/example_files>`.

Expand Down
35 changes: 35 additions & 0 deletions tests/test_simgenotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,38 @@ def test_pgen_output(capfd):
prefix.unlink()
prefix.with_suffix(".pvar").unlink()
prefix.with_suffix(".psam").unlink()


def test_pgen_output_chunked(capfd):
prefix = DATADIR / "example_simgenotype.pgen"
dat_file = DATADIR / "outvcf_gen.dat"
map_dir = DATADIR / "map"
ref_vcf_file = DATADIR / "outvcf_test.pgen"
samp_info_file = DATADIR / "outvcf_info.tab"

cmd = " ".join(
[
"simgenotype",
f"--model {dat_file}",
f"--mapdir {map_dir}",
"--region 1:1-83000",
f"--ref_vcf {ref_vcf_file}",
f"--sample_info {samp_info_file}",
f"--out {prefix}",
f"--chunk-size 1"
]
)
runner = CliRunner()
result = runner.invoke(main, cmd.split(" "), catch_exceptions=False)
captured = capfd.readouterr()
assert result.exit_code == 0
assert prefix.with_suffix(".bp").exists()
assert prefix.exists()
assert prefix.with_suffix(".pvar").exists()
assert prefix.with_suffix(".psam").exists()

# delete the files and directory we just created
prefix.with_suffix(".bp").unlink()
prefix.unlink()
prefix.with_suffix(".pvar").unlink()
prefix.with_suffix(".psam").unlink()

0 comments on commit 78ec92d

Please sign in to comment.