geney 1.4.26__py2.py3-none-any.whl → 1.4.28__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/pipelines.py CHANGED
@@ -40,7 +40,9 @@ def oncosplice_pipeline_single_transcript(mut_id, transcript_id=None, splicing_e
40
40
  report = []
41
41
  for variant_transcript, isoform_metadata in ss.get_viable_transcripts(metadata=True):
42
42
  onco = Oncosplice(reference_transcript.protein, variant_transcript.protein, reference_transcript.cons_vector)
43
- report.append(pd.concat([base_report, ss_metadata, isoform_metadata, onco.get_analysis_series()]))
43
+ report.append(pd.concat([base_report, ss_metadata, isoform_metadata,
44
+ pd.Series({'reference_mrna': reference_transcript.mature_mrna.seq, 'variant_mrna': variant_transcript.mature_mrna.seq}),
45
+ onco.get_analysis_series()]))
44
46
  return pd.DataFrame(report)
45
47
 
46
48
 
@@ -0,0 +1,65 @@
1
+
2
+ import absl.logging
3
+ absl.logging.set_verbosity(absl.logging.ERROR)
4
+
5
+ import sys
6
+ import numpy as np
7
+
8
+
9
+ import torch
10
+ from spliceai_pytorch import SpliceAI
11
+ model = SpliceAI.from_preconfigured('10k')
12
+
13
+
14
+ if sys.platform == 'darwin':
15
+ device = torch.device("mps") if torch.backends.mps.is_available() else torch.device("cpu")
16
+
17
+ if sys.platform == 'linux':
18
+ device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
19
+
20
+
21
+ print(f"SpliceAI loaded to {device}.")
22
+ model.to(device)
23
+
24
+ def one_hot_encode(seq):
25
+
26
+ map = np.asarray([[0, 0, 0, 0],
27
+ [1, 0, 0, 0],
28
+ [0, 1, 0, 0],
29
+ [0, 0, 1, 0],
30
+ [0, 0, 0, 1]])
31
+
32
+ seq = seq.upper().replace('A', '\x01').replace('C', '\x02')
33
+ seq = seq.replace('G', '\x03').replace('T', '\x04').replace('N', '\x00')
34
+
35
+ return map[np.fromstring(seq, np.int8) % 5]
36
+
37
+
38
+ def sai_predict_probs(seq: str, model) -> list:
39
+ '''
40
+ Predicts the donor and acceptor junction probability of each
41
+ NT in seq using SpliceAI.
42
+
43
+ Let m:=2*sai_mrg_context + L be the input seq length. It is assumed
44
+ that the input seq has the following structure:
45
+
46
+ seq = |<sai_mrg_context NTs><L NTs><sai_mrg_context NTs>|
47
+
48
+ The returned probability matrix is of size 2XL, where
49
+ the first row is the acceptor probability and the second row
50
+ is the donor probability. These probabilities corresponds to the
51
+ middel <L NTs> NTs of the input seq.
52
+ '''
53
+ x = one_hot_encode(seq)[None, :]
54
+ y = model(x)
55
+ y = y[0, :, 1:].T
56
+ return y[0, :], y[1, :]
57
+
58
+
59
+ def run_spliceai_seq(seq, indices, threshold=0):
60
+ # seq = 'N' * 5000 + seq + 'N' * 5000
61
+ ref_seq_probs_temp = sai_predict_probs(seq, model)
62
+ ref_seq_acceptor_probs, ref_seq_donor_probs = ref_seq_probs_temp[0, :], ref_seq_probs_temp[1, :]
63
+ acceptor_indices = {a: b for a, b in list(zip(indices, ref_seq_acceptor_probs)) if b >= threshold}
64
+ donor_indices = {a: b for a, b in list(zip(indices, ref_seq_donor_probs)) if b >= threshold}
65
+ return donor_indices, acceptor_indices
@@ -20,8 +20,9 @@ def run_splicing_engine(seq: str, engine: str = 'spliceai') -> Tuple[List[float]
20
20
  match engine:
21
21
  case 'spliceai':
22
22
  from geney.utils.spliceai_utils import sai_predict_probs, sai_models
23
+ from geney.utils.spliceai_pytorch_utils import sai_predict_probs, model
23
24
  # print(seq)
24
- acceptor_probs, donor_probs = sai_predict_probs(seq, models=sai_models)
25
+ acceptor_probs, donor_probs = sai_predict_probs(seq, models=model)
25
26
  case 'pangolin':
26
27
  from geney.utils.pangolin_utils import pangolin_predict_probs, pang_models
27
28
  # print(seq)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geney
3
- Version: 1.4.26
3
+ Version: 1.4.28
4
4
  Summary: A Python package for gene expression modeling.
5
5
  Home-page: https://github.com/nicolaslynn/geney
6
6
  Author: Nicolas Lynn
@@ -23,7 +23,7 @@ geney/gtex_utils.py,sha256=asL2lHyU5KsbWpV096vkf1Ka7hSo_RRfZqw7p5nERmE,1919
23
23
  geney/immune_utils.py,sha256=b-8dRcCti7xsU7RG3op18lkSnAD8dp_BymGaR-hbNcI,5272
24
24
  geney/mutation_utils.py,sha256=C_kv2MB_L8LlhX3W2ooXjJ3uDoJ8zX1WeDtZKoBZJkI,1547
25
25
  geney/pangolin_utils.py,sha256=9jdBXlOcRaUdfi-UpUxHA0AkTMZkUF-Lt7HVZ1nEm3s,2973
26
- geney/pipelines.py,sha256=XeC4NTqxzHzrGX6HIBXe8pe4pELpjYLgTmcOt7ESN0g,2916
26
+ geney/pipelines.py,sha256=p_zZjQRkcQ_MwOZWv247QVG5iNSrrV4g8BT3vJNwpZM,3103
27
27
  geney/power_utils.py,sha256=orOhsr9vkQ-Y4nD1zHj_MmR2J3uYiUsiklqVy-5T-2M,7331
28
28
  geney/seqmat_utils.py,sha256=wzb3PX5it5bpIFQvcxyzlxfhoJTbHHbsjg0rzh05iVs,19753
29
29
  geney/spliceai_utils.py,sha256=nyBnLdYs1rB-duA9lfJYM9Q2xNlvZA3I_sCJ1z5WjFw,3294
@@ -43,10 +43,11 @@ geney/utils/TranscriptLibrary.py,sha256=W1hv4Y8wRlmwTs3iFdn4_IqS-2suVDzZe4fwti2K
43
43
  geney/utils/__init__.py,sha256=-nJ-DMx1JzP-ZCe_QuQCeM0ZYIT_16jxoXDhUaO_4Oc,714
44
44
  geney/utils/mutation_utils.py,sha256=r-pHr56gEa5kh_DPX8MjFY3ZfYaOtyo4CUfJ5ZHlXPw,3243
45
45
  geney/utils/pangolin_utils.py,sha256=JQSPbWxdzqGFYfWQktkfLMaMSGR28eGQhNzO7MLMe5M,6162
46
+ geney/utils/spliceai_pytorch_utils.py,sha256=PfMgaoG6ftWfqKZKc_JNqj5wqQRUR2B-4YF22-zNh1M,2079
46
47
  geney/utils/spliceai_utils.py,sha256=VtrIbjyQxk_3lw86eWjftRYyal9OzxArJ0GV5u_ymTg,2721
47
- geney/utils/splicing_utils.py,sha256=vPCGnCPR1ooEZEHR79yFHLmRQXEJHXEQjjxpBR-YWOs,20635
48
+ geney/utils/splicing_utils.py,sha256=pg5UnlGPaVgV3mw1GUzC-J-bDC1EtjTgkWsqtN-XVMM,20714
48
49
  geney/utils/utils.py,sha256=m51Vd0cEbrcIHo6_8BAuI9YSPcKRs22e5LfVd2Qj6Is,2181
49
- geney-1.4.26.dist-info/METADATA,sha256=83NRlxbFuF6f3VZ4BJOqochC7Nre1zJZY1zAv4P6hFo,990
50
- geney-1.4.26.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
51
- geney-1.4.26.dist-info/top_level.txt,sha256=O-FuNUMb5fn9dhZ-dYCgF0aZtfi1EslMstnzhc5IIVo,6
52
- geney-1.4.26.dist-info/RECORD,,
50
+ geney-1.4.28.dist-info/METADATA,sha256=q7DMJSJXyJ2IJ1qQD8xofQ4f2-cZZi6TvTUmEvfbyaA,990
51
+ geney-1.4.28.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
52
+ geney-1.4.28.dist-info/top_level.txt,sha256=O-FuNUMb5fn9dhZ-dYCgF0aZtfi1EslMstnzhc5IIVo,6
53
+ geney-1.4.28.dist-info/RECORD,,
File without changes