OpenSpliceai 0.0.5__tar.gz → 0.0.6__tar.gz
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.
- openspliceai-0.0.6/MANIFEST.in +2 -0
- {openspliceai-0.0.5/openspliceai.egg-info → openspliceai-0.0.6}/PKG-INFO +36 -4
- {openspliceai-0.0.5 → openspliceai-0.0.6}/README.md +26 -3
- openspliceai-0.0.6/openspliceai/__init__.py +1 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/calibrate/calibrate.py +15 -6
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/calibrate/temperature_scaling_site_only.py +1 -3
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/create_data/create_datafile.py +10 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/create_data/create_dataset.py +9 -3
- openspliceai-0.0.6/openspliceai/create_data/gff_to_tsv.py +124 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/create_data/paralogs.py +4 -4
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/create_data/utils.py +14 -3
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/create_data/verify_h5_file.py +6 -4
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/header.py +1 -1
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/merge_data/merge_dataset.py +1 -4
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/openspliceai.py +18 -3
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/predict/predict.py +40 -27
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/predict/utils.py +2 -1
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/train/train.py +9 -3
- openspliceai-0.0.6/openspliceai/train_base/openspliceai.py +141 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/train_base/utils.py +43 -2
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/transfer/transfer.py +17 -5
- openspliceai-0.0.6/openspliceai/variant/annotations/grch37.txt +20275 -0
- openspliceai-0.0.6/openspliceai/variant/annotations/grch38.txt +19306 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/variant/utils.py +35 -6
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/variant/variant.py +13 -2
- {openspliceai-0.0.5 → openspliceai-0.0.6/openspliceai.egg-info}/PKG-INFO +36 -4
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai.egg-info/SOURCES.txt +4 -1
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai.egg-info/requires.txt +10 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/setup.py +7 -2
- openspliceai-0.0.5/MANIFEST.in +0 -1
- openspliceai-0.0.5/openspliceai/__init__.py +0 -1
- openspliceai-0.0.5/openspliceai/train_base/openspliceai.py +0 -72
- {openspliceai-0.0.5 → openspliceai-0.0.6}/LICENSE +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/logo/jhu-logo-dark.png +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/logo/logo_black.png +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/logo/logo_white.png +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/calibrate/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/calibrate/calibrate_utils.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/calibrate/model_utils.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/calibrate/temperature_scaling.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/calibrate/visualization.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/constants.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/create_data/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/merge_data/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/predict/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/test/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/test/test.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/train/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/train_base/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/transfer/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/variant/__init__.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/variant/get_anno.py +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai.egg-info/dependency_links.txt +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai.egg-info/entry_points.txt +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai.egg-info/top_level.txt +0 -0
- {openspliceai-0.0.5 → openspliceai-0.0.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openspliceai
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: Deep learning framework that decodes splicing across species
|
|
5
5
|
Home-page: https://github.com/Kuanhao-Chao/OpenSpliceAI
|
|
6
6
|
Author: Kuan-Hao Chao
|
|
@@ -24,21 +24,35 @@ Requires-Dist: matplotlib>=3.8.3
|
|
|
24
24
|
Requires-Dist: matplotlib-inline>=0.1.7
|
|
25
25
|
Requires-Dist: psutil>=5.9.2
|
|
26
26
|
Requires-Dist: mappy>=2.28
|
|
27
|
+
Provides-Extra: test
|
|
28
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
29
|
+
Requires-Dist: pytest-cov>=4; extra == "test"
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4; extra == "dev"
|
|
33
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
34
|
+
Requires-Dist: pre-commit>=3; extra == "dev"
|
|
27
35
|
Dynamic: author
|
|
28
36
|
Dynamic: author-email
|
|
29
37
|
Dynamic: description
|
|
30
38
|
Dynamic: description-content-type
|
|
31
39
|
Dynamic: home-page
|
|
32
40
|
Dynamic: license-file
|
|
41
|
+
Dynamic: provides-extra
|
|
33
42
|
Dynamic: requires-dist
|
|
34
43
|
Dynamic: requires-python
|
|
35
44
|
Dynamic: summary
|
|
36
45
|
|
|
37
|
-
<
|
|
46
|
+
<p align="center">
|
|
47
|
+
<picture>
|
|
48
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Kuanhao-Chao/OpenSpliceAI/main/logo/logo_white.png">
|
|
49
|
+
<img alt="OpenSpliceAI" src="https://raw.githubusercontent.com/Kuanhao-Chao/OpenSpliceAI/main/logo/logo_black.png" width="90%">
|
|
50
|
+
</picture>
|
|
51
|
+
</p>
|
|
38
52
|
|
|
39
53
|
|
|
40
54
|
<a class="reference external image-reference" href="https://img.shields.io/badge/License-GPLv3-yellow.svg"><img alt="https://img.shields.io/badge/License-GPLv3-yellow.svg" src="https://img.shields.io/badge/License-GPLv3-yellow.svg"></a>
|
|
41
|
-
<a class="reference external image-reference" href="https://img.shields.io/badge/version-v.0.0.
|
|
55
|
+
<a class="reference external image-reference" href="https://img.shields.io/badge/version-v.0.0.6-blue"><img alt="https://img.shields.io/badge/version-v.0.0.6-blue" src="https://img.shields.io/badge/version-v.0.0.6-blue"></a>
|
|
42
56
|
<a class="reference external image-reference" href="https://pepy.tech/project/openspliceai"><img alt="https://static.pepy.tech/personalized-badge/openspliceai?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=PyPi%20downloads" src="https://static.pepy.tech/personalized-badge/openspliceai?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=PyPi%20downloads"></a>
|
|
43
57
|
<a class="reference external image-reference" href="https://github.com/Kuanhao-Chao/OpenSpliceAI/releases"><img alt="https://img.shields.io/github/downloads/Kuanhao-Chao/OpenSpliceAI/total.svg?style=social&logo=github&label=Download" src="https://img.shields.io/github/downloads/Kuanhao-Chao/OpenSpliceAI/total.svg?style=social&logo=github&label=Download"></a>
|
|
44
58
|
<a class="reference external image-reference" href="https://github.com/Kuanhao-Chao/OpenSpliceAI/releases"><img alt="https://img.shields.io/badge/platform-macOS_/Linux-green.svg" src="https://img.shields.io/badge/platform-macOS_/Linux-green.svg"></a>
|
|
@@ -121,6 +135,22 @@ Annotates VCF files with delta scores and positions to evaluate the impact of ge
|
|
|
121
135
|
<div class="line"><br></div>
|
|
122
136
|
</div>
|
|
123
137
|
</section>
|
|
138
|
+
<section id="development-testing">
|
|
139
|
+
<h1>Development & Testing<a class="headerlink" href="#development-testing" title="Permalink to this heading">#</a></h1>
|
|
140
|
+
<p>Install the package with its development dependencies (pytest, pytest-cov, ruff, pre-commit) from a clone of the repository:</p>
|
|
141
|
+
<pre><code>pip install -e '.[dev]'</code></pre>
|
|
142
|
+
<p><strong>Tests</strong> live under <code>tests/</code> (<code>unit</code> / <code>integration</code> / <code>regression</code>) and run on CPU only:</p>
|
|
143
|
+
<pre><code>pytest -m "not slow and not integration" # fast inner loop
|
|
144
|
+
pytest # full suite</code></pre>
|
|
145
|
+
<p>Tests are tagged with markers (declared in <code>pytest.ini</code>) — <code>integration</code>, <code>slow</code>, <code>gpu</code>, and <code>keras</code> (auto-skipped when TensorFlow is absent) — selectable with <code>-m</code>, e.g. <code>pytest -m integration</code>.</p>
|
|
146
|
+
<p><strong>Lint and pre-commit hooks</strong> (configured in <code>ruff.toml</code> and <code>.pre-commit-config.yaml</code>):</p>
|
|
147
|
+
<pre><code>ruff check . # lint (add --fix to auto-fix)
|
|
148
|
+
pre-commit install # run ruff + checks on every commit</code></pre>
|
|
149
|
+
<p>See the <a class="reference external" href="https://ccb.jhu.edu/openspliceai/">full documentation</a> for the complete development and testing guide.</p>
|
|
150
|
+
<div class="line-block">
|
|
151
|
+
<div class="line"><br></div>
|
|
152
|
+
</div>
|
|
153
|
+
</section>
|
|
124
154
|
<section id="table-of-contents">
|
|
125
155
|
<h1>Table of Contents<a class="headerlink" href="#table-of-contents" title="Permalink to this heading">#</a></h1>
|
|
126
156
|
<div class="toctree-wrapper compound">
|
|
@@ -239,5 +269,7 @@ Annotates VCF files with delta scores and positions to evaluate the impact of ge
|
|
|
239
269
|
<div class="line"><br></div>
|
|
240
270
|
<div class="line"><br></div>
|
|
241
271
|
</div>
|
|
242
|
-
<
|
|
272
|
+
<p align="center">
|
|
273
|
+
<img alt="Johns Hopkins University" src="logo/jhu-logo-dark.png" width="40%">
|
|
274
|
+
</p>
|
|
243
275
|
</section>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
<
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Kuanhao-Chao/OpenSpliceAI/main/logo/logo_white.png">
|
|
4
|
+
<img alt="OpenSpliceAI" src="https://raw.githubusercontent.com/Kuanhao-Chao/OpenSpliceAI/main/logo/logo_black.png" width="90%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
8
|
|
|
4
9
|
<a class="reference external image-reference" href="https://img.shields.io/badge/License-GPLv3-yellow.svg"><img alt="https://img.shields.io/badge/License-GPLv3-yellow.svg" src="https://img.shields.io/badge/License-GPLv3-yellow.svg"></a>
|
|
5
|
-
<a class="reference external image-reference" href="https://img.shields.io/badge/version-v.0.0.
|
|
10
|
+
<a class="reference external image-reference" href="https://img.shields.io/badge/version-v.0.0.6-blue"><img alt="https://img.shields.io/badge/version-v.0.0.6-blue" src="https://img.shields.io/badge/version-v.0.0.6-blue"></a>
|
|
6
11
|
<a class="reference external image-reference" href="https://pepy.tech/project/openspliceai"><img alt="https://static.pepy.tech/personalized-badge/openspliceai?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=PyPi%20downloads" src="https://static.pepy.tech/personalized-badge/openspliceai?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=PyPi%20downloads"></a>
|
|
7
12
|
<a class="reference external image-reference" href="https://github.com/Kuanhao-Chao/OpenSpliceAI/releases"><img alt="https://img.shields.io/github/downloads/Kuanhao-Chao/OpenSpliceAI/total.svg?style=social&logo=github&label=Download" src="https://img.shields.io/github/downloads/Kuanhao-Chao/OpenSpliceAI/total.svg?style=social&logo=github&label=Download"></a>
|
|
8
13
|
<a class="reference external image-reference" href="https://github.com/Kuanhao-Chao/OpenSpliceAI/releases"><img alt="https://img.shields.io/badge/platform-macOS_/Linux-green.svg" src="https://img.shields.io/badge/platform-macOS_/Linux-green.svg"></a>
|
|
@@ -85,6 +90,22 @@ Annotates VCF files with delta scores and positions to evaluate the impact of ge
|
|
|
85
90
|
<div class="line"><br></div>
|
|
86
91
|
</div>
|
|
87
92
|
</section>
|
|
93
|
+
<section id="development-testing">
|
|
94
|
+
<h1>Development & Testing<a class="headerlink" href="#development-testing" title="Permalink to this heading">#</a></h1>
|
|
95
|
+
<p>Install the package with its development dependencies (pytest, pytest-cov, ruff, pre-commit) from a clone of the repository:</p>
|
|
96
|
+
<pre><code>pip install -e '.[dev]'</code></pre>
|
|
97
|
+
<p><strong>Tests</strong> live under <code>tests/</code> (<code>unit</code> / <code>integration</code> / <code>regression</code>) and run on CPU only:</p>
|
|
98
|
+
<pre><code>pytest -m "not slow and not integration" # fast inner loop
|
|
99
|
+
pytest # full suite</code></pre>
|
|
100
|
+
<p>Tests are tagged with markers (declared in <code>pytest.ini</code>) — <code>integration</code>, <code>slow</code>, <code>gpu</code>, and <code>keras</code> (auto-skipped when TensorFlow is absent) — selectable with <code>-m</code>, e.g. <code>pytest -m integration</code>.</p>
|
|
101
|
+
<p><strong>Lint and pre-commit hooks</strong> (configured in <code>ruff.toml</code> and <code>.pre-commit-config.yaml</code>):</p>
|
|
102
|
+
<pre><code>ruff check . # lint (add --fix to auto-fix)
|
|
103
|
+
pre-commit install # run ruff + checks on every commit</code></pre>
|
|
104
|
+
<p>See the <a class="reference external" href="https://ccb.jhu.edu/openspliceai/">full documentation</a> for the complete development and testing guide.</p>
|
|
105
|
+
<div class="line-block">
|
|
106
|
+
<div class="line"><br></div>
|
|
107
|
+
</div>
|
|
108
|
+
</section>
|
|
88
109
|
<section id="table-of-contents">
|
|
89
110
|
<h1>Table of Contents<a class="headerlink" href="#table-of-contents" title="Permalink to this heading">#</a></h1>
|
|
90
111
|
<div class="toctree-wrapper compound">
|
|
@@ -203,5 +224,7 @@ Annotates VCF files with delta scores and positions to evaluate the impact of ge
|
|
|
203
224
|
<div class="line"><br></div>
|
|
204
225
|
<div class="line"><br></div>
|
|
205
226
|
</div>
|
|
206
|
-
<
|
|
227
|
+
<p align="center">
|
|
228
|
+
<img alt="Johns Hopkins University" src="logo/jhu-logo-dark.png" width="40%">
|
|
229
|
+
</p>
|
|
207
230
|
</section>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = 'v0.0.6'
|
|
@@ -62,14 +62,14 @@ def evaluate_and_visualize(calibrated_model, data_loader, device, output_base_di
|
|
|
62
62
|
|
|
63
63
|
original_nll, original_ece = calibrated_model.compute_ece_nll(logits, labels)
|
|
64
64
|
with open(metric_original_file, 'w') as f:
|
|
65
|
-
f.write(
|
|
65
|
+
f.write("Original_NLL\tOriginal_ECE\n")
|
|
66
66
|
f.write(f"{original_nll:.8f}\t{original_ece:.8f}\n")
|
|
67
67
|
print(f"Original NLL: {original_nll:.8f}")
|
|
68
68
|
print(f"Original ECE: {original_ece:.8f}")
|
|
69
69
|
|
|
70
70
|
calibrated_nll, calibrated_ece = calibrated_model.compute_ece_nll(logits_scaled, labels)
|
|
71
71
|
with open(metric_calibrated_file, 'w') as f:
|
|
72
|
-
f.write(
|
|
72
|
+
f.write("Calibrated_NLL\tCalibrated_ECE\n")
|
|
73
73
|
f.write(f"{calibrated_nll:.8f}\t{calibrated_ece:.8f}\n")
|
|
74
74
|
print(f"Calibrated NLL: {calibrated_nll:.8f}")
|
|
75
75
|
print(f"Calibrated ECE: {calibrated_ece:.8f}")
|
|
@@ -110,6 +110,14 @@ def evaluate_and_visualize(calibrated_model, data_loader, device, output_base_di
|
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
def calibrate(args):
|
|
113
|
+
"""Temperature-scale a trained SpliceAI model (entry point for the ``calibrate`` subcommand).
|
|
114
|
+
|
|
115
|
+
Loads ``args.pretrained_model``, wraps it in a ``ModelWithTemperature``, and
|
|
116
|
+
fits a single temperature parameter on the validation set. Reports
|
|
117
|
+
calibration metrics (ECE/NLL/Brier) and writes calibration-curve plots and
|
|
118
|
+
per-dataset metric files, plus ``temperature.pt``/``.txt`` and a full
|
|
119
|
+
``calibrated_model.pt`` under ``{output_dir}/calibration``. Returns nothing.
|
|
120
|
+
"""
|
|
113
121
|
print("Running OpenSpliceAI with 'calibrate' mode")
|
|
114
122
|
start_time = time.time()
|
|
115
123
|
|
|
@@ -121,8 +129,8 @@ def calibrate(args):
|
|
|
121
129
|
|
|
122
130
|
# Set up the device, datasets, and indices
|
|
123
131
|
device = setup_environment(args)
|
|
124
|
-
train_h5f, test_h5f, batch_num = load_datasets(args)
|
|
125
|
-
train_idxs, val_idxs, test_idxs = generate_indices(
|
|
132
|
+
train_h5f, valid_h5f, test_h5f, batch_num = load_datasets(args)
|
|
133
|
+
train_idxs, val_idxs, test_idxs = generate_indices(train_h5f, valid_h5f, test_h5f)
|
|
126
134
|
|
|
127
135
|
# Initialize the model
|
|
128
136
|
model, model_params = initialize_model_and_optim(device, args.flanking_size, args.pretrained_model)
|
|
@@ -138,8 +146,9 @@ def calibrate(args):
|
|
|
138
146
|
print("Validation indices count:", len(val_idxs))
|
|
139
147
|
print("Test indices count:", len(test_idxs))
|
|
140
148
|
|
|
141
|
-
# Create data loaders for the validation (calibration) and test sets
|
|
142
|
-
|
|
149
|
+
# Create data loaders for the validation (calibration) and test sets.
|
|
150
|
+
# val_idxs index the validation file, so the loader must read from valid_h5f.
|
|
151
|
+
validation_loader = get_validation_loader(valid_h5f, val_idxs, model_params["BATCH_SIZE"])
|
|
143
152
|
test_loader = get_validation_loader(test_h5f, test_idxs, model_params["BATCH_SIZE"])
|
|
144
153
|
|
|
145
154
|
# Load or determine the temperature vector
|
{openspliceai-0.0.5 → openspliceai-0.0.6}/openspliceai/calibrate/temperature_scaling_site_only.py
RENAMED
|
@@ -5,14 +5,12 @@ Date: 2025-03-20
|
|
|
5
5
|
Description: Test script to calibrate the OpenSpliceAI model only on splice sites.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
import os
|
|
9
8
|
import torch
|
|
10
|
-
from torch import nn
|
|
9
|
+
from torch import nn
|
|
11
10
|
import torch.nn.functional as F
|
|
12
11
|
import numpy as np
|
|
13
12
|
from openspliceai.train_base.utils import *
|
|
14
13
|
from torch.utils.data import TensorDataset, DataLoader
|
|
15
|
-
from tqdm import tqdm
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
def load_data_from_shard(h5f, shard_idx):
|
|
@@ -131,6 +131,16 @@ def get_sequences_and_labels(db, output_dir, seq_dict, chrom_dict, train_or_test
|
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
def create_datafile(args):
|
|
134
|
+
"""Stage 1 of ``create-data``: extract per-gene sequences and splice labels into ``datafile_*.h5``.
|
|
135
|
+
|
|
136
|
+
Parses the annotation GFF (via gffutils) and genome FASTA, splits
|
|
137
|
+
chromosomes into train/test groups (``--split-method``), and for each gene
|
|
138
|
+
collects the (minus-strand reverse-complemented) sequence and a per-base
|
|
139
|
+
label marking donor=2 / acceptor=1 positions (optionally gated to canonical
|
|
140
|
+
motifs). Optionally removes paralogs between splits and carves a validation
|
|
141
|
+
set out of train. Side effect: writes ``datafile_{train,validation,test}.h5``
|
|
142
|
+
(string datasets SEQ/LABEL/STRAND/TX_START/TX_END) into ``args.output_dir``.
|
|
143
|
+
"""
|
|
134
144
|
print("Running OpenSpliceAI with 'create-data' mode")
|
|
135
145
|
print("--- Step 1: Creating datafile.h5 ... ---")
|
|
136
146
|
start_time = time.process_time()
|
|
@@ -15,6 +15,15 @@ from openspliceai.create_data.utils import ceil_div, replace_non_acgt_to_n, crea
|
|
|
15
15
|
CHUNK_SIZE = 100 # size of chunks to process data in
|
|
16
16
|
|
|
17
17
|
def create_dataset(args):
|
|
18
|
+
"""Stage 2 of ``create-data``: one-hot encode and window the datafiles into ``dataset_*.h5``.
|
|
19
|
+
|
|
20
|
+
Reads each ``datafile_{split}.h5`` produced by :func:`create_datafile`,
|
|
21
|
+
one-hot encodes the sequences (4 channels) and labels (3 channels), splits
|
|
22
|
+
them into fixed-length ``SL + CL_max`` windows, and stores them as chunked
|
|
23
|
+
``X0,X1,...`` / ``Y0,Y1,...`` datasets (100 genes per chunk). Side effect:
|
|
24
|
+
writes ``dataset_{train,validation,test}.h5`` into ``args.output_dir``,
|
|
25
|
+
ready to be streamed by the training loop.
|
|
26
|
+
"""
|
|
18
27
|
print("--- Step 2: Creating dataset.h5 ... ---")
|
|
19
28
|
start_time = time.process_time()
|
|
20
29
|
|
|
@@ -38,9 +47,6 @@ def create_dataset(args):
|
|
|
38
47
|
with h5py.File(input_file, 'r') as h5f:
|
|
39
48
|
SEQ = h5f['SEQ'][:]
|
|
40
49
|
LABEL = h5f['LABEL'][:]
|
|
41
|
-
STRAND = h5f['STRAND'][:]
|
|
42
|
-
TX_START = h5f['TX_START'][:]
|
|
43
|
-
TX_END = h5f['TX_END'][:]
|
|
44
50
|
|
|
45
51
|
print(f"\tWriting {output_file} ... ")
|
|
46
52
|
with h5py.File(output_file, 'w') as h5f2:
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
import gffutils
|
|
4
|
+
|
|
5
|
+
# Removed import openspliceai.create_data.utils as utils to avoid sklearn dependency
|
|
6
|
+
|
|
7
|
+
def create_or_load_db(gff_file, db_file='gff.db'):
|
|
8
|
+
"""
|
|
9
|
+
Create a gffutils database from a GFF file, or load it if it already exists.
|
|
10
|
+
"""
|
|
11
|
+
if not os.path.exists(db_file):
|
|
12
|
+
print("Creating new database...")
|
|
13
|
+
db = gffutils.create_db(gff_file, dbfn=db_file, force=True, keep_order=True, merge_strategy='merge', sort_attribute_values=True)
|
|
14
|
+
else:
|
|
15
|
+
print("Loading existing database...")
|
|
16
|
+
db = gffutils.FeatureDB(db_file)
|
|
17
|
+
return db
|
|
18
|
+
|
|
19
|
+
def get_canonical_transcript(gene, db):
|
|
20
|
+
"""
|
|
21
|
+
Select the canonical transcript for a gene (longest transcript).
|
|
22
|
+
"""
|
|
23
|
+
# Look for both 'mRNA' and 'transcript' feature types
|
|
24
|
+
transcripts_mRNA = list(db.children(gene, featuretype='mRNA', order_by='start'))
|
|
25
|
+
transcripts_transcript = list(db.children(gene, featuretype='transcript', order_by='start'))
|
|
26
|
+
|
|
27
|
+
transcripts = transcripts_mRNA + transcripts_transcript
|
|
28
|
+
|
|
29
|
+
if not transcripts:
|
|
30
|
+
return None
|
|
31
|
+
|
|
32
|
+
max_trans = transcripts[0]
|
|
33
|
+
max_len = max_trans.end - max_trans.start + 1
|
|
34
|
+
for transcript in transcripts:
|
|
35
|
+
length = transcript.end - transcript.start + 1
|
|
36
|
+
if length > max_len:
|
|
37
|
+
max_trans = transcript
|
|
38
|
+
max_len = length
|
|
39
|
+
return max_trans
|
|
40
|
+
|
|
41
|
+
def main():
|
|
42
|
+
parser = argparse.ArgumentParser(description="Convert GFF3 annotation to TSV format.")
|
|
43
|
+
parser.add_argument("gff_file", help="Path to the input GFF3 file.")
|
|
44
|
+
parser.add_argument("output_file", help="Path to the output TSV file.")
|
|
45
|
+
args = parser.parse_args()
|
|
46
|
+
|
|
47
|
+
print(f"Processing {args.gff_file}...")
|
|
48
|
+
db = create_or_load_db(args.gff_file, db_file=f'{args.gff_file}_db')
|
|
49
|
+
|
|
50
|
+
with open(args.output_file, 'w') as out_f:
|
|
51
|
+
# Write header
|
|
52
|
+
out_f.write("#NAME\tCHROM\tSTRAND\tTX_START\tTX_END\tEXON_START\tEXON_END\n")
|
|
53
|
+
|
|
54
|
+
for gene in db.features_of_type('gene'):
|
|
55
|
+
# Filter for protein_coding genes
|
|
56
|
+
# Check gene_biotype (Standard/Ensembl) or gene_type (MANE/Gencode)
|
|
57
|
+
is_protein_coding = False
|
|
58
|
+
if 'gene_biotype' in gene.attributes and gene.attributes['gene_biotype'][0] == 'protein_coding':
|
|
59
|
+
is_protein_coding = True
|
|
60
|
+
elif 'gene_type' in gene.attributes and gene.attributes['gene_type'][0] == 'protein_coding':
|
|
61
|
+
is_protein_coding = True
|
|
62
|
+
|
|
63
|
+
# If biotype/type is specified but not protein_coding, skip.
|
|
64
|
+
# If neither attribute exists, decision depends on strictness.
|
|
65
|
+
# Given the loop logic "Filter for protein_coding", we should probably skip if we can't confirm it's protein_coding?
|
|
66
|
+
# Or if it's missing, maybe include it?
|
|
67
|
+
# Previous logic was "if biotype exists and != protein_coding then skip".
|
|
68
|
+
# I will preserve that: if we find a type attribute and it says NOT protein_coding, we skip.
|
|
69
|
+
# If we find NO type attribute, we include it (assumed safe or user wants it).
|
|
70
|
+
# BUT, the user's issue was empty output, implying things got filtered out or not found.
|
|
71
|
+
# In MANE GFF, `gene_type=protein_coding` IS present.
|
|
72
|
+
# So I should check:
|
|
73
|
+
|
|
74
|
+
skip = False
|
|
75
|
+
if 'gene_biotype' in gene.attributes:
|
|
76
|
+
if gene.attributes['gene_biotype'][0] != 'protein_coding':
|
|
77
|
+
skip = True
|
|
78
|
+
elif 'gene_type' in gene.attributes:
|
|
79
|
+
if gene.attributes['gene_type'][0] != 'protein_coding':
|
|
80
|
+
skip = True
|
|
81
|
+
|
|
82
|
+
# If we want to strictly enforce protein_coding when the attribute exists.
|
|
83
|
+
# For MANE, we saw gene_type=protein_coding.
|
|
84
|
+
|
|
85
|
+
if skip:
|
|
86
|
+
continue
|
|
87
|
+
|
|
88
|
+
transcript = get_canonical_transcript(gene, db)
|
|
89
|
+
if not transcript:
|
|
90
|
+
continue
|
|
91
|
+
|
|
92
|
+
exons = list(db.children(transcript, featuretype='exon', order_by='start'))
|
|
93
|
+
if not exons:
|
|
94
|
+
continue
|
|
95
|
+
|
|
96
|
+
# Extract coordinates
|
|
97
|
+
# GFF is 1-based, output requires 0-based start, 1-based end.
|
|
98
|
+
tx_start = transcript.start - 1
|
|
99
|
+
tx_end = transcript.end
|
|
100
|
+
|
|
101
|
+
exon_starts = []
|
|
102
|
+
exon_ends = []
|
|
103
|
+
|
|
104
|
+
for exon in exons:
|
|
105
|
+
exon_starts.append(str(exon.start - 1))
|
|
106
|
+
exon_ends.append(str(exon.end))
|
|
107
|
+
|
|
108
|
+
exon_start_str = ",".join(exon_starts) + ","
|
|
109
|
+
exon_end_str = ",".join(exon_ends) + ","
|
|
110
|
+
|
|
111
|
+
# Name
|
|
112
|
+
# Try 'Name', then 'gene_name', then 'ID'
|
|
113
|
+
gene_name = gene.id
|
|
114
|
+
if 'Name' in gene.attributes:
|
|
115
|
+
gene_name = gene.attributes['Name'][0]
|
|
116
|
+
elif 'gene_name' in gene.attributes:
|
|
117
|
+
gene_name = gene.attributes['gene_name'][0]
|
|
118
|
+
|
|
119
|
+
out_f.write(f"{gene_name}\t{gene.seqid}\t{gene.strand}\t{tx_start}\t{tx_end}\t{exon_start_str}\t{exon_end_str}\n")
|
|
120
|
+
|
|
121
|
+
print(f"Done. Output written to {args.output_file}")
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
main()
|
|
@@ -22,7 +22,7 @@ def remove_paralogous_sequences(train_data, test_data, min_identity, min_coverag
|
|
|
22
22
|
:param min_coverage: Minimum coverage for sequences to be considered paralogous
|
|
23
23
|
:return: Tuple of (filtered_train_data, filtered_test_data)
|
|
24
24
|
"""
|
|
25
|
-
print(
|
|
25
|
+
print("\tStarting paralogy removal process...")
|
|
26
26
|
print(f"\tInitial train set size: {len(train_data[0])}")
|
|
27
27
|
print(f"\tInitial test set size: {len(test_data[0])}")
|
|
28
28
|
train_seqs = train_data[5] # SEQ is at index 5
|
|
@@ -44,7 +44,7 @@ def remove_paralogous_sequences(train_data, test_data, min_identity, min_coverag
|
|
|
44
44
|
filtered_test_data = [[] for _ in range(len(test_data))]
|
|
45
45
|
paralogous_count = 0
|
|
46
46
|
total_count = len(test_data[5])
|
|
47
|
-
fw = open(f"
|
|
47
|
+
fw = open(os.path.join(output_dir, f"removed_paralogs_{exp}.txt"), "w")
|
|
48
48
|
print("\tStarting to process test sequences...")
|
|
49
49
|
for i in range(total_count): # Iterate over test sequences
|
|
50
50
|
test_seq = test_data[5][i]
|
|
@@ -65,7 +65,7 @@ def remove_paralogous_sequences(train_data, test_data, min_identity, min_coverag
|
|
|
65
65
|
# Log progress every 1000 sequences
|
|
66
66
|
if (i + 1) % 1000 == 0:
|
|
67
67
|
print(f"\tProcessed {i + 1}/{total_count} sequences...")
|
|
68
|
-
print(
|
|
68
|
+
print("\tParalogy removal process completed.")
|
|
69
69
|
print(f"\tNumber of paralogous sequences removed: {paralogous_count}")
|
|
70
70
|
print(f"\tFinal {exp} set size: {len(filtered_test_data[0])}")
|
|
71
71
|
print(f"\tPercentage of {exp} set removed: {(paralogous_count / total_count) * 100:.2f}%")
|
|
@@ -77,7 +77,7 @@ def write_h5_file(output_dir, data_type, data):
|
|
|
77
77
|
"""
|
|
78
78
|
Write the data to an h5 file.
|
|
79
79
|
"""
|
|
80
|
-
h5fname = output_dir
|
|
80
|
+
h5fname = os.path.join(output_dir, f'datafile_{data_type}.h5')
|
|
81
81
|
h5f = h5py.File(h5fname, 'w')
|
|
82
82
|
dt = h5py.string_dtype(encoding='utf-8')
|
|
83
83
|
|
|
@@ -6,11 +6,11 @@ Description: Functions to process sequences to/from .h5 datasets.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import os
|
|
9
|
+
import warnings
|
|
9
10
|
import numpy as np
|
|
10
11
|
from math import ceil
|
|
11
12
|
import gffutils
|
|
12
13
|
import random
|
|
13
|
-
from sklearn.metrics import average_precision_score
|
|
14
14
|
from openspliceai.constants import *
|
|
15
15
|
|
|
16
16
|
def check_and_count_motifs(seq, labels, donor_motif_counts, acceptor_motif_counts):
|
|
@@ -62,7 +62,6 @@ def split_chromosomes(seq_dict, method='random', split_ratio=0.8):
|
|
|
62
62
|
print("Chromosome lengths: ", chromosome_lengths)
|
|
63
63
|
if method == 'random':
|
|
64
64
|
total_length = sum(chromosome_lengths.values())
|
|
65
|
-
target_train_length = total_length * split_ratio
|
|
66
65
|
target_test_length = total_length * (1-split_ratio)
|
|
67
66
|
chromosomes = list(chromosome_lengths.keys())
|
|
68
67
|
random.shuffle(chromosomes)
|
|
@@ -90,7 +89,19 @@ def split_chromosomes(seq_dict, method='random', split_ratio=0.8):
|
|
|
90
89
|
test_chroms = {
|
|
91
90
|
'chr1': 0, 'chr3': 0, 'chr5': 0, 'chr7': 0, 'chr9': 0
|
|
92
91
|
}
|
|
93
|
-
|
|
92
|
+
# Warn loudly if the genome's sequence names don't match the hardcoded UCSC-style
|
|
93
|
+
# human chromosome names -- otherwise every gene is silently skipped downstream,
|
|
94
|
+
# producing an (almost) empty dataset with no error.
|
|
95
|
+
present = set(seq_dict.keys())
|
|
96
|
+
requested = set(train_chroms) | set(test_chroms)
|
|
97
|
+
if present.isdisjoint(requested):
|
|
98
|
+
warnings.warn(
|
|
99
|
+
"split-method 'human' expects UCSC-style chromosome names (chr1, chr2, ...), "
|
|
100
|
+
f"but none were found in the genome (e.g. {sorted(present)[:3]}). All genes "
|
|
101
|
+
"will be skipped -- use --split-method random, or rename the sequences.",
|
|
102
|
+
stacklevel=2,
|
|
103
|
+
)
|
|
104
|
+
else:
|
|
94
105
|
raise ValueError("Invalid chromosome split method. Use 'random' or 'human'.")
|
|
95
106
|
return train_chroms, test_chroms
|
|
96
107
|
|
|
@@ -9,7 +9,6 @@ import h5py
|
|
|
9
9
|
import torch
|
|
10
10
|
import matplotlib.pyplot as plt
|
|
11
11
|
import time
|
|
12
|
-
import h5py
|
|
13
12
|
|
|
14
13
|
def verify_h5(args):
|
|
15
14
|
"""
|
|
@@ -44,9 +43,12 @@ def verify_h5(args):
|
|
|
44
43
|
Y0_tensor = torch.from_numpy(hf['Y0'][:])
|
|
45
44
|
print(f"X0 shape: {X0_tensor.shape}, Y0 shape: {Y0_tensor.shape}")
|
|
46
45
|
|
|
47
|
-
# process a
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
# process a representative chunk (the last available) for visualization.
|
|
47
|
+
# The dataset may have only a handful of chunks (X0, X1, ...), so pick the
|
|
48
|
+
# last one that exists rather than a hardcoded index.
|
|
49
|
+
last_idx = max((int(k[1:]) for k in hf.keys() if k.startswith('X')))
|
|
50
|
+
x = torch.from_numpy(hf[f'X{last_idx}'][:]).float()
|
|
51
|
+
y = torch.from_numpy(hf[f'Y{last_idx}'][:])
|
|
50
52
|
print(f"x[0].shape: {x[0].shape}, y[0].shape: {y[0].shape}")
|
|
51
53
|
|
|
52
54
|
# plot the sum of the last entry in the 'X3' dataset along its rows
|
|
@@ -6,12 +6,9 @@ Description: Merge dataset.h5 files.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import h5py
|
|
9
|
-
import
|
|
10
|
-
import sys, os
|
|
9
|
+
import os
|
|
11
10
|
import time
|
|
12
11
|
# from utils import *
|
|
13
|
-
import argparse
|
|
14
|
-
import openspliceai.create_data.utils as utils
|
|
15
12
|
|
|
16
13
|
donor_motif_counts = {} # Initialize counts
|
|
17
14
|
acceptor_motif_counts = {} # Initialize counts
|
|
@@ -19,6 +19,7 @@ from openspliceai.variant import variant
|
|
|
19
19
|
__VERSION__ = header.__version__
|
|
20
20
|
|
|
21
21
|
def parse_args_create_data(subparsers):
|
|
22
|
+
"""Register the ``create-data`` subcommand and its arguments (GFF + FASTA -> train/test HDF5 datasets)."""
|
|
22
23
|
parser_create_data = subparsers.add_parser('create-data', help='Create dataset for your genome for SpliceAI model training')
|
|
23
24
|
parser_create_data.add_argument('--annotation-gff', type=str, required=True, help='Path to the GFF file')
|
|
24
25
|
parser_create_data.add_argument('--genome-fasta', type=str, required=True, help='Path to the FASTA file')
|
|
@@ -39,6 +40,7 @@ def parse_args_create_data(subparsers):
|
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
def parse_args_train(subparsers):
|
|
43
|
+
"""Register the ``train`` subcommand and its arguments (train a SpliceAI model from scratch on HDF5 datasets)."""
|
|
42
44
|
parser_train = subparsers.add_parser('train', help='Train the SpliceAI model')
|
|
43
45
|
parser_train.add_argument('--epochs', '-n', type=int, default=10, help='Number of epochs for training')
|
|
44
46
|
parser_train.add_argument('--scheduler', '-s', type=str, default="MultiStepLR", choices=["MultiStepLR", "CosineAnnealingWarmRestarts"], help="Learning rate scheduler")
|
|
@@ -56,6 +58,7 @@ def parse_args_train(subparsers):
|
|
|
56
58
|
|
|
57
59
|
|
|
58
60
|
def parse_args_test(subparsers):
|
|
61
|
+
"""Register the (currently disabled) ``test`` subcommand and its arguments (evaluate a pretrained model)."""
|
|
59
62
|
parser_test = subparsers.add_parser('test', help='Test the SpliceAI model')
|
|
60
63
|
parser_test.add_argument("--pretrained-model", '-m', type=str, required=True, help="Path to the pre-trained model")
|
|
61
64
|
parser_test.add_argument('--output-dir', '-o', type=str, required=True, help='Output directory to save the data')
|
|
@@ -70,6 +73,7 @@ def parse_args_test(subparsers):
|
|
|
70
73
|
|
|
71
74
|
|
|
72
75
|
def parse_args_calibrate(subparsers):
|
|
76
|
+
"""Register the ``calibrate`` subcommand and its arguments (post-hoc temperature scaling of a trained model)."""
|
|
73
77
|
parser_calibrate = subparsers.add_parser('calibrate', help='Calibrate the SpliceAI model')
|
|
74
78
|
parser_calibrate.add_argument('--epochs', '-n', type=int, default=10, help='Number of epochs for training')
|
|
75
79
|
parser_calibrate.add_argument('--early-stopping', '-E', action='store_true', default=False, help='Enable early stopping')
|
|
@@ -87,6 +91,7 @@ def parse_args_calibrate(subparsers):
|
|
|
87
91
|
|
|
88
92
|
|
|
89
93
|
def parse_args_transfer(subparsers):
|
|
94
|
+
"""Register the ``transfer`` subcommand and its arguments (fine-tune a pretrained model on new data, optionally freezing layers)."""
|
|
90
95
|
parser_transfer = subparsers.add_parser('transfer', help='transfer a pre-trained SpliceAI model on new data.')
|
|
91
96
|
parser_transfer.add_argument('--epochs', '-n', type=int, default=10, help='Number of epochs for training')
|
|
92
97
|
parser_transfer.add_argument('--scheduler', '-s', type=str, default="MultiStepLR", choices=["MultiStepLR", "CosineAnnealingWarmRestarts"], help="Learning rate scheduler")
|
|
@@ -101,15 +106,16 @@ def parse_args_transfer(subparsers):
|
|
|
101
106
|
parser_transfer.add_argument("--train-dataset", '-train', type=str, required=True, help="Path to the training dataset")
|
|
102
107
|
parser_transfer.add_argument("--test-dataset", '-test', type=str, required=True, help="Path to the testing dataset")
|
|
103
108
|
parser_transfer.add_argument("--loss", '-l', type=str, default='cross_entropy_loss', choices=["cross_entropy_loss", "focal_loss"], help="Loss function for fine-tuning")
|
|
104
|
-
parser_transfer.add_argument("--unfreeze-all", '-A', action='store_true', default=
|
|
109
|
+
parser_transfer.add_argument("--unfreeze-all", '-A', action='store_true', default=False, help='Unfreeze all layers for fine-tuning (default: freeze all but the last --unfreeze residual units)')
|
|
105
110
|
parser_transfer.add_argument("--unfreeze", '-u', type=int, default=1, help="Number of layers to unfreeze for fine-tuning")
|
|
106
111
|
|
|
107
112
|
|
|
108
113
|
def parse_args_predict(subparsers):
|
|
114
|
+
"""Register the ``predict`` subcommand and its arguments (score a FASTA and write donor/acceptor BED predictions)."""
|
|
109
115
|
parser_predict = subparsers.add_parser('predict', help='Predict splice sites in a given sequence using the SpliceAI model')
|
|
110
116
|
parser_predict.add_argument('--input-sequence', '-i', type=str, required=True, help="Path to FASTA file of the input sequence")
|
|
111
117
|
parser_predict.add_argument('--model', '-m', type=str, required=True, help='Path to a PyTorch SpliceAI model file')
|
|
112
|
-
parser_predict.add_argument('--flanking-size', '-f', type=int, required=True, help='Sum of flanking sequence lengths on each side of input (i.e. 40+40)')
|
|
118
|
+
parser_predict.add_argument('--flanking-size', '-f', type=int, required=True, choices=[80, 400, 2000, 10000], help='Sum of flanking sequence lengths on each side of input (i.e. 40+40)')
|
|
113
119
|
parser_predict.add_argument('--output-dir', '-o', type=str, default="./predict_out", help='Output directory to save the data')
|
|
114
120
|
parser_predict.add_argument('--annotation-file', '-a', type=str, required=False, help="Path to GFF file of coordinates for genes")
|
|
115
121
|
parser_predict.add_argument('--threshold', '-t', type=float, default=1e-6, help="Threshold to determine acceptor and donor sites")
|
|
@@ -123,6 +129,7 @@ def parse_args_predict(subparsers):
|
|
|
123
129
|
|
|
124
130
|
|
|
125
131
|
def parse_args_variant(subparsers):
|
|
132
|
+
"""Register the ``variant`` subcommand and its arguments (annotate a VCF with splicing delta scores)."""
|
|
126
133
|
parser_variant = subparsers.add_parser('variant', help='Label genetic variations with their predicted effects on splicing.')
|
|
127
134
|
parser_variant.add_argument('-R', '--ref-genome', metavar='reference', required=True, help='path to the reference genome fasta file')
|
|
128
135
|
parser_variant.add_argument('-A', '--annotation', metavar='annotation', required=True, help='"grch37" (GENCODE V24lift37 canonical annotation file in '
|
|
@@ -138,12 +145,13 @@ def parse_args_variant(subparsers):
|
|
|
138
145
|
'unannotated acceptor/donor loss, defaults to 0')
|
|
139
146
|
'''AM: newly added flags below vv'''
|
|
140
147
|
parser_variant.add_argument('--model', '-m', default="SpliceAI", type=str, help='Path to a SpliceAI model file, or path to a directory of SpliceAI models, or "SpliceAI" for the default model')
|
|
141
|
-
parser_variant.add_argument('--flanking-size', '-f', type=int, default=80, help='Sum of flanking sequence lengths on each side of input (i.e. 40+40)')
|
|
148
|
+
parser_variant.add_argument('--flanking-size', '-f', type=int, default=80, choices=[80, 400, 2000, 10000], help='Sum of flanking sequence lengths on each side of input (i.e. 40+40)')
|
|
142
149
|
parser_variant.add_argument('--model-type', '-t', type=str, choices=['keras', 'pytorch'], default='pytorch', help='Type of model file (keras or pytorch)')
|
|
143
150
|
parser_variant.add_argument('--precision', '-p', type=int, default=2, help='Number of decimal places to round the output scores')
|
|
144
151
|
|
|
145
152
|
|
|
146
153
|
def parse_args(arglist):
|
|
154
|
+
"""Build the top-level argument parser with all subcommands and parse ``arglist`` (or ``sys.argv``)."""
|
|
147
155
|
parser = argparse.ArgumentParser(description='OpenSpliceAI toolkit to help you retrain your own splice site predictor')
|
|
148
156
|
# Create a parent subparser to house the common subcommands.
|
|
149
157
|
subparsers = parser.add_subparsers(dest='command', required=True, help='Subcommands: create-data, train, calibrate, predict, transfer, variant')
|
|
@@ -162,6 +170,13 @@ def parse_args(arglist):
|
|
|
162
170
|
|
|
163
171
|
|
|
164
172
|
def main(arglist=None):
|
|
173
|
+
"""Console entry point: print the banner, parse args, and dispatch to the chosen subcommand.
|
|
174
|
+
|
|
175
|
+
Dispatches ``args.command`` to its package: ``create-data`` runs
|
|
176
|
+
``create_datafile`` then ``create_dataset`` (and ``verify_h5`` if requested),
|
|
177
|
+
and ``train`` / ``calibrate`` / ``transfer`` / ``predict`` / ``variant`` each
|
|
178
|
+
call their respective entry-point function.
|
|
179
|
+
"""
|
|
165
180
|
# ANSI Shadow
|
|
166
181
|
banner = '''
|
|
167
182
|
============================================================
|