Skip to content

Commit

Permalink
fixed instrumentConfigurationRef missing
Browse files Browse the repository at this point in the history
  • Loading branch information
picciama committed Oct 5, 2023
1 parent 19234f7 commit 0ed85b8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spectrum_io/raw/msraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def read_mzml(
for spec in data_iter:
if spec["ms level"] != 1: # filter out ms1 spectra if there are any
spec_id = spec["id"].split("scan=")[-1]
instrument_configuration_ref = spec["scanList"]["scan"][0]["instrumentConfigurationRef"]
instrument_configuration_ref = spec["scanList"]["scan"][0].get("instrumentConfigurationRef", "")
fragmentation = spec["scanList"]["scan"][0]["filter string"].split("@")[1][:3].upper()
mz_range = spec["scanList"]["scan"][0]["filter string"].split("[")[1][:-1]
rt = spec["scanList"]["scan"][0]["scan start time"]
Expand All @@ -163,7 +163,7 @@ def read_mzml(
spec["m/z array"],
mz_range,
rt,
mass_analyzer[instrument_configuration_ref],
mass_analyzer.get(instrument_configuration_ref, "unknown"),
fragmentation,
]
data_iter.close()
Expand Down Expand Up @@ -229,7 +229,7 @@ def _get_scans_pymzml(
for spec in data_iter:
if spec.ms_level != 1: # filter out ms1 spectra if there are any
key = f"{file_name}_{spec.ID}"
instrument_configuration_ref = spec["scanList"]["scan"][0]["instrumentConfigurationRef"]
instrument_configuration_ref = spec["scanList"]["scan"][0].get("instrumentConfigurationRef", "")

Check warning on line 232 in spectrum_io/raw/msraw.py

View check run for this annotation

Codecov / codecov/patch

spectrum_io/raw/msraw.py#L232

Added line #L232 was not covered by tests
filter_string = str(spec.element.find(".//*[@accession='MS:1000512']").get("value"))
fragmentation = filter_string.split("@")[1][:3].upper()
mz_range = filter_string.split("[")[1][:-1]
Expand All @@ -240,7 +240,7 @@ def _get_scans_pymzml(
spec.mz,
mz_range,
spec.scan_time_in_minutes(),
mass_analyzer[instrument_configuration_ref],
mass_analyzer.get(instrument_configuration_ref, "unknown"),
fragmentation,
]
else:
Expand All @@ -250,7 +250,7 @@ def _get_scans_pymzml(
# https://github.com/pymzml/pymzML/blob/a883ff0e61fd97465b0a74667233ff594238e335/pymzml/file_classes
# /standardMzml.py#L81-L84
key = f"{file_name}_{spec.ID}"
instrument_configuration_ref = spec["scanList"]["scan"][0]["instrumentConfigurationRef"]
instrument_configuration_ref = spec["scanList"]["scan"][0].get("instrumentConfigurationRef", "")

Check warning on line 253 in spectrum_io/raw/msraw.py

View check run for this annotation

Codecov / codecov/patch

spectrum_io/raw/msraw.py#L253

Added line #L253 was not covered by tests
filter_string = str(spec.element.find(".//*[@accession='MS:1000512']").get("value"))
fragmentation = filter_string.split("@")[1][:3].upper()
mz_range = filter_string.split("[")[1][:-1]
Expand All @@ -261,7 +261,7 @@ def _get_scans_pymzml(
spec.mz,
mz_range,
spec.scan_time_in_minutes(),
mass_analyzer[instrument_configuration_ref],
mass_analyzer.get(instrument_configuration_ref, "unknown"),
fragmentation,
]
data_iter.close()

0 comments on commit 0ed85b8

Please sign in to comment.