MaldiAMRKit 0.16.0__tar.gz → 0.18.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.
Files changed (104) hide show
  1. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0/MaldiAMRKit.egg-info}/PKG-INFO +3 -3
  2. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/MaldiAMRKit.egg-info/SOURCES.txt +4 -2
  3. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/MaldiAMRKit.egg-info/requires.txt +2 -2
  4. {maldiamrkit-0.16.0/MaldiAMRKit.egg-info → maldiamrkit-0.18.0}/PKG-INFO +3 -3
  5. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/__init__.py +3 -3
  6. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/alignment/__init__.py +2 -0
  7. maldiamrkit-0.18.0/maldiamrkit/alignment/peak_align.py +123 -0
  8. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/alignment/raw_warping.py +2 -2
  9. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/alignment/strategies.py +1 -1
  10. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/alignment/warping.py +2 -2
  11. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/cli.py +0 -2
  12. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/__init__.py +0 -4
  13. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/dataset_layouts.py +2 -2
  14. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/site_info.py +13 -14
  15. maldiamrkit-0.18.0/maldiamrkit/detection/__init__.py +12 -0
  16. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/detection/peak_detector.py +275 -1
  17. maldiamrkit-0.18.0/maldiamrkit/detection/peaklist.py +469 -0
  18. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/drift/reference.py +1 -1
  19. maldiamrkit-0.18.0/maldiamrkit/evaluation/__init__.py +44 -0
  20. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/preprocessing/__init__.py +9 -1
  21. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/preprocessing/binning.py +94 -12
  22. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/preprocessing/preprocessing_pipeline.py +2 -2
  23. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/preprocessing/transformers.py +1 -1
  24. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/similarity/__init__.py +1 -2
  25. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/similarity/metrics.py +10 -4
  26. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/similarity/pairwise.py +3 -3
  27. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/susceptibility/label_encoder.py +0 -4
  28. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/visualization/_common.py +2 -2
  29. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/visualization/spectrum_plots.py +2 -2
  30. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/requirements-dev.txt +1 -1
  31. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/requirements-docs.txt +1 -1
  32. maldiamrkit-0.18.0/tests/test_peaklist.py +334 -0
  33. maldiamrkit-0.16.0/maldiamrkit/detection/__init__.py +0 -5
  34. maldiamrkit-0.16.0/maldiamrkit/evaluation/__init__.py +0 -81
  35. maldiamrkit-0.16.0/maldiamrkit/evaluation/label_encoder.py +0 -42
  36. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/LICENSE +0 -0
  37. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/MaldiAMRKit.egg-info/dependency_links.txt +0 -0
  38. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/MaldiAMRKit.egg-info/entry_points.txt +0 -0
  39. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/MaldiAMRKit.egg-info/top_level.txt +0 -0
  40. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/README.md +0 -0
  41. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/_compat.py +0 -0
  42. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/README.md +0 -0
  43. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v1.0.yaml +0 -0
  44. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v1.1.yaml +0 -0
  45. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v1.2.yaml +0 -0
  46. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v1.3.yaml +0 -0
  47. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v10.0.yaml +0 -0
  48. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v11.0.yaml +0 -0
  49. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v12.0.yaml +0 -0
  50. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v13.1.yaml +0 -0
  51. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v14.0.yaml +0 -0
  52. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v15.0.yaml +0 -0
  53. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v16.0.yaml +0 -0
  54. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v2.0.yaml +0 -0
  55. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v4.0.yaml +0 -0
  56. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v5.0.yaml +0 -0
  57. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v6.0.yaml +0 -0
  58. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v7.1.yaml +0 -0
  59. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v8.0.yaml +0 -0
  60. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v8.1.yaml +0 -0
  61. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/eucast/eucast_v9.0.yaml +0 -0
  62. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/breakpoints/example.yaml +0 -0
  63. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/builder.py +0 -0
  64. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/duplicates.py +0 -0
  65. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/input_layouts.py +0 -0
  66. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/data/loader.py +0 -0
  67. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/dataset.py +0 -0
  68. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/differential/__init__.py +0 -0
  69. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/differential/analysis.py +0 -0
  70. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/differential/plots.py +0 -0
  71. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/differential/stats.py +0 -0
  72. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/drift/__init__.py +0 -0
  73. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/drift/monitor.py +0 -0
  74. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/drift/pca_drift.py +0 -0
  75. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/drift/peak_drift.py +0 -0
  76. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/drift/plots.py +0 -0
  77. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/evaluation/metrics.py +0 -0
  78. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/evaluation/mic_regression.py +0 -0
  79. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/evaluation/splitting.py +0 -0
  80. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/filters.py +0 -0
  81. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/io/__init__.py +0 -0
  82. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/io/mic.py +0 -0
  83. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/io/readers.py +0 -0
  84. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/preprocessing/merging.py +0 -0
  85. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/preprocessing/pipeline.py +0 -0
  86. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/preprocessing/quality.py +0 -0
  87. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/py.typed +0 -0
  88. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/similarity/clustering.py +0 -0
  89. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/similarity/plots.py +0 -0
  90. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/spectrum.py +0 -0
  91. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/susceptibility/__init__.py +0 -0
  92. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/susceptibility/breakpoint.py +0 -0
  93. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/susceptibility/mic_encoder.py +0 -0
  94. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/visualization/__init__.py +0 -0
  95. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/visualization/alignment_plots.py +0 -0
  96. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/visualization/exploratory_plots.py +0 -0
  97. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/maldiamrkit/visualization/peak_plots.py +0 -0
  98. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/pyproject.toml +0 -0
  99. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/requirements-batch.txt +0 -0
  100. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/requirements.txt +0 -0
  101. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/setup.cfg +0 -0
  102. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/tests/test_compat.py +0 -0
  103. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/tests/test_numerical_edge_cases.py +0 -0
  104. {maldiamrkit-0.16.0 → maldiamrkit-0.18.0}/tests/test_peak_detector.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MaldiAMRKit
3
- Version: 0.16.0
3
+ Version: 0.18.0
4
4
  Summary: A comprehensive toolkit for MALDI-TOF mass spectrometry data preprocessing for antimicrobial resistance (AMR) prediction purposes
5
5
  Author-email: Ettore Rocchi <ettore.rocchi3@unibo.it>
6
6
  License-Expression: MIT
@@ -41,14 +41,14 @@ Requires-Dist: sphinx>=7.0.0; extra == "docs"
41
41
  Requires-Dist: pydata-sphinx-theme>=0.15.0; extra == "docs"
42
42
  Requires-Dist: sphinx-autodoc-typehints>=2.0.0; extra == "docs"
43
43
  Requires-Dist: sphinx-design>=0.6.0; extra == "docs"
44
- Requires-Dist: sphinx-click>=5.0.0; extra == "docs"
44
+ Requires-Dist: sphinxcontrib-typer>=0.5.0; extra == "docs"
45
45
  Requires-Dist: nbsphinx>=0.9.0; extra == "docs"
46
46
  Requires-Dist: ipykernel>=6.0.0; extra == "docs"
47
47
  Provides-Extra: dev
48
48
  Requires-Dist: pytest>=7.0.0; extra == "dev"
49
49
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
50
50
  Requires-Dist: ruff>=0.1.0; extra == "dev"
51
- Requires-Dist: sphinx-click>=5.0.0; extra == "dev"
51
+ Requires-Dist: sphinxcontrib-typer>=0.5.0; extra == "dev"
52
52
  Requires-Dist: hypothesis>=6.0.0; extra == "dev"
53
53
  Provides-Extra: batch
54
54
  Requires-Dist: umap-learn>=0.5; extra == "batch"
@@ -19,6 +19,7 @@ maldiamrkit/filters.py
19
19
  maldiamrkit/py.typed
20
20
  maldiamrkit/spectrum.py
21
21
  maldiamrkit/alignment/__init__.py
22
+ maldiamrkit/alignment/peak_align.py
22
23
  maldiamrkit/alignment/raw_warping.py
23
24
  maldiamrkit/alignment/strategies.py
24
25
  maldiamrkit/alignment/warping.py
@@ -52,6 +53,7 @@ maldiamrkit/data/breakpoints/eucast/eucast_v8.1.yaml
52
53
  maldiamrkit/data/breakpoints/eucast/eucast_v9.0.yaml
53
54
  maldiamrkit/detection/__init__.py
54
55
  maldiamrkit/detection/peak_detector.py
56
+ maldiamrkit/detection/peaklist.py
55
57
  maldiamrkit/differential/__init__.py
56
58
  maldiamrkit/differential/analysis.py
57
59
  maldiamrkit/differential/plots.py
@@ -63,7 +65,6 @@ maldiamrkit/drift/peak_drift.py
63
65
  maldiamrkit/drift/plots.py
64
66
  maldiamrkit/drift/reference.py
65
67
  maldiamrkit/evaluation/__init__.py
66
- maldiamrkit/evaluation/label_encoder.py
67
68
  maldiamrkit/evaluation/metrics.py
68
69
  maldiamrkit/evaluation/mic_regression.py
69
70
  maldiamrkit/evaluation/splitting.py
@@ -94,4 +95,5 @@ maldiamrkit/visualization/peak_plots.py
94
95
  maldiamrkit/visualization/spectrum_plots.py
95
96
  tests/test_compat.py
96
97
  tests/test_numerical_edge_cases.py
97
- tests/test_peak_detector.py
98
+ tests/test_peak_detector.py
99
+ tests/test_peaklist.py
@@ -21,7 +21,7 @@ combatlearn>=1.3
21
21
  pytest>=7.0.0
22
22
  pytest-cov>=4.0.0
23
23
  ruff>=0.1.0
24
- sphinx-click>=5.0.0
24
+ sphinxcontrib-typer>=0.5.0
25
25
  hypothesis>=6.0.0
26
26
 
27
27
  [docs]
@@ -29,6 +29,6 @@ sphinx>=7.0.0
29
29
  pydata-sphinx-theme>=0.15.0
30
30
  sphinx-autodoc-typehints>=2.0.0
31
31
  sphinx-design>=0.6.0
32
- sphinx-click>=5.0.0
32
+ sphinxcontrib-typer>=0.5.0
33
33
  nbsphinx>=0.9.0
34
34
  ipykernel>=6.0.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MaldiAMRKit
3
- Version: 0.16.0
3
+ Version: 0.18.0
4
4
  Summary: A comprehensive toolkit for MALDI-TOF mass spectrometry data preprocessing for antimicrobial resistance (AMR) prediction purposes
5
5
  Author-email: Ettore Rocchi <ettore.rocchi3@unibo.it>
6
6
  License-Expression: MIT
@@ -41,14 +41,14 @@ Requires-Dist: sphinx>=7.0.0; extra == "docs"
41
41
  Requires-Dist: pydata-sphinx-theme>=0.15.0; extra == "docs"
42
42
  Requires-Dist: sphinx-autodoc-typehints>=2.0.0; extra == "docs"
43
43
  Requires-Dist: sphinx-design>=0.6.0; extra == "docs"
44
- Requires-Dist: sphinx-click>=5.0.0; extra == "docs"
44
+ Requires-Dist: sphinxcontrib-typer>=0.5.0; extra == "docs"
45
45
  Requires-Dist: nbsphinx>=0.9.0; extra == "docs"
46
46
  Requires-Dist: ipykernel>=6.0.0; extra == "docs"
47
47
  Provides-Extra: dev
48
48
  Requires-Dist: pytest>=7.0.0; extra == "dev"
49
49
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
50
50
  Requires-Dist: ruff>=0.1.0; extra == "dev"
51
- Requires-Dist: sphinx-click>=5.0.0; extra == "dev"
51
+ Requires-Dist: sphinxcontrib-typer>=0.5.0; extra == "dev"
52
52
  Requires-Dist: hypothesis>=6.0.0; extra == "dev"
53
53
  Provides-Extra: batch
54
54
  Requires-Dist: umap-learn>=0.5; extra == "batch"
@@ -5,8 +5,8 @@ Subpackage guide
5
5
  - ``maldiamrkit.data`` -- DatasetBuilder, DatasetLoader, InputLayout, DatasetLayout
6
6
  - ``maldiamrkit.filters`` -- SpeciesFilter, DrugFilter, QualityFilter, MetadataFilter
7
7
  - ``maldiamrkit.preprocessing`` -- PreprocessingPipeline, transformers, binning, quality, merging
8
- - ``maldiamrkit.alignment`` -- Warping, RawWarping, create_raw_input, AlignmentStrategy, AlignmentMethod
9
- - ``maldiamrkit.detection`` -- MaldiPeakDetector
8
+ - ``maldiamrkit.alignment`` -- Warping, RawWarping, create_raw_input, align_peaks, AlignmentStrategy, AlignmentMethod
9
+ - ``maldiamrkit.detection`` -- MaldiPeakDetector, PeakSet, PeakList, create_peakset_input
10
10
  - ``maldiamrkit.evaluation`` -- AMR metrics (binary + mic_regression_report), splitting (LabelEncoder moved to susceptibility)
11
11
  - ``maldiamrkit.susceptibility`` -- MICEncoder, BreakpointTable, BreakpointResult, LabelEncoder
12
12
  - ``maldiamrkit.similarity`` -- spectral_distance, pairwise_distances, clustering, plots
@@ -27,7 +27,7 @@ Examples
27
27
  from .dataset import MaldiSet
28
28
  from .spectrum import MaldiSpectrum
29
29
 
30
- __version__ = "0.16.0"
30
+ __version__ = "0.18.0"
31
31
  __author__ = "Ettore Rocchi"
32
32
 
33
33
  __all__ = [
@@ -1,5 +1,6 @@
1
1
  """Spectral alignment and warping transformers."""
2
2
 
3
+ from .peak_align import align_peaks
3
4
  from .raw_warping import RawWarping, create_raw_input
4
5
  from .strategies import AlignmentMethod, AlignmentStrategy
5
6
  from .warping import Warping
@@ -9,5 +10,6 @@ __all__ = [
9
10
  "AlignmentStrategy",
10
11
  "RawWarping",
11
12
  "Warping",
13
+ "align_peaks",
12
14
  "create_raw_input",
13
15
  ]
@@ -0,0 +1,123 @@
1
+ """Fit-free peak-m/z alignment for peak sets.
2
+
3
+ :func:`align_peaks` warps the m/z positions of a :class:`~maldiamrkit.detection.PeakSet`
4
+ onto a reference peak list using the shared alignment strategies. It is
5
+ **fit-free**: the reference peaks are supplied by the caller, which is expected
6
+ to estimate them on the training split only (in the consumer's fold). The
7
+ intensities are carried through unchanged.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import numpy as np
13
+
14
+ from ..detection.peaklist import PeakSet
15
+ from .strategies import _ALIGNMENT_REGISTRY, AlignmentMethod, AlignmentStrategy
16
+
17
+
18
+ def _build_strategy(
19
+ method: AlignmentMethod,
20
+ max_shift_da: float,
21
+ n_segments: int,
22
+ smooth_sigma: float,
23
+ lowess_frac: float,
24
+ lowess_it: int,
25
+ ) -> AlignmentStrategy:
26
+ """Instantiate the requested alignment strategy with its parameters."""
27
+ cls = _ALIGNMENT_REGISTRY[method]
28
+ if method in (AlignmentMethod.shift, AlignmentMethod.linear):
29
+ return cls(max_shift=max_shift_da)
30
+ if method == AlignmentMethod.piecewise:
31
+ return cls(
32
+ n_segments=n_segments, smooth_sigma=smooth_sigma, max_shift=max_shift_da
33
+ )
34
+ if method == AlignmentMethod.quadratic:
35
+ return cls(max_shift=max_shift_da, degree=2)
36
+ if method == AlignmentMethod.cubic:
37
+ return cls(max_shift=max_shift_da, degree=3)
38
+ if method == AlignmentMethod.lowess:
39
+ return cls(max_shift=max_shift_da, frac=lowess_frac, it=lowess_it)
40
+ return cls()
41
+
42
+
43
+ def align_peaks(
44
+ peaks: PeakSet,
45
+ ref_peaks_mz: np.ndarray,
46
+ *,
47
+ method: str | AlignmentMethod = "shift",
48
+ max_shift_da: float = 50.0,
49
+ n_segments: int = 5,
50
+ smooth_sigma: float = 2.0,
51
+ lowess_frac: float = 0.3,
52
+ lowess_it: int = 3,
53
+ ) -> PeakSet:
54
+ """Align a peak set's m/z positions to a reference peak list.
55
+
56
+ Fit-free: ``ref_peaks_mz`` is supplied by the caller. Builds the requested
57
+ warping transform from the matched (sample, reference) peak pairs and applies
58
+ it to the peak m/z; intensities are unchanged.
59
+
60
+ Parameters
61
+ ----------
62
+ peaks : PeakSet
63
+ Peak set to align.
64
+ ref_peaks_mz : array-like
65
+ Reference peak m/z positions to align to.
66
+ method : {"shift", "linear", "piecewise", "quadratic", "cubic", "lowess"}, default="shift"
67
+ Warping strategy. ``"dtw"`` is unsupported for peak sets because it
68
+ resamples onto a dense grid and would destroy the set structure.
69
+ max_shift_da : float, default=50.0
70
+ Maximum allowed shift in Daltons (used by the shift fallback and the
71
+ rigid/linear strategies).
72
+ n_segments : int, default=5
73
+ Number of segments for ``method="piecewise"``.
74
+ smooth_sigma : float, default=2.0
75
+ Gaussian smoothing (Da) for piecewise transitions.
76
+ lowess_frac : float, default=0.3
77
+ LOWESS bandwidth for ``method="lowess"``.
78
+ lowess_it : int, default=3
79
+ LOWESS robustness iterations for ``method="lowess"``.
80
+
81
+ Returns
82
+ -------
83
+ PeakSet
84
+ A new peak set with warped m/z and unchanged intensities.
85
+
86
+ Raises
87
+ ------
88
+ ValueError
89
+ If ``method="dtw"``.
90
+
91
+ Notes
92
+ -----
93
+ ``"shift"``, ``"linear"``, ``"quadratic"``, ``"cubic"`` and ``"lowess"``
94
+ operate directly on the matched peak m/z and are the well-behaved choices
95
+ for sparse peak sets. ``"piecewise"`` derives its Gaussian smoothing width
96
+ from the median spacing of the input points; on a sparse peak set that
97
+ spacing is large, so the smoothing is effectively inactive and the warp
98
+ reduces to an unsmoothed piecewise-linear transform.
99
+ """
100
+ method = AlignmentMethod(method)
101
+ if method == AlignmentMethod.dtw:
102
+ raise ValueError(
103
+ "method='dtw' is not supported for peak sets (it resamples onto a "
104
+ "dense grid). Use 'shift', 'linear', 'piecewise', 'quadratic', "
105
+ "'cubic', or 'lowess'."
106
+ )
107
+
108
+ ref_peaks_mz = np.asarray(ref_peaks_mz, dtype=float).ravel()
109
+ if peaks.n_peaks == 0 or ref_peaks_mz.size == 0:
110
+ return PeakSet(peaks.mz.copy(), peaks.intensity.copy())
111
+
112
+ strategy = _build_strategy(
113
+ method, max_shift_da, n_segments, smooth_sigma, lowess_frac, lowess_it
114
+ )
115
+ new_mz, _ = strategy.align_raw(
116
+ peaks.mz,
117
+ peaks.intensity,
118
+ peaks.mz,
119
+ ref_peaks_mz,
120
+ ref_peaks_mz,
121
+ np.ones_like(ref_peaks_mz),
122
+ )
123
+ return PeakSet(np.asarray(new_mz, dtype=float), peaks.intensity.copy())
@@ -16,7 +16,7 @@ from ..io.readers import read_spectrum
16
16
  from ..preprocessing.binning import BinningMethod, bin_spectrum
17
17
  from ..preprocessing.pipeline import preprocess
18
18
  from ..preprocessing.preprocessing_pipeline import PreprocessingPipeline
19
- from .strategies import ALIGNMENT_REGISTRY, AlignmentMethod
19
+ from .strategies import _ALIGNMENT_REGISTRY, AlignmentMethod
20
20
 
21
21
 
22
22
  def create_raw_input(
@@ -393,7 +393,7 @@ class RawWarping(BaseEstimator, TransformerMixin):
393
393
 
394
394
  def _get_strategy(self):
395
395
  """Build strategy instance from current parameters."""
396
- cls = ALIGNMENT_REGISTRY[self.method]
396
+ cls = _ALIGNMENT_REGISTRY[self.method]
397
397
  if self.method == "shift":
398
398
  return cls(max_shift=self.max_shift_da)
399
399
  elif self.method == "linear":
@@ -689,7 +689,7 @@ class LOWESSStrategy(AlignmentStrategy):
689
689
  return new_mz, intensity
690
690
 
691
691
 
692
- ALIGNMENT_REGISTRY: dict[str, type[AlignmentStrategy]] = {
692
+ _ALIGNMENT_REGISTRY: dict[str, type[AlignmentStrategy]] = {
693
693
  "shift": ShiftStrategy,
694
694
  "linear": LinearStrategy,
695
695
  "piecewise": PiecewiseStrategy,
@@ -10,7 +10,7 @@ from joblib import Parallel, delayed
10
10
  from sklearn.base import BaseEstimator, TransformerMixin
11
11
 
12
12
  from ..detection.peak_detector import MaldiPeakDetector
13
- from .strategies import ALIGNMENT_REGISTRY, AlignmentMethod, DTWStrategy
13
+ from .strategies import _ALIGNMENT_REGISTRY, AlignmentMethod, DTWStrategy
14
14
 
15
15
 
16
16
  class Warping(BaseEstimator, TransformerMixin):
@@ -177,7 +177,7 @@ class Warping(BaseEstimator, TransformerMixin):
177
177
 
178
178
  def _get_strategy(self):
179
179
  """Build strategy instance from current parameters."""
180
- cls = ALIGNMENT_REGISTRY[self.method]
180
+ cls = _ALIGNMENT_REGISTRY[self.method]
181
181
  if self.method == "shift":
182
182
  return cls(max_shift=self.max_shift)
183
183
  elif self.method == "linear":
@@ -420,7 +420,5 @@ def build(
420
420
  )
421
421
 
422
422
 
423
- typer_click_object = typer.main.get_command(app)
424
-
425
423
  if __name__ == "__main__":
426
424
  app()
@@ -22,8 +22,6 @@ from .duplicates import DuplicateStrategy
22
22
  from .input_layouts import BrukerTreeLayout, FlatLayout, InputLayout
23
23
  from .loader import DatasetLoader
24
24
  from .site_info import (
25
- CURRENT_FORMAT_VERSION,
26
- MANIFEST_FILENAME,
27
25
  BuildInfo,
28
26
  SiteInfo,
29
27
  read_site_info,
@@ -53,6 +51,4 @@ __all__ = [
53
51
  "BuildInfo",
54
52
  "read_site_info",
55
53
  "write_site_info",
56
- "MANIFEST_FILENAME",
57
- "CURRENT_FORMAT_VERSION",
58
54
  ]
@@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)
30
30
  class _Sentinel:
31
31
  """Sentinel for ``DRIAMSLayout`` kwargs.
32
32
 
33
- A kwarg defaulted to :data:`_AUTO` means: "fill from ``site_info.json``
33
+ A kwarg defaulted to ``_AUTO`` means: "fill from ``site_info.json``
34
34
  if present, otherwise use the library default". Explicit kwargs
35
35
  always win.
36
36
  """
@@ -255,7 +255,7 @@ class DRIAMSLayout(DatasetLayout):
255
255
  ) -> None:
256
256
  """Initialise the layout.
257
257
 
258
- Several kwargs accept the sentinel :data:`_AUTO` as their default.
258
+ Several kwargs accept the sentinel ``_AUTO`` as their default.
259
259
  When ``_AUTO``, the value is filled from ``site_info.json`` at the
260
260
  dataset root (if present) and otherwise falls back to the
261
261
  library-level default. Explicit kwargs always win. Fields with
@@ -45,10 +45,10 @@ from datetime import datetime, timezone
45
45
  from pathlib import Path
46
46
  from typing import Any
47
47
 
48
- MANIFEST_FILENAME = "site_info.json"
48
+ _MANIFEST_FILENAME = "site_info.json"
49
49
  """On-disk filename for the manifest, written at the dataset root."""
50
50
 
51
- CURRENT_FORMAT_VERSION = 1
51
+ _CURRENT_FORMAT_VERSION = 1
52
52
  """Manifest schema version produced by *this* MaldiAMRKit release."""
53
53
 
54
54
  _REQUIRED_V1_KEYS: tuple[str, ...] = (
@@ -65,7 +65,7 @@ _REQUIRED_V1_KEYS: tuple[str, ...] = (
65
65
 
66
66
  @dataclass
67
67
  class BuildInfo:
68
- """Optional provenance block nested under :attr:`SiteInfo.build_info`.
68
+ """Optional provenance block nested under :attr:`~maldiamrkit.data.SiteInfo.build_info`.
69
69
 
70
70
  Informational only; readers may inspect it but are not required to
71
71
  interpret any field. All fields are optional.
@@ -102,8 +102,9 @@ class SiteInfo:
102
102
  Bin width in Daltons used at build time.
103
103
  build_info : BuildInfo, optional
104
104
  Optional provenance block.
105
- format_version : int, default=:data:`CURRENT_FORMAT_VERSION`
106
- Manifest schema version.
105
+ format_version : int, optional
106
+ Manifest schema version; defaults to the current release's schema
107
+ version.
107
108
  """
108
109
 
109
110
  id_column: str
@@ -114,7 +115,7 @@ class SiteInfo:
114
115
  mz_range: tuple[float, float]
115
116
  bin_width: float
116
117
  build_info: BuildInfo | None = None
117
- format_version: int = CURRENT_FORMAT_VERSION
118
+ format_version: int = _CURRENT_FORMAT_VERSION
118
119
 
119
120
  def to_dict(self) -> dict[str, Any]:
120
121
  """Serialise as a plain dict, with ``format_version`` first."""
@@ -134,7 +135,7 @@ class SiteInfo:
134
135
 
135
136
 
136
137
  def write_site_info(dataset_dir: str | Path, site_info: SiteInfo) -> Path:
137
- """Write a :class:`SiteInfo` to ``<dataset_dir>/site_info.json``.
138
+ """Write a :class:`~maldiamrkit.data.SiteInfo` to ``<dataset_dir>/site_info.json``.
138
139
 
139
140
  Parameters
140
141
  ----------
@@ -153,7 +154,7 @@ def write_site_info(dataset_dir: str | Path, site_info: SiteInfo) -> Path:
153
154
  raise FileNotFoundError(
154
155
  f"Cannot write manifest: dataset directory does not exist: {dataset_dir}"
155
156
  )
156
- path = dataset_dir / MANIFEST_FILENAME
157
+ path = dataset_dir / _MANIFEST_FILENAME
157
158
  data = site_info.to_dict()
158
159
  path.write_text(json.dumps(data, indent=2, sort_keys=False) + "\n")
159
160
  return path
@@ -187,11 +188,11 @@ def read_site_info(
187
188
  If the manifest is malformed, missing a required field, or has
188
189
  a non-integer ``format_version``.
189
190
  """
190
- path = Path(dataset_dir) / MANIFEST_FILENAME
191
+ path = Path(dataset_dir) / _MANIFEST_FILENAME
191
192
  if not path.exists():
192
193
  if missing_ok:
193
194
  return None
194
- raise FileNotFoundError(f"{MANIFEST_FILENAME} not found in {dataset_dir}")
195
+ raise FileNotFoundError(f"{_MANIFEST_FILENAME} not found in {dataset_dir}")
195
196
 
196
197
  try:
197
198
  raw = json.loads(path.read_text())
@@ -218,10 +219,10 @@ def _site_info_from_dict(
218
219
  if not isinstance(fv, int):
219
220
  raise ValueError(f"site_info{where} has non-integer format_version={fv!r}.")
220
221
 
221
- if fv > CURRENT_FORMAT_VERSION:
222
+ if fv > _CURRENT_FORMAT_VERSION:
222
223
  warnings.warn(
223
224
  f"site_info{where} was written by a newer MaldiAMRKit "
224
- f"(format_version={fv}; this reader knows v{CURRENT_FORMAT_VERSION}). "
225
+ f"(format_version={fv}; this reader knows v{_CURRENT_FORMAT_VERSION}). "
225
226
  "Reading what I can; unknown fields will be ignored. "
226
227
  "Upgrade `maldiamrkit` if loading misbehaves.",
227
228
  UserWarning,
@@ -282,8 +283,6 @@ def _current_iso_utc() -> str:
282
283
 
283
284
 
284
285
  __all__ = [
285
- "MANIFEST_FILENAME",
286
- "CURRENT_FORMAT_VERSION",
287
286
  "SiteInfo",
288
287
  "BuildInfo",
289
288
  "read_site_info",
@@ -0,0 +1,12 @@
1
+ """Peak detection algorithms and transformers."""
2
+
3
+ from .peak_detector import MaldiPeakDetector, PeakMethod
4
+ from .peaklist import PeakList, PeakSet, create_peakset_input
5
+
6
+ __all__ = [
7
+ "MaldiPeakDetector",
8
+ "PeakMethod",
9
+ "PeakList",
10
+ "PeakSet",
11
+ "create_peakset_input",
12
+ ]