Closed hanghu1024 closed 1 year ago
Hi @hanghu1024 ,
Thanks for adding the Jupyter notebook and example mzml, that definitely helps a lot for solving the issue.
You are accessing the spectrum using
spec = run.info['file_object'][identifier]
Unfortunately, that is not accessing the spectrum class correctly, so you have problems with the subsequent commands to access the spectrum attributes.
Instead, try accessing the spectrum e.g. like this:
spec = run[identifier]
The following then works perfectly fine
spec.peaks("centroided")
spec.peaks("raw")
spec.mz
spec.i
(note: spec.mz and spec.i should not have () )
You can also access the specs directly while iterating through your run
for n, spec in enumerate(run):
print(n)
print(
"Spectrum {0}, MS level {ms_level} @ RT {scan_time:1.2f}".format(
spec.ID, ms_level=spec.ms_level, scan_time=spec.scan_time_in_minutes()
)
)
print(spec.peaks('centroided'))
Also note that with mzML files that come from sciex .wiff files, the indexing doesn't necessarily work properly. So make sure to use spec.id_dict, spec.index, or spec.ID depending on what information you're looking for.
I hope that helps, otherwise let us know and we're happy to try to solve it further.
Thank you so much @StSchulze for response and corrections! I am closing this issue.
Describe the bug I am working on a mzml data converted from sciex .wiff file. I was able to load the data file with pymzml, return a spectrum object, and get spec.TIC, ID, scan_time, etc. But I got error message when I tried to get spectrum using spec.peaks("centroided")/spec.mz()/spec.i(). I was able to get spectrum data by using pyopenms with the same file. I have uploaded the data and Jupyter notebook, could you please have a look? Many thanks!
To Reproduce data file and Jypyter notebook are attached.
Expected behavior
Desktop (please complete the following information):
Files mzml&ipynb.zip