libgunshotmatch 0.10.1__tar.gz → 0.11.1__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.
Potentially problematic release.
This version of libgunshotmatch might be problematic. Click here for more details.
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/PKG-INFO +3 -3
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/README.rst +1 -1
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/__init__.py +1 -1
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/consolidate/__init__.py +38 -2
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/peak.py +27 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/project.py +6 -5
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/utils.py +6 -2
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/pyproject.toml +14 -17
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/LICENSE +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/comparison/__init__.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/comparison/_utils.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/comparison/projects.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/comparison/unknowns.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/consolidate/_fields.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/consolidate/_spectra.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/datafile.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/gzip_util.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/method/__init__.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/method/_fields.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/py.typed +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/libgunshotmatch/search.py +0 -0
- {libgunshotmatch-0.10.1 → libgunshotmatch-0.11.1}/requirements.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: libgunshotmatch
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.1
|
|
4
4
|
Summary: Base library for GunShotMatch.
|
|
5
5
|
Author-email: Dominic Davis-Foster <dominic@davis-foster.co.uk>
|
|
6
6
|
License: MIT
|
|
@@ -135,7 +135,7 @@ libgunshotmatch
|
|
|
135
135
|
.. |language| image:: https://img.shields.io/github/languages/top/GunShotMatch/libgunshotmatch
|
|
136
136
|
:alt: GitHub top language
|
|
137
137
|
|
|
138
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.
|
|
138
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.11.1
|
|
139
139
|
:target: https://github.com/GunShotMatch/libgunshotmatch/pulse
|
|
140
140
|
:alt: GitHub commits since tagged version
|
|
141
141
|
|
|
@@ -91,7 +91,7 @@ libgunshotmatch
|
|
|
91
91
|
.. |language| image:: https://img.shields.io/github/languages/top/GunShotMatch/libgunshotmatch
|
|
92
92
|
:alt: GitHub top language
|
|
93
93
|
|
|
94
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.
|
|
94
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.11.1
|
|
95
95
|
:target: https://github.com/GunShotMatch/libgunshotmatch/pulse
|
|
96
96
|
:alt: GitHub commits since tagged version
|
|
97
97
|
|
|
@@ -29,5 +29,5 @@ Base library for GunShotMatch.
|
|
|
29
29
|
__author__: str = "Dominic Davis-Foster"
|
|
30
30
|
__copyright__: str = "2020-2023 Dominic Davis-Foster"
|
|
31
31
|
__license__: str = "MIT License"
|
|
32
|
-
__version__: str = "0.
|
|
32
|
+
__version__: str = "0.11.1"
|
|
33
33
|
__email__: str = "dominic@davis-foster.co.uk"
|
|
@@ -27,7 +27,7 @@ Functions for combining peak identifications across aligned peaks into a single
|
|
|
27
27
|
#
|
|
28
28
|
|
|
29
29
|
# stdlib
|
|
30
|
-
from collections import Counter
|
|
30
|
+
from collections import Counter, defaultdict
|
|
31
31
|
from fnmatch import fnmatch
|
|
32
32
|
from itertools import permutations
|
|
33
33
|
from multiprocessing import Pool
|
|
@@ -61,6 +61,7 @@ __all__ = (
|
|
|
61
61
|
"pairwise_ms_comparisons",
|
|
62
62
|
"ConsolidatedPeakFilter",
|
|
63
63
|
"InvertedFilter",
|
|
64
|
+
"combine_spectra",
|
|
64
65
|
)
|
|
65
66
|
|
|
66
67
|
|
|
@@ -476,10 +477,17 @@ class ConsolidatedPeak:
|
|
|
476
477
|
for hit in d["hits"]:
|
|
477
478
|
hits.append(ConsolidatedSearchResult.from_dict(hit))
|
|
478
479
|
|
|
480
|
+
ms_list: MutableSequence[Optional[MassSpectrum]] = []
|
|
481
|
+
for msd in d["ms_list"]:
|
|
482
|
+
if msd is None:
|
|
483
|
+
ms_list.append(None)
|
|
484
|
+
else:
|
|
485
|
+
ms_list.append(MassSpectrum.from_dict(msd))
|
|
486
|
+
|
|
479
487
|
return cls(
|
|
480
488
|
rt_list=d["rt_list"],
|
|
481
489
|
area_list=d["area_list"],
|
|
482
|
-
ms_list=
|
|
490
|
+
ms_list=ms_list,
|
|
483
491
|
meta=d["meta"],
|
|
484
492
|
ms_comparison=d["ms_comparison"],
|
|
485
493
|
hits=hits,
|
|
@@ -804,3 +812,31 @@ class InvertedFilter(ConsolidatedPeakFilter):
|
|
|
804
812
|
filtered_consolidated_peaks.append(cp)
|
|
805
813
|
|
|
806
814
|
return filtered_consolidated_peaks
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
def combine_spectra(peak: ConsolidatedPeak) -> Tuple[List[int], List[float]]:
|
|
818
|
+
"""
|
|
819
|
+
Sum the intensities across all mass spectra in the given peak.
|
|
820
|
+
|
|
821
|
+
:param peak:
|
|
822
|
+
|
|
823
|
+
:returns: List of masses and list of corresponding intensities.
|
|
824
|
+
|
|
825
|
+
.. versionadded:: v0.11.0
|
|
826
|
+
"""
|
|
827
|
+
|
|
828
|
+
combined_ms_data: Dict[int, float] = defaultdict(float)
|
|
829
|
+
|
|
830
|
+
for ms in peak.ms_list:
|
|
831
|
+
if ms is not None:
|
|
832
|
+
for mass, intensity in zip(ms.mass_list, ms.intensity_list):
|
|
833
|
+
combined_ms_data[mass] += intensity
|
|
834
|
+
|
|
835
|
+
mass_list, intensity_list = [], []
|
|
836
|
+
for mass, intensity in combined_ms_data.items():
|
|
837
|
+
mass_list.append(mass)
|
|
838
|
+
intensity_list.append(intensity)
|
|
839
|
+
|
|
840
|
+
# mass_list, intensity_list = zip(*combined_ms_data.items())
|
|
841
|
+
|
|
842
|
+
return mass_list, intensity_list
|
|
@@ -55,6 +55,7 @@ __all__ = (
|
|
|
55
55
|
"filter_peaks",
|
|
56
56
|
"peak_from_dict",
|
|
57
57
|
"write_alignment",
|
|
58
|
+
"base_peak_mass",
|
|
58
59
|
)
|
|
59
60
|
|
|
60
61
|
|
|
@@ -240,6 +241,10 @@ class PeakList(List[Peak]):
|
|
|
240
241
|
|
|
241
242
|
peaks_as_pure_list: List[Dict[str, Any]] = []
|
|
242
243
|
for peak in self:
|
|
244
|
+
if peak is None:
|
|
245
|
+
peaks_as_pure_list.append(None)
|
|
246
|
+
continue
|
|
247
|
+
|
|
243
248
|
try:
|
|
244
249
|
ion_areas = peak.ion_areas
|
|
245
250
|
except ValueError:
|
|
@@ -531,3 +536,25 @@ def _to_peak_list(a_list: List[Peak]) -> PeakList:
|
|
|
531
536
|
return a_list
|
|
532
537
|
else:
|
|
533
538
|
return PeakList(a_list)
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
def base_peak_mass(peak: Peak) -> float:
|
|
542
|
+
"""
|
|
543
|
+
Returns the mass of the largest fragment in the peak's mass spectrum.
|
|
544
|
+
|
|
545
|
+
:param peak:
|
|
546
|
+
|
|
547
|
+
.. versionadded:: v0.11.0
|
|
548
|
+
"""
|
|
549
|
+
|
|
550
|
+
apex_mass_list = peak.mass_spectrum.mass_list
|
|
551
|
+
apex_mass_spec = peak.mass_spectrum.mass_spec
|
|
552
|
+
|
|
553
|
+
# Determine the intensity of the base peak in the mass spectrum
|
|
554
|
+
base_peak_intensity = max(apex_mass_spec)
|
|
555
|
+
|
|
556
|
+
# Determine the index of the base peak in the mass spectrum
|
|
557
|
+
base_peak_index = apex_mass_spec.index(base_peak_intensity)
|
|
558
|
+
|
|
559
|
+
# Finally, determine the mass of the base peak
|
|
560
|
+
return apex_mass_list[base_peak_index]
|
|
@@ -28,7 +28,7 @@ Represents a collection of repeat analyses.
|
|
|
28
28
|
|
|
29
29
|
# stdlib
|
|
30
30
|
import os
|
|
31
|
-
from typing import Any, Dict, List, Mapping, Optional, Type
|
|
31
|
+
from typing import Any, Dict, List, Mapping, MutableSequence, Optional, Type
|
|
32
32
|
|
|
33
33
|
# 3rd party
|
|
34
34
|
import attr
|
|
@@ -131,14 +131,15 @@ class Project:
|
|
|
131
131
|
"""
|
|
132
132
|
|
|
133
133
|
alignment_as_dict = d["alignment"]
|
|
134
|
-
alignment_peaks: List[
|
|
134
|
+
alignment_peaks: List[MutableSequence[Optional[Peak]]] = []
|
|
135
135
|
for row in alignment_as_dict["peaks"]:
|
|
136
136
|
alignment_peaks.append([])
|
|
137
137
|
for peak in row:
|
|
138
138
|
# print(peak)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
if peak is None:
|
|
140
|
+
alignment_peaks[-1].append(None)
|
|
141
|
+
else:
|
|
142
|
+
alignment_peaks[-1].append(peak_from_dict(peak))
|
|
142
143
|
|
|
143
144
|
alignment = create_alignment(
|
|
144
145
|
alignment_peaks,
|
|
@@ -171,7 +171,11 @@ def get_rt_range(project: "Project") -> Tuple[float, float]:
|
|
|
171
171
|
return min_rt, max_rt
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
def create_alignment(
|
|
174
|
+
def create_alignment(
|
|
175
|
+
peakpos: Sequence[Sequence[Optional[Peak]]],
|
|
176
|
+
expr_code: List[str],
|
|
177
|
+
similarity: float = 0,
|
|
178
|
+
) -> Alignment:
|
|
175
179
|
"""
|
|
176
180
|
Create a new :class:`pyms.DPA.Alignment.Alignment` object.
|
|
177
181
|
|
|
@@ -185,7 +189,7 @@ def create_alignment(peakpos: Sequence[Sequence[Peak]], expr_code: List[str], si
|
|
|
185
189
|
"""
|
|
186
190
|
|
|
187
191
|
alignment = Alignment(None)
|
|
188
|
-
alignment.peakpos = [list(p) for p in peakpos]
|
|
192
|
+
alignment.peakpos = [list(p) for p in peakpos] # type: ignore[arg-type]
|
|
189
193
|
alignment.peakalgt = numpy.transpose(alignment.peakpos).tolist() # type: ignore[arg-type]
|
|
190
194
|
alignment.expr_code = expr_code
|
|
191
195
|
alignment.similarity = similarity
|
|
@@ -4,7 +4,7 @@ build-backend = "whey"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "libgunshotmatch"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.11.1"
|
|
8
8
|
description = "Base library for GunShotMatch."
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
keywords = []
|
|
@@ -42,14 +42,13 @@ classifiers = [
|
|
|
42
42
|
]
|
|
43
43
|
requires-python = ">=3.8"
|
|
44
44
|
|
|
45
|
+
[project.license]
|
|
46
|
+
file = "LICENSE"
|
|
47
|
+
|
|
45
48
|
[[project.authors]]
|
|
46
49
|
name = "Dominic Davis-Foster"
|
|
47
50
|
email = "dominic@davis-foster.co.uk"
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
[project.license]
|
|
51
|
-
file = "LICENSE"
|
|
52
|
-
|
|
53
52
|
[project.urls]
|
|
54
53
|
Homepage = "https://github.com/GunShotMatch/libgunshotmatch"
|
|
55
54
|
"Issue Tracker" = "https://github.com/GunShotMatch/libgunshotmatch/issues"
|
|
@@ -92,6 +91,16 @@ show_error_codes = true
|
|
|
92
91
|
[tool.snippet-fmt]
|
|
93
92
|
directives = [ "code-block",]
|
|
94
93
|
|
|
94
|
+
[tool.snippet-fmt.languages.python]
|
|
95
|
+
reformat = true
|
|
96
|
+
|
|
97
|
+
[tool.snippet-fmt.languages.TOML]
|
|
98
|
+
reformat = true
|
|
99
|
+
|
|
100
|
+
[tool.snippet-fmt.languages.ini]
|
|
101
|
+
|
|
102
|
+
[tool.snippet-fmt.languages.json]
|
|
103
|
+
|
|
95
104
|
[tool.sphinx-pyproject]
|
|
96
105
|
github_username = "GunShotMatch"
|
|
97
106
|
github_repository = "libgunshotmatch"
|
|
@@ -113,7 +122,6 @@ extensions = [
|
|
|
113
122
|
"sphinx.ext.mathjax",
|
|
114
123
|
"sphinxcontrib.extras_require",
|
|
115
124
|
"sphinx.ext.todo",
|
|
116
|
-
"sphinxemoji.sphinxemoji",
|
|
117
125
|
"notfound.extension",
|
|
118
126
|
"sphinx_copybutton",
|
|
119
127
|
"sphinxcontrib.default_values",
|
|
@@ -126,7 +134,6 @@ extensions = [
|
|
|
126
134
|
"remove_factory_defaults",
|
|
127
135
|
"sphinx_toolbox.more_autosummary.column_widths",
|
|
128
136
|
]
|
|
129
|
-
sphinxemoji_style = "twemoji"
|
|
130
137
|
gitstamp_fmt = "%d %b %Y"
|
|
131
138
|
templates_path = [ "_templates",]
|
|
132
139
|
html_static_path = [ "_static",]
|
|
@@ -192,13 +199,3 @@ include = false
|
|
|
192
199
|
[tool.dependency-dash."tests/requirements.txt"]
|
|
193
200
|
order = 20
|
|
194
201
|
include = false
|
|
195
|
-
|
|
196
|
-
[tool.snippet-fmt.languages.python]
|
|
197
|
-
reformat = true
|
|
198
|
-
|
|
199
|
-
[tool.snippet-fmt.languages.TOML]
|
|
200
|
-
reformat = true
|
|
201
|
-
|
|
202
|
-
[tool.snippet-fmt.languages.ini]
|
|
203
|
-
|
|
204
|
-
[tool.snippet-fmt.languages.json]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|