genoray-cli 0.1.0__py3-none-any.whl → 0.1.1__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 CHANGED
@@ -1,8 +1,9 @@
1
1
  #! /usr/bin/env python
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  from importlib.metadata import version
4
6
  from pathlib import Path
5
- from typing import Optional, Union
6
7
 
7
8
  from cyclopts import App
8
9
 
@@ -36,42 +37,55 @@ def write(
36
37
  out: Path,
37
38
  max_mem: str = "1g",
38
39
  overwrite: bool = False,
39
- dosages: Optional[Union[bool, Path]] = None,
40
+ dosages: bool | str | None = None,
40
41
  ) -> None:
41
42
  """
42
43
  Convert a VCF or PGEN file to a SVAR file.
43
44
 
44
45
  Parameters
45
46
  ----------
46
- source : Path
47
+ source
47
48
  Path to the input VCF or PGEN file.
48
- out : Path
49
+ out
49
50
  Path to the output SVAR file.
50
- max_mem : str, optional
51
+ max_mem
51
52
  Maximum memory to use for conversion e.g. 1g, 250 MB, etc.
52
- overwrite : bool, optional
53
+ overwrite
53
54
  Whether to overwrite the output file if it exists.
54
- dosages : bool | Path | None, optional
55
+ dosages
55
56
  Whether to write dosages. If :code:`source` is a PGEN, this must be a path to a PGEN of dosages.
56
- If :code:`source` is a VCF, this should be a boolean.
57
+ If :code:`source` is a VCF, this must be the name of the FORMAT field to use for dosages.
57
58
  """
58
59
  from genoray import PGEN, VCF, SparseVar
59
60
  from genoray._utils import variant_file_type
60
61
 
61
62
  file_type = variant_file_type(source)
63
+
64
+ if dosages is None:
65
+ with_dosages = False
66
+ else:
67
+ with_dosages = True
68
+
62
69
  if file_type == "vcf":
63
- vcf = VCF(source)
64
- SparseVar.from_vcf(out, vcf, max_mem, overwrite, with_dosages=dosages)
70
+ if isinstance(dosages, bool):
71
+ raise ValueError(
72
+ "Dosages must be provided as a string for a VCF FORMAT field if the source is a VCF."
73
+ )
74
+
75
+ if dosages is not None and Path(dosages).exists():
76
+ raise ValueError(
77
+ "The `dosages` argument appears to be a path to an existing file, but VCF requires a FORMAT field name."
78
+ )
79
+
80
+ vcf = VCF(source, dosage_field=dosages)
81
+ SparseVar.from_vcf(out, vcf, max_mem, overwrite, with_dosages=with_dosages)
65
82
  elif file_type == "pgen":
66
83
  if dosages is False:
67
84
  dosages = None
68
- with_dosages = False
69
85
  elif dosages is True:
70
86
  raise ValueError(
71
87
  "Dosages must be provided as a path to a PGEN if source is a PGEN."
72
88
  )
73
- else:
74
- with_dosages = True
75
89
 
76
90
  pgen = PGEN(source, dosage_path=dosages)
77
91
  SparseVar.from_pgen(out, pgen, max_mem, overwrite, with_dosages=with_dosages)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: genoray-cli
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Command line interface for genoray
5
5
  Author-email: David Laub <dlaub@ucsd.edu>
6
6
  License: MIT License
@@ -0,0 +1,7 @@
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,,
@@ -1,7 +0,0 @@
1
- genoray_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- genoray_cli/__main__.py,sha256=plHNL0CBZkzFDegi2mXXcIVrtHnF0vBPZh5SikeXqlA,2430
3
- genoray_cli-0.1.0.dist-info/METADATA,sha256=3oUsBcWj4FTbIDWjnpeB3o5FgHtRHINUuTUjha3n42E,1546
4
- genoray_cli-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- genoray_cli-0.1.0.dist-info/entry_points.txt,sha256=zEVH4akzYLF810qEzeFM9J9tdcSYXopO_8X8SgCIshw,53
6
- genoray_cli-0.1.0.dist-info/licenses/LICENSE,sha256=ubiV4_yGkI9lmTqj0wsoakQI38ZaN4qgI_psNvVWpW4,1067
7
- genoray_cli-0.1.0.dist-info/RECORD,,