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

How to retrieve 'inverse reduced ion mobility' info? #343

Open patrick-willems opened 8 months ago

patrick-willems commented 8 months ago

Best,

I just started to use pymzml to retrieve spectral info, I find it a great tool!

I only do not manage to easily extract ion mobility from the data, for me this is for instance present as follows in the mzML file:

      <scanList count="1">
        <scan>
          <cvParam cvRef="MS" accession="MS:1000016" name="scan start time" value="0.01271000038832426" unitCvRef="UO" unitAccession="UO:0000031" unitName="minute"/>
          <cvParam cvRef="MS" accession="MS:1002815" name="inverse reduced ion mobility" value="1.0686218738555908"/>

How can I extract this when looping over the spectra (i.e. 'for index, spectrum in enumerate(data):' ) ?

Many thanks in advance, Patrick

MKoesters commented 8 months ago

Hi Patrick,

Can you try something like this:

for index, spectrum in enumerate(data):
    im = spectrum['inverse reduced ion mobility']

You could also have a look if the get_tims_tof_ion_mobility or get_array method of the spectrum class would be helpfull, for this you would need the IM array in the spectrum, I think you can achieve this while converting to mzML.

Best, Manu

StSchulze commented 8 months ago

Just as a quick addition: There were some issues with using the GO terms, so if 'inverse reduced ion motility' is not recognized, you might want to try using the accession number, i.e. spectrum['MS:1002815'] to access that information.

patrick-willems commented 8 months ago

Thanks!