Search in sources :

Example 6 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class SpectraVisualizerWindow method loadIsotopes.

public void loadIsotopes(IsotopePattern newPattern) {
    // We need to find a normalization factor for the new isotope
    // pattern, to show meaningful intensity range
    double mz = newPattern.getHighestDataPoint().getMZ();
    Range<Double> searchMZRange = Range.closed(mz - 0.5, mz + 0.5);
    ScanDataSet scanDataSet = spectrumPlot.getMainScanDataSet();
    double normalizationFactor = scanDataSet.getHighestIntensity(searchMZRange);
    // whole scan as normalization factor.
    if (normalizationFactor == 0) {
        searchMZRange = Range.atLeast(0.0);
        normalizationFactor = scanDataSet.getHighestIntensity(searchMZRange);
    }
    IsotopePattern normalizedPattern = IsotopePatternCalculator.normalizeIsotopePattern(newPattern, normalizationFactor);
    Color newColor;
    if (newPattern.getStatus() == IsotopePatternStatus.DETECTED)
        newColor = detectedIsotopesColor;
    else
        newColor = predictedIsotopesColor;
    IsotopesDataSet newDataSet = new IsotopesDataSet(normalizedPattern);
    spectrumPlot.addDataSet(newDataSet, newColor, true);
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) Color(java.awt.Color) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern) IsotopesDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.IsotopesDataSet)

Example 7 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class SpectraVisualizerWindow method loadRawData.

public void loadRawData(Scan scan) {
    logger.finest("Loading scan #" + scan.getScanNumber() + " from " + dataFile + " for spectra visualizer");
    spectrumDataSet = new ScanDataSet(scan);
    this.currentScan = scan;
    // If the plot mode has not been set yet, set it accordingly
    if (spectrumPlot.getPlotMode() == null) {
        spectrumPlot.setPlotMode(currentScan.getSpectrumType());
        toolBar.setCentroidButton(currentScan.getSpectrumType());
    }
    // Clean up the MS/MS selector combo
    final JComboBox<String> msmsSelector = bottomPanel.getMSMSSelector();
    // We disable the MSMS selector first and then enable it again later
    // after updating the items. If we skip this, the size of the
    // selector may not be adjusted properly (timing issues?)
    msmsSelector.setEnabled(false);
    msmsSelector.removeAllItems();
    boolean msmsVisible = false;
    // Add parent scan to MS/MS selector combo
    NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat();
    NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
    NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
    // Add all fragment scans to MS/MS selector combo
    int[] fragmentScans = currentScan.getFragmentScanNumbers();
    if (fragmentScans != null) {
        for (int fragment : fragmentScans) {
            Scan fragmentScan = dataFile.getScan(fragment);
            if (fragmentScan == null)
                continue;
            final String itemText = "Fragment scan #" + fragment + ", RT: " + rtFormat.format(fragmentScan.getRetentionTime()) + ", precursor m/z: " + mzFormat.format(fragmentScan.getPrecursorMZ());
            // Updating the combo in other than Swing thread may cause
            // exception
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    msmsSelector.addItem(itemText);
                }
            });
            msmsVisible = true;
        }
    }
    msmsSelector.setEnabled(true);
    // Update the visibility of MS/MS selection combo
    bottomPanel.setMSMSSelectorVisible(msmsVisible);
    // Set window and plot titles
    String windowTitle = "Spectrum: [" + dataFile.getName() + "; scan #" + currentScan.getScanNumber() + "]";
    String spectrumTitle = ScanUtils.scanToString(currentScan, true);
    DataPoint basePeak = currentScan.getHighestDataPoint();
    if (basePeak != null) {
        spectrumTitle += ", base peak: " + mzFormat.format(basePeak.getMZ()) + " m/z (" + intensityFormat.format(basePeak.getIntensity()) + ")";
    }
    String spectrumSubtitle = null;
    if (!Strings.isNullOrEmpty(currentScan.getScanDefinition())) {
        spectrumSubtitle = "Scan definition: " + currentScan.getScanDefinition();
    }
    setTitle(windowTitle);
    spectrumPlot.setTitle(spectrumTitle, spectrumSubtitle);
    // Set plot data set
    spectrumPlot.removeAllDataSets();
    spectrumPlot.addDataSet(spectrumDataSet, scanColor, false);
    // Reload feature list
    bottomPanel.rebuildPeakListSelector();
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) DataPoint(net.sf.mzmine.datamodel.DataPoint) Scan(net.sf.mzmine.datamodel.Scan) DataPoint(net.sf.mzmine.datamodel.DataPoint) NumberFormat(java.text.NumberFormat)

Example 8 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class SpectraPlot method addDataSet.

public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency) {
    XYItemRenderer newRenderer;
    if (dataSet instanceof ScanDataSet) {
        ScanDataSet scanDataSet = (ScanDataSet) dataSet;
        Scan scan = scanDataSet.getScan();
        if (scan.getSpectrumType() == MassSpectrumType.CENTROIDED)
            newRenderer = new PeakRenderer(color, transparency);
        else {
            newRenderer = new ContinuousRenderer(color, transparency);
            ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
        }
        // Add label generator for the dataset
        SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this);
        newRenderer.setDefaultItemLabelGenerator(labelGenerator);
        newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
        newRenderer.setDefaultItemLabelPaint(labelsColor);
    } else {
        newRenderer = new PeakRenderer(color, transparency);
    }
    plot.setDataset(numOfDataSets, dataSet);
    plot.setRenderer(numOfDataSets, newRenderer);
    numOfDataSets++;
    if (dataSet instanceof ScanDataSet)
        checkAndRunController();
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) ContinuousRenderer(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.ContinuousRenderer) SpectraItemLabelGenerator(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.SpectraItemLabelGenerator) Scan(net.sf.mzmine.datamodel.Scan) PeakRenderer(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.PeakRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer)

Example 9 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class SpectraPlot method checkAndRunController.

/**
 * Checks if the spectra processing is enabled & allowed and executes the controller if it is.
 * Processing is forbidden for instances of ParameterSetupDialogWithScanPreviews
 */
public void checkAndRunController() {
    // if controller != null, processing on the current spectra has already been executed. When
    // loading a new spectrum, the controller is set to null in removeAllDataSets()
    DataPointProcessingManager inst = DataPointProcessingManager.getInst();
    if (!isProcessingAllowed() || !inst.isEnabled())
        return;
    if (controller != null)
        controller = null;
    // if a controller is re-run then delete previous results
    removeDataPointProcessingResultDataSets();
    // if enabled, do the data point processing as set up by the user
    XYDataset dataSet = getMainScanDataSet();
    if (dataSet instanceof ScanDataSet) {
        Scan scan = ((ScanDataSet) dataSet).getScan();
        MSLevel mslevel = inst.decideMSLevel(scan);
        controller = new DataPointProcessingController(inst.getProcessingQueue(mslevel), this, getMainScanDataSet().getDataPoints());
        inst.addController(controller);
    }
}
Also used : DataPointProcessingManager(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager) ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) DataPointProcessingController(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingController) XYDataset(org.jfree.data.xy.XYDataset) Scan(net.sf.mzmine.datamodel.Scan) MSLevel(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.MSLevel)

Example 10 with ScanDataSet

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.

the class MassDetectorSetupDialog method loadPreview.

protected void loadPreview(SpectraPlot spectrumPlot, Scan previewScan) {
    ScanDataSet spectraDataSet = new ScanDataSet(previewScan);
    // Set plot mode only if it hasn't been set before
    // if the scan is centroided, switch to centroid mode
    spectrumPlot.setPlotMode(previewScan.getSpectrumType());
    spectrumPlot.removeAllDataSets();
    spectrumPlot.addDataSet(spectraDataSet, SpectraVisualizerWindow.scanColor, false);
    // If there is some illegal value, do not load the preview but just exit
    ArrayList<String> errorMessages = new ArrayList<String>();
    boolean paramsOK = parameterSet.checkParameterValues(errorMessages);
    if (!paramsOK)
        return;
    DataPoint[] mzValues = massDetector.getMassValues(previewScan, parameters);
    DataPointsDataSet peaksDataSet = new DataPointsDataSet("Detected peaks", mzValues);
    spectrumPlot.addDataSet(peaksDataSet, SpectraVisualizerWindow.peaksColor, false);
}
Also used : ScanDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet) DataPoint(net.sf.mzmine.datamodel.DataPoint) ArrayList(java.util.ArrayList) DataPointsDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet)

Aggregations

ScanDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet)10 Scan (net.sf.mzmine.datamodel.Scan)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)4 ContinuousRenderer (net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.ContinuousRenderer)3 PeakRenderer (net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.PeakRenderer)3 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)3 ArrayList (java.util.ArrayList)2 DataPointsDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet)2 SpectraItemLabelGenerator (net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.SpectraItemLabelGenerator)2 XYDataset (org.jfree.data.xy.XYDataset)2 Color (java.awt.Color)1 NumberFormat (java.text.NumberFormat)1 Vector (java.util.Vector)1 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1 MassList (net.sf.mzmine.datamodel.MassList)1 DataPointProcessingController (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingController)1 DataPointProcessingManager (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager)1 MSLevel (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.MSLevel)1 ProcessedDataPoint (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.ProcessedDataPoint)1 IsotopesDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.IsotopesDataSet)1