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

MS^n crashes Reader without precision specified #283

Closed benbowen closed 2 years ago

benbowen commented 2 years ago

I got stumped for a bit yesterday parsing an MS^n file. The first MS3 spectrum did not have a precision and it crashed the Reader. I overcame this by adding a precision attribute like this:

precision_dict = {}
for i in range(100):
    precision_dict[i] = 1e-5

run = pymzml.run.Reader(example_file, MS_precisions=precision_dict)
spectra = list(run)

but I bet there is a generic solution that is cleaner for the community.

You are probably already aware so feel free to disregard.

MKoesters commented 2 years ago

Hi @benbowen,

thanks for reporting this, I did a PR to fix this.

I added a default value of 20e-5 for MS3 precision.

An alternative would be to set MSn_precision when initializing the Run class, this would set the precision of MS2 and MS3 to what you specify.

Best, Manuel