Exemple #1
0
    def test_getKeys(self):
        expectedKeySet = set([
            'no compression', 'total ion current', 'filter string', 'scan_id',
            'isolation window upper offset', 'collision-induced dissociation',
            'scan start time', '64-bit float', 'intensity array',
            'isolation window lower offset', 'positive scan', 'peak intensity',
            'no combination', 'centroid spectrum', 'base peak m/z',
            'm/z array', 'ms level', 'selected ion m/z',
            'scan window lower limit', 'highest observed m/z',
            'preset scan configuration', 'base peak intensity', '32-bit float',
            'mass spectrum', '[thermo trailer extra]monoisotopic m/z:',
            'scan window upper limit', 'isolation window target m/z',
            'collision energy', 'lowest observed m/z', 'charge state',
            'activation energy'
        ])

        peaksMzML = parsePeaksMzML.Reader(
            testFolder +
            'peaksMzmlTestfile.peaks.mzML')  # make a Reader instance
        spectra = peaksMzML.getSimpleSpectraInfo()
        actualKeySet = set([])
        for spectrum in spectra:
            for keys in peaksMzML.getKeys():
                actualKeySet.add(keys)

        self.assertSetEqual(expectedKeySet, actualKeySet)
Exemple #2
0
	def test_getPeaks_mzWindow(self):
		peaks = parsePeaksMzML.Reader(testFolder+'peaksMzmlTestfile.peaks.mzML')
		peakLocation = getWindow.PeakLocation(peaks)
		peakList = []
		for peak in peakLocation.getPeaks_mzWindow(350,500):
			peakList.append(peak)
		
		self.assertIs(3, len(peakList))
Exemple #3
0
 def test_getitems(self):
     peaksMzML = parsePeaksMzML.Reader(
         testFolder +
         'peaksMzmlTestfile.peaks.mzML')  # make a Reader instance
     spectra = peaksMzML.getSimpleSpectraInfo()
     for spectrum in spectra:
         for key in peaksMzML.getKeys():
             # if this does not give any errors it means it works.
             peaksMzML[key]
Exemple #4
0
    def test_getAllElements(self):
        expectedElementcount = 253

        peaksMzML = parsePeaksMzML.Reader(
            testFolder +
            'peaksMzmlTestfile.peaks.mzML')  # make a Reader instance
        allElements = peaksMzML.getAllElements()
        actualElementCount = 0
        for element in allElements:
            actualElementCount += 1

        self.assertEqual(expectedElementcount, actualElementCount)
Exemple #5
0
    def test_getSpectra(self):
        expectedMaxId = 52

        peaksMzML = parsePeaksMzML.Reader(
            testFolder +
            'peaksMzmlTestfile.peaks.mzML')  # make a Reader instance
        spectra = peaksMzML.getSimpleSpectraInfo()
        for spectrum in spectra:
            actualMaxId = int(
                peaksMzML['scan_id']
            )  # this will hold the last value of the loop, so the max value

        self.assertEqual(expectedMaxId, actualMaxId)
Exemple #6
0
    def test_Reader(self):
        expectedDict = {
            'no compression': 'no compression',
            'total ion current': '1944280.875',
            '32-bit float': '32-bit float',
            '64-bit float': '64-bit float',
            '[thermo trailer extra]monoisotopic m/z:': '421.760772705078',
            'activation energy': '0',
            'base peak intensity': '204693.875',
            'base peak m/z': '348.990112304688',
            'centroid spectrum': 'centroid spectrum',
            'charge state': '2',
            'collision energy': '35',
            'collision-induced dissociation': 'collision-induced dissociation',
            'filter string': 'FTMS + p NSI Full ms [335.00-1800.00]',
            'highest observed m/z': '1807.22747568909',
            'intensity array': 'intensity array',
            'isolation window lower offset': '1',
            'isolation window target m/z': '421.760772705078',
            'isolation window upper offset': '1',
            'lowest observed m/z': '334.999113612625',
            'm/z array': 'm/z array',
            'mass spectrum': 'mass spectrum',
            'ms level': '1',
            'no combination': 'no combination',
            'no compression': 'no compression',
            'peak intensity': '567.059326171875',
            'positive scan': 'positive scan',
            'preset scan configuration': '1',
            'scan start time': '49.9378',
            'scan window lower limit': '335',
            'scan window upper limit': '1800',
            'scan_id': '52',
            'selected ion m/z': '421.760772705078',
            'total ion current': '1944280.875'
        }
        actualDict = {}
        peaksMzML = parsePeaksMzML.Reader(
            testFolder +
            'peaksMzmlTestfile.peaks.mzML')  # make a Reader instance
        spectra = peaksMzML.getSimpleSpectraInfo(
        )  # get all the spectra of the Reader instance
        for spectrum in spectra:  # loop through all the spectra
            for keys in peaksMzML.getKeys():  # get all the keys
                actualDict[keys] = peaksMzML[keys]

        self.assertDictEqual(expectedDict, actualDict)
Exemple #7
0
	def test_getPeaks_rtWindowException(self):
		peaks = parsePeaksMzML.Reader(testFolder+'peaksMzmlTestfile.peaks.mzML')
		peakLocation = getWindow.PeakLocation(peaks)
		self.assertRaises(TypeError, lambda: peakLocation.getPeaks_rtWindow, 'not an int', 1)
		self.assertRaises(TypeError, lambda: peakLocation.getPeaks_rtWindow , 1, 'not an int')