Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output option to vcztools view #66

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os.path
import pathlib

from tests.test_bcftools_validation import run_vcztools
from tests.utils import vcz_path_cache


def test_view_output(tmp_path):
vcf_path = pathlib.Path("tests/data/vcf/sample.vcf.gz")
vcz_path = vcz_path_cache(vcf_path)
output = tmp_path / "output.vcf"

run_vcztools(f"view {vcz_path} --output {output}")
assert os.path.exists(output)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you call assert_vcfs_close to check the output is correct?

Also, perhaps this should belong in test_bcftools_validation as you are using run_vcztools from there anyway?

6 changes: 5 additions & 1 deletion vcztools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def query(path, list_samples):

@click.command
@click.argument("path", type=click.Path())
@click.option(
"-o", "--output", type=str, default=None, help="File path to write output to."
)
@click.option(
"-h",
"--header-only",
Expand Down Expand Up @@ -92,6 +95,7 @@ def query(path, list_samples):
)
def view(
path,
output,
header_only,
no_header,
no_version,
Expand All @@ -103,7 +107,7 @@ def view(
):
vcf_writer.write_vcf(
path,
sys.stdout,
output,
header_only=header_only,
no_header=no_header,
variant_regions=regions,
Expand Down