masster 0.4.5__py3-none-any.whl → 0.4.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of masster might be problematic. Click here for more details.
- masster/__init__.py +8 -8
- masster/_version.py +1 -1
- masster/chromatogram.py +2 -2
- masster/logger.py +11 -11
- masster/sample/__init__.py +1 -1
- masster/sample/adducts.py +1 -1
- masster/sample/h5.py +7 -7
- masster/sample/lib.py +2 -2
- masster/sample/load.py +8 -8
- masster/sample/parameters.py +1 -1
- masster/sample/plot.py +2 -2
- masster/sample/processing.py +2 -2
- masster/sample/sample.py +86 -86
- masster/sample/save.py +1 -1
- masster/spectrum.py +2 -2
- masster/study/__init__.py +1 -1
- masster/study/export.py +7 -7
- masster/study/h5.py +6 -6
- masster/study/helpers.py +339 -146
- masster/study/id.py +4 -4
- masster/study/load.py +6 -6
- masster/study/plot.py +3 -3
- masster/study/processing.py +3 -3
- masster/study/save.py +1 -1
- masster/study/study.py +98 -98
- masster-0.4.9.dist-info/METADATA +788 -0
- {masster-0.4.5.dist-info → masster-0.4.9.dist-info}/RECORD +30 -36
- {masster-0.4.5.dist-info → masster-0.4.9.dist-info}/WHEEL +1 -2
- masster/data/libs/__pycache__/ccm.cpython-312.pyc +0 -0
- masster/data/libs/__pycache__/urine.cpython-312.pyc +0 -0
- masster/lib/__init__.py +0 -9
- masster/lib/lib.py +0 -598
- masster/study/helpers_optimized.py +0 -359
- masster-0.4.5.dist-info/METADATA +0 -131
- masster-0.4.5.dist-info/top_level.txt +0 -1
- {masster-0.4.5.dist-info → masster-0.4.9.dist-info}/entry_points.txt +0 -0
- {masster-0.4.5.dist-info → masster-0.4.9.dist-info}/licenses/LICENSE +0 -0
masster/__init__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
masster - Mass Spectrometry Analysis Assistant
|
|
3
3
|
|
|
4
4
|
A comprehensive Python package for processing and analyzing untargeted metabolomics data,
|
|
5
5
|
supporting both DDA (Data-Dependent Acquisition) and DIA (Data-Independent Acquisition)
|
|
@@ -8,14 +8,14 @@ mass spectrometry workflows.
|
|
|
8
8
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
-
from
|
|
11
|
+
from masster._version import __version__
|
|
12
12
|
|
|
13
|
-
# from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from
|
|
18
|
-
from
|
|
13
|
+
# from masster._version import get_version
|
|
14
|
+
from masster.chromatogram import Chromatogram
|
|
15
|
+
from masster.lib import Lib
|
|
16
|
+
from masster.sample.sample import Sample
|
|
17
|
+
from masster.spectrum import Spectrum
|
|
18
|
+
from masster.study.study import Study
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
__all__ = [
|
masster/_version.py
CHANGED
masster/chromatogram.py
CHANGED
|
@@ -88,10 +88,10 @@ class Chromatogram:
|
|
|
88
88
|
|
|
89
89
|
Example Usage:
|
|
90
90
|
>>> import numpy as np
|
|
91
|
-
>>> from
|
|
91
|
+
>>> from masster import Chromatogram
|
|
92
92
|
>>> rt = np.linspace(0, 300, 1000)
|
|
93
93
|
>>> intensity = np.random.normal(1000, 100, 1000)
|
|
94
|
-
>>> chromatogram =
|
|
94
|
+
>>> chromatogram = Chromatogram(rt=rt, inty=intensity, label="EIC m/z 150")
|
|
95
95
|
>>> chromatogram.find_peaks()
|
|
96
96
|
>>> chromatogram.calculate_area()
|
|
97
97
|
|
masster/logger.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# masster/logger.py
|
|
2
2
|
"""
|
|
3
|
-
Simple logger system for
|
|
3
|
+
Simple logger system for masster Study and Sample instances.
|
|
4
4
|
Uses basic Python logging timestamp = dt.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
|
5
5
|
|
|
6
6
|
# Loguru-style colors for different log levels
|
|
@@ -25,7 +25,7 @@ import datetime
|
|
|
25
25
|
from typing import Any
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
class
|
|
28
|
+
class MassterLogger:
|
|
29
29
|
"""Simple logger wrapper for Study/Sample instances.
|
|
30
30
|
Each instance gets its own Python logger to avoid conflicts.
|
|
31
31
|
|
|
@@ -59,7 +59,7 @@ class MasterLogger:
|
|
|
59
59
|
self.sink = sink
|
|
60
60
|
|
|
61
61
|
# Create a unique logger name for this instance
|
|
62
|
-
self.logger_name = f"
|
|
62
|
+
self.logger_name = f"masster.{self.instance_type}.{self.instance_id}"
|
|
63
63
|
|
|
64
64
|
# Get a Python logger instance
|
|
65
65
|
self.logger_instance = logging.getLogger(self.logger_name)
|
|
@@ -73,8 +73,8 @@ class MasterLogger:
|
|
|
73
73
|
# Create a stream handler
|
|
74
74
|
self.handler = logging.StreamHandler(self.sink)
|
|
75
75
|
|
|
76
|
-
# Create formatter that matches the original
|
|
77
|
-
class
|
|
76
|
+
# Create formatter that matches the original masster style
|
|
77
|
+
class massterFormatter(logging.Formatter):
|
|
78
78
|
def __init__(self, label):
|
|
79
79
|
super().__init__()
|
|
80
80
|
self.label = label
|
|
@@ -124,7 +124,7 @@ class MasterLogger:
|
|
|
124
124
|
f"{level_color}{record.getMessage()}\x1b[0m"
|
|
125
125
|
) # colored message
|
|
126
126
|
|
|
127
|
-
self.handler.setFormatter(
|
|
127
|
+
self.handler.setFormatter(massterFormatter(self.label))
|
|
128
128
|
self.logger_instance.addHandler(self.handler)
|
|
129
129
|
|
|
130
130
|
# Prevent propagation to avoid duplicate messages
|
|
@@ -143,7 +143,7 @@ class MasterLogger:
|
|
|
143
143
|
self.label = label
|
|
144
144
|
|
|
145
145
|
# Update formatter with new label
|
|
146
|
-
class
|
|
146
|
+
class massterFormatter(logging.Formatter):
|
|
147
147
|
def __init__(self, label):
|
|
148
148
|
super().__init__()
|
|
149
149
|
self.label = label
|
|
@@ -192,7 +192,7 @@ class MasterLogger:
|
|
|
192
192
|
f"{level_color}{record.getMessage()}\x1b[0m"
|
|
193
193
|
) # colored message
|
|
194
194
|
|
|
195
|
-
self.handler.setFormatter(
|
|
195
|
+
self.handler.setFormatter(massterFormatter(self.label))
|
|
196
196
|
|
|
197
197
|
def update_sink(self, sink: Any):
|
|
198
198
|
"""Update the output sink for log messages."""
|
|
@@ -207,7 +207,7 @@ class MasterLogger:
|
|
|
207
207
|
self.handler = logging.StreamHandler(self.sink)
|
|
208
208
|
|
|
209
209
|
# Apply formatter
|
|
210
|
-
class
|
|
210
|
+
class massterFormatter(logging.Formatter):
|
|
211
211
|
def __init__(self, label):
|
|
212
212
|
super().__init__()
|
|
213
213
|
self.label = label
|
|
@@ -256,7 +256,7 @@ class MasterLogger:
|
|
|
256
256
|
f"{level_color}{record.getMessage()}\x1b[0m"
|
|
257
257
|
) # colored message
|
|
258
258
|
|
|
259
|
-
self.handler.setFormatter(
|
|
259
|
+
self.handler.setFormatter(massterFormatter(self.label))
|
|
260
260
|
self.logger_instance.addHandler(self.handler)
|
|
261
261
|
|
|
262
262
|
# Logger method delegates
|
|
@@ -329,4 +329,4 @@ class MasterLogger:
|
|
|
329
329
|
self.handler = None
|
|
330
330
|
|
|
331
331
|
def __repr__(self):
|
|
332
|
-
return f"
|
|
332
|
+
return f"MassterLogger(type={self.instance_type}, id={self.instance_id}, level={self.level})"
|
masster/sample/__init__.py
CHANGED
masster/sample/adducts.py
CHANGED
|
@@ -18,7 +18,7 @@ from typing import List, Dict
|
|
|
18
18
|
from itertools import combinations
|
|
19
19
|
|
|
20
20
|
# Import defaults class for external use
|
|
21
|
-
from
|
|
21
|
+
from masster.sample.defaults.find_adducts_def import find_adducts_defaults
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def _get_adducts(self, adducts_list: list = None, **kwargs):
|
masster/sample/h5.py
CHANGED
|
@@ -7,8 +7,8 @@ import polars as pl
|
|
|
7
7
|
|
|
8
8
|
from typing import Any, Dict, List, Optional, Tuple
|
|
9
9
|
|
|
10
|
-
from
|
|
11
|
-
from
|
|
10
|
+
from masster.chromatogram import Chromatogram
|
|
11
|
+
from masster.spectrum import Spectrum
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _save_sample5(
|
|
@@ -33,7 +33,7 @@ def _save_sample5(
|
|
|
33
33
|
Set to True if you need to maintain featureXML files for legacy workflows.
|
|
34
34
|
|
|
35
35
|
Stores:
|
|
36
|
-
- metadata/format (str): Data format identifier (
|
|
36
|
+
- metadata/format (str): Data format identifier (masster-sample-1)
|
|
37
37
|
- metadata/file_path (str): Source file path
|
|
38
38
|
- metadata/file_type (str): Source file type
|
|
39
39
|
- metadata/label (str): Sample label
|
|
@@ -85,7 +85,7 @@ def _save_sample5(
|
|
|
85
85
|
ms1_group = f.create_group("ms1")
|
|
86
86
|
|
|
87
87
|
# Store metadata
|
|
88
|
-
metadata_group.attrs["format"] = "
|
|
88
|
+
metadata_group.attrs["format"] = "masster-sample-1"
|
|
89
89
|
if self.file_path is not None:
|
|
90
90
|
metadata_group.attrs["file_path"] = str(self.file_path)
|
|
91
91
|
else:
|
|
@@ -356,7 +356,7 @@ def _load_sample5(self, filename: str, map: bool = False):
|
|
|
356
356
|
loaded_data = load_parameters_from_metadata(metadata_group)
|
|
357
357
|
|
|
358
358
|
# Always create a fresh sample_defaults object
|
|
359
|
-
from
|
|
359
|
+
from masster.sample.defaults.sample_def import sample_defaults
|
|
360
360
|
|
|
361
361
|
self.parameters = sample_defaults()
|
|
362
362
|
|
|
@@ -1096,7 +1096,7 @@ def _load_sample5_study(self, filename: str, map: bool = False):
|
|
|
1096
1096
|
loaded_data = load_parameters_from_metadata(metadata_group)
|
|
1097
1097
|
|
|
1098
1098
|
# Always create a fresh sample_defaults object
|
|
1099
|
-
from
|
|
1099
|
+
from masster.sample.defaults.sample_def import sample_defaults
|
|
1100
1100
|
|
|
1101
1101
|
self.parameters = sample_defaults()
|
|
1102
1102
|
|
|
@@ -2213,7 +2213,7 @@ def create_h5_metadata_group(
|
|
|
2213
2213
|
label: Sample label
|
|
2214
2214
|
"""
|
|
2215
2215
|
metadata_group = f.create_group("metadata")
|
|
2216
|
-
metadata_group.attrs["format"] = "
|
|
2216
|
+
metadata_group.attrs["format"] = "masster-sample5-1"
|
|
2217
2217
|
metadata_group.attrs["file_path"] = str(file_path) if file_path is not None else ""
|
|
2218
2218
|
metadata_group.attrs["file_source"] = (
|
|
2219
2219
|
str(file_source) if file_source is not None else ""
|
masster/sample/lib.py
CHANGED
|
@@ -34,7 +34,7 @@ Supported Adducts:
|
|
|
34
34
|
|
|
35
35
|
Example Usage:
|
|
36
36
|
```python
|
|
37
|
-
from
|
|
37
|
+
from masster.sample.lib import Lib
|
|
38
38
|
|
|
39
39
|
# Create library instance
|
|
40
40
|
lib = Lib()
|
|
@@ -63,7 +63,7 @@ import pyopenms as oms
|
|
|
63
63
|
|
|
64
64
|
from tqdm import tqdm
|
|
65
65
|
|
|
66
|
-
from
|
|
66
|
+
from masster.chromatogram import Chromatogram
|
|
67
67
|
# Parameters removed - using hardcoded defaults
|
|
68
68
|
|
|
69
69
|
|
masster/sample/load.py
CHANGED
|
@@ -47,10 +47,10 @@ import pyopenms as oms
|
|
|
47
47
|
|
|
48
48
|
from tqdm import tqdm
|
|
49
49
|
|
|
50
|
-
from
|
|
50
|
+
from masster.chromatogram import Chromatogram
|
|
51
51
|
|
|
52
52
|
# Parameters removed - using hardcoded defaults
|
|
53
|
-
from
|
|
53
|
+
from masster.spectrum import Spectrum
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
def load(
|
|
@@ -556,12 +556,12 @@ def _load_wiff(
|
|
|
556
556
|
filename=None,
|
|
557
557
|
):
|
|
558
558
|
try:
|
|
559
|
-
# Use
|
|
560
|
-
from
|
|
559
|
+
# Use masster's own implementation first
|
|
560
|
+
from masster.sample.sciex import SciexWiffData as MassterSciexWiffData
|
|
561
561
|
|
|
562
|
-
SciexWiffDataClass =
|
|
562
|
+
SciexWiffDataClass = MassterSciexWiffData
|
|
563
563
|
except ImportError:
|
|
564
|
-
# Fallback to alpharaw if
|
|
564
|
+
# Fallback to alpharaw if masster implementation fails
|
|
565
565
|
from alpharaw.sciex import SciexWiffData as AlpharawSciexWiffData
|
|
566
566
|
|
|
567
567
|
SciexWiffDataClass = AlpharawSciexWiffData
|
|
@@ -972,8 +972,8 @@ def index_file(self):
|
|
|
972
972
|
try:
|
|
973
973
|
from alpharaw.sciex import SciexWiffData
|
|
974
974
|
except ImportError:
|
|
975
|
-
# Fallback to
|
|
976
|
-
from
|
|
975
|
+
# Fallback to masster's own implementation
|
|
976
|
+
from masster.sample.sciex import SciexWiffData
|
|
977
977
|
|
|
978
978
|
raw_data = SciexWiffData(centroided=False)
|
|
979
979
|
raw_data.keep_k_peaks_per_spec = self.parameters.max_points_per_spectrum
|
masster/sample/parameters.py
CHANGED
|
@@ -85,7 +85,7 @@ def update_parameters(self, **kwargs):
|
|
|
85
85
|
- Individual parameter names and values (see sample_defaults for details)
|
|
86
86
|
"""
|
|
87
87
|
# Import here to avoid circular imports
|
|
88
|
-
from
|
|
88
|
+
from masster.sample.defaults.sample_def import (
|
|
89
89
|
sample_defaults as SampleDefaults,
|
|
90
90
|
)
|
|
91
91
|
|
masster/sample/plot.py
CHANGED
|
@@ -2073,7 +2073,7 @@ def plot_tic(
|
|
|
2073
2073
|
return
|
|
2074
2074
|
|
|
2075
2075
|
# Import helper locally to avoid circular imports
|
|
2076
|
-
from
|
|
2076
|
+
from masster.study.helpers import get_tic
|
|
2077
2077
|
|
|
2078
2078
|
# Delegate TIC computation to study helper which handles ms1_df and scans_df fallbacks
|
|
2079
2079
|
try:
|
|
@@ -2128,7 +2128,7 @@ def plot_bpc(
|
|
|
2128
2128
|
return
|
|
2129
2129
|
|
|
2130
2130
|
# Import helper locally to avoid circular imports
|
|
2131
|
-
from
|
|
2131
|
+
from masster.study.helpers import get_bpc
|
|
2132
2132
|
|
|
2133
2133
|
# Delegate BPC computation to study helper
|
|
2134
2134
|
try:
|
masster/sample/processing.py
CHANGED
|
@@ -8,13 +8,13 @@ import pyopenms as oms
|
|
|
8
8
|
|
|
9
9
|
from tqdm import tqdm
|
|
10
10
|
|
|
11
|
-
from
|
|
11
|
+
from masster.spectrum import Spectrum
|
|
12
12
|
from .defaults.find_features_def import find_features_defaults
|
|
13
13
|
from .defaults.find_ms2_def import find_ms2_defaults
|
|
14
14
|
from .defaults.get_spectrum_def import get_spectrum_defaults
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from masster.chromatogram import Chromatogram
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def get_spectrum(self, scan, **kwargs):
|
masster/sample/sample.py
CHANGED
|
@@ -23,7 +23,7 @@ Classes:
|
|
|
23
23
|
|
|
24
24
|
Example Usage:
|
|
25
25
|
```python
|
|
26
|
-
from
|
|
26
|
+
from masster.sample import Sample
|
|
27
27
|
|
|
28
28
|
sample = Sample(file="example.mzML")
|
|
29
29
|
sample.find_features()
|
|
@@ -38,87 +38,87 @@ import sys
|
|
|
38
38
|
|
|
39
39
|
import polars as pl
|
|
40
40
|
|
|
41
|
-
from
|
|
42
|
-
from
|
|
41
|
+
from masster._version import get_version
|
|
42
|
+
from masster.logger import MassterLogger
|
|
43
43
|
|
|
44
|
-
from
|
|
45
|
-
from
|
|
46
|
-
from
|
|
47
|
-
from
|
|
48
|
-
from
|
|
44
|
+
from masster.sample.defaults.sample_def import sample_defaults
|
|
45
|
+
from masster.sample.defaults.find_features_def import find_features_defaults
|
|
46
|
+
from masster.sample.defaults.find_adducts_def import find_adducts_defaults
|
|
47
|
+
from masster.sample.defaults.find_ms2_def import find_ms2_defaults
|
|
48
|
+
from masster.sample.defaults.get_spectrum_def import get_spectrum_defaults
|
|
49
49
|
|
|
50
50
|
# Sample-specific imports
|
|
51
|
-
from
|
|
52
|
-
from
|
|
53
|
-
from
|
|
54
|
-
from
|
|
55
|
-
from
|
|
56
|
-
from
|
|
57
|
-
from
|
|
58
|
-
from
|
|
59
|
-
|
|
60
|
-
# from
|
|
61
|
-
# from
|
|
62
|
-
# from
|
|
63
|
-
# from
|
|
64
|
-
# from
|
|
65
|
-
# from
|
|
66
|
-
# from
|
|
67
|
-
# from
|
|
68
|
-
from
|
|
69
|
-
from
|
|
70
|
-
from
|
|
71
|
-
from
|
|
72
|
-
from
|
|
73
|
-
from
|
|
74
|
-
from
|
|
75
|
-
from
|
|
76
|
-
from
|
|
77
|
-
from
|
|
78
|
-
from
|
|
79
|
-
from
|
|
80
|
-
from
|
|
81
|
-
from
|
|
82
|
-
from
|
|
83
|
-
from
|
|
84
|
-
from
|
|
85
|
-
from
|
|
86
|
-
from
|
|
87
|
-
from
|
|
88
|
-
from
|
|
89
|
-
from
|
|
90
|
-
from
|
|
91
|
-
from
|
|
92
|
-
from
|
|
93
|
-
from
|
|
94
|
-
from
|
|
95
|
-
from
|
|
96
|
-
from
|
|
97
|
-
from
|
|
98
|
-
from
|
|
99
|
-
from
|
|
100
|
-
from
|
|
101
|
-
from
|
|
102
|
-
from
|
|
103
|
-
from
|
|
104
|
-
from
|
|
105
|
-
from
|
|
106
|
-
from
|
|
107
|
-
from
|
|
108
|
-
from
|
|
109
|
-
from
|
|
110
|
-
from
|
|
111
|
-
from
|
|
112
|
-
from
|
|
113
|
-
from
|
|
114
|
-
from
|
|
115
|
-
from
|
|
116
|
-
from
|
|
117
|
-
from
|
|
118
|
-
from
|
|
119
|
-
from
|
|
120
|
-
from
|
|
121
|
-
from
|
|
51
|
+
from masster.sample.h5 import _load_sample5
|
|
52
|
+
from masster.sample.h5 import _load_sample5_study
|
|
53
|
+
from masster.sample.h5 import _save_sample5
|
|
54
|
+
from masster.sample.helpers import _delete_ms2
|
|
55
|
+
from masster.sample.helpers import _estimate_memory_usage
|
|
56
|
+
from masster.sample.helpers import _get_scan_uids
|
|
57
|
+
from masster.sample.helpers import _get_feature_uids
|
|
58
|
+
from masster.sample.helpers import _features_sync
|
|
59
|
+
|
|
60
|
+
# from masster.sample.helpers import _parse_adduct_specs
|
|
61
|
+
# from masster.sample.helpers import _calculate_adduct_mass_shift
|
|
62
|
+
# from masster.sample.helpers import _parse_formula_expression
|
|
63
|
+
# from masster.sample.helpers import _calculate_molecular_mass
|
|
64
|
+
# from masster.sample.helpers import _parse_legacy_adduct_format
|
|
65
|
+
# from masster.sample.helpers import _extract_adduct_probability
|
|
66
|
+
# from masster.sample.helpers import _detect_adduct_groups_direct
|
|
67
|
+
# from masster.sample.helpers import _check_adduct_relationship
|
|
68
|
+
from masster.sample.adducts import _get_adducts
|
|
69
|
+
from masster.sample.adducts import find_adducts
|
|
70
|
+
from masster.sample.helpers import features_delete
|
|
71
|
+
from masster.sample.helpers import features_filter
|
|
72
|
+
from masster.sample.helpers import select
|
|
73
|
+
from masster.sample.helpers import select_closest_scan
|
|
74
|
+
from masster.sample.helpers import get_dda_stats
|
|
75
|
+
from masster.sample.helpers import get_feature
|
|
76
|
+
from masster.sample.helpers import get_scan
|
|
77
|
+
from masster.sample.helpers import get_eic
|
|
78
|
+
from masster.sample.helpers import set_source
|
|
79
|
+
from masster.sample.helpers import _recreate_feature_map
|
|
80
|
+
from masster.sample.helpers import _get_feature_map
|
|
81
|
+
from masster.sample.load import _load_featureXML
|
|
82
|
+
from masster.sample.load import _load_ms2data
|
|
83
|
+
from masster.sample.load import _load_mzML
|
|
84
|
+
from masster.sample.load import _load_raw
|
|
85
|
+
from masster.sample.load import _load_wiff
|
|
86
|
+
from masster.sample.load import chrom_extract
|
|
87
|
+
from masster.sample.load import index_file
|
|
88
|
+
from masster.sample.load import load
|
|
89
|
+
from masster.sample.load import load_noms1
|
|
90
|
+
from masster.sample.load import load_study
|
|
91
|
+
from masster.sample.load import sanitize
|
|
92
|
+
from masster.sample.plot import plot_2d
|
|
93
|
+
from masster.sample.plot import plot_2d_oracle
|
|
94
|
+
from masster.sample.plot import plot_dda_stats
|
|
95
|
+
from masster.sample.plot import plot_chrom
|
|
96
|
+
from masster.sample.plot import plot_feature_stats
|
|
97
|
+
from masster.sample.plot import plot_ms2_cycle
|
|
98
|
+
from masster.sample.plot import plot_ms2_eic
|
|
99
|
+
from masster.sample.plot import plot_ms2_q1
|
|
100
|
+
from masster.sample.plot import plot_bpc
|
|
101
|
+
from masster.sample.plot import plot_tic
|
|
102
|
+
from masster.sample.plot import _handle_sample_plot_output
|
|
103
|
+
from masster.sample.processing import _clean_features_df
|
|
104
|
+
from masster.sample.processing import _features_deisotope
|
|
105
|
+
from masster.sample.processing import _get_ztscan_stats
|
|
106
|
+
from masster.sample.processing import _spec_to_mat
|
|
107
|
+
from masster.sample.processing import analyze_dda
|
|
108
|
+
from masster.sample.processing import find_features
|
|
109
|
+
from masster.sample.processing import find_ms2
|
|
110
|
+
from masster.sample.processing import get_spectrum
|
|
111
|
+
from masster.sample.parameters import store_history
|
|
112
|
+
from masster.sample.parameters import get_parameters
|
|
113
|
+
from masster.sample.parameters import update_parameters
|
|
114
|
+
from masster.sample.parameters import get_parameters_property
|
|
115
|
+
from masster.sample.parameters import set_parameters_property
|
|
116
|
+
from masster.sample.save import _save_featureXML
|
|
117
|
+
from masster.sample.save import export_chrom
|
|
118
|
+
from masster.sample.save import export_dda_stats
|
|
119
|
+
from masster.sample.save import export_features
|
|
120
|
+
from masster.sample.save import export_mgf
|
|
121
|
+
from masster.sample.save import save
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
class Sample:
|
|
@@ -180,7 +180,7 @@ class Sample:
|
|
|
180
180
|
self.log_sink = params.log_sink
|
|
181
181
|
|
|
182
182
|
# Initialize independent logger
|
|
183
|
-
self.logger =
|
|
183
|
+
self.logger = MassterLogger(
|
|
184
184
|
instance_type="sample",
|
|
185
185
|
level=params.log_level.upper(),
|
|
186
186
|
label=params.log_label if params.log_label else "",
|
|
@@ -329,20 +329,20 @@ class Sample:
|
|
|
329
329
|
|
|
330
330
|
def _reload(self):
|
|
331
331
|
"""
|
|
332
|
-
Reloads all
|
|
332
|
+
Reloads all masster modules to pick up any changes to their source code,
|
|
333
333
|
and updates the instance's class reference to the newly reloaded class version.
|
|
334
334
|
This ensures that the instance uses the latest implementation without restarting the interpreter.
|
|
335
335
|
"""
|
|
336
336
|
# Reset logger configuration flags to allow proper reconfiguration after reload
|
|
337
337
|
try:
|
|
338
|
-
import
|
|
338
|
+
import masster.logger as logger_module
|
|
339
339
|
|
|
340
340
|
if hasattr(logger_module, "_SAMPLE_LOGGER_CONFIGURED"):
|
|
341
341
|
logger_module._SAMPLE_LOGGER_CONFIGURED = False
|
|
342
342
|
except Exception:
|
|
343
343
|
pass
|
|
344
344
|
|
|
345
|
-
# Get the base module name (
|
|
345
|
+
# Get the base module name (masster)
|
|
346
346
|
base_modname = self.__class__.__module__.split(".")[0]
|
|
347
347
|
current_module = self.__class__.__module__
|
|
348
348
|
|
|
@@ -358,7 +358,7 @@ class Sample:
|
|
|
358
358
|
):
|
|
359
359
|
sample_modules.append(module_name)
|
|
360
360
|
|
|
361
|
-
# Add core
|
|
361
|
+
# Add core masster modules
|
|
362
362
|
core_modules = [
|
|
363
363
|
f"{base_modname}._version",
|
|
364
364
|
f"{base_modname}.chromatogram",
|
|
@@ -437,9 +437,9 @@ class Sample:
|
|
|
437
437
|
|
|
438
438
|
def __str__(self):
|
|
439
439
|
if self.features_df is None:
|
|
440
|
-
str = f"
|
|
440
|
+
str = f"masster Sample, source: {os.path.basename(self.file_path)}, features: 0"
|
|
441
441
|
else:
|
|
442
|
-
str = f"
|
|
442
|
+
str = f"masster Sample, source: {os.path.basename(self.file_path)}, features: {len(self.features_df)}"
|
|
443
443
|
return str
|
|
444
444
|
|
|
445
445
|
|
masster/sample/save.py
CHANGED
masster/spectrum.py
CHANGED
|
@@ -138,10 +138,10 @@ class Spectrum:
|
|
|
138
138
|
|
|
139
139
|
Example Usage:
|
|
140
140
|
>>> import numpy as np
|
|
141
|
-
>>> from
|
|
141
|
+
>>> from masster import Spectrum
|
|
142
142
|
>>> mz = np.array([100.0, 150.0, 200.0, 250.0])
|
|
143
143
|
>>> intensity = np.array([1000, 5000, 3000, 800])
|
|
144
|
-
>>> spectrum =
|
|
144
|
+
>>> spectrum = Spectrum(mz=mz, inty=intensity, ms_level=1)
|
|
145
145
|
>>> spectrum.find_peaks()
|
|
146
146
|
>>> spectrum.plot()
|
|
147
147
|
|
masster/study/__init__.py
CHANGED
masster/study/export.py
CHANGED
|
@@ -10,9 +10,9 @@ import polars as pl
|
|
|
10
10
|
|
|
11
11
|
from tqdm import tqdm
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
13
|
+
from masster.spectrum import combine_peaks
|
|
14
|
+
from masster.study.defaults import export_mgf_defaults
|
|
15
|
+
from masster._version import get_version
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def _get_mgf_df(self, **kwargs):
|
|
@@ -444,7 +444,7 @@ def export_mztab(self, filename: str = None, include_mgf=True, **kwargs) -> None
|
|
|
444
444
|
full_id_data = None
|
|
445
445
|
try:
|
|
446
446
|
# Import here to avoid circular imports
|
|
447
|
-
from
|
|
447
|
+
from masster.study.id import get_id
|
|
448
448
|
|
|
449
449
|
# Get full enriched identification data for SOME section
|
|
450
450
|
full_id_data = get_id(self)
|
|
@@ -1157,7 +1157,7 @@ def export_xlsx(self, filename: str = None) -> None:
|
|
|
1157
1157
|
|
|
1158
1158
|
# 3. Identification results
|
|
1159
1159
|
try:
|
|
1160
|
-
from
|
|
1160
|
+
from masster.study.id import get_id
|
|
1161
1161
|
|
|
1162
1162
|
id_df = get_id(self)
|
|
1163
1163
|
if id_df is not None and not id_df.is_empty():
|
|
@@ -1171,7 +1171,7 @@ def export_xlsx(self, filename: str = None) -> None:
|
|
|
1171
1171
|
"get_id() returned empty data, skipping identification worksheet",
|
|
1172
1172
|
)
|
|
1173
1173
|
except Exception as e:
|
|
1174
|
-
self.logger.
|
|
1174
|
+
self.logger.debug(
|
|
1175
1175
|
f"Error getting identification data: {e}. Skipping identification worksheet.",
|
|
1176
1176
|
)
|
|
1177
1177
|
|
|
@@ -1272,7 +1272,7 @@ def export_parquet(self, basename: str = None) -> None:
|
|
|
1272
1272
|
|
|
1273
1273
|
# 3. Identification results
|
|
1274
1274
|
try:
|
|
1275
|
-
from
|
|
1275
|
+
from masster.study.id import get_id
|
|
1276
1276
|
|
|
1277
1277
|
id_df = get_id(self)
|
|
1278
1278
|
if id_df is not None and not id_df.is_empty():
|