masster 0.2.4__py3-none-any.whl → 0.2.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.

masster/_version.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
 
4
- __version__ = "0.2.4"
4
+ __version__ = "0.5.1"
5
5
 
6
6
 
7
7
  def get_version():
masster/sample/save.py CHANGED
@@ -168,7 +168,7 @@ def export_mgf(
168
168
  q1_ratio_max=None,
169
169
  eic_corr_min=None,
170
170
  deisotope=True,
171
- precursor_trim=-(-10.0),
171
+ precursor_trim=10.0,
172
172
  centroid_algo=None,
173
173
  ):
174
174
  """
@@ -354,81 +354,98 @@ def export_mgf(
354
354
  elif use_cache:
355
355
  spect = row["ms2_specs"]
356
356
  if spect is None:
357
- print(f"No MS2 spectrum for feature {row['fid']} is cached.")
358
- continue
359
- # check if spec is a list of spectra
360
- if isinstance(spect, list):
361
- if selection == "best":
362
- s = spect[0]
363
- scan_uid = row["ms2_scans"][0]
364
- s.energy = self.get_spectrum(scan_uid).energy
365
- spect = [s]
366
- scan_uids = [scan_uid]
367
- else:
368
- scan_uids = row["ms2_scans"]
369
-
370
- for i, s in enumerate(spect):
371
- if s is None:
372
- print(
373
- f"No MS2 spectrum for feature {row['fid']} is cached.",
357
+ # No cached spectra, fall through to fetch from scan_uid
358
+ use_cache = False
359
+ else:
360
+ # check if spec is a list of spectra
361
+ if isinstance(spect, list):
362
+ if selection == "best":
363
+ s = spect[0]
364
+ scan_uid = row["ms2_scans"][0]
365
+ s.energy = self.get_spectrum(scan_uid).energy
366
+ spect = [s]
367
+ scan_uids = [scan_uid]
368
+ else:
369
+ scan_uids = row["ms2_scans"]
370
+
371
+ for i, s in enumerate(spect):
372
+ if s is None:
373
+ print(
374
+ f"No MS2 spectrum for feature {feature_uid} is cached.",
375
+ )
376
+ continue
377
+ # check if s is a spectrum
378
+ if type(s).__name__ == "Spectrum":
379
+ s = filter_peaks(
380
+ s,
381
+ inty_min=inty_min,
382
+ q1_min=q1_ratio_min,
383
+ eic_min=eic_corr_min,
384
+ q1_max=q1_ratio_max,
385
+ )
386
+ # Get the corresponding scan_uid from the list
387
+ current_scan_uid = scan_uids[i] if i < len(scan_uids) else "unknown"
388
+ write_ion(
389
+ f,
390
+ f"fid:{feature_uid}, rt:{rt_str}, mz:{mz_str}, scan_uid:{current_scan_uid}",
391
+ feature_uid,
392
+ mz,
393
+ rt,
394
+ charge,
395
+ s,
396
+ )
397
+ c += 1
398
+ continue # Skip the rest of the processing for this feature
399
+
400
+ # If we reach here, either use_cache=False or no cached spectra were available
401
+ if split_energy:
402
+ # get energy of all scans with scan_uid in ms2_scans by fetching them
403
+ ms2_scan_uids = row["ms2_scans"]
404
+ if isinstance(ms2_scan_uids, list) and len(ms2_scan_uids) > 0:
405
+ # Fetch spectra to get energy information
406
+ spectra_with_energy = []
407
+ for scan_uid in ms2_scan_uids:
408
+ spec = self.get_spectrum(scan_uid)
409
+ if spec is not None:
410
+ spectra_with_energy.append((scan_uid, spec.energy if hasattr(spec, 'energy') else 0))
411
+
412
+ # Group by energy
413
+ energy_groups: dict[float, list[int]] = {}
414
+ for scan_uid, energy in spectra_with_energy:
415
+ if energy not in energy_groups:
416
+ energy_groups[energy] = []
417
+ energy_groups[energy].append(scan_uid)
418
+
419
+ for energy, scan_uids_for_energy in energy_groups.items():
420
+ if selection == "best":
421
+ # Keep only the first scan for this energy
422
+ scan_uids_for_energy = [scan_uids_for_energy[0]]
423
+
424
+ for scan_uid in scan_uids_for_energy:
425
+ spect = self.get_spectrum(
426
+ scan_uid,
427
+ centroid=centroid,
428
+ deisotope=deisotope,
429
+ precursor_trim=precursor_trim,
430
+ centroid_algo=centroid_algo,
374
431
  )
375
- continue
376
- # check if s is a spectrum
377
- if type(s).__name__ == "spec":
378
- s = filter_peaks(
379
- s,
432
+ spect = filter_peaks(
433
+ spect,
380
434
  inty_min=inty_min,
381
435
  q1_min=q1_ratio_min,
382
436
  eic_min=eic_corr_min,
383
437
  q1_max=q1_ratio_max,
384
438
  )
385
- # Get the corresponding scan_uid from the list
386
- current_scan_uid = scan_uids[i] if i < len(scan_uids) else "unknown"
387
439
  write_ion(
388
440
  f,
389
- f"fid:{feature_uid}, rt:{rt_str}, mz:{mz_str}, scan_uid:{current_scan_uid}",
441
+ f"fid:{feature_uid}, rt:{rt_str}, mz:{mz_str}, scan_uid:{scan_uid}, energy:{energy}",
390
442
  feature_uid,
391
443
  mz,
392
444
  rt,
393
445
  charge,
394
- s,
446
+ spect,
395
447
  )
396
448
  c += 1
397
- elif split_energy:
398
- # get energy of all scans with scan_uid in ms2_scans
399
- energy = [s.energy for s in row["ms2_specs"]]
400
- # find unique energies
401
- unique_energies = list(set(energy))
402
- for e in unique_energies:
403
- ms2_scans = [row["ms2_scans"][i] for i, s in enumerate(row["ms2_specs"]) if s.energy == e]
404
- if selection == "best":
405
- # Keep as list with single element
406
- ms2_scans = [ms2_scans[0]]
407
- for scan_uid in ms2_scans:
408
- spect = self.get_spectrum(
409
- scan_uid,
410
- centroid=centroid,
411
- deisotope=deisotope,
412
- precursor_trim=precursor_trim,
413
- centroid_algo=centroid_algo,
414
- )
415
- spect = filter_peaks(
416
- spect,
417
- inty_min=inty_min,
418
- q1_min=q1_ratio_min,
419
- eic_min=eic_corr_min,
420
- q1_max=q1_ratio_max,
421
- )
422
- write_ion(
423
- f,
424
- f"fid:{feature_uid}, rt:{rt_str}, mz:{mz_str}, scan_uid:{scan_uid}, energy:{e}",
425
- feature_uid,
426
- mz,
427
- rt,
428
- charge,
429
- spect,
430
- )
431
- c += 1
432
449
  else:
433
450
  if selection == "best":
434
451
  ms2_scans = row["ms2_scans"][0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: masster
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Mass spectrometry data analysis package
5
5
  Project-URL: homepage, https://github.com/zamboni-lab/masster
6
6
  Project-URL: repository, https://github.com/zamboni-lab/masster
@@ -1,5 +1,5 @@
1
1
  masster/__init__.py,sha256=xeh-hwR_2umE0CpRXn8t22wbkt4IT-FBEzeJknL8J6c,670
2
- masster/_version.py,sha256=WHz92m1tRN92ku0H9xVvQmdlLPlnlBvBEJkpDBTz-eQ,239
2
+ masster/_version.py,sha256=XwisdBCXGK6Rlum0rwaZ6ZBJxS8eMw72i3m-LXgksaY,239
3
3
  masster/chromatogram.py,sha256=f25rMrNvCQN0A93wp9QPdG3H4FiOlYPbRY3H4yd7Q5Y,18910
4
4
  masster/logger.py,sha256=9uzuVEPwQkVlnsqT_eVvh33FZY_FIm3Wn2TaJcGhZP8,10674
5
5
  masster/spectrum.py,sha256=XiClDcN1uiG-_2TIr7Bqp7x8gWvHPbC5oh3zUu3fr6Y,46789
@@ -17,7 +17,7 @@ masster/sample/plot.py,sha256=7iyBddUa8-4OAcNhbgNUR_mNJgh5KKLwIlIL0s14g9w,58110
17
17
  masster/sample/processing.py,sha256=-kWNWTYpyqlD2adF5uQ3laGZ9Zg8h79RgL5DY6qEoxM,56972
18
18
  masster/sample/sample.py,sha256=uTsLmm7aWvRZO1mIGD_9sYDlKO3Ws74aLp7fIeLn9Eo,15282
19
19
  masster/sample/sample5_schema.json,sha256=pnQMOM4z0P6BdrXGOovVoVZwt-1gS-v8KkhTgbSH8R8,3405
20
- masster/sample/save.py,sha256=begTBO8aSrneV44ncmb5bwlNLFuFoPJMg7xBBXpBkzA,29977
20
+ masster/sample/save.py,sha256=LCWYYhlq8K98eUB6EZIGep_RLujQ39ayqgbPHPuNYec,31198
21
21
  masster/sample/defaults/__init__.py,sha256=aNVdfpiJnyQQ9Jm5KCaJm-ySsi6S4aPEWFglVdKYnag,432
22
22
  masster/sample/defaults/find_adducts_def.py,sha256=dhk_F-cAd1lc39mmC7Xt5sZF20LmLugR8JS2hu0DHYE,11305
23
23
  masster/sample/defaults/find_features_def.py,sha256=LoIc2qDSiw9tsSyDJyjn6I3GSbatdkuzYY_14QkTFxQ,13512
@@ -43,8 +43,8 @@ masster/study/defaults/find_consensus_def.py,sha256=artvErq4w07SfHB0WHi68ZjxGg0X
43
43
  masster/study/defaults/find_ms2_def.py,sha256=k-GmnCKgQuVO6M-EAjzGOqgdFrqZviRaNAdiFmwVujY,4907
44
44
  masster/study/defaults/integrate_chrom_def.py,sha256=FY9QdJpdWe18sYucrwNKoZYY0eoOo0a_hcdkZHm_W00,7107
45
45
  masster/study/defaults/study_def.py,sha256=SzUzd2YTGDGCHNMR-Dw57j5PprEnPhpITonv7wx6HQA,9035
46
- masster-0.2.4.dist-info/METADATA,sha256=6lb1cYuf6QSAp_kpI7kTfR3N6Q9D5m-vegaw_vr_094,44324
47
- masster-0.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
48
- masster-0.2.4.dist-info/entry_points.txt,sha256=ZHguQ_vPmdbpqq2uGtmEOLJfgP-DQ1T0c07Lxh30wc8,58
49
- masster-0.2.4.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
50
- masster-0.2.4.dist-info/RECORD,,
46
+ masster-0.2.5.dist-info/METADATA,sha256=TtRzNj321SMax7E0IiDAUPd-En2lmQST8nEqSwTr_mw,44324
47
+ masster-0.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
48
+ masster-0.2.5.dist-info/entry_points.txt,sha256=ZHguQ_vPmdbpqq2uGtmEOLJfgP-DQ1T0c07Lxh30wc8,58
49
+ masster-0.2.5.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
50
+ masster-0.2.5.dist-info/RECORD,,