openproteo 1.0.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.
openproteo/__init__.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""OpenProteo: open proteomics vendor reader stack.
|
|
2
|
+
|
|
3
|
+
This metapackage is the single pip install surface for the stack. The
|
|
4
|
+
base install always brings ``openproteo_io`` (the Rust-backed reader
|
|
5
|
+
that converts vendor inputs to mzML / Arrow); the per-vendor extras
|
|
6
|
+
layer on direct Python bindings for each native vendor package:
|
|
7
|
+
|
|
8
|
+
* ``opentfraw`` - Thermo `.raw` files
|
|
9
|
+
* ``opentimstdf`` - Bruker timsTOF `.d/` bundles
|
|
10
|
+
* ``openwraw`` - Waters MassLynx `.raw/` directories
|
|
11
|
+
|
|
12
|
+
Install the umbrella::
|
|
13
|
+
|
|
14
|
+
pip install openproteo # openproteo_io only
|
|
15
|
+
pip install openproteo[thermo] # + opentfraw
|
|
16
|
+
pip install openproteo[bruker] # + opentimstdf
|
|
17
|
+
pip install openproteo[waters] # + openwraw
|
|
18
|
+
pip install openproteo[all] # + all vendor extensions
|
|
19
|
+
|
|
20
|
+
Top-level helpers fall into two layers:
|
|
21
|
+
|
|
22
|
+
* ``detect_format``, ``to_mzml``, ``iter_spectra`` are re-exports from
|
|
23
|
+
``openproteo_io`` - the vendor-agnostic reader.
|
|
24
|
+
* ``detect``, ``open_run`` use only structural checks and dispatch to
|
|
25
|
+
the vendor extension that matches the input path (requires the
|
|
26
|
+
corresponding extra).
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
import os
|
|
32
|
+
from importlib.metadata import PackageNotFoundError, version as _pkg_version
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
from typing import Optional
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
__version__ = _pkg_version("openproteo")
|
|
38
|
+
except PackageNotFoundError: # pragma: no cover - source checkout fallback
|
|
39
|
+
__version__ = "0.0.0+unknown"
|
|
40
|
+
|
|
41
|
+
# Re-export the openproteo_io reader surface so callers can write
|
|
42
|
+
# ``from openproteo import to_mzml, iter_spectra, detect_format``.
|
|
43
|
+
try:
|
|
44
|
+
from openproteo_io import ( # type: ignore[import-not-found]
|
|
45
|
+
Spectrum,
|
|
46
|
+
iter_spectra,
|
|
47
|
+
to_mzml,
|
|
48
|
+
)
|
|
49
|
+
from openproteo_io import detect as detect_format # type: ignore[import-not-found]
|
|
50
|
+
except ImportError: # pragma: no cover - openproteo_io is a hard dep
|
|
51
|
+
Spectrum = None # type: ignore[assignment]
|
|
52
|
+
detect_format = None # type: ignore[assignment]
|
|
53
|
+
iter_spectra = None # type: ignore[assignment]
|
|
54
|
+
to_mzml = None # type: ignore[assignment]
|
|
55
|
+
|
|
56
|
+
__all__ = [
|
|
57
|
+
"__version__",
|
|
58
|
+
"VENDORS",
|
|
59
|
+
"Spectrum",
|
|
60
|
+
"detect",
|
|
61
|
+
"detect_format",
|
|
62
|
+
"iter_spectra",
|
|
63
|
+
"open_run",
|
|
64
|
+
"to_mzml",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
VENDORS = ("thermo", "bruker", "waters")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def detect(path: str | os.PathLike[str]) -> Optional[str]:
|
|
71
|
+
"""Return ``"thermo"``, ``"bruker"``, ``"waters"`` or ``None`` for *path*.
|
|
72
|
+
|
|
73
|
+
The check is purely structural (extension + sentinel files); no vendor
|
|
74
|
+
reader needs to be importable.
|
|
75
|
+
"""
|
|
76
|
+
p = Path(path)
|
|
77
|
+
if not p.exists():
|
|
78
|
+
return None
|
|
79
|
+
if p.is_file() and p.suffix.lower() == ".raw":
|
|
80
|
+
return "thermo"
|
|
81
|
+
if p.is_dir():
|
|
82
|
+
suffix = p.suffix.lower()
|
|
83
|
+
if suffix == ".d" and (p / "analysis.tdf").is_file():
|
|
84
|
+
return "bruker"
|
|
85
|
+
if suffix == ".raw" and any(
|
|
86
|
+
(p / name).exists()
|
|
87
|
+
for name in ("_FUNCTNS.INF", "_extern.inf", "_HEADER.TXT")
|
|
88
|
+
):
|
|
89
|
+
return "waters"
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def open_run(path: str | os.PathLike[str]):
|
|
94
|
+
"""Detect *path*, import the matching vendor package, and open the run.
|
|
95
|
+
|
|
96
|
+
Raises ``ImportError`` if the matching vendor extra is not installed and
|
|
97
|
+
``ValueError`` if the format cannot be detected.
|
|
98
|
+
"""
|
|
99
|
+
kind = detect(path)
|
|
100
|
+
if kind is None:
|
|
101
|
+
raise ValueError(f"no supported vendor format detected at {path}")
|
|
102
|
+
if kind == "thermo":
|
|
103
|
+
import opentfraw # type: ignore[import-not-found]
|
|
104
|
+
|
|
105
|
+
return opentfraw.RawFile(str(path))
|
|
106
|
+
if kind == "bruker":
|
|
107
|
+
import opentimstdf # type: ignore[import-not-found]
|
|
108
|
+
|
|
109
|
+
return opentimstdf.Reader(str(path))
|
|
110
|
+
if kind == "waters":
|
|
111
|
+
import openwraw # type: ignore[import-not-found]
|
|
112
|
+
|
|
113
|
+
return openwraw.RawReader(str(path))
|
|
114
|
+
raise ValueError(f"unhandled vendor kind: {kind}")
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openproteo
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Open proteomics: one install for the OpenProteo vendor reader stack (Thermo, Bruker, Waters)
|
|
5
|
+
Author-email: Nathan Riley <git@nathanriley.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Sigilweaver/OpenProteo
|
|
8
|
+
Project-URL: Documentation, https://github.com/Sigilweaver/OpenProteo
|
|
9
|
+
Project-URL: Source, https://github.com/Sigilweaver/OpenProteo
|
|
10
|
+
Project-URL: Issues, https://github.com/Sigilweaver/OpenProteo/issues
|
|
11
|
+
Keywords: mass-spectrometry,proteomics,raw,thermo,bruker,waters,tdf,mzml
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Rust
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: openproteo-io
|
|
20
|
+
Provides-Extra: thermo
|
|
21
|
+
Requires-Dist: opentfraw; extra == "thermo"
|
|
22
|
+
Provides-Extra: bruker
|
|
23
|
+
Requires-Dist: opentimstdf; extra == "bruker"
|
|
24
|
+
Provides-Extra: waters
|
|
25
|
+
Requires-Dist: openwraw; extra == "waters"
|
|
26
|
+
Provides-Extra: all
|
|
27
|
+
Requires-Dist: opentfraw; extra == "all"
|
|
28
|
+
Requires-Dist: opentimstdf; extra == "all"
|
|
29
|
+
Requires-Dist: openwraw; extra == "all"
|
|
30
|
+
|
|
31
|
+
# openproteo
|
|
32
|
+
|
|
33
|
+
`openproteo` is a thin Python metapackage that bundles the OpenProteo vendor reader stack:
|
|
34
|
+
|
|
35
|
+
| Vendor | Format | Underlying package |
|
|
36
|
+
|--------|----------------|--------------------|
|
|
37
|
+
| Thermo | `.raw` file | `opentfraw` |
|
|
38
|
+
| Bruker | `.d/` bundle | `opentimstdf` |
|
|
39
|
+
| Waters | `.raw/` dir | `openwraw` |
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
Install just what you need:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install openproteo[thermo]
|
|
47
|
+
pip install openproteo[bruker]
|
|
48
|
+
pip install openproteo[waters]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or install every supported vendor reader:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install openproteo[all]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import openproteo
|
|
61
|
+
|
|
62
|
+
kind = openproteo.detect("/data/sample.raw") # "thermo" | "bruker" | "waters" | None
|
|
63
|
+
run = openproteo.open_run("/data/sample.raw") # vendor-specific reader object
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`open_run` raises `ImportError` if the matching vendor extra is not installed and
|
|
67
|
+
`ValueError` if the format cannot be detected.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
Apache-2.0. See [`LICENSE`](../LICENSE).
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
openproteo/__init__.py,sha256=cYrFgRqqSrsOmFXh36i_nHXUgVxh_MlFHISIHxm8wZA,3818
|
|
2
|
+
openproteo-1.0.2.dist-info/METADATA,sha256=xk0xJFzjc2DBNAMPrAxvOuCk_RmnCcbn3QsvltoCdQ4,2244
|
|
3
|
+
openproteo-1.0.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
4
|
+
openproteo-1.0.2.dist-info/top_level.txt,sha256=3hZgqbVRvdrhPoZ9OxQyxnyk8E8kHbFzcXS5iXemzRQ,11
|
|
5
|
+
openproteo-1.0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
openproteo
|