Skip to main content

Library of Python utilities that I needed so many times

Project description

ddgen

Build Status PyPI version

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 with the connection/cursor
            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.10.tar.gz (4.4 MB view details)

Uploaded Source

Built Distributions

ddgen-0.0.10-py3.6.egg (4.4 MB view details)

Uploaded Source

ddgen-0.0.10-py3-none-any.whl (4.4 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ddgen-0.0.10.tar.gz
  • Upload date:
  • Size: 4.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for ddgen-0.0.10.tar.gz
Algorithm Hash digest
SHA256 5ecdcafa7ecf36e059cff966698a607632098380a0ffc0d36446b646b0246515
MD5 aa932e37277201ddd1418f471a0eda87
BLAKE2b-256 62d48915656321fee41b339e01d6bebd5bc0f4f3ee358cc8baa3ba1751bdf304

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ddgen-0.0.10-py3.6.egg
  • Upload date:
  • Size: 4.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for ddgen-0.0.10-py3.6.egg
Algorithm Hash digest
SHA256 5f9c8e8a0ac0c716b6a548e4684c8abe0ad98652565cf965bf85bdabf30867e3
MD5 f77d3644e9bb55ece2614330540ccac0
BLAKE2b-256 824c0f9cce6746001d177b6e5fc4656aeb354cc2666194acacba4adc3c449f4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ddgen-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for ddgen-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1704cf0ef1015942c44da51fe578cdaa5732873bdb4a980f598ebb4b0e4dd55c
MD5 402fe17688969276fb9a010e306e2a73
BLAKE2b-256 1d35f3d364da84b0dde6df298e535be63a874445cf36692ab307f214231cde15

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