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

Issue Averaging Two Spectra #240

Open
michaelmarty opened this issue Jun 18, 2020 · 3 comments
Open

Issue Averaging Two Spectra #240

michaelmarty opened this issue Jun 18, 2020 · 3 comments

Comments

@michaelmarty
Copy link

I am trying to average together multiple scans into a single summed spectrum, and I'm having issues with the add function. Perhaps I'm using it wrong, but here is an example.

To Reproduce

import pymzml

path = "strep.mzML"
msrun = pymzml.run.Reader(path)

spec1 = msrun[1]
spec2 = msrun[2]

average_spec = spec1 + spec2

Expected behavior
The average_spec is the sum of spec1 and spec2.

Console Output

Traceback (most recent call last):
File "C:/Python/UniDec3/Scripts/MTM/mzml_test.py", line 9, in
average_spec = spec1 + spec2
File "C:\intelpython3\lib\site-packages\pymzml\spec.py", line 505, in add
for mz, i in other_spec.peaks("reprofiled"):
File "C:\intelpython3\lib\site-packages\pymzml\spec.py", line 1046, in peaks
self._peak_dict["reprofiled"] = self._reprofile_Peaks()
File "C:\intelpython3\lib\site-packages\pymzml\spec.py", line 1202, in _reprofile_Peaks
for mz, i in self.peaks("centroided"):
File "C:\intelpython3\lib\site-packages\pymzml\spec.py", line 1044, in peaks
self._peak_dict["centroided"] = self._centroid_peaks()
File "C:\intelpython3\lib\site-packages\pymzml\spec.py", line 1158, in _centroid_peaks
i_array = [i for mz, i in self.peaks("reprofiled")]
File "C:\intelpython3\lib\site-packages\pymzml\spec.py", line 1057, in peaks
peaks = list(self._peak_dict[peak_type].items())
AttributeError: 'numpy.ndarray' object has no attribute 'items'

Process finished with exit code 1

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 2.4.7

Additional context
I am happy to provide an example file via email. I tried to upload it, but it wouldn't accept files larger than 10 MB.

@MKoesters
Copy link
Contributor

MKoesters commented Jun 19, 2020

Hi,

sorry to hear that this does not work for you.
I tried to reproduce your issue and it worked for most of the spectra I was testing, however I saw that it did not work for spectra with too few peaks.
If you could send me the files via a filesharing website of your choice or via mail to [email protected], this would be helpful for debugging.
Also, can you check the length of your centroided peaks like len(spec.peaks("centroided")) ?

Best,
Manuel

@fu
Copy link
Member

fu commented Jun 22, 2020

Hi Manuel, Michael's data can be found here https://www.dropbox.com/s/1hqn7ij2lvw2zo9/strep.mzML?dl=0. Let me know if you don't find time to look into this :) Cheers, .c

@MKoesters
Copy link
Contributor

Hi,

I think I found the reason and solution for this problem, you can check it out here #244 .
As soon as I checked for possible side effect and maybe added another test file with an appropiate test, I'll merge this fix into the dev branch

Best,
Manuel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants