From f9004cc1de682be66cb38d0cc17e93c650e7edfc Mon Sep 17 00:00:00 2001 From: Adam English Date: Mon, 8 Apr 2024 16:09:37 -0400 Subject: [PATCH] pr #209 functional tests passed. pylint wanted changes ``` % python repo_utils/pylint_maker.py ************* Module truvari.utils truvari/utils.py:448:0: C0305: Trailing newlines (trailing-newlines) truvari/utils.py:447:11: R1729: Use a generator instead 'any(os.path.exists(vcf_path + '.' + x) for x in vcf_index_ext)' (use-a-generator) ``` Updated `truvari/annotations/trf.py` to use the new method. Added the new method to api docs in `docs/api/truvari.rst` --- docs/api/truvari.rst | 4 ++++ truvari/annotations/trf.py | 2 +- truvari/utils.py | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/api/truvari.rst b/docs/api/truvari.rst index 5159989d..cf24217e 100644 --- a/docs/api/truvari.rst +++ b/docs/api/truvari.rst @@ -92,6 +92,10 @@ calc_hwe ^^^^^^^^ .. autofunction:: calc_hwe +check_vcf_index +^^^^^^^^^^^^^^^ +.. autofunction:: check_vcf_index + compress_index_vcf ^^^^^^^^^^^^^^^^^^ .. autofunction:: compress_index_vcf diff --git a/truvari/annotations/trf.py b/truvari/annotations/trf.py index 91a88362..274f4f99 100644 --- a/truvari/annotations/trf.py +++ b/truvari/annotations/trf.py @@ -633,7 +633,7 @@ def check_params(args): if not args.input.endswith((".vcf.gz", ".bcf.gz")): logging.error(f"{args.input} isn't compressed vcf") check_fail = True - if not os.path.exists(args.input + ".tbi") and not os.path.exists(args.input + ".csi"): + if not truvari.check_vcf_index(args.input): logging.error(f"{args.input}[.tbi|.csi] doesn't exit") check_fail = True if not args.repeats.endswith(".bed.gz"): diff --git a/truvari/utils.py b/truvari/utils.py index f6d7365a..e0772540 100644 --- a/truvari/utils.py +++ b/truvari/utils.py @@ -444,5 +444,4 @@ def check_vcf_index(vcf_path): Return true if an index file is found for the vcf """ vcf_index_ext = ['tbi','csi'] - return any([os.path.exists(vcf_path + '.' + x) for x in vcf_index_ext]) - + return any(os.path.exists(vcf_path + '.' + x) for x in vcf_index_ext)