Skip to content

Commit

Permalink
Merge pull request #750 from broadinstitute/qh/browser_tables
Browse files Browse the repository at this point in the history
Add browser tables to resources
  • Loading branch information
KoalaQin authored Jan 14, 2025
2 parents 0ad49fa + 73397eb commit ae7730e
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gnomad/resources/grch37/gnomad.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ def _public_pext_path(pext_type: str = "base_level") -> str:
return pext_paths[pext_type]


def _public_browser_gene_ht_path() -> str:
"""
Get public browser gene table path.
.. note::
This table has smaller number of partitions (n=100) for faster computation and
contains pext data compared to gnomad.genes.GRCh37.GENCODEv19.ht (which was
used by the browser for ES export) under the same path.
:return: Path to browser gene Table.
"""
return "gs://gnomad-public-requester-pays/resources/grch37/browser/gnomad.genes.GRCh37.GENCODEv19.pext.ht"


def public_release(data_type: str) -> VersionedTableResource:
"""
Retrieve publicly released versioned table resource.
Expand Down Expand Up @@ -275,3 +290,12 @@ def constraint() -> GnomadPublicTableResource:
:return: Gene constraint Table.
"""
return GnomadPublicTableResource(path=_public_constraint_ht_path())


def browser_gene() -> GnomadPublicTableResource:
"""
Retrieve browser gene table.
:return: Browser gene Table.
"""
return GnomadPublicTableResource(path=_public_browser_gene_ht_path())
54 changes: 54 additions & 0 deletions gnomad/resources/grch38/gnomad.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
CURRENT_GENOME_RELEASE = "4.1"
CURRENT_JOINT_RELEASE = "4.1"

CURRENT_BROWSER_RELEASE = "4.1"

CURRENT_EXOME_COVERAGE_RELEASE = "4.0"
CURRENT_GENOME_COVERAGE_RELEASE = "3.0.1"

Expand All @@ -35,6 +37,7 @@
EXOME_RELEASES = ["4.0", "4.1"]
GENOME_RELEASES = ["3.0", "3.1", "3.1.1", "3.1.2", "4.0", "4.1"]
JOINT_RELEASES = ["4.1"]
BROWSER_RELEASES = ["4.1"]

EXOME_COVERAGE_RELEASES = ["4.0"]
GENOME_COVERAGE_RELEASES = ["3.0", "3.0.1"]
Expand Down Expand Up @@ -391,6 +394,31 @@ def _public_constraint_ht_path(version: str) -> str:
return f"gs://gnomad-public-requester-pays/release/{version}/constraint/gnomad.v{version}.constraint_metrics.ht"


def _public_browser_variant_ht_path(version: str) -> str:
"""
Get public browser variant table path.
:param version: One of the release versions of gnomAD on GRCh38.
:return: Path to browser variant Table.
"""
return f"gs://gnomad-public-requester-pays/release/{version}/ht/browser/gnomad.browser.v{version}.sites.ht"


def _public_browser_gene_ht_path() -> str:
"""
Get public browser gene table path.
.. note::
This table has smaller number of partitions (n=100) for faster computation and
contains pext data compared to gnomad.genes.GRCh38.GENCODEv39.ht (which was
used by the browser for ES export) under the same path.
:return: Path to browser gene Table.
"""
return "gs://gnomad-public-requester-pays/resources/grch38/browser/gnomad.genes.GRCh38.GENCODEv39.pext.ht"


def public_release(data_type: str) -> VersionedTableResource:
"""
Retrieve publicly released versioned table resource.
Expand Down Expand Up @@ -759,3 +787,29 @@ def constraint(version: str = CURRENT_EXOME_RELEASE) -> VersionedTableResource:
for release in EXOME_RELEASES
},
)


def browser_variant() -> VersionedTableResource:
"""
Retrieve browser variant table.
:return: Browser variant Table.
"""
return VersionedTableResource(
CURRENT_BROWSER_RELEASE,
{
release: GnomadPublicTableResource(
path=_public_browser_variant_ht_path(release)
)
for release in BROWSER_RELEASES
},
)


def browser_gene() -> GnomadPublicTableResource:
"""
Retrieve browser gene table.
:return: Browser gene Table.
"""
return GnomadPublicTableResource(path=_public_browser_gene_ht_path())

0 comments on commit ae7730e

Please sign in to comment.