genoray-cli 0.1.1__py3-none-any.whl → 0.2.0__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.
- genoray_cli/__main__.py +30 -19
- {genoray_cli-0.1.1.dist-info → genoray_cli-0.2.0.dist-info}/METADATA +3 -3
- genoray_cli-0.2.0.dist-info/RECORD +7 -0
- {genoray_cli-0.1.1.dist-info → genoray_cli-0.2.0.dist-info}/WHEEL +1 -1
- genoray_cli-0.1.1.dist-info/RECORD +0 -7
- {genoray_cli-0.1.1.dist-info → genoray_cli-0.2.0.dist-info}/entry_points.txt +0 -0
- {genoray_cli-0.1.1.dist-info → genoray_cli-0.2.0.dist-info}/licenses/LICENSE +0 -0
genoray_cli/__main__.py
CHANGED
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from importlib.metadata import version
|
|
6
6
|
from pathlib import Path
|
|
7
|
+
from typing import Union
|
|
7
8
|
|
|
8
9
|
from cyclopts import App
|
|
9
10
|
|
|
@@ -18,7 +19,8 @@ app = App(
|
|
|
18
19
|
@app.command
|
|
19
20
|
def index(source: Path):
|
|
20
21
|
"""Create a genoray index for a VCF or PGEN file."""
|
|
21
|
-
from genoray import
|
|
22
|
+
from genoray import VCF
|
|
23
|
+
from genoray._pgen import _write_index
|
|
22
24
|
from genoray._utils import variant_file_type
|
|
23
25
|
|
|
24
26
|
file_type = variant_file_type(source)
|
|
@@ -26,7 +28,16 @@ def index(source: Path):
|
|
|
26
28
|
vcf = VCF(source)
|
|
27
29
|
vcf._write_gvi_index()
|
|
28
30
|
elif file_type == "pgen":
|
|
29
|
-
|
|
31
|
+
index = source.with_suffix(".pvar")
|
|
32
|
+
|
|
33
|
+
if not index.exists():
|
|
34
|
+
index = source.with_suffix(".pvar.zst")
|
|
35
|
+
|
|
36
|
+
if not index.exists():
|
|
37
|
+
raise FileNotFoundError("No index file found.")
|
|
38
|
+
|
|
39
|
+
index = index.with_suffix(f"{index.suffix}.gvi")
|
|
40
|
+
_write_index(index)
|
|
30
41
|
else:
|
|
31
42
|
raise ValueError(f"Unsupported file type: {source}")
|
|
32
43
|
|
|
@@ -37,7 +48,8 @@ def write(
|
|
|
37
48
|
out: Path,
|
|
38
49
|
max_mem: str = "1g",
|
|
39
50
|
overwrite: bool = False,
|
|
40
|
-
dosages:
|
|
51
|
+
dosages: Union[str, None] = None,
|
|
52
|
+
threads: int | None = None,
|
|
41
53
|
) -> None:
|
|
42
54
|
"""
|
|
43
55
|
Convert a VCF or PGEN file to a SVAR file.
|
|
@@ -53,8 +65,12 @@ def write(
|
|
|
53
65
|
overwrite
|
|
54
66
|
Whether to overwrite the output file if it exists.
|
|
55
67
|
dosages
|
|
56
|
-
Whether to write dosages.
|
|
57
|
-
If
|
|
68
|
+
Whether to write dosages.
|
|
69
|
+
If `source` is a PGEN, this must be a path to a PGEN of dosages.
|
|
70
|
+
If `source` is a VCF, this must be the name of the FORMAT field to use for dosages.
|
|
71
|
+
If not provided, dosages will not be written.
|
|
72
|
+
threads
|
|
73
|
+
Number of threads to use for conversion. Defaults to the number of available CPU cores.
|
|
58
74
|
"""
|
|
59
75
|
from genoray import PGEN, VCF, SparseVar
|
|
60
76
|
from genoray._utils import variant_file_type
|
|
@@ -66,29 +82,24 @@ def write(
|
|
|
66
82
|
else:
|
|
67
83
|
with_dosages = True
|
|
68
84
|
|
|
69
|
-
if
|
|
70
|
-
|
|
71
|
-
raise ValueError(
|
|
72
|
-
"Dosages must be provided as a string for a VCF FORMAT field if the source is a VCF."
|
|
73
|
-
)
|
|
85
|
+
if threads is None:
|
|
86
|
+
threads = -1
|
|
74
87
|
|
|
88
|
+
if file_type == "vcf":
|
|
75
89
|
if dosages is not None and Path(dosages).exists():
|
|
76
90
|
raise ValueError(
|
|
77
91
|
"The `dosages` argument appears to be a path to an existing file, but VCF requires a FORMAT field name."
|
|
78
92
|
)
|
|
79
93
|
|
|
80
94
|
vcf = VCF(source, dosage_field=dosages)
|
|
81
|
-
SparseVar.from_vcf(
|
|
95
|
+
SparseVar.from_vcf(
|
|
96
|
+
out, vcf, max_mem, overwrite, with_dosages=with_dosages, n_jobs=threads
|
|
97
|
+
)
|
|
82
98
|
elif file_type == "pgen":
|
|
83
|
-
if dosages is False:
|
|
84
|
-
dosages = None
|
|
85
|
-
elif dosages is True:
|
|
86
|
-
raise ValueError(
|
|
87
|
-
"Dosages must be provided as a path to a PGEN if source is a PGEN."
|
|
88
|
-
)
|
|
89
|
-
|
|
90
99
|
pgen = PGEN(source, dosage_path=dosages)
|
|
91
|
-
SparseVar.from_pgen(
|
|
100
|
+
SparseVar.from_pgen(
|
|
101
|
+
out, pgen, max_mem, overwrite, with_dosages=with_dosages, n_jobs=threads
|
|
102
|
+
)
|
|
92
103
|
else:
|
|
93
104
|
raise ValueError(f"Unsupported file type: {source}")
|
|
94
105
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: genoray-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Command line interface for genoray
|
|
5
5
|
Author-email: David Laub <dlaub@ucsd.edu>
|
|
6
6
|
License: MIT License
|
|
@@ -25,9 +25,9 @@ License: MIT License
|
|
|
25
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
SOFTWARE.
|
|
27
27
|
License-File: LICENSE
|
|
28
|
-
Requires-Python: <3.
|
|
28
|
+
Requires-Python: <3.14,>=3.10
|
|
29
29
|
Requires-Dist: cyclopts
|
|
30
|
-
Requires-Dist: genoray
|
|
30
|
+
Requires-Dist: genoray>=2.1.0
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
|
|
33
33
|
# genoray-cli
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
genoray_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
genoray_cli/__main__.py,sha256=uia1uAAAseRKb8maAOrqsjP8Dthd56F3fm5SBGhj5Co,3084
|
|
3
|
+
genoray_cli-0.2.0.dist-info/METADATA,sha256=qhqwuPHZk43NA3oLeKJeYkkalbQ_Ktf-tuqh146utXQ,1554
|
|
4
|
+
genoray_cli-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
5
|
+
genoray_cli-0.2.0.dist-info/entry_points.txt,sha256=zEVH4akzYLF810qEzeFM9J9tdcSYXopO_8X8SgCIshw,53
|
|
6
|
+
genoray_cli-0.2.0.dist-info/licenses/LICENSE,sha256=ubiV4_yGkI9lmTqj0wsoakQI38ZaN4qgI_psNvVWpW4,1067
|
|
7
|
+
genoray_cli-0.2.0.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
genoray_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
genoray_cli/__main__.py,sha256=kmKfuqiAPVefh8b7D-ZNWIENNQG-x3klIymFxXxTBdo,2830
|
|
3
|
-
genoray_cli-0.1.1.dist-info/METADATA,sha256=5AuOMhu4upgNzQpBH_94LAx7B5iwhCtUjX0yGGPUlN4,1546
|
|
4
|
-
genoray_cli-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
5
|
-
genoray_cli-0.1.1.dist-info/entry_points.txt,sha256=zEVH4akzYLF810qEzeFM9J9tdcSYXopO_8X8SgCIshw,53
|
|
6
|
-
genoray_cli-0.1.1.dist-info/licenses/LICENSE,sha256=ubiV4_yGkI9lmTqj0wsoakQI38ZaN4qgI_psNvVWpW4,1067
|
|
7
|
-
genoray_cli-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|