Skip to main content

Library of Python utilities that I needed so many times

Project description

ddgen

Library of Python utilities that I needed so many times in the past

Select RefSeq transcript with the highest priority

RefSeq transcripts have following categories:

  • NM_, XM_, NR_, XR_

If we have transcripts from multiple sources, we want to select the one coming from the source with highest priority.

E.g. NM_ has higher priority than XM_.

If we have multiple transcripts from a single source, we want to select the one with smaller integer.

E.g. NM_123.4 has higher priority than NM_124.4.

from ddgen.utils import prioritize_refseq_transcripts

# tx will be `NM_123.4`
tx = prioritize_refseq_transcripts(['NM_123.4', 'NM_124.4', 'XM_100.1'])

Get priority for Jannovar variant effects

Jannovar assigns one or more effects to a variant. The effects look like

  • MISSENSE_VARIANT,
  • STOP_GAINED,
  • SPLICE_DONOR_VARIANT,
  • CODING_TRANSCRIPT_VARIANT, etc.

The effects are sorted in order of decreasing putative pathogenicity (i.e. CODING_TRANSCRIPT_VARIANT is likely to be less deleterious than STOP_GAINED in general).

If the variant affects multiple transcripts, it can have different effects on each of them. In some situations, it might be useful to select and evaluate only the most serious effect.

In order to make the selection, we work with concept of variant effect priority. The lower the number representing the priority, the higher the priority.

We can do it by comparing effect priorities:

from ddgen.utils import get_variant_effect_priority, VARIANT_EFFECT_PRIORITIES

# `p` is 21 
p = get_variant_effect_priority('MISSENSE_VARIANT')

# `u` is -1
u = get_variant_effect_priority('GIBBERISH')

# `p` is 21 again
p = VARIANT_EFFECT_PRIORITIES['MISSENSE_VARIANT']

Connect to H2 database

The H2 database is a pure Java SQL database, hence it is primarily meant to be used with Java. We can connect to the database from Python, if:

  • Java is installed on the local machine
  • the local machine runs UNIX-like OS (sorry, Windows users)

In that case:

from ddgen.db import H2DbManager

with H2DbManager("path/to/database.mv.db", 
                 user="sa", 
                 password="sa") as h2:
    with h2.get_connection() as conn:
        with conn.cursor() as cur:
            # do whatever you want
            cur.execute('SELECT * FROM DB.TABLE;')
            for i, x in zip(range(5), cur.fetchall()):
                # print first 5 lines 
                print(x)

Setup logging

Quick setup of Python built-in logging library:

from ddgen.utils import setup_logging
setup_logging()

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

ddgen-0.0.8.tar.gz (4.3 MB view details)

Uploaded Source

Built Distributions

ddgen-0.0.8-py3.6.egg (4.3 MB view details)

Uploaded Source

ddgen-0.0.8-py3-none-any.whl (4.3 MB view details)

Uploaded Python 3

File details

Details for the file ddgen-0.0.8.tar.gz.

File metadata

  • Download URL: ddgen-0.0.8.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

File hashes

Hashes for ddgen-0.0.8.tar.gz
Algorithm Hash digest
SHA256 420758fcf8e0d9006ffb378bee3565f4db5862e8bd759772b2b2f156344a57a9
MD5 8d0881c21368886679855f0526641a8e
BLAKE2b-256 7c1031b5cc757c4616a19501c672bc545caf69ade7dd8eb51f640b99f2a693f8

See more details on using hashes here.

File details

Details for the file ddgen-0.0.8-py3.6.egg.

File metadata

  • Download URL: ddgen-0.0.8-py3.6.egg
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

File hashes

Hashes for ddgen-0.0.8-py3.6.egg
Algorithm Hash digest
SHA256 6e2536f604a1569bee31df0ba8d05c8e7e3c52052f9aa4205b1f1bdd79376770
MD5 fa58f972eb2eb5827948198a4030b529
BLAKE2b-256 10fe4dddd45b464a2386d224b6504c19e10b88bafdd2082747e859648043525b

See more details on using hashes here.

File details

Details for the file ddgen-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: ddgen-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

File hashes

Hashes for ddgen-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 51a18dd37ff9e0328187425aacff8ce15a14764d531ff79ddb0a833593d9aa44
MD5 3b3d35df98df204835fdd874d2a1af31
BLAKE2b-256 ef522392f3a130e90fe5b478d6c67f33b8524837a4bb7786d9e882648b1178da

See more details on using hashes here.

Supported by

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