diff --git a/gnomad_toolbox/filtering/variant.py b/gnomad_toolbox/filtering/variant.py index ec00bc7..0de3172 100644 --- a/gnomad_toolbox/filtering/variant.py +++ b/gnomad_toolbox/filtering/variant.py @@ -3,6 +3,7 @@ from typing import Optional, Union import hail as hl +from gnomad.utils.parse import parse_variant from gnomad.utils.reference_genome import get_reference_genome from gnomad_toolbox.load_data import _get_gnomad_release @@ -47,21 +48,8 @@ def get_single_variant( # Determine the reference genome build for the ht. build = get_reference_genome(ht.locus).name - # TODO: Move this to gnomad_methods. - # Parse the variant string if provided. - try: - if variant and ":" not in variant: - contig, position, ref, alt = variant.split("-") - if all([contig, position, ref, alt]): - variant = f"{contig}:{position}:{ref}:{alt}" - variant = hl.eval(hl.parse_variant(variant, reference_genome=build)) - except ValueError: - raise ValueError( - f"Invalid variant format: {variant}. Expected format: chr12-235245-A-C " - f"or chr12:235245:A:C" - ) - # Filter to the Locus of the variant of interest. + variant = parse_variant(variant, contig, position, ref, alt, build) ht = hl.filter_intervals( ht, [hl.interval(variant.locus, variant.locus, includes_end=True)] ) @@ -72,7 +60,8 @@ def get_single_variant( # Check if the variant exists. if ht.count() == 0: hl.utils.warning( - f"No variant found at {variant.locus} with alleles {variant.alleles}" + f"No variant found at {hl.eval(variant.locus)} with alleles " + f"{hl.eval(variant.alleles)}" ) return ht diff --git a/requirements.txt b/requirements.txt index 32706b5..702bdab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ # We're using the main branch of gnomad_method on github rather than the pip version +# TODO: Decide on how to handle this. We might just need to have more releases of gnomad_methods. git+https://github.com/broadinstitute/gnomad_methods@main hail jupyter diff --git a/setup.py b/setup.py index 8bc0d5d..78ab1cb 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/broadinstitute/gnomad-toolbox", - packages=setuptools.find_namespace_packages(include=["gnomad_toolbox.*"]), + packages=setuptools.find_namespace_packages(include=["gnomad_toolbox*"]), project_urls={ "Documentation": "https://broadinstitute.github.io/gnomad-toolbox/", "Source Code": "https://github.com/broadinstitute/gnomad-toolbox",