The update is the right answer.
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
2 answers
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())
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.
Log in to answer this question.