コード例 #1
0
    def updateErrorCanvas(self):
        """Update error canvas."""

        # make container
        container = mspy.plot.container([])

        # make points object
        self.currentErrors.sort()
        points = mspy.plot.points(self.currentErrors,
                                  pointColour=(0, 255, 0),
                                  showPoints=True,
                                  showLines=False)
        container.append(points)

        # make peaklist object
        if self.currentPeaklist:
            peaks = self.makeCurrentPeaklist()
            peaklist = mspy.plot.spectrum(mspy.scan(peaklist=peaks),
                                          tickColour=(170, 170, 170),
                                          showLabels=False)
            container.append(peaklist)

        # set units
        self.errorCanvas.setProperties(yLabel='error (%s)' %
                                       (config.match['units']))

        # draw container
        self.errorCanvas.draw(container)
コード例 #2
0
 def updateSpectrumCanvas(self, rescale=True):
     """Show current profile and peaks in canvas."""
     
     # clear container
     self.spectrumContainer.empty()
     
     # check document
     if not self.currentDocument:
         self.spectrumCanvas.draw(self.spectrumContainer)
         return
     
     # get current peaklist
     peaklist = self.currentDocument.spectrum.peaklist
     
     # get current profile data
     profile = []
     if self.currentProfile != None:
         profile = self.currentProfile
     
     # add main profile spectrum to container
     labelFont = wx.Font(config.spectrum['labelFontSize'], wx.SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0)
     spectrum = mspy.plot.spectrum(
         scan = mspy.scan(profile=profile, peaklist=peaklist),
         spectrumColour = (16,71,185),
         tickColour = (255,0,0),
         showPoints = config.spectrum['showDataPoints'],
         showLabels = config.spectrum['showLabels'],
         showTicks = True,
         labelDigits = config.main['mzDigits'],
         labelBgr = config.spectrum['labelBgr'],
         labelAngle = config.spectrum['labelAngle'],
         labelFont = labelFont
     )
     self.spectrumContainer.append(spectrum)
     
     # add individual peaks to container
     if config.spectrumGenerator['showPeaks']:
         if self.currentPeaks != None:
             for peak in self.currentPeaks:
                 spectrum = mspy.plot.points(
                     points = peak,
                     lineColour = (50,140,0),
                     showLines = True,
                     showPoints = False,
                     exactFit = True
                 )
                 self.spectrumContainer.append(spectrum)
     
     # get current axis
     if not rescale:
         xAxis = self.spectrumCanvas.getCurrentXRange()
         yAxis = self.spectrumCanvas.getCurrentYRange()
     else:
         xAxis = None
         yAxis = None
     
     # draw spectra
     self.spectrumCanvas.draw(self.spectrumContainer, xAxis=xAxis, yAxis=yAxis)
コード例 #3
0
ファイル: panel_match.py プロジェクト: jojoelfe/mMass_HDX
 def updateErrorCanvas(self):
     """Update error canvas."""
     
     # make container
     container = mspy.plot.container([])
     
     # make points object
     self.currentErrors.sort()
     points = mspy.plot.points(self.currentErrors, pointColour=(0,255,0), showPoints=True, showLines=False)
     container.append(points)
     
     # make peaklist object
     if self.currentPeaklist:
         peaks = self.makeCurrentPeaklist()
         peaklist = mspy.plot.spectrum(mspy.scan(peaklist=peaks), tickColour=(170,170,170), showLabels=False)
         container.append(peaklist)
     
     # set units
     self.errorCanvas.setProperties(yLabel='error (%s)' % (config.match['units']))
     
     # draw container
     self.errorCanvas.draw(container)
コード例 #4
0
ファイル: panel_calibration.py プロジェクト: wwissdorf/mmass
    def updateErrorPlot(self):
        """Update error plot."""

        # make container
        container = mspy.plot.container([])
        minY = 0
        maxY = 1

        # make points
        if self.currentReferences:
            intensities = []

            # get after points
            pointsAfter = []
            for item in self.currentReferences:
                if item[6] and item[5] != None:
                    pointsAfter.append([item[2], item[5]])
                    intensities.append(item[5])
            if pointsAfter:
                pointsAfter.sort()
                obj = mspy.plot.points(pointsAfter,
                                       pointColour=(0, 255, 0),
                                       legend='after',
                                       showLines=False,
                                       showPoints=True)
                container.append(obj)

            # get before points
            pointsBefore = []
            for item in self.currentReferences:
                if item[6] and item[4] != None:
                    pointsBefore.append([item[2], item[4]])
                    intensities.append(item[4])
            if pointsBefore:
                pointsBefore.sort()
                obj = mspy.plot.points(pointsBefore,
                                       pointColour=(255, 100, 100),
                                       legend='before',
                                       showLines=False,
                                       showPoints=True)
                container.append(obj)

            # set range
            if intensities:
                minY = min(intensities)
                maxY = max(intensities)
                if minY == maxY:
                    minY -= minY * 0.1
                    maxY += maxY * 0.1

            # make calibration curve
            if self.currentCalibration and self.currentDocument and self.currentDocument.spectrum.peaklist:
                curvePoints = self.makeCalibrationCurve()
                curvePoints = numpy.array(curvePoints)
                if config.calibration['units'] == 'ppm':
                    obj = mspy.plot.points(curvePoints,
                                           lineColour=(255, 100, 100),
                                           showLines=True,
                                           showPoints=False,
                                           lineStyle=mwx.DASHED_LINE)
                else:
                    obj = mspy.plot.points(curvePoints,
                                           lineColour=(255, 100, 100),
                                           showLines=True,
                                           showPoints=False)
                container.append(obj)

                # set range
                if intensities:
                    minY = min(minY,
                               float(numpy.minimum.reduce(curvePoints)[1]))
                    maxY = max(maxY,
                               float(numpy.maximum.reduce(curvePoints)[1]))
                else:
                    minY = float(numpy.minimum.reduce(curvePoints)[1])
                    maxY = float(numpy.maximum.reduce(curvePoints)[1])

        # make peaklist
        if self.currentDocument and self.currentDocument.spectrum.peaklist:
            peaks = self.makeCurrentPeaklist(minY, maxY)
            obj = mspy.plot.spectrum(mspy.scan(peaklist=peaks),
                                     tickColour=(170, 170, 170),
                                     showLabels=False)
            container.append(obj)

        # set units
        self.errorCanvas.setProperties(yLabel='error (%s)' %
                                       (config.calibration['units']))

        # draw container
        self.errorCanvas.draw(container)
コード例 #5
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)
コード例 #6
0
    def updateErrorPlot(self):
        """Update error plot."""

        # make container
        container = mspy.plot.container([])
        minY = 0
        maxY = 1

        # make points
        if self.currentReferences:
            intensities = []

            # get after points
            pointsAfter = []
            for item in self.currentReferences:
                if item[6] and item[5] != None:
                    pointsAfter.append([item[2], item[5]])
                    intensities.append(item[5])
            if pointsAfter:
                pointsAfter.sort()
                obj = mspy.plot.points(
                    pointsAfter, pointColour=(0, 255, 0), legend="after", showLines=False, showPoints=True
                )
                container.append(obj)

            # get before points
            pointsBefore = []
            for item in self.currentReferences:
                if item[6] and item[4] != None:
                    pointsBefore.append([item[2], item[4]])
                    intensities.append(item[4])
            if pointsBefore:
                pointsBefore.sort()
                obj = mspy.plot.points(
                    pointsBefore, pointColour=(255, 100, 100), legend="before", showLines=False, showPoints=True
                )
                container.append(obj)

            # set range
            if intensities:
                minY = min(intensities)
                maxY = max(intensities)
                if minY == maxY:
                    minY -= minY * 0.1
                    maxY += maxY * 0.1

            # make calibration curve
            if self.currentCalibration and self.currentDocument and self.currentDocument.spectrum.peaklist:
                curvePoints = self.makeCalibrationCurve()
                curvePoints = numpy.array(curvePoints)
                if config.calibration["units"] == "ppm":
                    obj = mspy.plot.points(
                        curvePoints,
                        lineColour=(255, 100, 100),
                        showLines=True,
                        showPoints=False,
                        lineStyle=mwx.DASHED_LINE,
                    )
                else:
                    obj = mspy.plot.points(curvePoints, lineColour=(255, 100, 100), showLines=True, showPoints=False)
                container.append(obj)

                # set range
                if intensities:
                    minY = min(minY, float(numpy.minimum.reduce(curvePoints)[1]))
                    maxY = max(maxY, float(numpy.maximum.reduce(curvePoints)[1]))
                else:
                    minY = float(numpy.minimum.reduce(curvePoints)[1])
                    maxY = float(numpy.maximum.reduce(curvePoints)[1])

        # make peaklist
        if self.currentDocument and self.currentDocument.spectrum.peaklist:
            peaks = self.makeCurrentPeaklist(minY, maxY)
            obj = mspy.plot.spectrum(mspy.scan(peaklist=peaks), tickColour=(170, 170, 170), showLabels=False)
            container.append(obj)

        # set units
        self.errorCanvas.setProperties(yLabel="error (%s)" % (config.calibration["units"]))

        # draw container
        self.errorCanvas.draw(container)
コード例 #7
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)