openmassspec 1.0.0__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.
- openmassspec-1.0.0/LICENSE +202 -0
- openmassspec-1.0.0/PKG-INFO +73 -0
- openmassspec-1.0.0/README.md +41 -0
- openmassspec-1.0.0/openmassspec/__init__.py +115 -0
- openmassspec-1.0.0/openmassspec.egg-info/PKG-INFO +73 -0
- openmassspec-1.0.0/openmassspec.egg-info/SOURCES.txt +11 -0
- openmassspec-1.0.0/openmassspec.egg-info/dependency_links.txt +1 -0
- openmassspec-1.0.0/openmassspec.egg-info/requires.txt +15 -0
- openmassspec-1.0.0/openmassspec.egg-info/top_level.txt +1 -0
- openmassspec-1.0.0/pyproject.toml +50 -0
- openmassspec-1.0.0/setup.cfg +4 -0
- openmassspec-1.0.0/tests/test_metapackage.py +155 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openmassspec
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Open mass spectrometry: one install for the OpenMassSpec 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/OpenMassSpec
|
|
8
|
+
Project-URL: Documentation, https://github.com/Sigilweaver/OpenMassSpec
|
|
9
|
+
Project-URL: Source, https://github.com/Sigilweaver/OpenMassSpec
|
|
10
|
+
Project-URL: Issues, https://github.com/Sigilweaver/OpenMassSpec/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
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: openmassspec-io
|
|
21
|
+
Provides-Extra: thermo
|
|
22
|
+
Requires-Dist: opentfraw; extra == "thermo"
|
|
23
|
+
Provides-Extra: bruker
|
|
24
|
+
Requires-Dist: opentimstdf; extra == "bruker"
|
|
25
|
+
Provides-Extra: waters
|
|
26
|
+
Requires-Dist: openwraw; extra == "waters"
|
|
27
|
+
Provides-Extra: all
|
|
28
|
+
Requires-Dist: opentfraw; extra == "all"
|
|
29
|
+
Requires-Dist: opentimstdf; extra == "all"
|
|
30
|
+
Requires-Dist: openwraw; extra == "all"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# openmassspec
|
|
34
|
+
|
|
35
|
+
`openmassspec` is a thin Python metapackage that bundles the OpenMassSpec vendor reader stack:
|
|
36
|
+
|
|
37
|
+
| Vendor | Format | Underlying package |
|
|
38
|
+
|--------|----------------|--------------------|
|
|
39
|
+
| Thermo | `.raw` file | `opentfraw` |
|
|
40
|
+
| Bruker | `.d/` bundle | `opentimstdf` |
|
|
41
|
+
| Waters | `.raw/` dir | `openwraw` |
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
Install just what you need:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install openmassspec[thermo]
|
|
49
|
+
pip install openmassspec[bruker]
|
|
50
|
+
pip install openmassspec[waters]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or install every supported vendor reader:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install openmassspec[all]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import openmassspec
|
|
63
|
+
|
|
64
|
+
kind = openmassspec.detect("/data/sample.raw") # "thermo" | "bruker" | "waters" | None
|
|
65
|
+
run = openmassspec.open_run("/data/sample.raw") # vendor-specific reader object
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`open_run` raises `ImportError` if the matching vendor extra is not installed and
|
|
69
|
+
`ValueError` if the format cannot be detected.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
Apache-2.0. See [`LICENSE`](../LICENSE).
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# openmassspec
|
|
2
|
+
|
|
3
|
+
`openmassspec` is a thin Python metapackage that bundles the OpenMassSpec vendor reader stack:
|
|
4
|
+
|
|
5
|
+
| Vendor | Format | Underlying package |
|
|
6
|
+
|--------|----------------|--------------------|
|
|
7
|
+
| Thermo | `.raw` file | `opentfraw` |
|
|
8
|
+
| Bruker | `.d/` bundle | `opentimstdf` |
|
|
9
|
+
| Waters | `.raw/` dir | `openwraw` |
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Install just what you need:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install openmassspec[thermo]
|
|
17
|
+
pip install openmassspec[bruker]
|
|
18
|
+
pip install openmassspec[waters]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or install every supported vendor reader:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install openmassspec[all]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import openmassspec
|
|
31
|
+
|
|
32
|
+
kind = openmassspec.detect("/data/sample.raw") # "thermo" | "bruker" | "waters" | None
|
|
33
|
+
run = openmassspec.open_run("/data/sample.raw") # vendor-specific reader object
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`open_run` raises `ImportError` if the matching vendor extra is not installed and
|
|
37
|
+
`ValueError` if the format cannot be detected.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
Apache-2.0. See [`LICENSE`](../LICENSE).
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""OpenMassSpec: open proteomics vendor reader stack.
|
|
2
|
+
|
|
3
|
+
This metapackage is the single pip install surface for the stack. The
|
|
4
|
+
base install always brings ``openmassspec_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 openmassspec # openmassspec_io only
|
|
15
|
+
pip install openmassspec[thermo] # + opentfraw
|
|
16
|
+
pip install openmassspec[bruker] # + opentimstdf
|
|
17
|
+
pip install openmassspec[waters] # + openwraw
|
|
18
|
+
pip install openmassspec[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
|
+
``openmassspec_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
|
|
33
|
+
from importlib.metadata import version as _pkg_version
|
|
34
|
+
from pathlib import Path
|
|
35
|
+
from typing import Optional
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
__version__ = _pkg_version("openmassspec")
|
|
39
|
+
except PackageNotFoundError: # pragma: no cover - source checkout fallback
|
|
40
|
+
__version__ = "0.0.0+unknown"
|
|
41
|
+
|
|
42
|
+
# Re-export the openmassspec_io reader surface so callers can write
|
|
43
|
+
# ``from openmassspec import to_mzml, iter_spectra, detect_format``.
|
|
44
|
+
try:
|
|
45
|
+
from openmassspec_io import ( # type: ignore[import-not-found]
|
|
46
|
+
Spectrum,
|
|
47
|
+
iter_spectra,
|
|
48
|
+
to_mzml,
|
|
49
|
+
)
|
|
50
|
+
from openmassspec_io import detect as detect_format # type: ignore[import-not-found]
|
|
51
|
+
except ImportError: # pragma: no cover - openmassspec_io is a hard dep
|
|
52
|
+
Spectrum = None # type: ignore[assignment]
|
|
53
|
+
detect_format = None # type: ignore[assignment]
|
|
54
|
+
iter_spectra = None # type: ignore[assignment]
|
|
55
|
+
to_mzml = None # type: ignore[assignment]
|
|
56
|
+
|
|
57
|
+
__all__ = [
|
|
58
|
+
"__version__",
|
|
59
|
+
"VENDORS",
|
|
60
|
+
"Spectrum",
|
|
61
|
+
"detect",
|
|
62
|
+
"detect_format",
|
|
63
|
+
"iter_spectra",
|
|
64
|
+
"open_run",
|
|
65
|
+
"to_mzml",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
VENDORS = ("thermo", "bruker", "waters")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def detect(path: str | os.PathLike[str]) -> Optional[str]:
|
|
72
|
+
"""Return ``"thermo"``, ``"bruker"``, ``"waters"`` or ``None`` for *path*.
|
|
73
|
+
|
|
74
|
+
The check is purely structural (extension + sentinel files); no vendor
|
|
75
|
+
reader needs to be importable.
|
|
76
|
+
"""
|
|
77
|
+
p = Path(path)
|
|
78
|
+
if not p.exists():
|
|
79
|
+
return None
|
|
80
|
+
if p.is_file() and p.suffix.lower() == ".raw":
|
|
81
|
+
return "thermo"
|
|
82
|
+
if p.is_dir():
|
|
83
|
+
suffix = p.suffix.lower()
|
|
84
|
+
if suffix == ".d" and (p / "analysis.tdf").is_file():
|
|
85
|
+
return "bruker"
|
|
86
|
+
if suffix == ".raw" and any(
|
|
87
|
+
(p / name).exists()
|
|
88
|
+
for name in ("_FUNCTNS.INF", "_extern.inf", "_HEADER.TXT")
|
|
89
|
+
):
|
|
90
|
+
return "waters"
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def open_run(path: str | os.PathLike[str]):
|
|
95
|
+
"""Detect *path*, import the matching vendor package, and open the run.
|
|
96
|
+
|
|
97
|
+
Raises ``ImportError`` if the matching vendor extra is not installed and
|
|
98
|
+
``ValueError`` if the format cannot be detected.
|
|
99
|
+
"""
|
|
100
|
+
kind = detect(path)
|
|
101
|
+
if kind is None:
|
|
102
|
+
raise ValueError(f"no supported vendor format detected at {path}")
|
|
103
|
+
if kind == "thermo":
|
|
104
|
+
import opentfraw # type: ignore[import-not-found]
|
|
105
|
+
|
|
106
|
+
return opentfraw.RawFile(str(path))
|
|
107
|
+
if kind == "bruker":
|
|
108
|
+
import opentimstdf # type: ignore[import-not-found]
|
|
109
|
+
|
|
110
|
+
return opentimstdf.Reader(str(path))
|
|
111
|
+
if kind == "waters":
|
|
112
|
+
import openwraw # type: ignore[import-not-found]
|
|
113
|
+
|
|
114
|
+
return openwraw.RawReader(str(path))
|
|
115
|
+
raise ValueError(f"unhandled vendor kind: {kind}")
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openmassspec
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Open mass spectrometry: one install for the OpenMassSpec 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/OpenMassSpec
|
|
8
|
+
Project-URL: Documentation, https://github.com/Sigilweaver/OpenMassSpec
|
|
9
|
+
Project-URL: Source, https://github.com/Sigilweaver/OpenMassSpec
|
|
10
|
+
Project-URL: Issues, https://github.com/Sigilweaver/OpenMassSpec/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
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: openmassspec-io
|
|
21
|
+
Provides-Extra: thermo
|
|
22
|
+
Requires-Dist: opentfraw; extra == "thermo"
|
|
23
|
+
Provides-Extra: bruker
|
|
24
|
+
Requires-Dist: opentimstdf; extra == "bruker"
|
|
25
|
+
Provides-Extra: waters
|
|
26
|
+
Requires-Dist: openwraw; extra == "waters"
|
|
27
|
+
Provides-Extra: all
|
|
28
|
+
Requires-Dist: opentfraw; extra == "all"
|
|
29
|
+
Requires-Dist: opentimstdf; extra == "all"
|
|
30
|
+
Requires-Dist: openwraw; extra == "all"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# openmassspec
|
|
34
|
+
|
|
35
|
+
`openmassspec` is a thin Python metapackage that bundles the OpenMassSpec vendor reader stack:
|
|
36
|
+
|
|
37
|
+
| Vendor | Format | Underlying package |
|
|
38
|
+
|--------|----------------|--------------------|
|
|
39
|
+
| Thermo | `.raw` file | `opentfraw` |
|
|
40
|
+
| Bruker | `.d/` bundle | `opentimstdf` |
|
|
41
|
+
| Waters | `.raw/` dir | `openwraw` |
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
Install just what you need:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install openmassspec[thermo]
|
|
49
|
+
pip install openmassspec[bruker]
|
|
50
|
+
pip install openmassspec[waters]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or install every supported vendor reader:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install openmassspec[all]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import openmassspec
|
|
63
|
+
|
|
64
|
+
kind = openmassspec.detect("/data/sample.raw") # "thermo" | "bruker" | "waters" | None
|
|
65
|
+
run = openmassspec.open_run("/data/sample.raw") # vendor-specific reader object
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`open_run` raises `ImportError` if the matching vendor extra is not installed and
|
|
69
|
+
`ValueError` if the format cannot be detected.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
Apache-2.0. See [`LICENSE`](../LICENSE).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
./openmassspec/__init__.py
|
|
5
|
+
openmassspec/__init__.py
|
|
6
|
+
openmassspec.egg-info/PKG-INFO
|
|
7
|
+
openmassspec.egg-info/SOURCES.txt
|
|
8
|
+
openmassspec.egg-info/dependency_links.txt
|
|
9
|
+
openmassspec.egg-info/requires.txt
|
|
10
|
+
openmassspec.egg-info/top_level.txt
|
|
11
|
+
tests/test_metapackage.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
openmassspec
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "openmassspec"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Open mass spectrometry: one install for the OpenMassSpec vendor reader stack (Thermo, Bruker, Waters)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "Apache-2.0" }
|
|
11
|
+
authors = [{ name = "Nathan Riley", email = "git@nathanriley.com" }]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
keywords = [
|
|
14
|
+
"mass-spectrometry",
|
|
15
|
+
"proteomics",
|
|
16
|
+
"raw",
|
|
17
|
+
"thermo",
|
|
18
|
+
"bruker",
|
|
19
|
+
"waters",
|
|
20
|
+
"tdf",
|
|
21
|
+
"mzml",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 4 - Beta",
|
|
25
|
+
"License :: OSI Approved :: Apache Software License",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Rust",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
29
|
+
]
|
|
30
|
+
dependencies = ["openmassspec-io"]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
# The base install always brings openmassspec-io (the vendor-agnostic Rust
|
|
34
|
+
# reader). Each extra layers on a per-vendor native binding; the `all`
|
|
35
|
+
# extra installs every supported vendor.
|
|
36
|
+
thermo = ["opentfraw"]
|
|
37
|
+
bruker = ["opentimstdf"]
|
|
38
|
+
waters = ["openwraw"]
|
|
39
|
+
all = ["opentfraw", "opentimstdf", "openwraw"]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/Sigilweaver/OpenMassSpec"
|
|
43
|
+
Documentation = "https://github.com/Sigilweaver/OpenMassSpec"
|
|
44
|
+
Source = "https://github.com/Sigilweaver/OpenMassSpec"
|
|
45
|
+
Issues = "https://github.com/Sigilweaver/OpenMassSpec/issues"
|
|
46
|
+
|
|
47
|
+
[tool.setuptools]
|
|
48
|
+
packages = ["openmassspec"]
|
|
49
|
+
package-dir = { "" = "." }
|
|
50
|
+
license-files = ["LICENSE"]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""Smoke tests for the `openmassspec` metapackage.
|
|
2
|
+
|
|
3
|
+
These tests do not require any vendor corpus. They exercise:
|
|
4
|
+
|
|
5
|
+
* metadata (`__version__`, `__all__`),
|
|
6
|
+
* structural `detect()` against synthesized directories/files,
|
|
7
|
+
* `open_run()` error paths,
|
|
8
|
+
* presence of the `openmassspec_io` re-exports (when installed).
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
import openmassspec
|
|
16
|
+
import pytest
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_version_string():
|
|
20
|
+
assert isinstance(openmassspec.__version__, str)
|
|
21
|
+
assert openmassspec.__version__.count(".") >= 1
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_vendors_tuple():
|
|
25
|
+
assert openmassspec.VENDORS == ("thermo", "bruker", "waters")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_detect_thermo_file(tmp_path: Path):
|
|
29
|
+
f = tmp_path / "sample.raw"
|
|
30
|
+
f.write_bytes(b"")
|
|
31
|
+
assert openmassspec.detect(f) == "thermo"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_detect_bruker_d(tmp_path: Path):
|
|
35
|
+
d = tmp_path / "sample.d"
|
|
36
|
+
d.mkdir()
|
|
37
|
+
(d / "analysis.tdf").write_bytes(b"")
|
|
38
|
+
assert openmassspec.detect(d) == "bruker"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_detect_waters_raw(tmp_path: Path):
|
|
42
|
+
d = tmp_path / "sample.raw"
|
|
43
|
+
d.mkdir()
|
|
44
|
+
(d / "_HEADER.TXT").write_bytes(b"")
|
|
45
|
+
assert openmassspec.detect(d) == "waters"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_detect_unknown_returns_none(tmp_path: Path):
|
|
49
|
+
p = tmp_path / "something.txt"
|
|
50
|
+
p.write_bytes(b"hello")
|
|
51
|
+
assert openmassspec.detect(p) is None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_detect_missing_path_returns_none(tmp_path: Path):
|
|
55
|
+
assert openmassspec.detect(tmp_path / "does-not-exist") is None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_open_run_unknown_raises(tmp_path: Path):
|
|
59
|
+
p = tmp_path / "nope.txt"
|
|
60
|
+
p.write_bytes(b"")
|
|
61
|
+
with pytest.raises(ValueError):
|
|
62
|
+
openmassspec.open_run(p)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_openmassspec_io_reexports_present():
|
|
66
|
+
# The base install pulls openmassspec_io; the re-exports should be
|
|
67
|
+
# importable callables. If openmassspec_io is genuinely missing the
|
|
68
|
+
# module falls back to None and we skip.
|
|
69
|
+
if openmassspec.to_mzml is None:
|
|
70
|
+
pytest.skip("openmassspec_io not importable in this environment")
|
|
71
|
+
assert callable(openmassspec.to_mzml)
|
|
72
|
+
assert callable(openmassspec.iter_spectra)
|
|
73
|
+
assert callable(openmassspec.detect_format)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_version_matches_installed_metadata():
|
|
77
|
+
"""Catch ``__version__`` drift from ``pyproject.toml`` early."""
|
|
78
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
79
|
+
|
|
80
|
+
try:
|
|
81
|
+
installed = version("openmassspec")
|
|
82
|
+
except PackageNotFoundError:
|
|
83
|
+
pytest.skip("openmassspec not installed (running from source)")
|
|
84
|
+
assert openmassspec.__version__ == installed
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_open_run_thermo_dispatch(monkeypatch, tmp_path: Path):
|
|
88
|
+
"""``open_run`` on a thermo file imports opentfraw and calls ``RawFile``."""
|
|
89
|
+
import sys
|
|
90
|
+
import types
|
|
91
|
+
|
|
92
|
+
f = tmp_path / "sample.raw"
|
|
93
|
+
f.write_bytes(b"")
|
|
94
|
+
calls: list[str] = []
|
|
95
|
+
|
|
96
|
+
fake = types.ModuleType("opentfraw")
|
|
97
|
+
fake.RawFile = lambda p: calls.append(("thermo", p)) or "thermo-handle" # type: ignore[attr-defined]
|
|
98
|
+
monkeypatch.setitem(sys.modules, "opentfraw", fake)
|
|
99
|
+
|
|
100
|
+
assert openmassspec.open_run(f) == "thermo-handle"
|
|
101
|
+
assert calls == [("thermo", str(f))]
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def test_open_run_bruker_dispatch(monkeypatch, tmp_path: Path):
|
|
105
|
+
import sys
|
|
106
|
+
import types
|
|
107
|
+
|
|
108
|
+
d = tmp_path / "sample.d"
|
|
109
|
+
d.mkdir()
|
|
110
|
+
(d / "analysis.tdf").write_bytes(b"")
|
|
111
|
+
calls: list[str] = []
|
|
112
|
+
|
|
113
|
+
fake = types.ModuleType("opentimstdf")
|
|
114
|
+
fake.Reader = lambda p: calls.append(("bruker", p)) or "bruker-handle" # type: ignore[attr-defined]
|
|
115
|
+
monkeypatch.setitem(sys.modules, "opentimstdf", fake)
|
|
116
|
+
|
|
117
|
+
assert openmassspec.open_run(d) == "bruker-handle"
|
|
118
|
+
assert calls == [("bruker", str(d))]
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_open_run_waters_dispatch(monkeypatch, tmp_path: Path):
|
|
122
|
+
import sys
|
|
123
|
+
import types
|
|
124
|
+
|
|
125
|
+
d = tmp_path / "sample.raw"
|
|
126
|
+
d.mkdir()
|
|
127
|
+
(d / "_HEADER.TXT").write_bytes(b"")
|
|
128
|
+
calls: list[str] = []
|
|
129
|
+
|
|
130
|
+
fake = types.ModuleType("openwraw")
|
|
131
|
+
fake.RawReader = lambda p: calls.append(("waters", p)) or "waters-handle" # type: ignore[attr-defined]
|
|
132
|
+
monkeypatch.setitem(sys.modules, "openwraw", fake)
|
|
133
|
+
|
|
134
|
+
assert openmassspec.open_run(d) == "waters-handle"
|
|
135
|
+
assert calls == [("waters", str(d))]
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def test_vendors_is_immutable_tuple():
|
|
139
|
+
assert isinstance(openmassspec.VENDORS, tuple)
|
|
140
|
+
with pytest.raises((TypeError, AttributeError)):
|
|
141
|
+
openmassspec.VENDORS[0] = "nope" # type: ignore[index]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def test_public_api_surface():
|
|
145
|
+
expected = {
|
|
146
|
+
"__version__",
|
|
147
|
+
"VENDORS",
|
|
148
|
+
"Spectrum",
|
|
149
|
+
"detect",
|
|
150
|
+
"detect_format",
|
|
151
|
+
"iter_spectra",
|
|
152
|
+
"open_run",
|
|
153
|
+
"to_mzml",
|
|
154
|
+
}
|
|
155
|
+
assert set(openmassspec.__all__) == expected
|