Skip to content

Commit

Permalink
Allow missing precursor charge in mzML
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfG committed Sep 18, 2023
1 parent d220a04 commit 42003cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ms2pip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)


from ms2pip.core import (
from ms2pip.core import ( # noqa: F401 E402
predict_single,
predict_batch,
predict_library,
Expand Down
6 changes: 5 additions & 1 deletion ms2pip/spectrum_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ def read_mzml(spectrum_file: str) -> Generator[ObservedSpectrum, None, None]:
precursor = spectrum["precursorList"]["precursor"][0]["selectedIonList"][
"selectedIon"
][0]
try:
precursor_charge = precursor["charge state"]
except KeyError:
precursor_charge = None
spectrum = ObservedSpectrum(
identifier=spectrum["id"],
mz=spectrum["m/z array"],
intensity=spectrum["intensity array"],
precursor_mz=precursor["selected ion m/z"],
precursor_charge=precursor["charge state"],
precursor_charge=precursor_charge,
)
yield spectrum

Expand Down

0 comments on commit 42003cf

Please sign in to comment.