@@ -29,11 +29,12 @@ def read_spectrum_file(spectrum_file: str) -> Generator[ObservedSpectrum, None,
29
29
If the file extension is not supported.
30
30
31
31
"""
32
- file_extension = Path (spectrum_file ).suffix .lower ()
33
- if file_extension not in [".mgf" , ".mzml" , ".d" ] and not _is_minitdf (spectrum_file ):
34
- raise UnsupportedSpectrumFiletypeError (file_extension )
32
+ try :
33
+ spectra = get_ms2_spectra (str (spectrum_file ))
34
+ except ValueError :
35
+ raise UnsupportedSpectrumFiletypeError (Path (spectrum_file ).suffixes )
35
36
36
- for spectrum in get_ms2_spectra ( str ( spectrum_file )) :
37
+ for spectrum in spectra :
37
38
obs_spectrum = ObservedSpectrum (
38
39
mz = np .array (spectrum .mz , dtype = np .float32 ),
39
40
intensity = np .array (spectrum .intensity , dtype = np .float32 ),
@@ -50,15 +51,3 @@ def read_spectrum_file(spectrum_file: str) -> Generator[ObservedSpectrum, None,
50
51
):
51
52
continue
52
53
yield obs_spectrum
53
-
54
-
55
- def _is_minitdf (spectrum_file : str ) -> bool :
56
- """
57
- Check if the spectrum file is a Bruker miniTDF folder.
58
-
59
- A Bruker miniTDF folder has no fixed name, but contains files matching the patterns
60
- ``*ms2spectrum.bin`` and ``*ms2spectrum.parquet``.
61
- """
62
- files = set (Path (spectrum_file ).glob ("*ms2spectrum.bin" ))
63
- files .update (Path (spectrum_file ).glob ("*ms2spectrum.parquet" ))
64
- return len (files ) >= 2
0 commit comments