Issues reading mzxml

74 views
Skip to first unread message

Christopher Leber

unread,
Oct 7, 2017, 10:30:31 AM10/7/17
to pyte...@googlegroups.com
Hello,

I am attempting to access data from an mzXML file and it seems pyteomics should be able to help! However, I am having issues with iterating through the scans in the file, as well as direct indexing.

I can open the file and print a tree:

from pyteomics import mzxml, auxiliary
with mzxml.read('2232.mzXML') as reader:
    auxiliary.print_tree(next(reader))

num
scanType
centroided
msLevel
peaksCount
polarity
retentionTime
basePeakMz
basePeakIntensity
totIonCurrent
msInstrumentID
id
m/z array
intensity array

From here, I am stuck. Cannot figure out, based on the documentation, how to iterate through the data or directly index.

Any assistance would be greatly appreciated!!

Thanks,
Chris


--
Christopher A. Leber
Graduate Student Researcher | Gerwick Laboratory
Center for Marine Biotechnology and Biomedicine
Scripps Institution of Oceanography | UCSD

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Lev Levitsky

unread,
Oct 7, 2017, 10:39:28 AM10/7/17
to pyteomics, cle...@ucsd.edu
Hi Chris,

auxiliary.print_tree simply shows the structure of an arbitrary dict you give it. In this case, next(reader) is the first item read from the file, and what is printed are the keys of this dict.
To see the dict itself, just call print instead of auxiliary.print_tree.

To read the file sequentially, you just iterate over the reader object while processing each spectrum dict the way you need:

with mzxml.read('2232.mzXML') as reader:
    for spectrum in reader:
        # do something with spectrum

Or, if you want to access a specific spectrum, you can directly index the reader object with its id:

with mzxml.read('2232.mzXML') as reader:
    spectrum = reader[spec_id]
    # do something with spectrum

Best regards,
Lev

--

---
You received this message because you are subscribed to the Google Groups "Pyteomics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyteomics+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lev Levitsky
Institute for Energy Problems of Chemical Physics RAS
Laboratory of Physical and Chemical Methods for Structure Analysis
Leninsky pr. 38, bld. 2 119334 Moscow Russia
tel: +7 499 1378257 fax: +7 499 1378257, +7 499 1378258
Reply all
Reply to author
Forward
0 new messages