Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support reading gzipped spectrum files #226

Open
wants to merge 4 commits into
base: releases
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ms2pip/spectrum_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def read_spectrum_file(spectrum_file: str) -> Generator[ObservedSpectrum, None,
If the file extension is not supported.

"""
file_extension = Path(spectrum_file).suffix.lower()
if file_extension not in [".mgf", ".mzml", ".d"] and not _is_minitdf(spectrum_file):
paretje marked this conversation as resolved.
Show resolved Hide resolved
raise UnsupportedSpectrumFiletypeError(file_extension)
try:
spectra = get_ms2_spectra(str(spectrum_file))
except ValueError:
raise UnsupportedSpectrumFiletypeError(Path(spectrum_file).suffixes)

for spectrum in get_ms2_spectra(str(spectrum_file)):
for spectrum in spectra:
obs_spectrum = ObservedSpectrum(
mz=np.array(spectrum.mz, dtype=np.float32),
intensity=np.array(spectrum.intensity, dtype=np.float32),
Expand Down