From fa65984e019b57be2ebbd85fe6d5801d50dcd8f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 17:59:16 +0000 Subject: [PATCH 1/3] Bump black from 23.7.0 to 24.3.0 Bumps [black](https://github.com/psf/black) from 23.7.0 to 24.3.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/23.7.0...24.3.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- requirements-dev.in | 2 +- requirements-dev.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-dev.in b/requirements-dev.in index b8d3e217e..1f521b7c5 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -1,7 +1,7 @@ # Used to create the requirements-dev.txt file # Note: `pip-compile requirements-dev.in` needs to be run before changes in requirements-dev.in are reflected in # requirements-dev.txt, which is used for GitHub Actions -black==23.7.0 # This should be kept in sync with the version in .pre-commit-config.yaml +black==24.3.0 # This should be kept in sync with the version in .pre-commit-config.yaml isort==5.12.0 # This should be kept in sync with the version in .pre-commit-config.yaml autopep8==2.0.2 # This should be kept in sync with the version in .pre-commit-config.yaml pre-commit diff --git a/requirements-dev.txt b/requirements-dev.txt index 03f0b2ced..7c14a0da0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,7 +8,7 @@ astroid==3.0.1 # via pylint autopep8==2.0.2 # via -r requirements-dev.in -black==23.7.0 +black==24.3.0 # via -r requirements-dev.in cfgv==3.4.0 # via pre-commit From 7e44e1e52a3df16ec29fd79c90badc3fa1fa6894 Mon Sep 17 00:00:00 2001 From: KoalaQin Date: Mon, 8 Apr 2024 11:39:18 -0400 Subject: [PATCH 2/3] Reformat 9 files with Black 24.3.0 --- gnomad/sample_qc/relatedness.py | 2 +- gnomad/utils/constraint.py | 4 ++-- gnomad/utils/filtering.py | 6 +++--- gnomad/utils/liftover.py | 2 +- gnomad/utils/sparse_mt.py | 2 +- gnomad/utils/transcript_annotation.py | 1 + 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gnomad/sample_qc/relatedness.py b/gnomad/sample_qc/relatedness.py index 1a0be1669..3d402ed40 100644 --- a/gnomad/sample_qc/relatedness.py +++ b/gnomad/sample_qc/relatedness.py @@ -411,7 +411,7 @@ def infer_families( """ def group_parent_child_pairs_by_fam( - parent_child_pairs: Iterable[Tuple[str, str]] + parent_child_pairs: Iterable[Tuple[str, str]], ) -> List[List[Tuple[str, str]]]: """ Group parent-child pairs into a list of families. diff --git a/gnomad/utils/constraint.py b/gnomad/utils/constraint.py index 178a3afdf..78e1b9035 100644 --- a/gnomad/utils/constraint.py +++ b/gnomad/utils/constraint.py @@ -409,7 +409,7 @@ def annotate_mutation_type( def trimer_from_heptamer( - t: Union[hl.MatrixTable, hl.Table] + t: Union[hl.MatrixTable, hl.Table], ) -> Union[hl.MatrixTable, hl.Table]: """ Trim heptamer context to create trimer context. @@ -426,7 +426,7 @@ def trimer_from_heptamer( def collapse_strand( - t: Union[hl.Table, hl.MatrixTable] + t: Union[hl.Table, hl.MatrixTable], ) -> Union[hl.Table, hl.MatrixTable]: """ Return the deduplicated context by collapsing DNA strands. diff --git a/gnomad/utils/filtering.py b/gnomad/utils/filtering.py index 21b52dffe..62049e791 100644 --- a/gnomad/utils/filtering.py +++ b/gnomad/utils/filtering.py @@ -197,7 +197,7 @@ def filter_low_conf_regions( def filter_to_autosomes( - t: Union[hl.MatrixTable, hl.Table] + t: Union[hl.MatrixTable, hl.Table], ) -> Union[hl.MatrixTable, hl.Table]: """ Filter the Table or MatrixTable to autosomes only. @@ -470,7 +470,7 @@ def remove_fields_from_constant( def filter_x_nonpar( - t: Union[hl.Table, hl.MatrixTable] + t: Union[hl.Table, hl.MatrixTable], ) -> Union[hl.Table, hl.MatrixTable]: """ Filter to loci that are in non-PAR regions on chromosome X. @@ -496,7 +496,7 @@ def filter_x_nonpar( def filter_y_nonpar( - t: Union[hl.Table, hl.MatrixTable] + t: Union[hl.Table, hl.MatrixTable], ) -> Union[hl.Table, hl.MatrixTable]: """ Filter to loci that are in non-PAR regions on chromosome Y. diff --git a/gnomad/utils/liftover.py b/gnomad/utils/liftover.py index 45282ddc4..809c6259c 100644 --- a/gnomad/utils/liftover.py +++ b/gnomad/utils/liftover.py @@ -27,7 +27,7 @@ def get_liftover_genome( - t: Union[hl.MatrixTable, hl.Table] + t: Union[hl.MatrixTable, hl.Table], ) -> Tuple[hl.genetics.ReferenceGenome, hl.genetics.ReferenceGenome]: """ Infer reference genome build of input data and assume destination reference genome build. diff --git a/gnomad/utils/sparse_mt.py b/gnomad/utils/sparse_mt.py index ddf6fe1e0..8ba579867 100644 --- a/gnomad/utils/sparse_mt.py +++ b/gnomad/utils/sparse_mt.py @@ -1390,7 +1390,7 @@ def compute_allele_number_per_ref_site( def filter_ref_blocks( - t: Union[hl.MatrixTable, hl.Table] + t: Union[hl.MatrixTable, hl.Table], ) -> Union[hl.MatrixTable, hl.Table]: """ Filter ref blocks out of the Table or MatrixTable. diff --git a/gnomad/utils/transcript_annotation.py b/gnomad/utils/transcript_annotation.py index 8300455ed..b88e6abab 100644 --- a/gnomad/utils/transcript_annotation.py +++ b/gnomad/utils/transcript_annotation.py @@ -1,4 +1,5 @@ """Utils module containing generic functions that are useful for adding transcript expression-aware annotations.""" + import logging from typing import Callable, List, Optional, Tuple, Union From 277ca377ed1d3bb26eb6d7c9b13f613b1e586429 Mon Sep 17 00:00:00 2001 From: KoalaQin Date: Mon, 8 Apr 2024 11:59:40 -0400 Subject: [PATCH 3/3] Update Black in pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- gnomad/resources/grch37/gnomad_ld.py | 16 ++++------------ gnomad/sample_qc/filtering.py | 3 ++- gnomad/utils/sparse_mt.py | 13 ++++++------- gnomad/utils/vep.py | 9 ++++++--- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 02e9788f7..22ca75faa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.7.0 # This should be kept in sync with the version in requirements-dev.in + rev: 24.3.0 # This should be kept in sync with the version in requirements-dev.in hooks: - id: black language_version: python3 diff --git a/gnomad/resources/grch37/gnomad_ld.py b/gnomad/resources/grch37/gnomad_ld.py index 3b933f5b5..04442b636 100644 --- a/gnomad/resources/grch37/gnomad_ld.py +++ b/gnomad/resources/grch37/gnomad_ld.py @@ -21,9 +21,7 @@ def _ld_matrix_path( CURRENT_EXOME_RELEASE if data_type == "exomes" else CURRENT_GENOME_RELEASE ) subdir = "sv/" if data_type == "genomes_snv_sv" else "" - return ( - f'gs://gnomad-public-requester-pays/release/{version}/ld/{subdir}gnomad.{data_type}.r{version}.{pop}.{"common." if common_only else ""}{"adj." if adj else ""}ld.bm' - ) + return f'gs://gnomad-public-requester-pays/release/{version}/ld/{subdir}gnomad.{data_type}.r{version}.{pop}.{"common." if common_only else ""}{"adj." if adj else ""}ld.bm' def _ld_index_path( @@ -38,9 +36,7 @@ def _ld_index_path( CURRENT_EXOME_RELEASE if data_type == "exomes" else CURRENT_GENOME_RELEASE ) subdir = "sv/" if data_type == "genomes_snv_sv" else "" - return ( - f'gs://gnomad-public-requester-pays/release/{version}/ld/{subdir}gnomad.{data_type}.r{version}.{pop}.{"common." if common_only else ""}{"adj." if adj else ""}ld.variant_indices.ht' - ) + return f'gs://gnomad-public-requester-pays/release/{version}/ld/{subdir}gnomad.{data_type}.r{version}.{pop}.{"common." if common_only else ""}{"adj." if adj else ""}ld.variant_indices.ht' def _ld_snv_sv_path(pop): @@ -62,9 +58,7 @@ def _cross_pop_ld_scores_path( version = ( CURRENT_EXOME_RELEASE if data_type == "exomes" else CURRENT_GENOME_RELEASE ) - return ( - f'gs://gnomad-public-requester-pays/release/{version}/ld/scores/gnomad.{data_type}.r{version}.{pop1}.{pop2}.{"adj." if adj else ""}ld_scores.ht' - ) + return f'gs://gnomad-public-requester-pays/release/{version}/ld/scores/gnomad.{data_type}.r{version}.{pop1}.{pop2}.{"adj." if adj else ""}ld_scores.ht' def _ld_scores_path( @@ -74,9 +68,7 @@ def _ld_scores_path( version = ( CURRENT_EXOME_RELEASE if data_type == "exomes" else CURRENT_GENOME_RELEASE ) - return ( - f'gs://gnomad-public-requester-pays/release/{version}/ld/scores/gnomad.{data_type}.r{version}.{pop}.{"adj." if adj else ""}ld_scores.ht' - ) + return f'gs://gnomad-public-requester-pays/release/{version}/ld/scores/gnomad.{data_type}.r{version}.{pop}.{"adj." if adj else ""}ld_scores.ht' def ld_matrix(pop: str) -> GnomadPublicBlockMatrixResource: diff --git a/gnomad/sample_qc/filtering.py b/gnomad/sample_qc/filtering.py index d7aa3d3d7..9f28c1a13 100644 --- a/gnomad/sample_qc/filtering.py +++ b/gnomad/sample_qc/filtering.py @@ -251,7 +251,8 @@ def compute_stratified_metrics_filter( **{ f"fail_{metric}": ( ht._qc_metrics[metric] <= metrics_stats_expr[metric].lower - ) | (ht._qc_metrics[metric] >= metrics_stats_expr[metric].upper) + ) + | (ht._qc_metrics[metric] >= metrics_stats_expr[metric].upper) for metric in qc_metrics } ) diff --git a/gnomad/utils/sparse_mt.py b/gnomad/utils/sparse_mt.py index 8ba579867..6714bb629 100644 --- a/gnomad/utils/sparse_mt.py +++ b/gnomad/utils/sparse_mt.py @@ -869,7 +869,8 @@ def get_chr_dp_ann(chrom: str) -> hl.Table: f"{chrom}_mean_dp": hl.agg.filter( chr_mt.LGT.is_non_ref(), hl.agg.sum(chr_mt.DP), - ) / hl.agg.filter(chr_mt.LGT.is_non_ref(), hl.agg.count()) + ) + / hl.agg.filter(chr_mt.LGT.is_non_ref(), hl.agg.count()) } ).cols() else: @@ -899,12 +900,10 @@ def get_chr_dp_ann(chrom: str) -> hl.Table: return ht.annotate( **{ - f"{chr_x}_ploidy": ht[f"{chr_x}_mean_dp"] / ( - ht[f"{normalization_contig}_mean_dp"] / 2 - ), - f"{chr_y}_ploidy": ht[f"{chr_y}_mean_dp"] / ( - ht[f"{normalization_contig}_mean_dp"] / 2 - ), + f"{chr_x}_ploidy": ht[f"{chr_x}_mean_dp"] + / (ht[f"{normalization_contig}_mean_dp"] / 2), + f"{chr_y}_ploidy": ht[f"{chr_y}_mean_dp"] + / (ht[f"{normalization_contig}_mean_dp"] / 2), } ) diff --git a/gnomad/utils/vep.py b/gnomad/utils/vep.py index ed1d767cf..887550daa 100644 --- a/gnomad/utils/vep.py +++ b/gnomad/utils/vep.py @@ -544,18 +544,21 @@ def get_csq_from_struct( "gene": element.gene_id, "symbol": element.gene_symbol, "symbol_source": element.gene_symbol_source, - "cdna_position": hl.str(element.cdna_start) + hl.if_else( + "cdna_position": hl.str(element.cdna_start) + + hl.if_else( element.cdna_start == element.cdna_end, "", "-" + hl.str(element.cdna_end), ), - "cds_position": hl.str(element.cds_start) + hl.if_else( + "cds_position": hl.str(element.cds_start) + + hl.if_else( element.cds_start == element.cds_end, "", "-" + hl.str(element.cds_end), ), "mirna": hl.delimit(element.mirna, "&") if "mirna" in element else None, - "protein_position": hl.str(element.protein_start) + hl.if_else( + "protein_position": hl.str(element.protein_start) + + hl.if_else( element.protein_start == element.protein_end, "", "-" + hl.str(element.protein_end),