masster 0.2.4__tar.gz → 0.2.5__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.
Potentially problematic release.
This version of masster might be problematic. Click here for more details.
- {masster-0.2.4 → masster-0.2.5}/PKG-INFO +1 -1
- {masster-0.2.4 → masster-0.2.5}/pyproject.toml +1 -1
- {masster-0.2.4 → masster-0.2.5}/src/masster/_version.py +1 -1
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/save.py +79 -62
- {masster-0.2.4 → masster-0.2.5}/uv.lock +1 -1
- {masster-0.2.4 → masster-0.2.5}/.github/workflows/publish.yml +0 -0
- {masster-0.2.4 → masster-0.2.5}/.github/workflows/security.yml +0 -0
- {masster-0.2.4 → masster-0.2.5}/.github/workflows/test.yml +0 -0
- {masster-0.2.4 → masster-0.2.5}/.gitignore +0 -0
- {masster-0.2.4 → masster-0.2.5}/.pre-commit-config.yaml +0 -0
- {masster-0.2.4 → masster-0.2.5}/LICENSE +0 -0
- {masster-0.2.4 → masster-0.2.5}/Makefile +0 -0
- {masster-0.2.4 → masster-0.2.5}/README.md +0 -0
- {masster-0.2.4 → masster-0.2.5}/TESTING.md +0 -0
- {masster-0.2.4 → masster-0.2.5}/demo/example_batch_process.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/demo/example_sample_process.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/__init__.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/chromatogram.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/data/examples/2025_01_14_VW_7600_LpMx_DBS_CID_2min_TOP15_030msecMS1_005msecReac_CE35_DBS-ON_3.mzML +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/data/examples/2025_01_14_VW_7600_LpMx_DBS_CID_2min_TOP15_030msecMS1_005msecReac_CE35_DBS-ON_3.timeseries.data +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/data/examples/2025_01_14_VW_7600_LpMx_DBS_CID_2min_TOP15_030msecMS1_005msecReac_CE35_DBS-ON_3.wiff +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/data/examples/2025_01_14_VW_7600_LpMx_DBS_CID_2min_TOP15_030msecMS1_005msecReac_CE35_DBS-ON_3.wiff.scan +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/data/examples/2025_01_14_VW_7600_LpMx_DBS_CID_2min_TOP15_030msecMS1_005msecReac_CE35_DBS-ON_3.wiff2 +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/logger.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/__init__.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/defaults/__init__.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/defaults/find_adducts_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/defaults/find_features_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/defaults/find_ms2_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/defaults/get_spectrum_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/defaults/sample_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/h5.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/helpers.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/load.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/parameters.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/plot.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/processing.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/sample.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/sample/sample5_schema.json +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/spectrum.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/__init__.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/defaults/__init__.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/defaults/align_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/defaults/export_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/defaults/fill_chrom_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/defaults/find_consensus_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/defaults/find_ms2_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/defaults/integrate_chrom_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/defaults/study_def.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/export.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/h5.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/helpers.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/load.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/parameters.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/plot.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/processing.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/save.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/study.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/src/masster/study/study5_schema.json +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/conftest.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_chromatogram.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_defaults.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_imports.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_integration.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_logger.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_parameters.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_sample.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_spectrum.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_study.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tests/test_version.py +0 -0
- {masster-0.2.4 → masster-0.2.5}/tox.ini +0 -0
|
@@ -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
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
if
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
376
|
-
|
|
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:{
|
|
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
|
-
|
|
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]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|