Esempio n. 1
0
 def makeCurrentPeaklist(self):
     """Convert peaklist for current error range."""
     
     # get error range
     minY = 0
     maxY = 1
     if self.currentErrors:
         errors = [x[1] for x in self.currentErrors]
         minY = min(errors)
         maxY = max(errors)
         if minY == maxY:
             minY -= abs(minY*0.1)
             maxY += abs(maxY*0.1)
         minY -= 0.05 * abs(maxY - minY)
     
     # convert peaklist
     peaklist = []
     basePeak = self.currentPeaklist.basepeak
     f = abs(maxY - minY) / basePeak.intensity
     for peak in self.currentPeaklist:
         intensity = (peak.intensity * f) + minY
         peaklist.append(mspy.peak(mz=peak.mz, ai=intensity, base=minY))
     
     # convert to mspy.peaklist
     return mspy.peaklist(peaklist)
Esempio n. 2
0
    def makeCurrentPeaklist(self):
        """Convert peaklist for current error range."""

        # get error range
        minY = 0
        maxY = 1
        if self.currentErrors:
            errors = [x[1] for x in self.currentErrors]
            minY = min(errors)
            maxY = max(errors)
            if minY == maxY:
                minY -= abs(minY * 0.1)
                maxY += abs(maxY * 0.1)
            minY -= 0.05 * abs(maxY - minY)

        # convert peaklist
        peaklist = []
        basePeak = self.currentPeaklist.basepeak
        f = abs(maxY - minY) / basePeak.intensity
        for peak in self.currentPeaklist:
            intensity = (peak.intensity * f) + minY
            peaklist.append(mspy.peak(mz=peak.mz, ai=intensity, base=minY))

        # convert to mspy.peaklist
        return mspy.peaklist(peaklist)
Esempio n. 3
0
 def getPeakEditorData(self):
     """Get data of edited peak."""
     
     try:
         # get data
         mz = self.peakMz_value.GetValue()
         ai = self.peakAi_value.GetValue()
         base = self.peakBase_value.GetValue()
         sn = self.peakSN_value.GetValue()
         charge = self.peakCharge_value.GetValue()
         fwhm = self.peakFwhm_value.GetValue()
         group = self.peakGroup_value.GetValue()
         monoisotope = self.peakMonoisotopic_check.GetValue()
         
         # format data
         mz = float(mz)
         ai = float(ai)
         
         if ai == 0:
             raise ValueError
         
         if base:
             base = float(base)
         else:
             base = 0.
         
         if sn:
             sn = float(sn)
         else:
             sn = None
         
         if charge:
             charge = int(charge)
         else:
             charge = None
         
         if fwhm:
             fwhm = float(fwhm)
         else:
             fwhm = None
         
         if not group:
             group = ''
         
         if monoisotope:
             isotope = 0
         else:
             isotope = None
         
         # make peak
         peak = mspy.peak(mz=mz, ai=ai, base=base, sn=sn, charge=charge, isotope=isotope, fwhm=fwhm, group=group)
         return peak
     
     except:
         wx.Bell()
         return False
Esempio n. 4
0
    def makeCurrentPeaklist(self, minY, maxY):
        """Convert peaklist for current error range."""

        # shift peaklist
        if (minY, maxY) != (0, 1):
            minY -= 0.05 * abs(maxY - minY)

        # convert peaklist
        peaklist = []
        basePeak = self.currentDocument.spectrum.peaklist.basepeak
        f = abs(maxY - minY) / basePeak.intensity
        for peak in self.currentDocument.spectrum.peaklist:
            intensity = (peak.intensity * f) + minY
            peaklist.append(mspy.peak(mz=peak.mz, ai=intensity, base=minY))

        # convert to mspy.peaklist
        return mspy.peaklist(peaklist)
Esempio n. 5
0
    def makeCurrentPeaklist(self, minY, maxY):
        """Convert peaklist for current error range."""

        # shift peaklist
        if (minY, maxY) != (0, 1):
            minY -= 0.05 * abs(maxY - minY)

        # convert peaklist
        peaklist = []
        basePeak = self.currentDocument.spectrum.peaklist.basepeak
        f = abs(maxY - minY) / basePeak.intensity
        for peak in self.currentDocument.spectrum.peaklist:
            intensity = (peak.intensity * f) + minY
            peaklist.append(mspy.peak(mz=peak.mz, ai=intensity, base=minY))

        # convert to mspy.peaklist
        return mspy.peaklist(peaklist)
Esempio n. 6
0
    def makeProfile(self):
        """Generate pattern profile."""

        self.currentPatternProfile = None
        self.currentPatternPeaks = None
        self.currentPatternScan = None

        # check pattern
        if self.currentPattern == None:
            return

        # get selected charge
        charge = 0
        if self.currentIon != None:
            charge = self.currentIon[3]

        # make profile
        self.currentPatternProfile = mspy.profile(
            peaklist=self.currentPattern,
            fwhm=config.massCalculator['patternFwhm'],
            points=20,
            model=config.massCalculator['patternPeakShape'],
        )

        # get scale and shift for specified intensity and baseline
        basepeak = mspy.basepeak(self.currentPatternProfile)
        scale = (config.massCalculator['patternIntensity'] -
                 config.massCalculator['patternBaseline']
                 ) / self.currentPatternProfile[basepeak][1]
        shift = config.massCalculator['patternBaseline']

        # rescale profile
        self.currentPatternProfile = mspy.multiply(self.currentPatternProfile,
                                                   y=scale)
        self.currentPatternProfile = mspy.offset(self.currentPatternProfile,
                                                 y=shift)

        # make real peaklist from profile
        peaklist = []
        for isotope in mspy.maxima(self.currentPatternProfile):
            mz = isotope[0]
            centroid = mspy.centroid(self.currentPatternProfile, isotope[0],
                                     isotope[1] * 0.99)
            if abs(mz - centroid) < config.massCalculator['patternFwhm'] / 20:
                mz = centroid
            peak = mspy.peak(mz=mz, ai=isotope[1], base=shift, charge=charge)
            peaklist.append(peak)
        peaklist = mspy.peaklist(peaklist)

        # make individual peak shapes
        self.currentPatternPeaks = []
        if config.massCalculator['patternShowPeaks']:

            # gaussian shape
            if config.massCalculator['patternPeakShape'] == 'gaussian':
                for isotope in self.currentPattern:
                    peak = mspy.gaussian(
                        x=isotope[0],
                        minY=shift,
                        maxY=isotope[1] * scale + shift,
                        fwhm=config.massCalculator['patternFwhm'])
                    self.currentPatternPeaks.append(peak)

            # lorentzian shape
            elif config.massCalculator['patternPeakShape'] == 'lorentzian':
                for isotope in self.currentPattern:
                    peak = mspy.lorentzian(
                        x=isotope[0],
                        minY=shift,
                        maxY=isotope[1] * scale + shift,
                        fwhm=config.massCalculator['patternFwhm'])
                    self.currentPatternPeaks.append(peak)

            # gauss-lorentzian shape
            elif config.massCalculator[
                    'patternPeakShape'] == 'gausslorentzian':
                for isotope in self.currentPattern:
                    peak = mspy.gausslorentzian(
                        x=isotope[0],
                        minY=shift,
                        maxY=isotope[1] * scale + shift,
                        fwhm=config.massCalculator['patternFwhm'])
                    self.currentPatternPeaks.append(peak)

        # make scan object
        self.currentPatternScan = mspy.scan(profile=self.currentPatternProfile,
                                            peaklist=peaklist)
 def makeProfile(self):
     """Generate pattern profile."""
     
     self.currentPatternProfile = None
     self.currentPatternPeaks = None
     self.currentPatternScan = None
     
     # check pattern
     if self.currentPattern == None:
         return
     
     # get selected charge
     charge = 0
     if self.currentIon != None:
         charge = self.currentIon[3]
     
     # make profile
     self.currentPatternProfile = mspy.profile(
         peaklist = self.currentPattern,
         fwhm = config.massCalculator['patternFwhm'],
         points = 20,
         model = config.massCalculator['patternPeakShape'],
     )
     
     # get scale and shift for specified intensity and baseline
     basepeak = mspy.basepeak(self.currentPatternProfile)
     scale = (config.massCalculator['patternIntensity'] - config.massCalculator['patternBaseline']) / self.currentPatternProfile[basepeak][1]
     shift = config.massCalculator['patternBaseline']
     
     # rescale profile
     self.currentPatternProfile = mspy.multiply(self.currentPatternProfile, y=scale)
     self.currentPatternProfile = mspy.offset(self.currentPatternProfile, y=shift)
     
     # make real peaklist from profile
     peaklist = []
     for isotope in mspy.maxima(self.currentPatternProfile):
         mz = isotope[0]
         centroid = mspy.centroid(self.currentPatternProfile, isotope[0], isotope[1]*0.99)
         if abs(mz-centroid) < config.massCalculator['patternFwhm']/20:
             mz = centroid
         peak = mspy.peak(
             mz = mz,
             ai = isotope[1],
             base = shift,
             charge = charge
         )
         peaklist.append(peak)
     peaklist = mspy.peaklist(peaklist)
     
     # make individual peak shapes
     self.currentPatternPeaks = []
     if config.massCalculator['patternShowPeaks']:
         
         # gaussian shape
         if config.massCalculator['patternPeakShape'] == 'gaussian':
             for isotope in self.currentPattern:
                 peak = mspy.gaussian(
                     x = isotope[0],
                     minY = shift,
                     maxY = isotope[1]*scale+shift,
                     fwhm = config.massCalculator['patternFwhm']
                 )
                 self.currentPatternPeaks.append(peak)
         
         # lorentzian shape
         elif config.massCalculator['patternPeakShape'] == 'lorentzian':
             for isotope in self.currentPattern:
                 peak = mspy.lorentzian(
                     x = isotope[0],
                     minY = shift,
                     maxY = isotope[1]*scale+shift,
                     fwhm = config.massCalculator['patternFwhm']
                 )
                 self.currentPatternPeaks.append(peak)
         
         # gauss-lorentzian shape
         elif config.massCalculator['patternPeakShape'] == 'gausslorentzian':
             for isotope in self.currentPattern:
                 peak = mspy.gausslorentzian(
                     x = isotope[0],
                     minY = shift,
                     maxY = isotope[1]*scale+shift,
                     fwhm = config.massCalculator['patternFwhm']
                 )
                 self.currentPatternPeaks.append(peak)
     
     # make scan object
     self.currentPatternScan = mspy.scan(profile=self.currentPatternProfile, peaklist=peaklist)