pymzml / pymzML

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

Issue using "TIC" with data set #300

Open backertix opened 2 years ago

backertix commented 2 years ago

Trying to access and plot my total ion chromatogram is not working. It does not seem to recognise it for my data. I exported my data from mzmine 3, and there definitely should be a TIC present. Has anyone had a similar issue? How do I access my chromatogram?

Issue using JupyterLab on Ubuntu 20.04.4.

My CODE: mzml_basename = os.path.basename("22Jun0804.mzML") pf = Factory() pf.new_plot() pf.add(run["TIC"].peaks(), color=(0, 0, 0), style="lines", title=mzmlbasename) pf.save( "chromatogram{0}.html".format(mzml_basename), layout={"xaxis": {"title": "Retention time"}, "yaxis": {"title": "TIC"}}, )

ERROR OUTPUT:

StopIteration Traceback (most recent call last) Input In [24], in <cell line: 4>() 2 pf = Factory() 3 pf.new_plot() ----> 4 pf.add(run["TIC"].peaks(), color=(0, 0, 0), style="lines", title=mzmlbasename) 5 pf.save( 6 "chromatogram{0}.html".format(mzml_basename), 7 layout={"xaxis": {"title": "Retention time"}, "yaxis": {"title": "TIC"}}, 8 )

File ~/anaconda3/lib/python3.9/site-packages/pymzml/run.py:198, in Reader.getitem(self, identifier) 196 except: 197 pass --> 198 spectrum = self.info["file_object"][identifier] 199 spectrum.calling_instance = self 200 if isinstance(spectrum, spec.Spectrum):

File ~/anaconda3/lib/python3.9/site-packages/pymzml/file_interface.py:101, in FileInterface.getitem(self, identifier) 90 """ 91 Access the item with id 'identifier' in the file. 92 (...) 97 data (str): text associated with the given identifier 98 """ 99 # if type(self.offset_dict) == dict: 100 # self.offset_dict.update(self.file_handler.offset_dict) --> 101 return self.file_handler[identifier]

File ~/anaconda3/lib/python3.9/site-packages/pymzml/file_classes/standardMzml.py:103, in StandardMzml.getitem(self, identifier) 99 spectrum = spec.Chromatogram( 100 element, measured_precision=5e-6 101 ) 102 elif event == "STOP": --> 103 raise StopIteration 105 elif identifier in self.offset_dict: 107 start = self.offset_dict[identifier]

StopIteration:

MKoesters commented 2 years ago

Hi @backertix ,

Could you check if 'TIC' is present in run.info['offset_dict']? If yes I'd need the file or the Chromatogram element from your file to debug this. If its not, maybe the TIC has another name which you would find in run.info['offset_dict']

Best, Manuel

backertix commented 2 years ago

Hi Manuel,

thank you for your response! I tried this, and got the following:

{'TIC': None, 1: (3744236,)}

I am not too sure how to interpret this, I would assume the TIC is under a different name in this case? There should definitely be a chromatogram present, as I can access it using MZmine3.

Thank you!

MKoesters commented 2 years ago

Hi @backertix,

Could you upload a sample of the mzML file? Just the chromatogram element would probably be enough, you can also remove the binary data if necessary. I'll have a look as soon as possible, however i'm on vacation for the next few week, so I guess it will take some time to get this working, sorry!

Best, Manuel