Skip to main content

Python interface to access and manipulate genome annotations in TxDB SQLite format.

Project description

PyPI-Server Unit tests

TxDb

This package provides a Python interface to access and manipulate genome annotations, implemented in the Bioconductor GenomicFeatures package. It allows users to interact with TxDb SQLite databases to extract genomic features such as transcripts, exons, CDS, and promoters as GenomicRanges objects. It also includes a registry system to easily download and cache standard TxDb databases.

Install

To get started, install the package from PyPI

pip install txdb

Usage

Using TxDbRegistry

The TxDbRegistry provides easy access to hosted TxDb databases in AnnotationHub.

from txdb import TxDbRegistry

# Initialize registry
registry = TxDbRegistry()

# List available databases
print(registry.list_txdb())

# Load a specific database (downloads and caches it automatically)
# Example: hg38 knownGene
txdb = registry.load_db("TxDb.Hsapiens.UCSC.hg38.knownGene.sqlite")

# Access features
transcripts = txdb.transcripts()
print(transcripts)
## OUTPUT
GenomicRanges with 412044 ranges and 3 metadata columns
                    seqnames          ranges          strand   _tx_id           tx_name tx_type
                    <str>       <IRanges> <ndarray[int8]>   <list>            <list>  <list>
    [0]                chr1   11121 - 14413               + |      1 ENST00000832824.1    None
    [1]                chr1   11125 - 14405               + |      2 ENST00000832825.1    None
    [2]                chr1   11410 - 14413               + |      3 ENST00000832826.1    None
                        ...             ...             ... |    ...               ...     ...
[412041] chrX_MU273397v1_alt 314193 - 316302               - | 412042 ENST00000710030.1    None
[412042] chrX_MU273397v1_alt 314813 - 315236               - | 412043 ENST00000710216.1    None
[412043] chrX_MU273397v1_alt 324527 - 324923               - | 412044 ENST00000710031.1    None
------
seqinfo(711 sequences): chr1 chr2 chr3 ... chrX_MU273395v1_alt chrX_MU273396v1_alt chrX_MU273397v1_alt

Using a Local TxDb File

If you have a local SQLite file (e.g., generated from R), you can load it directly.

from txdb import TxDb

txdb = TxDb("path/to/custom_txdb.sqlite")

# Extract exons
exons = txdb.exons()

# Extract promoters (2kb upstream)
promoters = txdb.promoters(upstream=2000, downstream=200)

# Filter for a specific chromosome
chr1_tx = txdb.transcripts(filter={"tx_chrom": "chr1"})

Check out the documentation for all supported extractors from TxDB files.

Note

This project has been set up using BiocSetup and PyScaffold.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

txdb-0.0.1.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

txdb-0.0.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file txdb-0.0.1.tar.gz.

File metadata

  • Download URL: txdb-0.0.1.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for txdb-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e9f49cc91e543687e21ccf7953b7c6bb159caefa790f4e3eb5dec43eb7f75d54
MD5 82602b1ea2b30c7988135bf1c2a0644c
BLAKE2b-256 8cbff43ff942cf0e9f265ea3f8fb5effdf5aaba2749b57a53672dea799f32a17

See more details on using hashes here.

Provenance

The following attestation bundles were made for txdb-0.0.1.tar.gz:

Publisher: publish-pypi.yml on BiocPy/txdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file txdb-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: txdb-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for txdb-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c98a00420b5755e27a5fcd27788e608cedc19eb0d31530db9fa0d29aa7b90e5
MD5 c850d61294e4cbc1d3faece1cf1b0faf
BLAKE2b-256 842c18ceb36f8c9b85228e1d8b8eced6ea71aae2d79bfd0cb3216090f8bf99f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for txdb-0.0.1-py3-none-any.whl:

Publisher: publish-pypi.yml on BiocPy/txdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page