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

Files changed (39) hide show
  1. masster/__init__.py +8 -8
  2. masster/chromatogram.py +1 -1
  3. masster/data/libs/urine.csv +3 -3
  4. masster/logger.py +11 -11
  5. masster/sample/__init__.py +1 -1
  6. masster/sample/adducts.py +338 -264
  7. masster/sample/defaults/find_adducts_def.py +21 -8
  8. masster/sample/h5.py +561 -282
  9. masster/sample/helpers.py +131 -75
  10. masster/sample/lib.py +4 -4
  11. masster/sample/load.py +31 -17
  12. masster/sample/parameters.py +1 -1
  13. masster/sample/plot.py +7 -7
  14. masster/sample/processing.py +117 -87
  15. masster/sample/sample.py +103 -90
  16. masster/sample/sample5_schema.json +44 -44
  17. masster/sample/save.py +35 -12
  18. masster/spectrum.py +1 -1
  19. masster/study/__init__.py +1 -1
  20. masster/study/defaults/align_def.py +5 -1
  21. masster/study/defaults/identify_def.py +3 -1
  22. masster/study/defaults/study_def.py +58 -25
  23. masster/study/export.py +360 -210
  24. masster/study/h5.py +560 -158
  25. masster/study/helpers.py +496 -203
  26. masster/study/helpers_optimized.py +1 -1
  27. masster/study/id.py +538 -349
  28. masster/study/load.py +233 -143
  29. masster/study/plot.py +71 -71
  30. masster/study/processing.py +456 -254
  31. masster/study/save.py +15 -5
  32. masster/study/study.py +213 -131
  33. masster/study/study5_schema.json +149 -149
  34. {masster-0.4.4.dist-info → masster-0.4.5.dist-info}/METADATA +3 -1
  35. {masster-0.4.4.dist-info → masster-0.4.5.dist-info}/RECORD +39 -39
  36. {masster-0.4.4.dist-info → masster-0.4.5.dist-info}/WHEEL +0 -0
  37. {masster-0.4.4.dist-info → masster-0.4.5.dist-info}/entry_points.txt +0 -0
  38. {masster-0.4.4.dist-info → masster-0.4.5.dist-info}/licenses/LICENSE +0 -0
  39. {masster-0.4.4.dist-info → masster-0.4.5.dist-info}/top_level.txt +0 -0
masster/sample/sample.py CHANGED
@@ -23,7 +23,7 @@ Classes:
23
23
 
24
24
  Example Usage:
25
25
  ```python
26
- from masster.sample import Sample
26
+ from master.sample import Sample
27
27
 
28
28
  sample = Sample(file="example.mzML")
29
29
  sample.find_features()
@@ -38,86 +38,87 @@ import sys
38
38
 
39
39
  import polars as pl
40
40
 
41
- from masster._version import get_version
42
- from masster.logger import MassterLogger
41
+ from master._version import get_version
42
+ from master.logger import MasterLogger
43
43
 
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
44
+ from master.sample.defaults.sample_def import sample_defaults
45
+ from master.sample.defaults.find_features_def import find_features_defaults
46
+ from master.sample.defaults.find_adducts_def import find_adducts_defaults
47
+ from master.sample.defaults.find_ms2_def import find_ms2_defaults
48
+ from master.sample.defaults.get_spectrum_def import get_spectrum_defaults
49
49
 
50
50
  # Sample-specific imports
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
- #from masster.sample.helpers import _parse_adduct_specs
60
- #from masster.sample.helpers import _calculate_adduct_mass_shift
61
- #from masster.sample.helpers import _parse_formula_expression
62
- #from masster.sample.helpers import _calculate_molecular_mass
63
- #from masster.sample.helpers import _parse_legacy_adduct_format
64
- #from masster.sample.helpers import _extract_adduct_probability
65
- #from masster.sample.helpers import _detect_adduct_groups_direct
66
- #from masster.sample.helpers import _check_adduct_relationship
67
- from masster.sample.adducts import _get_adducts
68
- from masster.sample.adducts import find_adducts
69
- from masster.sample.helpers import features_delete
70
- from masster.sample.helpers import features_filter
71
- from masster.sample.helpers import select
72
- from masster.sample.helpers import select_closest_scan
73
- from masster.sample.helpers import get_dda_stats
74
- from masster.sample.helpers import get_feature
75
- from masster.sample.helpers import get_scan
76
- from masster.sample.helpers import get_eic
77
- from masster.sample.helpers import set_source
78
- from masster.sample.helpers import _recreate_feature_map
79
- from masster.sample.helpers import _get_feature_map
80
- from masster.sample.load import _load_featureXML
81
- from masster.sample.load import _load_ms2data
82
- from masster.sample.load import _load_mzML
83
- from masster.sample.load import _load_raw
84
- from masster.sample.load import _load_wiff
85
- from masster.sample.load import chrom_extract
86
- from masster.sample.load import index_file
87
- from masster.sample.load import load
88
- from masster.sample.load import load_noms1
89
- from masster.sample.load import load_study
90
- from masster.sample.load import sanitize
91
- from masster.sample.plot import plot_2d
92
- from masster.sample.plot import plot_2d_oracle
93
- from masster.sample.plot import plot_dda_stats
94
- from masster.sample.plot import plot_chrom
95
- from masster.sample.plot import plot_feature_stats
96
- from masster.sample.plot import plot_ms2_cycle
97
- from masster.sample.plot import plot_ms2_eic
98
- from masster.sample.plot import plot_ms2_q1
99
- from masster.sample.plot import plot_bpc
100
- from masster.sample.plot import plot_tic
101
- from masster.sample.plot import _handle_sample_plot_output
102
- from masster.sample.processing import _clean_features_df
103
- from masster.sample.processing import _features_deisotope
104
- from masster.sample.processing import _get_ztscan_stats
105
- from masster.sample.processing import _spec_to_mat
106
- from masster.sample.processing import analyze_dda
107
- from masster.sample.processing import find_features
108
- from masster.sample.processing import find_ms2
109
- from masster.sample.processing import get_spectrum
110
- from masster.sample.parameters import store_history
111
- from masster.sample.parameters import get_parameters
112
- from masster.sample.parameters import update_parameters
113
- from masster.sample.parameters import get_parameters_property
114
- from masster.sample.parameters import set_parameters_property
115
- from masster.sample.save import _save_featureXML
116
- from masster.sample.save import export_chrom
117
- from masster.sample.save import export_dda_stats
118
- from masster.sample.save import export_features
119
- from masster.sample.save import export_mgf
120
- from masster.sample.save import save
51
+ from master.sample.h5 import _load_sample5
52
+ from master.sample.h5 import _load_sample5_study
53
+ from master.sample.h5 import _save_sample5
54
+ from master.sample.helpers import _delete_ms2
55
+ from master.sample.helpers import _estimate_memory_usage
56
+ from master.sample.helpers import _get_scan_uids
57
+ from master.sample.helpers import _get_feature_uids
58
+ from master.sample.helpers import _features_sync
59
+
60
+ # from master.sample.helpers import _parse_adduct_specs
61
+ # from master.sample.helpers import _calculate_adduct_mass_shift
62
+ # from master.sample.helpers import _parse_formula_expression
63
+ # from master.sample.helpers import _calculate_molecular_mass
64
+ # from master.sample.helpers import _parse_legacy_adduct_format
65
+ # from master.sample.helpers import _extract_adduct_probability
66
+ # from master.sample.helpers import _detect_adduct_groups_direct
67
+ # from master.sample.helpers import _check_adduct_relationship
68
+ from master.sample.adducts import _get_adducts
69
+ from master.sample.adducts import find_adducts
70
+ from master.sample.helpers import features_delete
71
+ from master.sample.helpers import features_filter
72
+ from master.sample.helpers import select
73
+ from master.sample.helpers import select_closest_scan
74
+ from master.sample.helpers import get_dda_stats
75
+ from master.sample.helpers import get_feature
76
+ from master.sample.helpers import get_scan
77
+ from master.sample.helpers import get_eic
78
+ from master.sample.helpers import set_source
79
+ from master.sample.helpers import _recreate_feature_map
80
+ from master.sample.helpers import _get_feature_map
81
+ from master.sample.load import _load_featureXML
82
+ from master.sample.load import _load_ms2data
83
+ from master.sample.load import _load_mzML
84
+ from master.sample.load import _load_raw
85
+ from master.sample.load import _load_wiff
86
+ from master.sample.load import chrom_extract
87
+ from master.sample.load import index_file
88
+ from master.sample.load import load
89
+ from master.sample.load import load_noms1
90
+ from master.sample.load import load_study
91
+ from master.sample.load import sanitize
92
+ from master.sample.plot import plot_2d
93
+ from master.sample.plot import plot_2d_oracle
94
+ from master.sample.plot import plot_dda_stats
95
+ from master.sample.plot import plot_chrom
96
+ from master.sample.plot import plot_feature_stats
97
+ from master.sample.plot import plot_ms2_cycle
98
+ from master.sample.plot import plot_ms2_eic
99
+ from master.sample.plot import plot_ms2_q1
100
+ from master.sample.plot import plot_bpc
101
+ from master.sample.plot import plot_tic
102
+ from master.sample.plot import _handle_sample_plot_output
103
+ from master.sample.processing import _clean_features_df
104
+ from master.sample.processing import _features_deisotope
105
+ from master.sample.processing import _get_ztscan_stats
106
+ from master.sample.processing import _spec_to_mat
107
+ from master.sample.processing import analyze_dda
108
+ from master.sample.processing import find_features
109
+ from master.sample.processing import find_ms2
110
+ from master.sample.processing import get_spectrum
111
+ from master.sample.parameters import store_history
112
+ from master.sample.parameters import get_parameters
113
+ from master.sample.parameters import update_parameters
114
+ from master.sample.parameters import get_parameters_property
115
+ from master.sample.parameters import set_parameters_property
116
+ from master.sample.save import _save_featureXML
117
+ from master.sample.save import export_chrom
118
+ from master.sample.save import export_dda_stats
119
+ from master.sample.save import export_features
120
+ from master.sample.save import export_mgf
121
+ from master.sample.save import save
121
122
 
122
123
 
123
124
  class Sample:
@@ -179,7 +180,7 @@ class Sample:
179
180
  self.log_sink = params.log_sink
180
181
 
181
182
  # Initialize independent logger
182
- self.logger = MassterLogger(
183
+ self.logger = MasterLogger(
183
184
  instance_type="sample",
184
185
  level=params.log_level.upper(),
185
186
  label=params.log_label if params.log_label else "",
@@ -298,7 +299,12 @@ class Sample:
298
299
  find_ms2_defaults = find_ms2_defaults
299
300
  get_spectrum_defaults = get_spectrum_defaults
300
301
 
301
- def logger_update(self, level: str | None = None, label: str | None = None, sink: str | None = None):
302
+ def logger_update(
303
+ self,
304
+ level: str | None = None,
305
+ label: str | None = None,
306
+ sink: str | None = None,
307
+ ):
302
308
  """Update the logging configuration for this Sample instance.
303
309
 
304
310
  Args:
@@ -323,20 +329,20 @@ class Sample:
323
329
 
324
330
  def _reload(self):
325
331
  """
326
- Reloads all masster modules to pick up any changes to their source code,
332
+ Reloads all master modules to pick up any changes to their source code,
327
333
  and updates the instance's class reference to the newly reloaded class version.
328
334
  This ensures that the instance uses the latest implementation without restarting the interpreter.
329
335
  """
330
336
  # Reset logger configuration flags to allow proper reconfiguration after reload
331
337
  try:
332
- import masster.logger as logger_module
338
+ import master.logger as logger_module
333
339
 
334
340
  if hasattr(logger_module, "_SAMPLE_LOGGER_CONFIGURED"):
335
341
  logger_module._SAMPLE_LOGGER_CONFIGURED = False
336
342
  except Exception:
337
343
  pass
338
344
 
339
- # Get the base module name (masster)
345
+ # Get the base module name (master)
340
346
  base_modname = self.__class__.__module__.split(".")[0]
341
347
  current_module = self.__class__.__module__
342
348
 
@@ -346,10 +352,13 @@ class Sample:
346
352
 
347
353
  # Get all currently loaded modules that are part of the sample package
348
354
  for module_name in sys.modules:
349
- if module_name.startswith(sample_module_prefix) and module_name != current_module:
355
+ if (
356
+ module_name.startswith(sample_module_prefix)
357
+ and module_name != current_module
358
+ ):
350
359
  sample_modules.append(module_name)
351
360
 
352
- # Add core masster modules
361
+ # Add core master modules
353
362
  core_modules = [
354
363
  f"{base_modname}._version",
355
364
  f"{base_modname}.chromatogram",
@@ -361,7 +370,10 @@ class Sample:
361
370
  study_modules = []
362
371
  study_module_prefix = f"{base_modname}.study."
363
372
  for module_name in sys.modules:
364
- if module_name.startswith(study_module_prefix) and module_name != current_module:
373
+ if (
374
+ module_name.startswith(study_module_prefix)
375
+ and module_name != current_module
376
+ ):
365
377
  study_modules.append(module_name)
366
378
 
367
379
  """ # Add parameters submodules
@@ -372,7 +384,9 @@ class Sample:
372
384
  parameters_modules.append(module_name)
373
385
  """
374
386
 
375
- all_modules_to_reload = core_modules + sample_modules + study_modules # + parameters_modules
387
+ all_modules_to_reload = (
388
+ core_modules + sample_modules + study_modules
389
+ ) # + parameters_modules
376
390
 
377
391
  # Reload all discovered modules
378
392
  for full_module_name in all_modules_to_reload:
@@ -401,7 +415,6 @@ class Sample:
401
415
  def get_version(self):
402
416
  return get_version()
403
417
 
404
-
405
418
  def info(self):
406
419
  # show the key attributes of the object
407
420
  str = f"File: {os.path.basename(self.file_path)}\n"
@@ -424,9 +437,9 @@ class Sample:
424
437
 
425
438
  def __str__(self):
426
439
  if self.features_df is None:
427
- str = f"masster Sample, source: {os.path.basename(self.file_path)}, features: 0"
440
+ str = f"master Sample, source: {os.path.basename(self.file_path)}, features: 0"
428
441
  else:
429
- str = f"masster Sample, source: {os.path.basename(self.file_path)}, features: {len(self.features_df)}"
442
+ str = f"master Sample, source: {os.path.basename(self.file_path)}, features: {len(self.features_df)}"
430
443
  return str
431
444
 
432
445
 
@@ -1,47 +1,53 @@
1
1
  {
2
2
  "features_df": {
3
3
  "columns": {
4
- "feature_uid": {
5
- "dtype": "pl.Int64"
6
- },
7
- "feature_id": {
4
+ "adduct": {
8
5
  "dtype": "pl.Utf8"
9
6
  },
10
- "sample_uid": {
11
- "dtype": "pl.Int32"
7
+ "adduct_charge": {
8
+ "dtype": "pl.Int64"
12
9
  },
13
- "mz": {
14
- "dtype": "pl.Float64"
10
+ "adduct_group": {
11
+ "dtype": "pl.Int64"
15
12
  },
16
- "rt": {
13
+ "adduct_mass_neutral": {
17
14
  "dtype": "pl.Float64"
18
15
  },
19
- "rt_original": {
16
+ "adduct_mass_shift": {
20
17
  "dtype": "pl.Float64"
21
18
  },
22
- "rt_start": {
23
- "dtype": "pl.Float64"
19
+ "charge": {
20
+ "dtype": "pl.Int32"
24
21
  },
25
- "rt_end": {
26
- "dtype": "pl.Float64"
22
+ "chrom": {
23
+ "dtype": "pl.Object"
27
24
  },
28
- "rt_delta": {
25
+ "chrom_area": {
29
26
  "dtype": "pl.Float64"
30
27
  },
31
- "mz_start": {
28
+ "chrom_coherence": {
32
29
  "dtype": "pl.Float64"
33
30
  },
34
- "mz_end": {
31
+ "chrom_height_scaled": {
35
32
  "dtype": "pl.Float64"
36
33
  },
37
- "inty": {
34
+ "chrom_prominence": {
38
35
  "dtype": "pl.Float64"
39
36
  },
40
- "quality": {
37
+ "chrom_prominence_scaled": {
41
38
  "dtype": "pl.Float64"
42
39
  },
43
- "charge": {
44
- "dtype": "pl.Int32"
40
+ "feature_id": {
41
+ "dtype": "pl.Utf8"
42
+ },
43
+ "feature_uid": {
44
+ "dtype": "pl.Int64"
45
+ },
46
+ "filled": {
47
+ "dtype": "pl.Boolean"
48
+ },
49
+ "inty": {
50
+ "dtype": "pl.Float64"
45
51
  },
46
52
  "iso": {
47
53
  "dtype": "pl.Int64"
@@ -49,47 +55,41 @@
49
55
  "iso_of": {
50
56
  "dtype": "pl.Int64"
51
57
  },
52
- "adduct": {
53
- "dtype": "pl.Utf8"
58
+ "ms2_scans": {
59
+ "dtype": "pl.Object"
54
60
  },
55
- "adduct_charge": {
56
- "dtype": "pl.Int64"
61
+ "ms2_specs": {
62
+ "dtype": "pl.Object"
57
63
  },
58
- "adduct_mass_shift": {
64
+ "mz": {
59
65
  "dtype": "pl.Float64"
60
66
  },
61
- "adduct_mass_neutral": {
67
+ "mz_end": {
62
68
  "dtype": "pl.Float64"
63
69
  },
64
- "adduct_group": {
65
- "dtype": "pl.Int64"
66
- },
67
- "chrom": {
68
- "dtype": "pl.Object"
69
- },
70
- "filled": {
71
- "dtype": "pl.Boolean"
70
+ "mz_start": {
71
+ "dtype": "pl.Float64"
72
72
  },
73
- "chrom_area": {
73
+ "quality": {
74
74
  "dtype": "pl.Float64"
75
75
  },
76
- "chrom_coherence": {
76
+ "rt": {
77
77
  "dtype": "pl.Float64"
78
78
  },
79
- "chrom_prominence": {
79
+ "rt_delta": {
80
80
  "dtype": "pl.Float64"
81
81
  },
82
- "chrom_prominence_scaled": {
82
+ "rt_end": {
83
83
  "dtype": "pl.Float64"
84
84
  },
85
- "chrom_height_scaled": {
85
+ "rt_original": {
86
86
  "dtype": "pl.Float64"
87
87
  },
88
- "ms2_scans": {
89
- "dtype": "pl.Object"
88
+ "rt_start": {
89
+ "dtype": "pl.Float64"
90
90
  },
91
- "ms2_specs": {
92
- "dtype": "pl.Object"
91
+ "sample_uid": {
92
+ "dtype": "pl.Int32"
93
93
  }
94
94
  }
95
95
  },
masster/sample/save.py CHANGED
@@ -67,7 +67,7 @@ import pyopenms as oms
67
67
  from tqdm import tqdm
68
68
 
69
69
  # Parameters removed - using hardcoded defaults
70
- from masster.spectrum import combine_peaks
70
+ from master.spectrum import combine_peaks
71
71
 
72
72
 
73
73
  def save(self, filename=None):
@@ -139,9 +139,13 @@ def export_features(self, filename="features.csv"):
139
139
  clean_df = clean_df.with_columns(
140
140
  (pl.col("ms2_scans").is_not_null()).alias("has_ms2"),
141
141
  )
142
- clean_df = self.features_df.select([
143
- col for col in self.features_df.columns if self.features_df[col].dtype not in (pl.List, pl.Object)
144
- ])
142
+ clean_df = self.features_df.select(
143
+ [
144
+ col
145
+ for col in self.features_df.columns
146
+ if self.features_df[col].dtype not in (pl.List, pl.Object)
147
+ ],
148
+ )
145
149
  if filename.lower().endswith((".xls", ".xlsx")):
146
150
  clean_df.to_pandas().to_excel(filename, index=False)
147
151
  self.logger.info(f"Features exported to {filename} (Excel format)")
@@ -275,7 +279,10 @@ def export_mgf(
275
279
  if spect.ms_level > 1 and hasattr(spect, "energy"):
276
280
  f.write(f"ENERGY={spect.energy}\n")
277
281
  # Use list comprehension for better performance
278
- peak_lines = [f"{mz_val:.5f} {inty_val:.0f}\n" for mz_val, inty_val in zip(spect.mz, spect.inty, strict=False)]
282
+ peak_lines = [
283
+ f"{mz_val:.5f} {inty_val:.0f}\n"
284
+ for mz_val, inty_val in zip(spect.mz, spect.inty, strict=False)
285
+ ]
279
286
  f.writelines(peak_lines)
280
287
  f.write("END IONS\n\n")
281
288
 
@@ -287,7 +294,8 @@ def export_mgf(
287
294
 
288
295
  # count how many features have charge < 0
289
296
  if (
290
- self.features_df.filter(pl.col("charge") < 0).shape[0] - self.features_df.filter(pl.col("charge") > 0).shape[0]
297
+ self.features_df.filter(pl.col("charge") < 0).shape[0]
298
+ - self.features_df.filter(pl.col("charge") > 0).shape[0]
291
299
  > 0
292
300
  ):
293
301
  preferred_charge = -1
@@ -388,7 +396,9 @@ def export_mgf(
388
396
  q1_max=q1_ratio_max,
389
397
  )
390
398
  # Get the corresponding scan_uid from the list
391
- current_scan_uid = scan_uids[i] if i < len(scan_uids) else "unknown"
399
+ current_scan_uid = (
400
+ scan_uids[i] if i < len(scan_uids) else "unknown"
401
+ )
392
402
  write_ion(
393
403
  f,
394
404
  f"fid:{feature_uid}, rt:{rt_str}, mz:{mz_str}, scan_uid:{current_scan_uid}",
@@ -411,7 +421,12 @@ def export_mgf(
411
421
  for scan_uid in ms2_scan_uids:
412
422
  spec = self.get_spectrum(scan_uid)
413
423
  if spec is not None:
414
- spectra_with_energy.append((scan_uid, spec.energy if hasattr(spec, "energy") else 0))
424
+ spectra_with_energy.append(
425
+ (
426
+ scan_uid,
427
+ spec.energy if hasattr(spec, "energy") else 0,
428
+ ),
429
+ )
415
430
 
416
431
  # Group by energy
417
432
  energy_groups: dict[float, list[int]] = {}
@@ -496,14 +511,18 @@ def export_mgf(
496
511
  spect = spect.centroid(
497
512
  tolerance=self.parameters["mz_tol_ms1_da"],
498
513
  ppm=self.parameters["mz_tol_ms1_ppm"],
499
- min_points=self.parameters["centroid_min_points_ms1"],
514
+ min_points=self.parameters[
515
+ "centroid_min_points_ms1"
516
+ ],
500
517
  algo=centroid_algo,
501
518
  )
502
519
  elif spect.ms_level == 2:
503
520
  spect = spect.centroid(
504
521
  tolerance=self.parameters["mz_tol_ms2_da"],
505
522
  ppm=self.parameters["mz_tol_ms2_ppm"],
506
- min_points=self.parameters["centroid_min_points_ms2"],
523
+ min_points=self.parameters[
524
+ "centroid_min_points_ms2"
525
+ ],
507
526
  algo=centroid_algo,
508
527
  )
509
528
  if deisotope:
@@ -595,7 +614,9 @@ def export_dda_stats(self, filename="stats.csv"):
595
614
  ms2_count = len(self.scans_df.filter(pl.col("ms_level") == 2))
596
615
  features_count = len(self.features_df) if self.features_df is not None else 0
597
616
  features_with_ms2 = (
598
- self.features_df.filter(pl.col("ms2_scans").is_not_null()).height if self.features_df is not None else 0
617
+ self.features_df.filter(pl.col("ms2_scans").is_not_null()).height
618
+ if self.features_df is not None
619
+ else 0
599
620
  )
600
621
 
601
622
  # Initialize a dictionary to hold statistics
@@ -610,7 +631,9 @@ def export_dda_stats(self, filename="stats.csv"):
610
631
  if "time_cycle" in self.scans_df.columns:
611
632
  ms1_df = self.scans_df.filter(pl.col("ms_level") == 1)
612
633
  avg_cycle_time = ms1_df["time_cycle"].mean()
613
- stats["Average_cycle_time"] = avg_cycle_time if avg_cycle_time is not None else ""
634
+ stats["Average_cycle_time"] = (
635
+ avg_cycle_time if avg_cycle_time is not None else ""
636
+ )
614
637
  else:
615
638
  stats["Average_cycle_time"] = 0
616
639
 
masster/spectrum.py CHANGED
@@ -138,7 +138,7 @@ class Spectrum:
138
138
 
139
139
  Example Usage:
140
140
  >>> import numpy as np
141
- >>> from masster import spec
141
+ >>> from master import spec
142
142
  >>> mz = np.array([100.0, 150.0, 200.0, 250.0])
143
143
  >>> intensity = np.array([1000, 5000, 3000, 800])
144
144
  >>> spectrum = spec(mz=mz, inty=intensity, ms_level=1)
masster/study/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """
2
- Study module for masster.
2
+ Study module for master.
3
3
 
4
4
  This module provides the Sample class for handling mass spectrometry data.
5
5
  """
@@ -298,7 +298,11 @@ class align_defaults:
298
298
  "dtype": str,
299
299
  "description": "Method to use for extrapolation outside the data range in LOWESS",
300
300
  "default": "four-point-linear",
301
- "allowed_values": ["two-point-linear", "four-point-linear", "global-linear"],
301
+ "allowed_values": [
302
+ "two-point-linear",
303
+ "four-point-linear",
304
+ "global-linear",
305
+ ],
302
306
  },
303
307
  },
304
308
  repr=False,
@@ -158,7 +158,9 @@ class identify_defaults:
158
158
  if not isinstance(value, list):
159
159
  return False
160
160
  # For heteroatoms, ensure all elements are strings
161
- if param_name == "heteroatoms" and not all(isinstance(item, str) for item in value):
161
+ if param_name == "heteroatoms" and not all(
162
+ isinstance(item, str) for item in value
163
+ ):
162
164
  return False
163
165
 
164
166
  # Range validation for numeric types