Skip to content
Snippets Groups Projects
Commit 7b50bc24 authored by van den Berg's avatar van den Berg
Browse files

Make sure the parent output folder exists

Also update the argparse help text for the --discordant-vcf flag to
refer to a regular VCF file, instead of a gzipped VCF file.
parent e6309163
No related branches found
No related tags found
No related merge requests found
Pipeline #2903 failed
......@@ -6,6 +6,7 @@ vtools.cli
:copyright: (c) Leiden University Medical Center
:license: MIT
"""
import os
import json
import click
from cyvcf2 import VCF, Writer
......@@ -35,7 +36,7 @@ from .gcoverage import RefRecord, region_coverages
@click.option("-s", "--stats", type=click.Path(writable=True),
help="Path to output stats json file")
@click.option("-dvcf", "--discordant-vcf", type=click.Path(writable=True),
help="Path to output gzipped discordant vcf file",
help="Path to output the discordant vcf file",
required=False)
@click.option("-mq", "--min-qual", type=float,
help="Minimum quality of variants to consider", default=30)
......@@ -56,6 +57,10 @@ def evaluate_cli(call_vcf, positive_vcf, call_samples, positive_samples,
# If there were discordand records, and a discordant-vcf should be written
if len(disc) > 0 and discordant_vcf:
# make sure the parent folder exists
parent_folder = os.path.dirname(discordant_vcf)
os.makedirs(parent_folder, exist_ok=True)
with click.open_file(discordant_vcf, 'w') as fout:
# First, we write the vcf header
with gzip.open(call_vcf, 'rt') as fin:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment