genoray-cli 0.1.0__py3-none-any.whl → 0.1.2__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,10 @@
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
7
+ from typing import Union
6
8
 
7
9
  from cyclopts import App
8
10
 
@@ -36,43 +38,46 @@ def write(
36
38
  out: Path,
37
39
  max_mem: str = "1g",
38
40
  overwrite: bool = False,
39
- dosages: Optional[Union[bool, Path]] = None,
41
+ dosages: Union[str, None] = None,
40
42
  ) -> None:
41
43
  """
42
44
  Convert a VCF or PGEN file to a SVAR file.
43
45
 
44
46
  Parameters
45
47
  ----------
46
- source : Path
48
+ source
47
49
  Path to the input VCF or PGEN file.
48
- out : Path
50
+ out
49
51
  Path to the output SVAR file.
50
- max_mem : str, optional
52
+ max_mem
51
53
  Maximum memory to use for conversion e.g. 1g, 250 MB, etc.
52
- overwrite : bool, optional
54
+ overwrite
53
55
  Whether to overwrite the output file if it exists.
54
- dosages : bool | Path | None, optional
55
- 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.
56
+ dosages
57
+ Whether to write dosages.
58
+ If `source` is a PGEN, this must be a path to a PGEN of dosages.
59
+ If `source` is a VCF, this must be the name of the FORMAT field to use for dosages.
60
+ If not provided, dosages will not be written.
57
61
  """
58
62
  from genoray import PGEN, VCF, SparseVar
59
63
  from genoray._utils import variant_file_type
60
64
 
61
65
  file_type = variant_file_type(source)
66
+
67
+ if dosages is None:
68
+ with_dosages = False
69
+ else:
70
+ with_dosages = True
71
+
62
72
  if file_type == "vcf":
63
- vcf = VCF(source)
64
- SparseVar.from_vcf(out, vcf, max_mem, overwrite, with_dosages=dosages)
65
- elif file_type == "pgen":
66
- if dosages is False:
67
- dosages = None
68
- with_dosages = False
69
- elif dosages is True:
73
+ if dosages is not None and Path(dosages).exists():
70
74
  raise ValueError(
71
- "Dosages must be provided as a path to a PGEN if source is a PGEN."
75
+ "The `dosages` argument appears to be a path to an existing file, but VCF requires a FORMAT field name."
72
76
  )
73
- else:
74
- with_dosages = True
75
77
 
78
+ vcf = VCF(source, dosage_field=dosages)
79
+ SparseVar.from_vcf(out, vcf, max_mem, overwrite, with_dosages=with_dosages)
80
+ elif file_type == "pgen":
76
81
  pgen = PGEN(source, dosage_path=dosages)
77
82
  SparseVar.from_pgen(out, pgen, max_mem, overwrite, with_dosages=with_dosages)
78
83
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: genoray-cli
3
- Version: 0.1.0
3
+ Version: 0.1.2
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=MsRY1SYTk_OIDPwPcToX1nvvno86HnEpFFl9-IqDvok,2504
3
+ genoray_cli-0.1.2.dist-info/METADATA,sha256=KcBMLujL41z47WFzdpmT4w79IUERlgacKTHN-MMQ8vA,1546
4
+ genoray_cli-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ genoray_cli-0.1.2.dist-info/entry_points.txt,sha256=zEVH4akzYLF810qEzeFM9J9tdcSYXopO_8X8SgCIshw,53
6
+ genoray_cli-0.1.2.dist-info/licenses/LICENSE,sha256=ubiV4_yGkI9lmTqj0wsoakQI38ZaN4qgI_psNvVWpW4,1067
7
+ genoray_cli-0.1.2.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,,