masster 0.3.10__py3-none-any.whl → 0.3.12__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.

File without changes
File without changes
masster/logger.py CHANGED
@@ -86,40 +86,44 @@ class MassterLogger:
86
86
 
87
87
  # Loguru-style colors for different log levels
88
88
  level_colors = {
89
- 'TRACE': '\x1b[34m', # blue
90
- 'DEBUG': '\x1b[36m', # cyan
91
- 'INFO': '\x1b[37m', # white
92
- 'SUCCESS': '\x1b[32m', # green
93
- 'WARNING': '\x1b[33m', # yellow
94
- 'ERROR': '\x1b[31m', # red
95
- 'CRITICAL': '\x1b[35m', # magenta
89
+ "TRACE": "\x1b[34m", # blue
90
+ "DEBUG": "\x1b[36m", # cyan
91
+ "INFO": "\x1b[37m", # white
92
+ "SUCCESS": "\x1b[32m", # green
93
+ "WARNING": "\x1b[33m", # yellow
94
+ "ERROR": "\x1b[31m", # red
95
+ "CRITICAL": "\x1b[35m", # magenta
96
96
  }
97
97
 
98
98
  level_str = record.levelname.ljust(8)
99
- level_color = level_colors.get(record.levelname, '\x1b[37m') # default white
99
+ level_color = level_colors.get(record.levelname, "\x1b[37m") # default white
100
100
  label_part = self.label + " | " if self.label else ""
101
-
101
+
102
102
  # For DEBUG and TRACE levels, add module/location information
103
103
  location_info = ""
104
- if record.levelname in ['TRACE']:
104
+ if record.levelname in ["TRACE"]:
105
105
  # Use caller information if available (from extra), otherwise fall back to record info
106
- if hasattr(record, 'caller_module'):
107
- module_name = record.caller_module.split('.')[-1] if record.caller_module else 'unknown'
106
+ if hasattr(record, "caller_module"):
107
+ module_name = record.caller_module.split(".")[-1] if record.caller_module else "unknown"
108
108
  line_no = record.caller_lineno
109
109
  func_name = record.caller_funcname
110
110
  else:
111
- module_name = record.module if hasattr(record, 'module') else 'unknown'
111
+ module_name = record.module if hasattr(record, "module") else "unknown"
112
112
  line_no = record.lineno
113
113
  func_name = record.funcName
114
- location_info = f"\x1b[90m{module_name}:{func_name}:{line_no}\x1b[0m | " # dim gray for location info
115
-
114
+ location_info = (
115
+ f"\x1b[90m{module_name}:{func_name}:{line_no}\x1b[0m | " # dim gray for location info
116
+ )
117
+
116
118
  # Loguru-style format: <white>timestamp</white> | <level>LEVEL</level> | <location> | <cyan>label</cyan> - <level>message</level>
117
- return (f"\x1b[37m{timestamp}\x1b[0m | " # white timestamp
118
- f"{level_color}{level_str}\x1b[0m | " # colored level
119
- f"{location_info}" # location info for DEBUG/TRACE
120
- f"{level_color}{label_part}\x1b[0m" # colored label
121
- f"{level_color}{record.getMessage()}\x1b[0m") # colored message
122
-
119
+ return (
120
+ f"\x1b[37m{timestamp}\x1b[0m | " # white timestamp
121
+ f"{level_color}{level_str}\x1b[0m | " # colored level
122
+ f"{location_info}" # location info for DEBUG/TRACE
123
+ f"{level_color}{label_part}\x1b[0m" # colored label
124
+ f"{level_color}{record.getMessage()}\x1b[0m"
125
+ ) # colored message
126
+
123
127
  self.handler.setFormatter(massterFormatter(self.label))
124
128
  self.logger_instance.addHandler(self.handler)
125
129
 
@@ -150,40 +154,44 @@ class MassterLogger:
150
154
 
151
155
  # Loguru-style colors for different log levels
152
156
  level_colors = {
153
- 'TRACE': '\x1b[34m', # blue
154
- 'DEBUG': '\x1b[36m', # cyan
155
- 'INFO': '\x1b[37m', # white
156
- 'SUCCESS': '\x1b[32m', # green
157
- 'WARNING': '\x1b[33m', # yellow
158
- 'ERROR': '\x1b[31m', # red
159
- 'CRITICAL': '\x1b[35m', # magenta
157
+ "TRACE": "\x1b[34m", # blue
158
+ "DEBUG": "\x1b[36m", # cyan
159
+ "INFO": "\x1b[37m", # white
160
+ "SUCCESS": "\x1b[32m", # green
161
+ "WARNING": "\x1b[33m", # yellow
162
+ "ERROR": "\x1b[31m", # red
163
+ "CRITICAL": "\x1b[35m", # magenta
160
164
  }
161
165
 
162
166
  level_str = record.levelname.ljust(8)
163
- level_color = level_colors.get(record.levelname, '\x1b[37m') # default white
167
+ level_color = level_colors.get(record.levelname, "\x1b[37m") # default white
164
168
  label_part = self.label + " | " if self.label else ""
165
-
169
+
166
170
  # For DEBUG and TRACE levels, add module/location information
167
171
  location_info = ""
168
- if record.levelname in ['TRACE']:
172
+ if record.levelname in ["TRACE"]:
169
173
  # Use caller information if available (from extra), otherwise fall back to record info
170
- if hasattr(record, 'caller_module'):
171
- module_name = record.caller_module.split('.')[-1] if record.caller_module else 'unknown'
174
+ if hasattr(record, "caller_module"):
175
+ module_name = record.caller_module.split(".")[-1] if record.caller_module else "unknown"
172
176
  line_no = record.caller_lineno
173
177
  func_name = record.caller_funcname
174
178
  else:
175
- module_name = record.module if hasattr(record, 'module') else 'unknown'
179
+ module_name = record.module if hasattr(record, "module") else "unknown"
176
180
  line_no = record.lineno
177
181
  func_name = record.funcName
178
- location_info = f"\x1b[90m{module_name}:{func_name}:{line_no}\x1b[0m | " # dim gray for location info
179
-
182
+ location_info = (
183
+ f"\x1b[90m{module_name}:{func_name}:{line_no}\x1b[0m | " # dim gray for location info
184
+ )
185
+
180
186
  # Loguru-style format: <white>timestamp</white> | <level>LEVEL</level> | <location> | <cyan>label</cyan> - <level>message</level>
181
- return (f"\x1b[37m{timestamp}\x1b[0m | " # white timestamp
182
- f"{level_color}{level_str}\x1b[0m | " # colored level
183
- f"{location_info}" # location info for DEBUG/TRACE
184
- f"{level_color}{label_part}\x1b[0m" # colored label
185
- f"{level_color}{record.getMessage()}\x1b[0m") # colored message
186
-
187
+ return (
188
+ f"\x1b[37m{timestamp}\x1b[0m | " # white timestamp
189
+ f"{level_color}{level_str}\x1b[0m | " # colored level
190
+ f"{location_info}" # location info for DEBUG/TRACE
191
+ f"{level_color}{label_part}\x1b[0m" # colored label
192
+ f"{level_color}{record.getMessage()}\x1b[0m"
193
+ ) # colored message
194
+
187
195
  self.handler.setFormatter(massterFormatter(self.label))
188
196
 
189
197
  def update_sink(self, sink: Any):
@@ -210,40 +218,44 @@ class MassterLogger:
210
218
 
211
219
  # Loguru-style colors for different log levels
212
220
  level_colors = {
213
- 'TRACE': '\x1b[34m', # blue
214
- 'DEBUG': '\x1b[36m', # cyan
215
- 'INFO': '\x1b[37m', # white
216
- 'SUCCESS': '\x1b[32m', # green
217
- 'WARNING': '\x1b[33m', # yellow
218
- 'ERROR': '\x1b[31m', # red
219
- 'CRITICAL': '\x1b[35m', # magenta
221
+ "TRACE": "\x1b[34m", # blue
222
+ "DEBUG": "\x1b[36m", # cyan
223
+ "INFO": "\x1b[37m", # white
224
+ "SUCCESS": "\x1b[32m", # green
225
+ "WARNING": "\x1b[33m", # yellow
226
+ "ERROR": "\x1b[31m", # red
227
+ "CRITICAL": "\x1b[35m", # magenta
220
228
  }
221
229
 
222
230
  level_str = record.levelname.ljust(8)
223
- level_color = level_colors.get(record.levelname, '\x1b[37m') # default white
231
+ level_color = level_colors.get(record.levelname, "\x1b[37m") # default white
224
232
  label_part = self.label + " | " if self.label else ""
225
-
233
+
226
234
  # For DEBUG and TRACE levels, add module/location information
227
235
  location_info = ""
228
- if record.levelname in ['TRACE']:
236
+ if record.levelname in ["TRACE"]:
229
237
  # Use caller information if available (from extra), otherwise fall back to record info
230
- if hasattr(record, 'caller_module'):
231
- module_name = record.caller_module.split('.')[-1] if record.caller_module else 'unknown'
238
+ if hasattr(record, "caller_module"):
239
+ module_name = record.caller_module.split(".")[-1] if record.caller_module else "unknown"
232
240
  line_no = record.caller_lineno
233
241
  func_name = record.caller_funcname
234
242
  else:
235
243
  module_name = record.module
236
244
  line_no = record.lineno
237
245
  func_name = record.funcName
238
- location_info = f"\x1b[90m{module_name}:{func_name}:{line_no}\x1b[0m | " # dim gray for location info
239
-
246
+ location_info = (
247
+ f"\x1b[90m{module_name}:{func_name}:{line_no}\x1b[0m | " # dim gray for location info
248
+ )
249
+
240
250
  # Loguru-style format: <white>timestamp</white> | <level>LEVEL</level> | <location> | <cyan>label</cyan> - <level>message</level>
241
- return (f"\x1b[37m{timestamp}\x1b[0m | " # white timestamp
242
- f"{level_color}{level_str}\x1b[0m | " # colored level
243
- f"{location_info}" # location info for DEBUG/TRACE
244
- f"{level_color}{label_part}\x1b[0m" # colored label
245
- f"{level_color}{record.getMessage()}\x1b[0m") # colored message
246
-
251
+ return (
252
+ f"\x1b[37m{timestamp}\x1b[0m | " # white timestamp
253
+ f"{level_color}{level_str}\x1b[0m | " # colored level
254
+ f"{location_info}" # location info for DEBUG/TRACE
255
+ f"{level_color}{label_part}\x1b[0m" # colored label
256
+ f"{level_color}{record.getMessage()}\x1b[0m"
257
+ ) # colored message
258
+
247
259
  self.handler.setFormatter(massterFormatter(self.label))
248
260
  self.logger_instance.addHandler(self.handler)
249
261
 
@@ -252,36 +264,38 @@ class MassterLogger:
252
264
  """Log a TRACE level message (mapped to DEBUG)."""
253
265
  # Get caller frame information (skip this method and go to actual caller)
254
266
  import inspect
267
+
255
268
  frame = inspect.currentframe().f_back
256
-
269
+
257
270
  # Add caller information as extra parameters
258
- extra = kwargs.get('extra', {})
271
+ extra = kwargs.get("extra", {})
259
272
  extra.update({
260
- 'caller_module': frame.f_globals.get('__name__', 'unknown'),
261
- 'caller_filename': frame.f_code.co_filename,
262
- 'caller_lineno': frame.f_lineno,
263
- 'caller_funcname': frame.f_code.co_name
273
+ "caller_module": frame.f_globals.get("__name__", "unknown"),
274
+ "caller_filename": frame.f_code.co_filename,
275
+ "caller_lineno": frame.f_lineno,
276
+ "caller_funcname": frame.f_code.co_name,
264
277
  })
265
- kwargs['extra'] = extra
266
-
278
+ kwargs["extra"] = extra
279
+
267
280
  self.logger_instance.debug(message, *args, **kwargs)
268
281
 
269
282
  def debug(self, message: str, *args, **kwargs):
270
283
  """Log a DEBUG level message."""
271
284
  # Get caller frame information (skip this method and go to actual caller)
272
285
  import inspect
286
+
273
287
  frame = inspect.currentframe().f_back
274
-
288
+
275
289
  # Add caller information as extra parameters
276
- extra = kwargs.get('extra', {})
290
+ extra = kwargs.get("extra", {})
277
291
  extra.update({
278
- 'caller_module': frame.f_globals.get('__name__', 'unknown'),
279
- 'caller_filename': frame.f_code.co_filename,
280
- 'caller_lineno': frame.f_lineno,
281
- 'caller_funcname': frame.f_code.co_name
292
+ "caller_module": frame.f_globals.get("__name__", "unknown"),
293
+ "caller_filename": frame.f_code.co_filename,
294
+ "caller_lineno": frame.f_lineno,
295
+ "caller_funcname": frame.f_code.co_name,
282
296
  })
283
- kwargs['extra'] = extra
284
-
297
+ kwargs["extra"] = extra
298
+
285
299
  self.logger_instance.debug(message, *args, **kwargs)
286
300
 
287
301
  def info(self, message: str, *args, **kwargs):
@@ -52,6 +52,10 @@ class find_features_defaults:
52
52
  peaks accepted). Typical values range from ~3 (relaxed) to >10
53
53
  (stringent). Default: 10.0.
54
54
 
55
+ - isotope_filtering_model (str):
56
+ Isotope filtering model to use ('metabolites (2% RMS)', 'metabolites (5% RMS)',
57
+ 'peptides', 'none'). Default: 'metabolites (5% RMS)'.
58
+
55
59
  Use these three parameters together to balance sensitivity and
56
60
  specificity for your dataset: tune `chrom_fwhm` to match chromatographic
57
61
  peak shapes, set `noise` to a conservative background level for your
@@ -62,12 +66,12 @@ class find_features_defaults:
62
66
  isotope handling, post-processing and reporting flags). See individual
63
67
  parameter metadata (`_param_metadata`) for allowed ranges and types.
64
68
  """
65
-
69
+
66
70
  # Main params
67
71
  noise: float = 200.0
68
72
  chrom_fwhm: float = 1.0
69
73
  chrom_peak_snr: float = 10.0
70
-
74
+
71
75
  # Mass Trace Detection parameters
72
76
  tol_ppm: float = 30.0
73
77
  reestimate_mt_sd: bool = True
@@ -78,7 +82,7 @@ class find_features_defaults:
78
82
 
79
83
  min_trace_length: float = 0.5
80
84
  min_trace_length_multiplier: float = 0.2
81
- max_trace_length: float = -1.0
85
+ max_trace_length: float = -1.0
82
86
 
83
87
  # Elution Peak Detection parameters
84
88
  enabled: bool = True
@@ -108,9 +112,9 @@ class find_features_defaults:
108
112
  deisotope: bool = True
109
113
  deisotope_mz_tol: float = 0.02
110
114
  deisotope_rt_tol_factor: float = 0.5 # Will be multiplied by chrom_fwhm
115
+ isotope_filtering_model: str = "metabolites (5% RMS)"
111
116
 
112
117
  # chrom extraction parameters
113
-
114
118
 
115
119
  # Parameter metadata for validation and description
116
120
  _param_metadata: dict[str, dict[str, Any]] = field(
@@ -202,6 +206,12 @@ class find_features_defaults:
202
206
  "min_value": 0.1,
203
207
  "max_value": 2.0,
204
208
  },
209
+ "isotope_filtering_model": {
210
+ "dtype": str,
211
+ "description": "Isotope filtering model",
212
+ "default": "metabolites (5% RMS)",
213
+ "allowed_values": ["metabolites (2% RMS)", "metabolites (5% RMS)", "peptides", "none"],
214
+ },
205
215
  "threads": {
206
216
  "dtype": int,
207
217
  "description": "Number of threads to use for parallel processing",
@@ -228,12 +238,12 @@ class find_features_defaults:
228
238
  "min_value": 2,
229
239
  "max_value": 100,
230
240
  },
231
- ''' "min_fwhm": {
241
+ """ "min_fwhm": {
232
242
  "dtype": float,
233
243
  "description": "Minimum full width at half maximum for peaks (seconds)",
234
244
  "min_value": 0.1,
235
245
  "max_value": 10.0,
236
- },'''
246
+ },"""
237
247
  "chrom_fwhm_max": {
238
248
  "dtype": float,
239
249
  "description": "Maximum full width at half maximum for peaks (seconds)",
@@ -53,7 +53,7 @@ class sample_defaults:
53
53
  centroid_prominence: int = -1
54
54
  max_points_per_spectrum: int = 50000
55
55
  dia_window: float | None = None
56
-
56
+
57
57
  eic_mz_tol: float = 0.01
58
58
  eic_rt_tol: float = 10.0
59
59
 
masster/sample/h5.py CHANGED
@@ -294,13 +294,13 @@ def _load_sample5(self, filename: str, map: bool = True):
294
294
  if "metadata" in f:
295
295
  metadata_group = f["metadata"]
296
296
  self.file_path = decode_metadata_attr(metadata_group.attrs.get("file_path", ""))
297
-
297
+
298
298
  # Load file_source if it exists, otherwise set it equal to file_path
299
299
  if "file_source" in metadata_group.attrs:
300
300
  self.file_source = decode_metadata_attr(metadata_group.attrs.get("file_source", ""))
301
301
  else:
302
302
  self.file_source = self.file_path
303
-
303
+
304
304
  self.file_type = decode_metadata_attr(metadata_group.attrs.get("file_type", ""))
305
305
  self.label = decode_metadata_attr(metadata_group.attrs.get("label", ""))
306
306