pymzml / pymzML

pymzML - an interface between Python and mzML Mass spectrometry Files
https://pymzml.readthedocs.io/en/latest/
MIT License
158 stars 91 forks source link

pulling spectrum numbers caused a problem, Exception( Exception: Spectrum ID should be between 1 and 1), [Warning] Not index found and build_index_from_scratch is False #358

Closed mremachine1 closed 2 months ago

mremachine1 commented 2 months ago

Describe the bug first on some random mzml files (i assume it isnt random), i received the following warning upon instantiating a reader object. [Warning] Not index found and build_index_from_scratch is False then upon trying to call a particular spectrum id ie object[spectrum id] i received the following exception: Exception( Exception: Spectrum ID should be between 1 and 1) the object and the file it came from hold spectrums above one and so i am confused (i have both tried the object intially and with build_index_from_scratch both come up with a 1 to 1 spectrum. any help would be appreciated.

To Reproduce

import pymzml new_path = "X:\JS\Adductomics\BariatricStudy\DIAumpire\" new_fh = new_path + "JS-CS_LI_221120_GroopmanJ_JS_PAA_3_P3_C_correct_Q2.mzML" test_mzml = pymzml.run.Reader(new_fh) [Warning] Not index found and build_index_from_scratch is False test_mzml = pymzml.run.Reader(new_fh, build_index_from_scratch=True) data = test_mzml[1944] Traceback (most recent call last): File "", line 1, in File "C:\Users\Cole Lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pymzml\run.py", line 201, in getitem spectrum = self.info["file_object"][identifier]


File "C:\Users\Cole Lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pymzml\file_interface.py", line 106, in __getitem__
return self.file_handler[identifier]
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "C:\Users\Cole Lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pymzml\file_classes\standardMzml.py", line 123, in __getitem__
spectrum = self._binary_search(identifier)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Cole Lab\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pymzml\file_classes\standardMzml.py", line 155, in _binary_search
raise Exception(
Exception: Spectrum ID should be between 1 and 1

Expected behavior

import pymzml new_path = "X:\JS\Adductomics\BariatricStudy\DIAumpire\" new_fh = new_path + "JS-CS_LI_221120_GroopmanJ_JS_PAA_3_P3_C_correct_Q2.mzML" test_mzml = pymzml.run.Reader(new_fh) [Warning] Not index found and build_index_from_scratch is False test_mzml = pymzml.run.Reader(new_fh, build_index_from_scratch=True) data = test_mzml[1944]

data holds spectrum info

Desktop (please complete the following information):

Schulze-lab commented 2 months ago

This is the same issue as #357 , right?

mremachine1 commented 2 months ago

duplicate