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 thanXM_.
If we have multiple transcripts from a single source, we want to select the one with smaller integer.
E.g.
NM_123.4has higher priority thanNM_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()
Metadata
Release files for ddgen 0.0.10.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ddgen-0.0.10.post1.tar.gz | 4.4 MB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ddgen-0.0.10.post1-py3.6.egg | Legacy Egg format | - | - | Details |
| ddgen-0.0.10.post1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.1 MB
Release files / ddgen-0.0.10.post1.tar.gz
| Download URL | ddgen-0.0.10.post1.tar.gz |
|---|---|
| Size | 4.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99d5031bc1e1f1ea4d52680be0d14f8cfd0a5152e2ff3655d19e107774bddd1e
|
|
BLAKE2b-256 checksum How to use checksums |
5620bbfadeed61ad96ea2f43bcef8273fc2ad07c7d90ecc6c233c45df9f68b5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / ddgen-0.0.10.post1-py3.6.egg
| Download URL | ddgen-0.0.10.post1-py3.6.egg |
|---|---|
| Size | 4.4 MB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
0f3396e7063c6bb9a95e0517d8356e342cac18b3544242f40bd450bc1f6301e2
|
|
BLAKE2b-256 checksum How to use checksums |
bcc7b414533546420d6788a36bc4ec399a0e61faaf3d5b98b998f47e9212b15b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / ddgen-0.0.10.post1-py3-none-any.whl
| Download URL | ddgen-0.0.10.post1-py3-none-any.whl |
|---|---|
| Size | 4.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d38cca678597e4abdbdf8a05d882c227a126c9c49a8d6923431712877bc7dd2
|
|
BLAKE2b-256 checksum How to use checksums |
f75a5e563c40137945d21048ad5f2eca54b008f92ea45bcb80b8dba7edd92956
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|