Ejemplo n.º 1
0
    def runSpectrumGenerator(self):
        """Generate spectrum."""

        self.currentProfile = None
        self.currentPeaks = None

        # run task
        try:

            # make profile spectrum
            self.currentProfile = mspy.profile(
                peaklist=self.currentDocument.spectrum.peaklist,
                fwhm=config.spectrumGenerator["fwhm"],
                points=config.spectrumGenerator["points"],
                noise=config.spectrumGenerator["noise"],
                forceFwhm=config.spectrumGenerator["forceFwhm"],
                model=config.spectrumGenerator["peakShape"],
            )

            # make peak spectra
            self.currentPeaks = []
            for peak in self.currentDocument.spectrum.peaklist:

                # get fwhm
                fwhm = config.spectrumGenerator["fwhm"]
                if peak.fwhm and not config.spectrumGenerator["forceFwhm"]:
                    fwhm = peak.fwhm

                # gaussian shape
                if config.spectrumGenerator["peakShape"] == "gaussian":
                    points = mspy.gaussian(
                        x=peak.mz, minY=peak.base, maxY=peak.ai, fwhm=fwhm
                    )

                # lorentzian shape
                elif config.spectrumGenerator["peakShape"] == "lorentzian":
                    points = mspy.lorentzian(
                        x=peak.mz, minY=peak.base, maxY=peak.ai, fwhm=fwhm
                    )

                # gauss-lorentzian shape
                elif config.spectrumGenerator["peakShape"] == "gausslorentzian":
                    points = mspy.gausslorentzian(
                        x=peak.mz, minY=peak.base, maxY=peak.ai, fwhm=fwhm
                    )

                self.currentPeaks.append(points)

        # task canceled
        except mspy.ForceQuit:
            self.currentProfile = None
            self.currentPeaks = None
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def runSpectrumGenerator(self):
     """Generate spectrum."""
     
     self.currentProfile = None
     self.currentPeaks = None
     
     # run task
     try:
         
         # make profile spectrum
         self.currentProfile = mspy.profile(
             peaklist = self.currentDocument.spectrum.peaklist,
             fwhm = config.spectrumGenerator['fwhm'],
             points = config.spectrumGenerator['points'],
             noise = config.spectrumGenerator['noise'],
             forceFwhm = config.spectrumGenerator['forceFwhm'],
             model = config.spectrumGenerator['peakShape'],
         )
         
         # make peak spectra
         self.currentPeaks = []
         for peak in self.currentDocument.spectrum.peaklist:
             
             # get fwhm
             fwhm = config.spectrumGenerator['fwhm']
             if peak.fwhm and not config.spectrumGenerator['forceFwhm']:
                 fwhm = peak.fwhm
             
             # gaussian shape
             if config.spectrumGenerator['peakShape'] == 'gaussian':
                 points = mspy.gaussian(
                     x = peak.mz,
                     minY = peak.base,
                     maxY = peak.ai,
                     fwhm = fwhm
                 )
             
             # lorentzian shape
             elif config.spectrumGenerator['peakShape'] == 'lorentzian':
                 points = mspy.lorentzian(
                     x = peak.mz,
                     minY = peak.base,
                     maxY = peak.ai,
                     fwhm = fwhm
                 )
             
             # gauss-lorentzian shape
             elif config.spectrumGenerator['peakShape'] == 'gausslorentzian':
                 points = mspy.gausslorentzian(
                     x = peak.mz,
                     minY = peak.base,
                     maxY = peak.ai,
                     fwhm = fwhm
                 )
             
             self.currentPeaks.append(points)
     
     # task canceled
     except mspy.ForceQuit:
         self.currentProfile = None
         self.currentPeaks = None