geney 1.3.27__py2.py3-none-any.whl → 1.3.29__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
geney/splicing_utils.py
CHANGED
|
@@ -8,6 +8,9 @@ import sqlite3
|
|
|
8
8
|
import json
|
|
9
9
|
import os
|
|
10
10
|
from typing import Dict, Any
|
|
11
|
+
from typing import Dict, Any
|
|
12
|
+
from redis import Redis
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
DB_PATH = os.path.join(config['hg38']['splicing_db'], 'mutation_data.db')
|
|
13
16
|
|
|
@@ -382,7 +385,7 @@ def process_pairwise_epistasis(mids, engine='pangolin', fprint=False, db=None):
|
|
|
382
385
|
print(missplicing_both)
|
|
383
386
|
|
|
384
387
|
max_delta = 0
|
|
385
|
-
flag = {'mut_id': mid, 'corrective': 0, '
|
|
388
|
+
flag = {'mut_id': mid, 'corrective': 0, 'cumulative': 0}
|
|
386
389
|
cummulative_deltas, corrective_deltas = [], []
|
|
387
390
|
ms1, ms2, msb = [], [], []
|
|
388
391
|
increased_canonical_splicing = False
|
|
@@ -409,6 +412,7 @@ def process_pairwise_epistasis(mids, engine='pangolin', fprint=False, db=None):
|
|
|
409
412
|
delta2 = m2.get(k, {'delta': 0})['delta'] # max(-1, min(10, m2.get(k, {'delta': 0})['delta'] / ref_val))
|
|
410
413
|
deltab = mb.get(k, {'delta': 0})['delta'] # max(-1, min(10, mb.get(k, {'delta': 0})['delta'] / ref_val))
|
|
411
414
|
|
|
415
|
+
print(event, k, delta1, delta2, deltab)
|
|
412
416
|
ms1.append(delta1)
|
|
413
417
|
ms2.append(delta2)
|
|
414
418
|
msb.append(deltab)
|
|
@@ -423,10 +427,10 @@ def process_pairwise_epistasis(mids, engine='pangolin', fprint=False, db=None):
|
|
|
423
427
|
corrective_deltas.append(max((deltab - delta1, deltab - delta2), key=abs))
|
|
424
428
|
|
|
425
429
|
if (abs(deltab) > 0.25) and (
|
|
426
|
-
(abs(delta1) < 0.25 and (abs(delta1 - deltab) > 0.25))
|
|
430
|
+
(abs(delta1) < 0.25 and (abs(delta1 - deltab) > 0.25)) and
|
|
427
431
|
(abs(delta2) < 0.25 and (abs(delta2 - deltab) > 0.25))
|
|
428
432
|
):
|
|
429
|
-
flag['
|
|
433
|
+
flag['cumulative'] += 1
|
|
430
434
|
cummulative_deltas.append(max((deltab - delta1, deltab - delta2), key=abs))
|
|
431
435
|
|
|
432
436
|
if (0.4 <= ref_val <= 0.75) and (
|
|
@@ -600,6 +604,76 @@ def benchmark_splicing(gene, organism='hg38', engine='spliceai'):
|
|
|
600
604
|
return len(correct_donor_preds) / num_introns, len(correct_acceptor_preds) / num_introns, len(transcript.introns)
|
|
601
605
|
|
|
602
606
|
|
|
607
|
+
class SplicingDatabaseRedis:
|
|
608
|
+
"""
|
|
609
|
+
A class to handle interactions with Redis for storing mutation data.
|
|
610
|
+
Designed for concurrency and parallel reads/writes across multiple Dask workers or threads.
|
|
611
|
+
"""
|
|
612
|
+
|
|
613
|
+
def __init__(self, host='localhost', port=6379, db=0):
|
|
614
|
+
"""
|
|
615
|
+
Initialize the Redis-based SplicingDatabase.
|
|
616
|
+
|
|
617
|
+
Args:
|
|
618
|
+
host (str): Redis host.
|
|
619
|
+
port (int): Redis port.
|
|
620
|
+
db (int): Redis database index.
|
|
621
|
+
"""
|
|
622
|
+
# Create a Redis client. By default, this client is thread-safe and uses a connection pool.
|
|
623
|
+
self.client = Redis(host=host, port=port, db=db, decode_responses=True)
|
|
624
|
+
|
|
625
|
+
def _make_key(self, engine: str, gene: str, mut_id: str, transcript_id: str) -> str:
|
|
626
|
+
"""
|
|
627
|
+
Construct a unique key for identifying a mutation record in Redis.
|
|
628
|
+
"""
|
|
629
|
+
return f"{engine}:{gene}:{mut_id}:{transcript_id}"
|
|
630
|
+
|
|
631
|
+
def get_mutation_data(self, engine: str, gene: str, mut_id: str, transcript_id: str) -> Dict[str, Any]:
|
|
632
|
+
"""
|
|
633
|
+
Retrieve mutation data from Redis.
|
|
634
|
+
|
|
635
|
+
Args:
|
|
636
|
+
engine (str): Name of the tool used for computation.
|
|
637
|
+
gene (str): Gene name or identifier.
|
|
638
|
+
mut_id (str): A unique identifier for the mutation.
|
|
639
|
+
transcript_id (str): ID for the transcript.
|
|
640
|
+
|
|
641
|
+
Returns:
|
|
642
|
+
Dict[str, Any]: The mutation data if found, else None.
|
|
643
|
+
"""
|
|
644
|
+
key = self._make_key(engine, gene, mut_id, transcript_id)
|
|
645
|
+
data_json = self.client.get(key)
|
|
646
|
+
if data_json:
|
|
647
|
+
return json.loads(data_json)
|
|
648
|
+
return None
|
|
649
|
+
|
|
650
|
+
def store_mutation_data(self, engine: str, gene: str, mut_id: str, transcript_id: str, data: Dict[str, Any]):
|
|
651
|
+
"""
|
|
652
|
+
Store mutation data in Redis.
|
|
653
|
+
|
|
654
|
+
Args:
|
|
655
|
+
engine (str): Name of the tool used for computation.
|
|
656
|
+
gene (str): Gene name or identifier.
|
|
657
|
+
mut_id (str): A unique identifier for the mutation.
|
|
658
|
+
transcript_id (str): ID for the transcript.
|
|
659
|
+
data (Dict[str, Any]): The mutation data to store.
|
|
660
|
+
"""
|
|
661
|
+
data_native = convert_numpy_to_native(data)
|
|
662
|
+
data_json = json.dumps(data_native)
|
|
663
|
+
key = self._make_key(engine, gene, mut_id, transcript_id)
|
|
664
|
+
self.client.set(key, data_json)
|
|
665
|
+
|
|
666
|
+
def close(self):
|
|
667
|
+
"""
|
|
668
|
+
Close the Redis connection.
|
|
669
|
+
Since Redis uses a connection pool by default, closing isn't strictly necessary.
|
|
670
|
+
We provide this method for API consistency.
|
|
671
|
+
"""
|
|
672
|
+
# Redis client connections are managed by the pool, no explicit close required.
|
|
673
|
+
pass
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
603
677
|
class SplicingDatabase:
|
|
604
678
|
"""
|
|
605
679
|
A class to handle interactions with the splicing SQLite database.
|
|
@@ -622,6 +696,8 @@ class SplicingDatabase:
|
|
|
622
696
|
"""
|
|
623
697
|
Create the mutations table if it doesn't exist.
|
|
624
698
|
"""
|
|
699
|
+
self.cursor.execute('PRAGMA journal_mode=WAL;') # Enable WAL mode
|
|
700
|
+
self.cursor.execute('PRAGMA synchronous=NORMAL;') # Set synchronous to NORMAL for better performance
|
|
625
701
|
self.cursor.execute('''
|
|
626
702
|
CREATE TABLE IF NOT EXISTS mutations (
|
|
627
703
|
engine TEXT,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: geney
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.29
|
|
4
4
|
Summary: A Python package for gene expression modeling.
|
|
5
5
|
Home-page: https://github.com/nicolaslynn/geney
|
|
6
6
|
Author: Nicolas Lynn
|
|
@@ -12,7 +12,7 @@ Classifier: License :: Free for non-commercial use
|
|
|
12
12
|
Classifier: Operating System :: POSIX :: Linux
|
|
13
13
|
Classifier: Operating System :: MacOS
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
-
Requires-Python: >3.
|
|
15
|
+
Requires-Python: >3.10
|
|
16
16
|
Requires-Dist: numpy
|
|
17
17
|
Requires-Dist: pandas
|
|
18
18
|
Requires-Dist: networkx
|
|
@@ -30,4 +30,5 @@ Requires-Dist: gffutils
|
|
|
30
30
|
Requires-Dist: pyfastx
|
|
31
31
|
Requires-Dist: tensorflow
|
|
32
32
|
Requires-Dist: keras
|
|
33
|
+
Requires-Dist: redis
|
|
33
34
|
|
|
@@ -16,7 +16,7 @@ geney/pangolin_utils.py,sha256=i5j5vEMCWOTIa1mRP2377BAhlUFZjHBzTQBips4lA_4,2934
|
|
|
16
16
|
geney/power_utils.py,sha256=MehZFUdkJ2EFUot709yPEDxSkXmH5XevMebX2HD768A,7330
|
|
17
17
|
geney/seqmat_utils.py,sha256=wzb3PX5it5bpIFQvcxyzlxfhoJTbHHbsjg0rzh05iVs,19753
|
|
18
18
|
geney/spliceai_utils.py,sha256=PFIhTK8Ihrj-cv5tgRN0UFPYEmC4uxtqXSP9bBLnZRM,3077
|
|
19
|
-
geney/splicing_utils.py,sha256=
|
|
19
|
+
geney/splicing_utils.py,sha256=elu5KtkcNGTWhviimIRt0DRWNcjwZrshDphM5XFPImA,38485
|
|
20
20
|
geney/survival_utils.py,sha256=KnAzEviMuXh6SnVXId9PgsFLSbgkduTvYoIthxN7FPA,6886
|
|
21
21
|
geney/tcga_utils.py,sha256=D_BNHm-D_K408dlcJm3hzH2c6QNFjQsKvUcOPiQRk7g,17612
|
|
22
22
|
geney/tis_utils.py,sha256=2makfGfVlDFVIbxzXE85AY9jmAjcNmxyIAxjvkRA5LY,7396
|
|
@@ -25,7 +25,7 @@ geney/translation_initiation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
|
25
25
|
geney/translation_initiation/tis_utils.py,sha256=AF3siFjuQH-Rs44EV-80zHdbxRMvN4woLFSHroWIETc,4448
|
|
26
26
|
geney/translation_initiation/resources/kozak_pssm.json,sha256=pcd0Olziutq-6H3mFWDCD9cujQ_AlZO-iiOvBl82hqE,1165
|
|
27
27
|
geney/translation_initiation/resources/tis_regressor_model.joblib,sha256=IXb4DUDhJ5rBDKcqMk9zE3ECTZZcdj7Jixz3KpoZ7OA,2592025
|
|
28
|
-
geney-1.3.
|
|
29
|
-
geney-1.3.
|
|
30
|
-
geney-1.3.
|
|
31
|
-
geney-1.3.
|
|
28
|
+
geney-1.3.29.dist-info/METADATA,sha256=Chxu6iycgZPwhUI1X7-VrCdFoZC3TQqF3MMnX6SS9Ps,990
|
|
29
|
+
geney-1.3.29.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
|
|
30
|
+
geney-1.3.29.dist-info/top_level.txt,sha256=O-FuNUMb5fn9dhZ-dYCgF0aZtfi1EslMstnzhc5IIVo,6
|
|
31
|
+
geney-1.3.29.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|