Skip to content

Commit

Permalink
feat(cli.vcf2parquet): format string is controlable
Browse files Browse the repository at this point in the history
  • Loading branch information
natir committed Apr 27, 2023
1 parent 92e2261 commit 8f178c7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
17 changes: 15 additions & 2 deletions src/variantplaner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,20 @@ def main(threads: int = 1, verbose: int = 0) -> None:
help="Path where the genotypes will be written in parquet",
type=click.Path(dir_okay=False, writable=True, path_type=pathlib.Path),
)
def vcf2parquet(input_path: pathlib.Path, variants: pathlib.Path, genotypes: pathlib.Path) -> None:
@click.option(
"-f",
"--format-string",
help="Value of FORMAT column, line not match with this are ignored",
type=str,
default="GT:AD:DP:GQ",
show_default=True,
)
def vcf2parquet(
input_path: pathlib.Path,
variants: pathlib.Path,
genotypes: pathlib.Path,
format_string: str = "GT:AD:DP:GQ",
) -> None:
"""Convert a vcf in parquet."""
logger = logging.getLogger("vcf2parquet")

Expand All @@ -89,7 +102,7 @@ def vcf2parquet(input_path: pathlib.Path, variants: pathlib.Path, genotypes: pat
if genotypes:
try:
vcf_header = io.vcf.extract_header(input_path)
extract.genotypes(lf, io.vcf.format2expr(vcf_header, input_path), "GT:AD:DP:GQ").sink_parquet(genotypes)
extract.genotypes(lf, io.vcf.format2expr(vcf_header, input_path), format_string).sink_parquet(genotypes)
except exception.NoGenotypeError:
logger.exception("")
sys.exit(2)
Expand Down
12 changes: 7 additions & 5 deletions tests/test_cli_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ def test_show_help_vcf2parquet() -> None:
Convert a vcf in parquet.
Options:
-i, --input-path FILE Path to vcf input file [required]
-v, --variants FILE Path where the variants will be written in parquet
[required]
-g, --genotypes FILE Path where the genotypes will be written in parquet
--help Show this message and exit.
-i, --input-path FILE Path to vcf input file [required]
-v, --variants FILE Path where the variants will be written in parquet
[required]
-g, --genotypes FILE Path where the genotypes will be written in parquet
-f, --format-string TEXT Value of FORMAT column, line not match with this are
ignored [default: GT:AD:DP:GQ]
--help Show this message and exit.
"""
)

Expand Down

0 comments on commit 8f178c7

Please sign in to comment.