sgkit-dev / vcztools

Partial reimplementation of bcftools for VCF Zarr
Apache License 2.0
3 stars 3 forks source link

vcztools view: allow writing to /dev/null #92

Open Will-Tyler opened 1 day ago

Will-Tyler commented 1 day ago

Description

vcztools checks that the output file has a .vcf extension. This prevents the user from writing the output to /dev/null. vcztools should allow writing to /dev/null.

Example

vcztools view performance/data/chr22.vcz -o /dev/null
Traceback (most recent call last):
  File "/opt/miniconda3/envs/vcztools/bin/vcztools", line 8, in <module>
    sys.exit(vcztools_main())
  File "/opt/miniconda3/envs/vcztools/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/opt/miniconda3/envs/vcztools/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/opt/miniconda3/envs/vcztools/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/miniconda3/envs/vcztools/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/miniconda3/envs/vcztools/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/willtyler/Desktop/vcztools/vcztools/cli.py", line 156, in view
    raise ValueError(f"Output file extension must be .vcf, got: .{split[-1]}")
ValueError: Output file extension must be .vcf, got: ./dev/null
jeromekelleher commented 1 day ago

You could just redirect the output to dev null? It never occurred to me to open it as a file tbh

Will-Tyler commented 1 day ago

I think doing -o /dev/null allows Python to print debug messages and that would not work with input redirection.

Or when I was profiling, I wanted to do python -m cProfile vcztools view performance/data/chr22.vcz -o /dev/null. I think input redirection would prevent me from seeing the profiling output.