def __init__(self, filename, **kwargs):
super(mzDataIterator, self).__init__(filename)<EOL>self.peptides = {}<EOL>self.store = kwargs.get('<STR_LIT:store>', False)<EOL>try:<EOL><INDENT>peps = etree.iterparse(self.filename.name, tag=('<STR_LIT>',))<EOL>for tag, peptideXML in peps:<EOL><INDENT>pepObj = PeptideObject()<EOL>peptide = peptideXML.find('<STR_LIT>').text<EOL>spectrum = peptideXML.find('<STR_LIT>').text<EOL>pepObj.rawId = spectrum<EOL>pepObj.title = spectrum<EOL>pepObj.id = spectrum<EOL>pepObj.peptide = peptide<EOL>additional = peptideXML.find('<STR_LIT>')<EOL>userParams = dict([(j.get('<STR_LIT:name>'),j.get('<STR_LIT:value>')) for j in additional.findall('<STR_LIT>')])<EOL>cvParam = dict([(j.get('<STR_LIT:name>'),j.get('<STR_LIT:value>')) for j in additional.findall('<STR_LIT>')])<EOL>pepObj.charge = cvParam.get('<STR_LIT>', None)<EOL>pepObj.mass = userParams.get('<STR_LIT>')<EOL>modifications = peptideXML.iterfind('<STR_LIT>')<EOL>for modification in modifications:<EOL><INDENT>position = int(modification.find('<STR_LIT>').text)-<NUM_LIT:1><EOL>mod_aa = peptide[position]<EOL>mass = modification.find('<STR_LIT>').text<EOL>additional = modification.find('<STR_LIT>')<EOL>userParams = dict([(j.get('<STR_LIT:name>'),j.get('<STR_LIT:value>')) for j in additional.findall('<STR_LIT>')])<EOL>mod_name = userParams.get('<STR_LIT:Name>')<EOL>pepObj.addModification(mod_aa, position, mod_name, mass)<EOL><DEDENT>self.peptides[spectrum] = pepObj<EOL><DEDENT>self.filename.seek(<NUM_LIT:0>)<EOL>dom1 = etree.iterparse(self.filename.name, tag=('<STR_LIT>',))<EOL>self.lxml = True<EOL><DEDENT>except NameError:<EOL><INDENT>self.lxml = False<EOL>sys.stderr.write('<STR_LIT>')<EOL>return<EOL><DEDENT>if self.lxml:<EOL><INDENT>self.spectra = dom1<EOL>self.scans = {}<EOL>self.ra = {}<EOL><DEDENT>else:<EOL><INDENT>self.nest = <NUM_LIT:0><EOL><DEDENT>self.ptm_regex = re.compile(r'<STR_LIT>')<EOL>self.db = None<EOL>
An iterator over the mzData file format.

        mzData doesn't have random access built in, for now this is more of a reader
        class since we read in all the peptides then match them up while we iterate over
        spectra. This is also clunky and not optimized because I rarely use this format, if ever.

        The returned items are PeptideObjects