How Can I Get The Retention Time Of An Ms/Ms Precursor Out Of A Mzml File Using Pymzml?
2
3
Entering edit mode
12.8 years ago
Niek De Klein ★ 2.6k

I need to know the positions of the MS/MS precursors found in a mzML file, using pymzml as a parser. Looking at the precursors with this code:

import pymzml
file = '/homes/ndeklein/EP-B1.mzML'
msrun = pymzml.run.Reader(file)
for spectrum in msrun:
    if spectrum['ms level'] == 2:
        print spectrum["precursors"].keys()
        sys.exit()

only gives 'charge' and 'mz' as keys. Looking at the spectra:

file = '/homes/ndeklein/EP-B1.mzML'
msrun = pymzml.run.Reader(file)
for spectrum in msrun:
    if spectrum['ms level'] == 2:
        print spectrum.keys()
        sys.exit()

gives the following keys:

'no compression', 'total ion current', 'scan time', 'filter string', 'PY:0000000', 'precursors', 'MS:1000041', 'id', 'MS:1000285', 'MS:1000512', 'MS:1000511', 'MS:1000576', 'collision-induced dissociation', 'MS:1000744', 'MS:1000514', '64-bit float', 'defaultArrayLength', 'MS:1000127', 'm/z array', 'MS:1000515', 'centroid mass spectrum', 'None', 'ms level', 'intensity array', 'BinaryArrayOrder', '32-bit float', 'MS:1000016', 'encodedData', 'MS:1000523', 'MS:1000521', 'MS:1000133', 'charge state'

At none of these can I find the retention time. Where can I get this from?

Thanks, Niek

python • 4.6k views
ADD COMMENT
3
Entering edit mode
12.8 years ago
fufezan ▴ 40

if you don't know the MS tags you can use queryOBO.py within the example scripts of pymzML or iter over the original xml tree of the spectrum if the conversion was done using an older obo version. Iter example taken from the pymzML web site

example_file = get_example_file.open_example('small.pwiz.1.1.mzML')
run = pymzml.run.Reader(example_file, MSn_Precision = 250e-6)
spectrum = run[1]

for element in spectrum.xmlTree:
    print('-'*40)
    print(element)
    print(element.get('accession'))
    print(element.tag)
    print(element.items())
ADD COMMENT
2
Entering edit mode
12.8 years ago
Laurent ★ 1.7k

Could it be MS:1000016, which is PSI's term for The time that an analyzer started a scan, relative to the start of the MS? May be you could print out the values, to see if they would make sense.

Note that there is also

MS:1001114                            retention time(s)
MS:1000894                               retention time

which seem however more appropriate for retention time.

UPDATE: after checking some mzML files (see also this answer), MS:1000016 is what you are looking for.

ADD COMMENT
0
Entering edit mode

The update is the right answer.

ADD REPLY

Login before adding your answer.

Traffic: 2441 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6