libgunshotmatch 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.
- libgunshotmatch-1.0.0/LICENSE +19 -0
- libgunshotmatch-1.0.0/PKG-INFO +170 -0
- libgunshotmatch-1.0.0/README.rst +124 -0
- libgunshotmatch-1.0.0/libgunshotmatch/__init__.py +33 -0
- libgunshotmatch-1.0.0/libgunshotmatch/comparison/__init__.py +116 -0
- libgunshotmatch-1.0.0/libgunshotmatch/comparison/_utils.py +60 -0
- libgunshotmatch-1.0.0/libgunshotmatch/comparison/projects.py +93 -0
- libgunshotmatch-1.0.0/libgunshotmatch/comparison/unknowns.py +76 -0
- libgunshotmatch-1.0.0/libgunshotmatch/consolidate/__init__.py +846 -0
- libgunshotmatch-1.0.0/libgunshotmatch/consolidate/_fields.py +95 -0
- libgunshotmatch-1.0.0/libgunshotmatch/consolidate/_spectra.py +74 -0
- libgunshotmatch-1.0.0/libgunshotmatch/datafile.py +545 -0
- libgunshotmatch-1.0.0/libgunshotmatch/gzip_util.py +80 -0
- libgunshotmatch-1.0.0/libgunshotmatch/method/__init__.py +252 -0
- libgunshotmatch-1.0.0/libgunshotmatch/method/_fields.py +105 -0
- libgunshotmatch-1.0.0/libgunshotmatch/peak.py +672 -0
- libgunshotmatch-1.0.0/libgunshotmatch/project.py +240 -0
- libgunshotmatch-1.0.0/libgunshotmatch/py.typed +0 -0
- libgunshotmatch-1.0.0/libgunshotmatch/search.py +100 -0
- libgunshotmatch-1.0.0/libgunshotmatch/utils.py +197 -0
- libgunshotmatch-1.0.0/pyproject.toml +203 -0
- libgunshotmatch-1.0.0/requirements.txt +15 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2023 Dominic Davis-Foster
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
15
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
18
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
19
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: libgunshotmatch
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Base library for GunShotMatch.
|
|
5
|
+
Author-email: Dominic Davis-Foster <dominic@davis-foster.co.uk>
|
|
6
|
+
License: MIT
|
|
7
|
+
Home-page: https://github.com/GunShotMatch/libgunshotmatch
|
|
8
|
+
Project-URL: Issue Tracker, https://github.com/GunShotMatch/libgunshotmatch/issues
|
|
9
|
+
Project-URL: Source Code, https://github.com/GunShotMatch/libgunshotmatch
|
|
10
|
+
Project-URL: Documentation, https://libgunshotmatch.readthedocs.io/en/latest
|
|
11
|
+
Platform: Windows
|
|
12
|
+
Platform: macOS
|
|
13
|
+
Platform: Linux
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.8
|
|
29
|
+
Requires-Dist: attrs>=23.1.0
|
|
30
|
+
Requires-Dist: chemistry-tools>=v1.0.0b2
|
|
31
|
+
Requires-Dist: dom-toml[config]>=2.2.0
|
|
32
|
+
Requires-Dist: domdf-python-tools>=3.6.1
|
|
33
|
+
Requires-Dist: enum-tools>=0.10.0
|
|
34
|
+
Requires-Dist: mathematical>=0.5.1
|
|
35
|
+
Requires-Dist: numpy>=1.22
|
|
36
|
+
Requires-Dist: pandas>=2.0.3
|
|
37
|
+
Requires-Dist: pymassspec>=2.3.0
|
|
38
|
+
Requires-Dist: pyms-nist-search>=0.6.1
|
|
39
|
+
Requires-Dist: scipy>=1.9.0
|
|
40
|
+
Requires-Dist: sdjson>=0.4.0
|
|
41
|
+
Requires-Dist: tomli>=1.2.3; python_version < "3.11"
|
|
42
|
+
Requires-Dist: tomli-w>=1.0.0
|
|
43
|
+
Requires-Dist: typing-extensions>=4.12.2
|
|
44
|
+
Description-Content-Type: text/x-rst
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
================
|
|
48
|
+
libgunshotmatch
|
|
49
|
+
================
|
|
50
|
+
|
|
51
|
+
.. start short_desc
|
|
52
|
+
|
|
53
|
+
**Base library for GunShotMatch.**
|
|
54
|
+
|
|
55
|
+
.. end short_desc
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
.. start shields
|
|
59
|
+
|
|
60
|
+
.. list-table::
|
|
61
|
+
:stub-columns: 1
|
|
62
|
+
:widths: 10 90
|
|
63
|
+
|
|
64
|
+
* - Docs
|
|
65
|
+
- |docs| |docs_check|
|
|
66
|
+
* - Tests
|
|
67
|
+
- |actions_linux| |actions_windows| |actions_macos| |coveralls|
|
|
68
|
+
* - PyPI
|
|
69
|
+
- |pypi-version| |supported-versions| |supported-implementations| |wheel|
|
|
70
|
+
* - Activity
|
|
71
|
+
- |commits-latest| |commits-since| |maintained| |pypi-downloads|
|
|
72
|
+
* - QA
|
|
73
|
+
- |codefactor| |actions_flake8| |actions_mypy|
|
|
74
|
+
* - Other
|
|
75
|
+
- |license| |language| |requires|
|
|
76
|
+
|
|
77
|
+
.. |docs| image:: https://img.shields.io/readthedocs/libgunshotmatch/latest?logo=read-the-docs
|
|
78
|
+
:target: https://libgunshotmatch.readthedocs.io/en/latest
|
|
79
|
+
:alt: Documentation Build Status
|
|
80
|
+
|
|
81
|
+
.. |docs_check| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/Docs%20Check/badge.svg
|
|
82
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22Docs+Check%22
|
|
83
|
+
:alt: Docs Check Status
|
|
84
|
+
|
|
85
|
+
.. |actions_linux| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/Linux/badge.svg
|
|
86
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22Linux%22
|
|
87
|
+
:alt: Linux Test Status
|
|
88
|
+
|
|
89
|
+
.. |actions_windows| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/Windows/badge.svg
|
|
90
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22Windows%22
|
|
91
|
+
:alt: Windows Test Status
|
|
92
|
+
|
|
93
|
+
.. |actions_macos| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/macOS/badge.svg
|
|
94
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22macOS%22
|
|
95
|
+
:alt: macOS Test Status
|
|
96
|
+
|
|
97
|
+
.. |actions_flake8| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/Flake8/badge.svg
|
|
98
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22Flake8%22
|
|
99
|
+
:alt: Flake8 Status
|
|
100
|
+
|
|
101
|
+
.. |actions_mypy| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/mypy/badge.svg
|
|
102
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22mypy%22
|
|
103
|
+
:alt: mypy status
|
|
104
|
+
|
|
105
|
+
.. |requires| image:: https://dependency-dash.repo-helper.uk/github/GunShotMatch/libgunshotmatch/badge.svg
|
|
106
|
+
:target: https://dependency-dash.repo-helper.uk/github/GunShotMatch/libgunshotmatch/
|
|
107
|
+
:alt: Requirements Status
|
|
108
|
+
|
|
109
|
+
.. |coveralls| image:: https://img.shields.io/coveralls/github/GunShotMatch/libgunshotmatch/master?logo=coveralls
|
|
110
|
+
:target: https://coveralls.io/github/GunShotMatch/libgunshotmatch?branch=master
|
|
111
|
+
:alt: Coverage
|
|
112
|
+
|
|
113
|
+
.. |codefactor| image:: https://img.shields.io/codefactor/grade/github/GunShotMatch/libgunshotmatch?logo=codefactor
|
|
114
|
+
:target: https://www.codefactor.io/repository/github/GunShotMatch/libgunshotmatch
|
|
115
|
+
:alt: CodeFactor Grade
|
|
116
|
+
|
|
117
|
+
.. |pypi-version| image:: https://img.shields.io/pypi/v/libgunshotmatch
|
|
118
|
+
:target: https://pypi.org/project/libgunshotmatch/
|
|
119
|
+
:alt: PyPI - Package Version
|
|
120
|
+
|
|
121
|
+
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/libgunshotmatch?logo=python&logoColor=white
|
|
122
|
+
:target: https://pypi.org/project/libgunshotmatch/
|
|
123
|
+
:alt: PyPI - Supported Python Versions
|
|
124
|
+
|
|
125
|
+
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/libgunshotmatch
|
|
126
|
+
:target: https://pypi.org/project/libgunshotmatch/
|
|
127
|
+
:alt: PyPI - Supported Implementations
|
|
128
|
+
|
|
129
|
+
.. |wheel| image:: https://img.shields.io/pypi/wheel/libgunshotmatch
|
|
130
|
+
:target: https://pypi.org/project/libgunshotmatch/
|
|
131
|
+
:alt: PyPI - Wheel
|
|
132
|
+
|
|
133
|
+
.. |license| image:: https://img.shields.io/github/license/GunShotMatch/libgunshotmatch
|
|
134
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/blob/master/LICENSE
|
|
135
|
+
:alt: License
|
|
136
|
+
|
|
137
|
+
.. |language| image:: https://img.shields.io/github/languages/top/GunShotMatch/libgunshotmatch
|
|
138
|
+
:alt: GitHub top language
|
|
139
|
+
|
|
140
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v1.0.0
|
|
141
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/pulse
|
|
142
|
+
:alt: GitHub commits since tagged version
|
|
143
|
+
|
|
144
|
+
.. |commits-latest| image:: https://img.shields.io/github/last-commit/GunShotMatch/libgunshotmatch
|
|
145
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/commit/master
|
|
146
|
+
:alt: GitHub last commit
|
|
147
|
+
|
|
148
|
+
.. |maintained| image:: https://img.shields.io/maintenance/yes/2026
|
|
149
|
+
:alt: Maintenance
|
|
150
|
+
|
|
151
|
+
.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/libgunshotmatch
|
|
152
|
+
:target: https://pypistats.org/packages/libgunshotmatch
|
|
153
|
+
:alt: PyPI - Downloads
|
|
154
|
+
|
|
155
|
+
.. end shields
|
|
156
|
+
|
|
157
|
+
Installation
|
|
158
|
+
--------------
|
|
159
|
+
|
|
160
|
+
.. start installation
|
|
161
|
+
|
|
162
|
+
``libgunshotmatch`` can be installed from PyPI.
|
|
163
|
+
|
|
164
|
+
To install with ``pip``:
|
|
165
|
+
|
|
166
|
+
.. code-block:: bash
|
|
167
|
+
|
|
168
|
+
$ python -m pip install libgunshotmatch
|
|
169
|
+
|
|
170
|
+
.. end installation
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
================
|
|
2
|
+
libgunshotmatch
|
|
3
|
+
================
|
|
4
|
+
|
|
5
|
+
.. start short_desc
|
|
6
|
+
|
|
7
|
+
**Base library for GunShotMatch.**
|
|
8
|
+
|
|
9
|
+
.. end short_desc
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
.. start shields
|
|
13
|
+
|
|
14
|
+
.. list-table::
|
|
15
|
+
:stub-columns: 1
|
|
16
|
+
:widths: 10 90
|
|
17
|
+
|
|
18
|
+
* - Docs
|
|
19
|
+
- |docs| |docs_check|
|
|
20
|
+
* - Tests
|
|
21
|
+
- |actions_linux| |actions_windows| |actions_macos| |coveralls|
|
|
22
|
+
* - PyPI
|
|
23
|
+
- |pypi-version| |supported-versions| |supported-implementations| |wheel|
|
|
24
|
+
* - Activity
|
|
25
|
+
- |commits-latest| |commits-since| |maintained| |pypi-downloads|
|
|
26
|
+
* - QA
|
|
27
|
+
- |codefactor| |actions_flake8| |actions_mypy|
|
|
28
|
+
* - Other
|
|
29
|
+
- |license| |language| |requires|
|
|
30
|
+
|
|
31
|
+
.. |docs| image:: https://img.shields.io/readthedocs/libgunshotmatch/latest?logo=read-the-docs
|
|
32
|
+
:target: https://libgunshotmatch.readthedocs.io/en/latest
|
|
33
|
+
:alt: Documentation Build Status
|
|
34
|
+
|
|
35
|
+
.. |docs_check| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/Docs%20Check/badge.svg
|
|
36
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22Docs+Check%22
|
|
37
|
+
:alt: Docs Check Status
|
|
38
|
+
|
|
39
|
+
.. |actions_linux| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/Linux/badge.svg
|
|
40
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22Linux%22
|
|
41
|
+
:alt: Linux Test Status
|
|
42
|
+
|
|
43
|
+
.. |actions_windows| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/Windows/badge.svg
|
|
44
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22Windows%22
|
|
45
|
+
:alt: Windows Test Status
|
|
46
|
+
|
|
47
|
+
.. |actions_macos| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/macOS/badge.svg
|
|
48
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22macOS%22
|
|
49
|
+
:alt: macOS Test Status
|
|
50
|
+
|
|
51
|
+
.. |actions_flake8| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/Flake8/badge.svg
|
|
52
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22Flake8%22
|
|
53
|
+
:alt: Flake8 Status
|
|
54
|
+
|
|
55
|
+
.. |actions_mypy| image:: https://github.com/GunShotMatch/libgunshotmatch/workflows/mypy/badge.svg
|
|
56
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/actions?query=workflow%3A%22mypy%22
|
|
57
|
+
:alt: mypy status
|
|
58
|
+
|
|
59
|
+
.. |requires| image:: https://dependency-dash.repo-helper.uk/github/GunShotMatch/libgunshotmatch/badge.svg
|
|
60
|
+
:target: https://dependency-dash.repo-helper.uk/github/GunShotMatch/libgunshotmatch/
|
|
61
|
+
:alt: Requirements Status
|
|
62
|
+
|
|
63
|
+
.. |coveralls| image:: https://img.shields.io/coveralls/github/GunShotMatch/libgunshotmatch/master?logo=coveralls
|
|
64
|
+
:target: https://coveralls.io/github/GunShotMatch/libgunshotmatch?branch=master
|
|
65
|
+
:alt: Coverage
|
|
66
|
+
|
|
67
|
+
.. |codefactor| image:: https://img.shields.io/codefactor/grade/github/GunShotMatch/libgunshotmatch?logo=codefactor
|
|
68
|
+
:target: https://www.codefactor.io/repository/github/GunShotMatch/libgunshotmatch
|
|
69
|
+
:alt: CodeFactor Grade
|
|
70
|
+
|
|
71
|
+
.. |pypi-version| image:: https://img.shields.io/pypi/v/libgunshotmatch
|
|
72
|
+
:target: https://pypi.org/project/libgunshotmatch/
|
|
73
|
+
:alt: PyPI - Package Version
|
|
74
|
+
|
|
75
|
+
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/libgunshotmatch?logo=python&logoColor=white
|
|
76
|
+
:target: https://pypi.org/project/libgunshotmatch/
|
|
77
|
+
:alt: PyPI - Supported Python Versions
|
|
78
|
+
|
|
79
|
+
.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/libgunshotmatch
|
|
80
|
+
:target: https://pypi.org/project/libgunshotmatch/
|
|
81
|
+
:alt: PyPI - Supported Implementations
|
|
82
|
+
|
|
83
|
+
.. |wheel| image:: https://img.shields.io/pypi/wheel/libgunshotmatch
|
|
84
|
+
:target: https://pypi.org/project/libgunshotmatch/
|
|
85
|
+
:alt: PyPI - Wheel
|
|
86
|
+
|
|
87
|
+
.. |license| image:: https://img.shields.io/github/license/GunShotMatch/libgunshotmatch
|
|
88
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/blob/master/LICENSE
|
|
89
|
+
:alt: License
|
|
90
|
+
|
|
91
|
+
.. |language| image:: https://img.shields.io/github/languages/top/GunShotMatch/libgunshotmatch
|
|
92
|
+
:alt: GitHub top language
|
|
93
|
+
|
|
94
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v1.0.0
|
|
95
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/pulse
|
|
96
|
+
:alt: GitHub commits since tagged version
|
|
97
|
+
|
|
98
|
+
.. |commits-latest| image:: https://img.shields.io/github/last-commit/GunShotMatch/libgunshotmatch
|
|
99
|
+
:target: https://github.com/GunShotMatch/libgunshotmatch/commit/master
|
|
100
|
+
:alt: GitHub last commit
|
|
101
|
+
|
|
102
|
+
.. |maintained| image:: https://img.shields.io/maintenance/yes/2026
|
|
103
|
+
:alt: Maintenance
|
|
104
|
+
|
|
105
|
+
.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/libgunshotmatch
|
|
106
|
+
:target: https://pypistats.org/packages/libgunshotmatch
|
|
107
|
+
:alt: PyPI - Downloads
|
|
108
|
+
|
|
109
|
+
.. end shields
|
|
110
|
+
|
|
111
|
+
Installation
|
|
112
|
+
--------------
|
|
113
|
+
|
|
114
|
+
.. start installation
|
|
115
|
+
|
|
116
|
+
``libgunshotmatch`` can be installed from PyPI.
|
|
117
|
+
|
|
118
|
+
To install with ``pip``:
|
|
119
|
+
|
|
120
|
+
.. code-block:: bash
|
|
121
|
+
|
|
122
|
+
$ python -m pip install libgunshotmatch
|
|
123
|
+
|
|
124
|
+
.. end installation
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# __init__.py
|
|
4
|
+
"""
|
|
5
|
+
Base library for GunShotMatch.
|
|
6
|
+
"""
|
|
7
|
+
#
|
|
8
|
+
# Copyright © 2020-2023 Dominic Davis-Foster <dominic@davis-foster.co.uk>
|
|
9
|
+
#
|
|
10
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
# in the Software without restriction, including without limitation the rights
|
|
13
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
# furnished to do so, subject to the following conditions:
|
|
16
|
+
#
|
|
17
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
# copies or substantial portions of the Software.
|
|
19
|
+
#
|
|
20
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
21
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
22
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
23
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
24
|
+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
25
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
26
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
__author__: str = "Dominic Davis-Foster"
|
|
30
|
+
__copyright__: str = "2020-2023 Dominic Davis-Foster"
|
|
31
|
+
__license__: str = "MIT License"
|
|
32
|
+
__version__: str = "1.0.0"
|
|
33
|
+
__email__: str = "dominic@davis-foster.co.uk"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# __init__.py
|
|
4
|
+
"""
|
|
5
|
+
Comparison between projects and unknowns.
|
|
6
|
+
|
|
7
|
+
The two submodules, :mod:`~.comparison.projects` and :mod:`~.comparison.unknowns`,
|
|
8
|
+
provide identical APIs with different internals to handle reference projects (containing two or more repeats)
|
|
9
|
+
and unknown samples (from a single datafile).
|
|
10
|
+
|
|
11
|
+
.. versionadded:: 0.8.0
|
|
12
|
+
"""
|
|
13
|
+
#
|
|
14
|
+
# Copyright © 2024 Dominic Davis-Foster <dominic@davis-foster.co.uk>
|
|
15
|
+
#
|
|
16
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
# in the Software without restriction, including without limitation the rights
|
|
19
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
# furnished to do so, subject to the following conditions:
|
|
22
|
+
#
|
|
23
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
# copies or substantial portions of the Software.
|
|
25
|
+
#
|
|
26
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
27
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
28
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
29
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
30
|
+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
31
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
32
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
|
33
|
+
#
|
|
34
|
+
|
|
35
|
+
# stdlib
|
|
36
|
+
from typing import List, Sequence, Tuple, Union
|
|
37
|
+
|
|
38
|
+
# 3rd party
|
|
39
|
+
from pyms.DPA.Alignment import Alignment
|
|
40
|
+
from pyms.DPA.PairwiseAlignment import PairwiseAlignment, align_with_tree
|
|
41
|
+
|
|
42
|
+
# this package
|
|
43
|
+
from libgunshotmatch.project import Project
|
|
44
|
+
|
|
45
|
+
# this package
|
|
46
|
+
from . import projects, unknowns
|
|
47
|
+
from ._utils import _PaddedPeakList
|
|
48
|
+
|
|
49
|
+
__all__ = ("align_projects", "get_padded_peak_lists")
|
|
50
|
+
|
|
51
|
+
# Aliases to prevent clashes with argument names
|
|
52
|
+
_projects_mod = projects
|
|
53
|
+
_unknowns_mod = unknowns
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def align_projects(
|
|
57
|
+
projects: Union[Sequence[Project], Project] = (),
|
|
58
|
+
unknowns: Union[Sequence[Project], Project] = (),
|
|
59
|
+
D: float = 2.5,
|
|
60
|
+
gap: float = 0.3,
|
|
61
|
+
) -> Alignment:
|
|
62
|
+
"""
|
|
63
|
+
Align multiple projects and/or unknowns.
|
|
64
|
+
|
|
65
|
+
:param projects:
|
|
66
|
+
:param unknowns:
|
|
67
|
+
:param D: Retention time tolerance for pairwise alignments (in seconds).
|
|
68
|
+
:param gap: Gap penalty for pairwise alignments.
|
|
69
|
+
|
|
70
|
+
:rtype:
|
|
71
|
+
|
|
72
|
+
.. versionchanged:: 0.9.0
|
|
73
|
+
|
|
74
|
+
* Added ``D`` and ``gap`` arguments.
|
|
75
|
+
* ``projects`` and ``unknowns`` can now be a single :class:`~.Project`.
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
if isinstance(projects, Project):
|
|
79
|
+
projects = [projects]
|
|
80
|
+
|
|
81
|
+
if isinstance(unknowns, Project):
|
|
82
|
+
unknowns = [unknowns]
|
|
83
|
+
|
|
84
|
+
project_alignments = map(_projects_mod.filter_alignment_to_consolidate, projects)
|
|
85
|
+
unknown_alignments = map(_unknowns_mod.filter_alignment_to_consolidate, unknowns)
|
|
86
|
+
|
|
87
|
+
pwa = PairwiseAlignment([*project_alignments, *unknown_alignments], D=float(D), gap=float(gap))
|
|
88
|
+
return align_with_tree(pwa)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def get_padded_peak_lists(
|
|
92
|
+
alignment: Alignment,
|
|
93
|
+
projects: Union[Sequence[Project], Project] = (),
|
|
94
|
+
unknowns: Union[Sequence[Project], Project] = (),
|
|
95
|
+
) -> Tuple[List[_PaddedPeakList], List[_PaddedPeakList]]:
|
|
96
|
+
"""
|
|
97
|
+
Pad the consolidated peak lists in each project/unknown, from the given between-project alignment.
|
|
98
|
+
|
|
99
|
+
:param alignment:
|
|
100
|
+
:param projects:
|
|
101
|
+
:param unknowns:
|
|
102
|
+
|
|
103
|
+
.. versionchanged:: 0.9.0 ``projects`` and ``unknowns`` can now be a single :class:`~.Project`.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
if isinstance(projects, Project):
|
|
107
|
+
projects = [projects]
|
|
108
|
+
|
|
109
|
+
if isinstance(unknowns, Project):
|
|
110
|
+
unknowns = [unknowns]
|
|
111
|
+
|
|
112
|
+
data = alignment.get_peak_alignment(require_all_expr=False, minutes=False)
|
|
113
|
+
|
|
114
|
+
projects_padded_cp = [_projects_mod.get_padded_peak_list(p, data) for p in projects]
|
|
115
|
+
unknowns_padded_cp = [_unknowns_mod.get_padded_peak_list(p, data) for p in unknowns]
|
|
116
|
+
return projects_padded_cp, unknowns_padded_cp
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# _utils.py
|
|
4
|
+
"""
|
|
5
|
+
Utility functions.
|
|
6
|
+
"""
|
|
7
|
+
#
|
|
8
|
+
# Copyright © 2024 Dominic Davis-Foster <dominic@davis-foster.co.uk>
|
|
9
|
+
#
|
|
10
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
# in the Software without restriction, including without limitation the rights
|
|
13
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
# furnished to do so, subject to the following conditions:
|
|
16
|
+
#
|
|
17
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
# copies or substantial portions of the Software.
|
|
19
|
+
#
|
|
20
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
21
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
22
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
23
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
24
|
+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
25
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
26
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
# stdlib
|
|
30
|
+
from typing import List, MutableSequence, Optional
|
|
31
|
+
|
|
32
|
+
# 3rd party
|
|
33
|
+
import numpy
|
|
34
|
+
|
|
35
|
+
# this package
|
|
36
|
+
from libgunshotmatch import project
|
|
37
|
+
from libgunshotmatch.consolidate import ConsolidatedPeak
|
|
38
|
+
|
|
39
|
+
_PaddedPeakList = MutableSequence[Optional[ConsolidatedPeak]]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _get_padded_peak_list(project: project.Project, rts: List[float]) -> _PaddedPeakList:
|
|
43
|
+
|
|
44
|
+
assert project.consolidated_peaks is not None
|
|
45
|
+
|
|
46
|
+
padded_cp_list: _PaddedPeakList = []
|
|
47
|
+
|
|
48
|
+
for cp in project.consolidated_peaks:
|
|
49
|
+
if rts:
|
|
50
|
+
top_rt = rts.pop(0)
|
|
51
|
+
while numpy.isnan(top_rt):
|
|
52
|
+
padded_cp_list.append(None)
|
|
53
|
+
if rts:
|
|
54
|
+
top_rt = rts.pop(0)
|
|
55
|
+
else: # pragma: no cover
|
|
56
|
+
# We've run out of retention times
|
|
57
|
+
break
|
|
58
|
+
padded_cp_list.append(cp)
|
|
59
|
+
|
|
60
|
+
return padded_cp_list
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# project.py
|
|
4
|
+
"""
|
|
5
|
+
Comparison between projects.
|
|
6
|
+
"""
|
|
7
|
+
#
|
|
8
|
+
# Copyright © 2024 Dominic Davis-Foster <dominic@davis-foster.co.uk>
|
|
9
|
+
#
|
|
10
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
# in the Software without restriction, including without limitation the rights
|
|
13
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
# furnished to do so, subject to the following conditions:
|
|
16
|
+
#
|
|
17
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
# copies or substantial portions of the Software.
|
|
19
|
+
#
|
|
20
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
21
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
22
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
23
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
24
|
+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
25
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
26
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
# 3rd party
|
|
30
|
+
import numpy
|
|
31
|
+
import pandas # type: ignore[import-untyped]
|
|
32
|
+
from pyms.DPA.Alignment import Alignment
|
|
33
|
+
|
|
34
|
+
# this package
|
|
35
|
+
from libgunshotmatch.project import Project
|
|
36
|
+
from libgunshotmatch.utils import create_alignment
|
|
37
|
+
|
|
38
|
+
# this package
|
|
39
|
+
from ._utils import _get_padded_peak_list, _PaddedPeakList
|
|
40
|
+
|
|
41
|
+
__all__ = ("filter_alignment_to_consolidate", "get_padded_peak_list")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def filter_alignment_to_consolidate(project: Project) -> Alignment:
|
|
45
|
+
"""
|
|
46
|
+
Filter peaks from a project's ``alignment`` to only those which survived the ``consolidate`` process.
|
|
47
|
+
|
|
48
|
+
:param project:
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
assert project.consolidated_peaks is not None
|
|
52
|
+
|
|
53
|
+
# Sort expr_code and peakpos into order from datafile_data
|
|
54
|
+
desired_order = list(project.datafile_data)[::-1]
|
|
55
|
+
sort_map = [project.alignment.expr_code.index(code) for code in desired_order]
|
|
56
|
+
expr_code = [project.alignment.expr_code[idx] for idx in sort_map]
|
|
57
|
+
peakpos = [project.alignment.peakpos[idx] for idx in sort_map]
|
|
58
|
+
assert desired_order == expr_code
|
|
59
|
+
|
|
60
|
+
consolidated_peak_retention_times = []
|
|
61
|
+
for cp in project.consolidated_peaks:
|
|
62
|
+
consolidated_peak_retention_times.append([None if numpy.isnan(rt) else rt for rt in cp.rt_list])
|
|
63
|
+
|
|
64
|
+
aligned_peaks_surviving_consolidate = []
|
|
65
|
+
for aligned_peaks in zip(*peakpos):
|
|
66
|
+
aprt = [None if p is None else p.rt for p in reversed(aligned_peaks)]
|
|
67
|
+
if aprt in consolidated_peak_retention_times:
|
|
68
|
+
aligned_peaks_surviving_consolidate.append(aligned_peaks)
|
|
69
|
+
|
|
70
|
+
alignment_surviving_consolidate = list(zip(*aligned_peaks_surviving_consolidate))
|
|
71
|
+
|
|
72
|
+
# Sanity check
|
|
73
|
+
for c_expr_peaks, expr_peaks in zip(alignment_surviving_consolidate, peakpos):
|
|
74
|
+
for peak in c_expr_peaks:
|
|
75
|
+
assert peak in expr_peaks
|
|
76
|
+
|
|
77
|
+
# Create new Alignment object
|
|
78
|
+
return create_alignment(alignment_surviving_consolidate, expr_code)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def get_padded_peak_list(project: Project, alignment_rts: pandas.DataFrame) -> _PaddedPeakList:
|
|
82
|
+
"""
|
|
83
|
+
Returns a list of consolidated peaks for the project, based on the between-project alignment.
|
|
84
|
+
|
|
85
|
+
:param project:
|
|
86
|
+
:param alignment_rts: Pandas DataFrame giving retention times for the peak alignment.
|
|
87
|
+
The output of :meth:`~pyms.DPA.Alignment.Alignment.get_peak_alignment`.
|
|
88
|
+
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
rts = [numpy.mean(row[1:]) for row in alignment_rts[list(project.datafile_data)].itertuples()]
|
|
92
|
+
|
|
93
|
+
return _get_padded_peak_list(project, rts)
|