EMSL-Computing / CoreMS

CoreMS is a comprehensive mass spectrometry software framework
BSD 2-Clause "Simplified" License
51 stars 25 forks source link

Fix for a bug causing an index error in mass_spectrum\calc\PeakPicking.py #2

Closed Kzra closed 3 years ago

Kzra commented 3 years ago

Running this code:

from corems.transient.input.brukerSolarix import ReadBrukerSolarix
from corems.encapsulation.factory.parameters import MSParameters
MSParameters.mass_spectrum.threshold_method = 'signal_noise'
MSParameters.mass_spectrum.s2n_threshold = 4
file_path= 'Ezra MS 060532_000005.d srfa iii'
bruker_reader = ReadBrukerSolarix(file_path)
bruker_transient_obj = bruker_reader.get_transient()
mass_spectrum_obj = bruker_transient_obj.get_mass_spectrum(plot_result=False, auto_process=True)

gave the following error: Screenshot 2021-05-13 163859

This was due to the list freq having a different length to mzand abundance in the PeakPicking.py class. I think this problem is due to the mz cut offs not being equally applied to self.freq_exp_profile in the cut_mz_domain_peak_picking(self) function which returns these lists.

I have come up with a possible fix for this by first applying the low mz cut off to self.freq_exp_profile to create a new variable freq_domain_low_Y_cutoff and then applying the high mz cut off. This gets rid of the error when running the above code, but I haven't tested the change in any other way. I'm also not 100 % sure about this, so definitely needs reviewing.

corilo commented 3 years ago

Erza, thanks! I tested and it looks like you solution is working; good catch!