Skip to main content

Transcripts for HGVS libraries

Project description

cdot

PyPi version Python versions tests DOI

cdot provides the transcript data needed to map and validate HGVS variants - the gene/transcript coordinates, exon structure and genome alignments - for the two most popular Python HGVS libraries: biocommons HGVS and PyHGVS.

To do HGVS work (e.g. convert NM_001637.3:c.1582G>A to genomic coordinates) those libraries need a transcript data source. The usual source, UTA, is a PostgreSQL database that's slow and heavy to run. cdot instead converts the official RefSeq/Ensembl annotation files (GTF/GFF3) into compact JSON and ships fast loaders for the HGVS libraries. You can use it via:

Because it reads the released annotation files directly, cdot covers 1.58 million transcript/genome alignments, including historical transcript versions - vs ~141k in UTA (v.20210129) - which matters when resolving legacy HGVS. See cdot vs UTA for the trade-offs.

Recent changes are in the changelog.

Install

pip install cdot

Optional extras:

pip install 'cdot[fasta]'   # local genome FASTA sequence fetching (pysam) - needed for the PyHGVS example below. Quotes are required in zsh (macOS default).

(hgvs is a core dependency, so the biocommons HGVS examples work out of the box.)

Examples

Biocommons HGVS example:

import hgvs
from hgvs.assemblymapper import AssemblyMapper
from cdot.hgvs.dataproviders import JSONDataProvider, RESTDataProvider

hdp = RESTDataProvider()  # Uses API server at cdotlib.org
# hdp = JSONDataProvider(["./cdot-0.2.32.refseq.grch37.json.gz"])  # Uses local JSON file

am = AssemblyMapper(hdp,
                    assembly_name='GRCh37',
                    alt_aln_method='splign', replace_reference=True)

hp = hgvs.parser.Parser()
var_c = hp.parse_hgvs_variant('NM_001637.3:c.1582G>A')
am.c_to_g(var_c)

more Biocommons examples:

Tip: cdot provides many transcripts that aren't in SeqRepo, so the default sequence fetcher will raise HGVSDataNotAvailableError for them. You almost always want to supply a FastaSeqFetcher (chained after SeqRepo) so every cdot transcript resolves against a local genome FASTA.

For fixing messy HGVS input and fast bulk processing, see Advanced usage.

PyHGVS example (needs pip install 'cdot[fasta]' for pysam):

import pyhgvs
from pysam.libcfaidx import FastaFile
from cdot.pyhgvs.pyhgvs_transcript import JSONPyHGVSTranscriptFactory, RESTPyHGVSTranscriptFactory

genome = FastaFile("/data/annotation/fasta/GCF_000001405.25_GRCh37.p13_genomic.fna.gz")
factory = RESTPyHGVSTranscriptFactory()
# factory = JSONPyHGVSTranscriptFactory(["./cdot-0.2.32.refseq.grch37.json.gz"])  # Uses local JSON file
pyhgvs.parse_hgvs_name('NM_001637.3:c.1582G>A', genome, get_transcript=factory.get_transcript_grch37)

more PyHGVS examples:

Documentation

See docs/ for reference and how-to guides:

See the docs index for the full list (examples, FastaSeqFetcher, creating data, cdot vs UTA, …).

Q. What's the performance like?

Resolving real ClinVar c.HGVS to genomic coordinates (GRCh38, biocommons HGVS, local sequence fetching):

  • UTA public DB: ~1-1.5 seconds / transcript
  • cdot REST service: ~30 HGVS/second sequential, ~500 HGVS/second with prefetch() batch cache-warming
  • cdot JSON.gz (local): 500-1k/second

prefetch() warms every transcript in one batch round-trip up front, so bulk resolution over the REST service runs almost entirely from cache - closing most of the gap to local JSON.gz (~16x faster end-to-end on 500 variants). Reproduce with paper/scripts/benchmark_resolution.py.

Q. Where can I download the JSON.gz files?

Download from GitHub releases - RefSeq (37/38) - 72M, Ensembl (37/38) 61M

Details on what the files contain here

Q. How does this compare to Universal Transcript Archive?

Both projects have similar goals of providing transcripts for loading HGVS, but they approach it from different ways

  • UTA aligns sequences, then stores coordinates in an SQL database.
  • cdot convert existing Ensembl/RefSeq GTFs into JSON

See cdot vs UTA for more details

Q. How do you store transcripts in JSON?

See the JSON data format reference for a full description of every field, with a machine-readable JSON Schema alongside it. Coordinates & exon alignments explains how exon coordinates and the alignment gap strings work. See also design notes on why the format looks the way it does.

You can also read the data with typed Python objects (no extra install required):

from cdot import models

data = models.load("cdot-0.2.32.refseq.GRCh38.json.gz")
tx = data.transcripts["NM_001637.3"]
print(tx.gene_name, tx.protein)

We think a standard for JSON gene/transcript information would be a great thing, and am keen to collaborate to make it happen!

Q. What does cdot stand for?

cdot, pronounced "see dot", is a play on the HGVS coding-sequence prefix :c.

This was developed for the Australian Genomics Shariant project, due to the need to load historical HGVS from lab archives.

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

cdot-0.2.30.tar.gz (86.7 kB view details)

Uploaded Source

Built Distribution

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

cdot-0.2.30-py3-none-any.whl (59.6 kB view details)

Uploaded Python 3

File details

Details for the file cdot-0.2.30.tar.gz.

File metadata

  • Download URL: cdot-0.2.30.tar.gz
  • Upload date:
  • Size: 86.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cdot-0.2.30.tar.gz
Algorithm Hash digest
SHA256 2ed53e3288b689ad6e9cd48632050f4f01cfa1d48d1153032ebe256f9fd1b7ca
MD5 96f11186b0f9c6eec72d5886ddbfdc58
BLAKE2b-256 f8e6407035b5136fabe0cb80528cb72116e70bf4e03fbc039d84c412b0a27151

See more details on using hashes here.

File details

Details for the file cdot-0.2.30-py3-none-any.whl.

File metadata

  • Download URL: cdot-0.2.30-py3-none-any.whl
  • Upload date:
  • Size: 59.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cdot-0.2.30-py3-none-any.whl
Algorithm Hash digest
SHA256 bb5ffa4b7098a977b4da74c990cf085efca30cca59da9954be66b44bb16f9346
MD5 3e6c39ed83df43e9b086e694606cb564
BLAKE2b-256 921983c72137d0c07328cf9928ef58f79ea990cf238a2420fe1a3890aea354eb

See more details on using hashes here.

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