masster 0.5.23__py3-none-any.whl → 0.5.25__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.5.23"
4
+ __version__ = "0.5.25"
5
5
 
6
6
 
7
7
  def get_version():
masster/study/export.py CHANGED
@@ -1305,10 +1305,34 @@ def export_parquet(self, filename: str | None = None) -> None:
1305
1305
  if self.consensus_df is not None and not self.consensus_df.is_empty():
1306
1306
  consensus_file = f"{filename}_consensus.parquet"
1307
1307
  try:
1308
- self.consensus_df.write_parquet(consensus_file)
1308
+ # Create a copy of consensus_df for parquet export
1309
+ consensus_export_df = self.consensus_df.clone()
1310
+
1311
+ # Handle Object dtype columns that can't be serialized to parquet
1312
+ for col in consensus_export_df.columns:
1313
+ if consensus_export_df[col].dtype == pl.Object:
1314
+ if col == "iso":
1315
+ # Convert numpy arrays to string representation for parquet compatibility
1316
+ # This preserves the data while making it parquet-serializable
1317
+ consensus_export_df = consensus_export_df.with_columns([
1318
+ pl.col("iso").map_elements(
1319
+ lambda x: str(x.tolist()) if x is not None else None,
1320
+ return_dtype=pl.String
1321
+ ).alias("iso")
1322
+ ])
1323
+ else:
1324
+ # For other Object columns, convert to string representation
1325
+ consensus_export_df = consensus_export_df.with_columns([
1326
+ pl.col(col).map_elements(
1327
+ lambda x: str(x) if x is not None else None,
1328
+ return_dtype=pl.String
1329
+ ).alias(col)
1330
+ ])
1331
+
1332
+ consensus_export_df.write_parquet(consensus_file)
1309
1333
  exported_files.append(consensus_file)
1310
1334
  self.logger.debug(
1311
- f"Exported consensus to {consensus_file} ({self.consensus_df.height} rows)",
1335
+ f"Exported consensus to {consensus_file} ({consensus_export_df.height} rows)",
1312
1336
  )
1313
1337
  except Exception as e:
1314
1338
  self.logger.error(f"Error writing consensus parquet file: {e}")
masster/study/h5.py CHANGED
@@ -717,11 +717,33 @@ def _reconstruct_object_column(data_col, col_name: str):
717
717
  # Handle isotope patterns (numpy arrays with [mz, intensity] data)
718
718
  try:
719
719
  import numpy as np
720
-
721
- iso_data = json.loads(item)
722
- # Convert back to numpy array
723
- reconstructed_data.append(np.array(iso_data) if iso_data else None)
724
- except (json.JSONDecodeError, ValueError, ImportError):
720
+
721
+ # Try JSON parsing first (new format)
722
+ try:
723
+ iso_data = json.loads(item)
724
+ # Convert back to numpy array
725
+ reconstructed_data.append(np.array(iso_data) if iso_data else None)
726
+ except json.JSONDecodeError:
727
+ # Handle numpy array string representation (old format)
728
+ # This handles strings like "[[ 875.7865 447675. ]\n [ 876.7902 168819. ]]"
729
+ try:
730
+ # Use numpy's string representation parser
731
+ iso_array = np.fromstring(item.replace('[', '').replace(']', '').replace('\n', ' '), sep=' ')
732
+ # Reshape to 2D array (pairs of mz, intensity)
733
+ if len(iso_array) % 2 == 0:
734
+ iso_array = iso_array.reshape(-1, 2)
735
+ reconstructed_data.append(iso_array)
736
+ else:
737
+ reconstructed_data.append(None)
738
+ except (ValueError, AttributeError):
739
+ # If all else fails, try to evaluate the string as a literal
740
+ try:
741
+ import ast
742
+ iso_data = ast.literal_eval(item)
743
+ reconstructed_data.append(np.array(iso_data) if iso_data else None)
744
+ except (ValueError, SyntaxError):
745
+ reconstructed_data.append(None)
746
+ except (ValueError, ImportError):
725
747
  reconstructed_data.append(None)
726
748
  elif col_name == "ms1_spec":
727
749
  # Handle MS1 spectra patterns (numpy arrays with [mz, intensity] data)
@@ -1952,10 +1974,15 @@ def _load_study5(self, filename=None):
1952
1974
  f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]} | INFO | {self.log_label}Loading consensus",
1953
1975
  )
1954
1976
  if "consensus" in f and len(f["consensus"].keys()) > 0:
1955
- # Only include adducts in object_columns if it actually exists in the file
1977
+ # Only include object columns if they actually exist in the file
1956
1978
  object_columns = []
1957
- if "adducts" in f["consensus"]:
1958
- object_columns.append("adducts")
1979
+ try:
1980
+ if "adducts" in f["consensus"]:
1981
+ object_columns.append("adducts")
1982
+ if "iso" in f["consensus"]:
1983
+ object_columns.append("iso")
1984
+ except (KeyError, TypeError):
1985
+ pass
1959
1986
 
1960
1987
  self.consensus_df = _load_dataframe_from_group(
1961
1988
  f["consensus"],
masster/wizard/wizard.py CHANGED
@@ -526,7 +526,7 @@ class Wizard:
526
526
  " # === Processing Parameters ===",
527
527
  f' "adducts": {self.params.adducts!r}, # Adduct specifications for feature detection and annotation',
528
528
  f' "noise": {noise}, # Noise threshold for feature detection',
529
- f' "chrom_fwhm": {self.params.chrom_fwhm}, # Chromatographic peak full width at half maximum (seconds)',
529
+ f' "chrom_fwhm": {chrom_fwhm}, # Chromatographic peak full width at half maximum (seconds)',
530
530
  f' "chrom_peak_snr": {self.params.chrom_peak_snr}, # Minimum signal-to-noise ratio for chromatographic peaks',
531
531
  "",
532
532
  " # === Alignment & Merging ===",
@@ -1267,7 +1267,7 @@ class Wizard:
1267
1267
  " )",
1268
1268
  " sample.find_adducts(adducts=PARAMS['adducts'])",
1269
1269
  " sample.find_ms2()",
1270
- " # sample.find_iso()",
1270
+ " sample.find_iso()",
1271
1271
  " # sample.export_mgf()",
1272
1272
  " # sample.export_mztab()",
1273
1273
  ' # sample.plot_2d(filename="{sample_name}.html")',
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: masster
3
- Version: 0.5.23
3
+ Version: 0.5.25
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
@@ -684,7 +684,6 @@ Requires-Dist: alpharaw>=0.4.8
684
684
  Requires-Dist: bokeh>=3.7.3
685
685
  Requires-Dist: cmap>=0.6.2
686
686
  Requires-Dist: datashader>=0.18.1
687
- Requires-Dist: get-gecko-driver>=1.4
688
687
  Requires-Dist: h5py>=3.14.0
689
688
  Requires-Dist: hdbscan>=0.8.40
690
689
  Requires-Dist: holoviews>=1.21.0
@@ -1,5 +1,5 @@
1
1
  masster/__init__.py,sha256=B7zftzdElF2Wb5B7KvkD6TONnMIY-Jxeen3s49dgmzs,1029
2
- masster/_version.py,sha256=AAUbq19nHieC5cNn0e7AMQbQcm3CFM5qt-dNA9Bc6e0,257
2
+ masster/_version.py,sha256=1ymsIuIjSvggBFAIWxPqWntiqdxjPZEjAmDJy3vRsLE,257
3
3
  masster/chromatogram.py,sha256=iYpdv8C17zVnlWvOFgAn9ns2uFGiF-GgoYf5QVVAbHs,19319
4
4
  masster/logger.py,sha256=oHEFPH1LzBHbmeP9WFaRZCWyqd14GasJjZMLI8a4O3I,19439
5
5
  masster/spectrum.py,sha256=LlmxrI5MFS3aPrGSdqUSKVY0rJnKeBh3Frdh6a4dPvA,49722
@@ -35,8 +35,8 @@ masster/sample/defaults/get_spectrum_def.py,sha256=o62p31PhGd-LiIkTOzKQhwPtnO2At
35
35
  masster/sample/defaults/sample_def.py,sha256=MWWeEexGG2Ahbs-id4uq2doIgH-Ja96GioXaSl2CxN8,15449
36
36
  masster/study/__init__.py,sha256=55axdFuqRX4aXtJ8ocnhcLB32fNtmmJpCi58moO0r4g,237
37
37
  masster/study/analysis.py,sha256=bf2o_ywvwdPz1mZAHPETCPjWbvhoL9eEl1rLaz46Rp4,82032
38
- masster/study/export.py,sha256=63xP7pPBNsrAKWZP6XnqAyWO4lEfqtqKfO0SafNvzyg,58871
39
- masster/study/h5.py,sha256=XZDhMNGEt8D5ueyDEFfzhcpSduux8CfWGZK6AcDA5kk,97447
38
+ masster/study/export.py,sha256=oRgM4F4hL3-nBRr_xd4KTin8WoH8QqCJnz3K_S1M14E,60258
39
+ masster/study/h5.py,sha256=gJRWNQxBTyFKD3qRmEbM24YZ-HdyUk-veYgwQbK0eoE,99104
40
40
  masster/study/helpers.py,sha256=pRcVvGmm6NX-GEvWfYZXZjGc_C0WyklqSQx1PdpYn2E,189694
41
41
  masster/study/id.py,sha256=dTMNdBE7eOQZdFSU0KZwd7vFpqOmNlQnLI0VGW98y8w,89570
42
42
  masster/study/importers.py,sha256=iOe9w6uEn39ShosRms8n_zIrsSBczb51CAMoMrxSUw4,13587
@@ -60,9 +60,9 @@ masster/study/defaults/integrate_def.py,sha256=Vf4SAzdBfnsSZ3IRaF0qZvWu3gMDPHdgP
60
60
  masster/study/defaults/merge_def.py,sha256=99TJtIk7mSoq8NMJMJ4b-cy7gUUixQN69krxttBnkfA,12899
61
61
  masster/study/defaults/study_def.py,sha256=xXOAcb8hez0woWwA1_T3fcokjiLJkq3hwA3OS6elb6I,15965
62
62
  masster/wizard/__init__.py,sha256=L9G_datyGSFJjrBVklEVpZVLGXzUhDiWobtiygBH8vQ,669
63
- masster/wizard/wizard.py,sha256=9lGqslH5OTwktS_nnP-Nymh74kyRlYUpdnhmfhKBXBU,66497
64
- masster-0.5.23.dist-info/METADATA,sha256=4Ilme9EZdtcP_0UvMKczmzMgbyw-JRT9ACtGy5hcSlw,45970
65
- masster-0.5.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
66
- masster-0.5.23.dist-info/entry_points.txt,sha256=ZHguQ_vPmdbpqq2uGtmEOLJfgP-DQ1T0c07Lxh30wc8,58
67
- masster-0.5.23.dist-info/licenses/LICENSE,sha256=bx5iLIKjgAdYQ7sISn7DsfHRKkoCUm1154sJJKhgqnU,35184
68
- masster-0.5.23.dist-info/RECORD,,
63
+ masster/wizard/wizard.py,sha256=11utDrZSt7R8D16Sl-NbRKHcgzhQEu8gW_q2V02-Qi0,66483
64
+ masster-0.5.25.dist-info/METADATA,sha256=cs-J_TOWWtYmlrTJPL_XVSLg9iyxNYdGd24C1mE4wIo,45933
65
+ masster-0.5.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
66
+ masster-0.5.25.dist-info/entry_points.txt,sha256=ZHguQ_vPmdbpqq2uGtmEOLJfgP-DQ1T0c07Lxh30wc8,58
67
+ masster-0.5.25.dist-info/licenses/LICENSE,sha256=bx5iLIKjgAdYQ7sISn7DsfHRKkoCUm1154sJJKhgqnU,35184
68
+ masster-0.5.25.dist-info/RECORD,,