Skip to content

Commit

Permalink
Add browser tables to resources
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaQin committed Jan 6, 2025
1 parent a0f0f33 commit 26a2727
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
18 changes: 18 additions & 0 deletions gnomad/resources/grch37/gnomad.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ 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.
:return: Path to browser gene Table.
"""
return "gs://gnomad-public-requester-pays/resources/grch37/browser/gnomad.genes.GRCh37.GENCODEv19.ht"


def public_release(data_type: str) -> VersionedTableResource:
"""
Retrieve publicly released versioned table resource.
Expand Down Expand Up @@ -275,3 +284,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())
44 changes: 44 additions & 0 deletions gnomad/resources/grch38/gnomad.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,25 @@ 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.
:return: Path to browser gene Table.
"""
return "gs://gnomad-public-requester-pays/resources/grch38/browser/gnomad.genes.GRCh38.GENCODEv39.ht"


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


def browser_variant(version: str = CURRENT_EXOME_RELEASE) -> GnomadPublicTableResource:
"""
Retrieve browser variant table.
:param version: One of the release versions of gnomAD on GRCh38. Default is the current exome release.
:return: Browser variant Table.
:raises ValueError: If the version is not a valid release.
"""
if version not in EXOME_RELEASES:
raise ValueError(
f"Invalid version: {version}. Must be one of {EXOME_RELEASES}."
)

return GnomadPublicTableResource(path=_public_browser_variant_ht_path(version))


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

0 comments on commit 26a2727

Please sign in to comment.