Search in sources :

Example 1 with DataPointProcessingManager

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager 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 2 with DataPointProcessingManager

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager in project mzmine2 by mzmine.

the class SpectraVisualizerWindow method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals("PEAKLIST_CHANGE")) {
        // If no scan is loaded yet, ignore
        if (currentScan == null)
            return;
        PeakList selectedPeakList = bottomPanel.getSelectedPeakList();
        loadPeaks(selectedPeakList);
    }
    if (command.equals("PREVIOUS_SCAN")) {
        if (dataFile == null)
            return;
        int msLevel = currentScan.getMSLevel();
        int[] scanNumbers = dataFile.getScanNumbers(msLevel);
        int scanIndex = Arrays.binarySearch(scanNumbers, currentScan.getScanNumber());
        if (scanIndex > 0) {
            final int prevScanIndex = scanNumbers[scanIndex - 1];
            Runnable newThreadRunnable = new Runnable() {

                @Override
                public void run() {
                    loadRawData(dataFile.getScan(prevScanIndex));
                }
            };
            Thread newThread = new Thread(newThreadRunnable);
            newThread.start();
        }
    }
    if (command.equals("NEXT_SCAN")) {
        if (dataFile == null)
            return;
        int msLevel = currentScan.getMSLevel();
        int[] scanNumbers = dataFile.getScanNumbers(msLevel);
        int scanIndex = Arrays.binarySearch(scanNumbers, currentScan.getScanNumber());
        if (scanIndex < (scanNumbers.length - 1)) {
            final int nextScanIndex = scanNumbers[scanIndex + 1];
            Runnable newThreadRunnable = new Runnable() {

                @Override
                public void run() {
                    loadRawData(dataFile.getScan(nextScanIndex));
                }
            };
            Thread newThread = new Thread(newThreadRunnable);
            newThread.start();
        }
    }
    if (command.equals("SHOW_MSMS")) {
        String selectedScanString = (String) bottomPanel.getMSMSSelector().getSelectedItem();
        if (selectedScanString == null)
            return;
        int sharpIndex = selectedScanString.indexOf('#');
        int commaIndex = selectedScanString.indexOf(',');
        selectedScanString = selectedScanString.substring(sharpIndex + 1, commaIndex);
        int selectedScan = Integer.valueOf(selectedScanString);
        SpectraVisualizerModule.showNewSpectrumWindow(dataFile, selectedScan);
    }
    if (command.equals("TOGGLE_PLOT_MODE")) {
        if (spectrumPlot.getPlotMode() == MassSpectrumType.CENTROIDED) {
            spectrumPlot.setPlotMode(MassSpectrumType.PROFILE);
            toolBar.setCentroidButton(MassSpectrumType.PROFILE);
        } else {
            spectrumPlot.setPlotMode(MassSpectrumType.CENTROIDED);
            toolBar.setCentroidButton(MassSpectrumType.CENTROIDED);
        }
    }
    if (command.equals("SHOW_DATA_POINTS")) {
        spectrumPlot.switchDataPointsVisible();
    }
    if (command.equals("SHOW_ANNOTATIONS")) {
        spectrumPlot.switchItemLabelsVisible();
    }
    if (command.equals("SHOW_PICKED_PEAKS")) {
        spectrumPlot.switchPickedPeaksVisible();
    }
    if (command.equals("SHOW_ISOTOPE_PEAKS")) {
        spectrumPlot.switchIsotopePeaksVisible();
    }
    if (command.equals("SETUP_AXES")) {
        AxesSetupDialog dialog = new AxesSetupDialog(this, spectrumPlot.getXYPlot());
        dialog.setVisible(true);
    }
    // library entry creation
    if (command.equals("CREATE_LIBRARY_ENTRY")) {
        // open window with all selected rows
        MSMSLibrarySubmissionWindow libraryWindow = new MSMSLibrarySubmissionWindow();
        libraryWindow.setData(currentScan);
        libraryWindow.setVisible(true);
    }
    if (command.equals("EXPORT_SPECTRA")) {
        ExportScansModule.showSetupDialog(currentScan);
    }
    if (command.equals("ADD_ISOTOPE_PATTERN")) {
        IsotopePattern newPattern = IsotopePatternCalculator.showIsotopePredictionDialog(this, true);
        if (newPattern == null)
            return;
        loadIsotopes(newPattern);
    }
    if ((command.equals("ZOOM_IN")) || (command.equals("ZOOM_IN_BOTH_COMMAND"))) {
        spectrumPlot.getXYPlot().getDomainAxis().resizeRange(1 / zoomCoefficient);
    }
    if ((command.equals("ZOOM_OUT")) || (command.equals("ZOOM_OUT_BOTH_COMMAND"))) {
        spectrumPlot.getXYPlot().getDomainAxis().resizeRange(zoomCoefficient);
    }
    if (command.equals("SET_SAME_RANGE")) {
        // Get current axes range
        NumberAxis xAxis = (NumberAxis) spectrumPlot.getXYPlot().getDomainAxis();
        NumberAxis yAxis = (NumberAxis) spectrumPlot.getXYPlot().getRangeAxis();
        double xMin = xAxis.getRange().getLowerBound();
        double xMax = xAxis.getRange().getUpperBound();
        double xTick = xAxis.getTickUnit().getSize();
        double yMin = yAxis.getRange().getLowerBound();
        double yMax = yAxis.getRange().getUpperBound();
        double yTick = yAxis.getTickUnit().getSize();
        // Get all frames of my class
        Window[] spectraFrames = JFrame.getWindows();
        // Set the range of these frames
        for (Window frame : spectraFrames) {
            if (!(frame instanceof SpectraVisualizerWindow))
                continue;
            SpectraVisualizerWindow spectraFrame = (SpectraVisualizerWindow) frame;
            spectraFrame.setAxesRange(xMin, xMax, xTick, yMin, yMax, yTick);
        }
    }
    if (command.equals("ONLINEDATABASESEARCH")) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                OnlineDBSpectraSearchModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
            }
        });
    }
    if (command.equals("CUSTOMDATABASESEARCH")) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                CustomDBSpectraSearchModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
            }
        });
    }
    if (command.equals("LIPIDSEARCH")) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                LipidSpectraSearchModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
            }
        });
    }
    if (command.equals("SUMFORMULA")) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                SumFormulaSpectraSearchModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
            }
        });
    }
    if (command.equals("SPECTRALDATABASESEARCH")) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                SpectraIdentificationSpectralDatabaseModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
            }
        });
    }
    if (command.equals("SET_PROCESSING_PARAMETERS")) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                if (!dppmWindowOpen) {
                    dppmWindowOpen = true;
                    ExitCode exitCode = DataPointProcessingManager.getInst().getParameters().showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
                    dppmWindowOpen = false;
                    if (exitCode == ExitCode.OK && DataPointProcessingManager.getInst().isEnabled()) {
                        // if processing was run before, this removes the previous results.
                        getSpectrumPlot().removeDataPointProcessingResultDataSets();
                        getSpectrumPlot().checkAndRunController();
                    }
                }
            }
        });
    }
    if (command.equals("ENABLE_PROCESSING")) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                DataPointProcessingManager inst = DataPointProcessingManager.getInst();
                inst.setEnabled(!inst.isEnabled());
                bottomPanel.updateProcessingButton();
                getSpectrumPlot().checkAndRunController();
                // if the tick is removed, set the data back to default
                if (!inst.isEnabled()) {
                    getSpectrumPlot().removeDataPointProcessingResultDataSets();
                // loadRawData(currentScan);
                }
            }
        });
    }
}
Also used : MSMSLibrarySubmissionWindow(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.view.MSMSLibrarySubmissionWindow) Window(java.awt.Window) NumberAxis(org.jfree.chart.axis.NumberAxis) MSMSLibrarySubmissionWindow(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.view.MSMSLibrarySubmissionWindow) ExitCode(net.sf.mzmine.util.ExitCode) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern) DataPoint(net.sf.mzmine.datamodel.DataPoint) AxesSetupDialog(net.sf.mzmine.util.dialogs.AxesSetupDialog) DataPointProcessingManager(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager) PeakList(net.sf.mzmine.datamodel.PeakList)

Example 3 with DataPointProcessingManager

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager in project mzmine2 by mzmine.

the class ProcessingComponent method sendValueWrapper.

/**
 * Sends the queues to the DataPointProcessingManager.
 */
private void sendValueWrapper() {
    // if (((DefaultMutableTreeNode) tvProcessing.getModel().getRoot()).getChildCount() < 1)
    // return;
    List<String> errorMessage = new ArrayList<String>();
    DPPParameterValueWrapper value = getValueFromComponent();
    if (!value.checkValue(errorMessage))
        logger.info(errorMessage.toString());
    DataPointProcessingManager manager = DataPointProcessingManager.getInst();
// manager.clearProcessingSteps();
// manager.setProcessingParameters(value);
}
Also used : DataPointProcessingManager(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager) ArrayList(java.util.ArrayList) DPPParameterValueWrapper(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.DPPParameterValueWrapper)

Aggregations

DataPointProcessingManager (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager)3 Window (java.awt.Window)1 ArrayList (java.util.ArrayList)1 DataPoint (net.sf.mzmine.datamodel.DataPoint)1 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1 PeakList (net.sf.mzmine.datamodel.PeakList)1 Scan (net.sf.mzmine.datamodel.Scan)1 MSMSLibrarySubmissionWindow (net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.view.MSMSLibrarySubmissionWindow)1 DataPointProcessingController (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingController)1 DPPParameterValueWrapper (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.DPPParameterValueWrapper)1 MSLevel (net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.MSLevel)1 ScanDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet)1 ExitCode (net.sf.mzmine.util.ExitCode)1 AxesSetupDialog (net.sf.mzmine.util.dialogs.AxesSetupDialog)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 XYDataset (org.jfree.data.xy.XYDataset)1