Search in sources :

Example 6 with ExitCode

use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.

the class ManualPeakPickerModule method runManualDetection.

public static ExitCode runManualDetection(RawDataFile[] dataFiles, PeakListRow peakListRow, PeakList peakList, PeakListTable table) {
    Range<Double> mzRange = null, rtRange = null;
    // Check the peaks for selected data files
    for (RawDataFile dataFile : dataFiles) {
        Feature peak = peakListRow.getPeak(dataFile);
        if (peak == null)
            continue;
        if ((mzRange == null) || (rtRange == null)) {
            mzRange = peak.getRawDataPointsMZRange();
            rtRange = peak.getRawDataPointsRTRange();
        } else {
            mzRange = mzRange.span(peak.getRawDataPointsMZRange());
            rtRange = rtRange.span(peak.getRawDataPointsRTRange());
        }
    }
    // If none of the data files had a peak, check the whole row
    if (mzRange == null) {
        for (Feature peak : peakListRow.getPeaks()) {
            if (peak == null)
                continue;
            if ((mzRange == null) || (rtRange == null)) {
                mzRange = peak.getRawDataPointsMZRange();
                rtRange = peak.getRawDataPointsRTRange();
            } else {
                mzRange = mzRange.span(peak.getRawDataPointsMZRange());
                rtRange = rtRange.span(peak.getRawDataPointsRTRange());
            }
        }
    }
    ManualPickerParameters parameters = new ManualPickerParameters();
    if (mzRange != null) {
        parameters.getParameter(ManualPickerParameters.retentionTimeRange).setValue(rtRange);
        parameters.getParameter(ManualPickerParameters.mzRange).setValue(mzRange);
    }
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return exitCode;
    ManualPickerTask task = new ManualPickerTask(MZmineCore.getProjectManager().getCurrentProject(), peakListRow, dataFiles, parameters, peakList, table);
    MZmineCore.getTaskController().addTask(task);
    return exitCode;
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ExitCode(net.sf.mzmine.util.ExitCode) Feature(net.sf.mzmine.datamodel.Feature)

Example 7 with ExitCode

use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.

the class XICManualPickerModule method runManualDetection.

// public static ExitCode runManualDetection(RawDataFile dataFile, PeakListRow peakListRow,
// PeakList peakList, PeakListTable table) {
// return runManualDetection(new RawDataFile[] {dataFile}, peakListRow, peakList, table);
// }
public static ExitCode runManualDetection(RawDataFile dataFile, PeakListRow peakListRow, PeakList peakList, PeakListTable table) {
    Range<Double> mzRange = null, rtRange = null;
    mzRange = Range.closed(peakListRow.getAverageMZ(), peakListRow.getAverageMZ());
    rtRange = Range.closed(peakListRow.getAverageRT(), peakListRow.getAverageRT());
    for (Feature peak : peakListRow.getPeaks()) {
        if (peak == null)
            continue;
        // if the peak exists in the file, then we just use that one as a base
        if (peak.getDataFile() == dataFile) {
            mzRange = peak.getRawDataPointsMZRange();
            rtRange = peak.getRawDataPointsRTRange();
            break;
        }
        // if it does not exist, we set up on basis of the other peaks
        if (peak != null) {
            mzRange = mzRange.span(peak.getRawDataPointsMZRange());
            rtRange = rtRange.span(peak.getRawDataPointsRTRange());
        }
    }
    XICManualPickerParameters parameters = new XICManualPickerParameters();
    if (mzRange != null) {
        parameters.getParameter(XICManualPickerParameters.rtRange).setValue(rtRange);
        parameters.getParameter(XICManualPickerParameters.mzRange).setValue(mzRange);
    }
    if (dataFile != null) {
        RawDataFilesSelection selection = new RawDataFilesSelection();
        selection.setSpecificFiles(new RawDataFile[] { dataFile });
        selection.setSelectionType(RawDataFilesSelectionType.SPECIFIC_FILES);
        parameters.getParameter(XICManualPickerParameters.rawDataFiles).setValue(selection);
    }
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return exitCode;
    ManualPickerParameters param = new ManualPickerParameters();
    param.getParameter(ManualPickerParameters.mzRange).setValue(parameters.getParameter(XICManualPickerParameters.mzRange).getValue());
    param.getParameter(ManualPickerParameters.retentionTimeRange).setValue(parameters.getParameter(XICManualPickerParameters.rtRange).getValue());
    ManualPickerTask task = new ManualPickerTask(MZmineCore.getProjectManager().getCurrentProject(), peakListRow, new RawDataFile[] { dataFile }, param, peakList, table);
    MZmineCore.getTaskController().addTask(task);
    return exitCode;
}
Also used : RawDataFilesSelection(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection) ExitCode(net.sf.mzmine.util.ExitCode) Feature(net.sf.mzmine.datamodel.Feature)

Example 8 with ExitCode

use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.

the class ProcessingComponent method setParameters.

/**
 * Opens the parameter setup dialog of the selected module.
 */
private void setParameters(@Nonnull DefaultMutableTreeNode _selected) {
    if (_selected == null || !(_selected instanceof DPPModuleTreeNode))
        return;
    DPPModuleTreeNode selected = (DPPModuleTreeNode) _selected;
    ParameterSet stepParameters = selected.getParameters();
    if (stepParameters.getParameters().length > 0 && !selected.isDialogShowing()) {
        selected.setDialogShowing(true);
        ExitCode exitCode = stepParameters.showSetupDialog(null, true);
        selected.setDialogShowing(false);
        if (exitCode == ExitCode.OK) {
            // store the parameters in the tree item
            selected.setParameters(stepParameters);
        // sendValueWrapper(); // update the list
        }
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) DPPModuleTreeNode(net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.customguicomponents.DPPModuleTreeNode) ExitCode(net.sf.mzmine.util.ExitCode)

Example 9 with ExitCode

use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.

the class BatchSetupComponent method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Object src = e.getSource();
    if (btnAdd.equals(src)) {
        // Processing module selected?
        final Object selectedItem = methodsCombo.getSelectedItem();
        if (selectedItem instanceof BatchModuleWrapper) {
            // Show method's set-up dialog.
            final BatchModuleWrapper wrappedModule = (BatchModuleWrapper) selectedItem;
            final MZmineProcessingModule selectedMethod = (MZmineProcessingModule) wrappedModule.getModule();
            final ParameterSet methodParams = MZmineCore.getConfiguration().getModuleParameters(selectedMethod.getClass());
            // Clone the parameter set
            final ParameterSet stepParams = methodParams.cloneParameterSet();
            // data file and feature list selection
            if (!batchQueue.isEmpty()) {
                for (Parameter<?> param : stepParams.getParameters()) {
                    if (param instanceof RawDataFilesParameter) {
                        final RawDataFilesParameter rdfp = (RawDataFilesParameter) param;
                        final RawDataFilesSelection selection = new RawDataFilesSelection();
                        selection.setSelectionType(RawDataFilesSelectionType.BATCH_LAST_FILES);
                        rdfp.setValue(selection);
                    }
                    if (param instanceof PeakListsParameter) {
                        final PeakListsParameter plp = (PeakListsParameter) param;
                        final PeakListsSelection selection = new PeakListsSelection();
                        selection.setSelectionType(PeakListsSelectionType.BATCH_LAST_PEAKLISTS);
                        plp.setValue(selection);
                    }
                }
            }
            // Configure parameters
            if (stepParams.getParameters().length > 0) {
                Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
                ExitCode exitCode = stepParams.showSetupDialog(parent, false);
                if (exitCode != ExitCode.OK)
                    return;
            }
            // Make a new batch step
            final MZmineProcessingStep<MZmineProcessingModule> step = new MZmineProcessingStepImpl<MZmineProcessingModule>(selectedMethod, stepParams);
            // Add step to queue.
            batchQueue.add(step);
            currentStepsList.setListData(batchQueue);
            currentStepsList.setSelectedIndex(currentStepsList.getModel().getSize() - 1);
        }
    }
    if (btnRemove.equals(src)) {
        // Remove selected step.
        final MZmineProcessingStep<?> selected = (MZmineProcessingStep<?>) currentStepsList.getSelectedValue();
        if (selected != null) {
            final int index = currentStepsList.getSelectedIndex();
            batchQueue.remove(selected);
            currentStepsList.setListData(batchQueue);
            selectStep(index);
        }
    }
    if (btnClear.equals(src)) {
        // Clear the queue.
        batchQueue.clear();
        currentStepsList.setListData(batchQueue);
    }
    if (btnConfig.equals(src)) {
        // Configure the selected item.
        final MZmineProcessingStep<?> selected = (MZmineProcessingStep<?>) currentStepsList.getSelectedValue();
        final ParameterSet parameters = selected == null ? null : selected.getParameterSet();
        if (parameters != null) {
            Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            parameters.showSetupDialog(parent, false);
        }
    }
    if (btnSave.equals(src)) {
        try {
            final File file = chooser.getSaveFile(this, XML_EXTENSION);
            if (file != null) {
                saveBatchSteps(file);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "A problem occurred saving the file.\n" + ex.getMessage(), "Saving Failed", JOptionPane.ERROR_MESSAGE);
        }
    }
    if (btnLoad.equals(src)) {
        try {
            // Load the steps.
            final File file = chooser.getLoadFile(this);
            if (file != null) {
                // Load the batch steps.
                loadBatchSteps(file);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "A problem occurred loading the file.\n" + ex.getMessage(), "Loading Failed", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) Window(java.awt.Window) ExitCode(net.sf.mzmine.util.ExitCode) MZmineProcessingStepImpl(net.sf.mzmine.modules.impl.MZmineProcessingStepImpl) MZmineProcessingModule(net.sf.mzmine.modules.MZmineProcessingModule) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) MZmineProcessingStep(net.sf.mzmine.modules.MZmineProcessingStep) RawDataFilesSelection(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection) PeakListsSelection(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsSelection) PeakListsParameter(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter) File(java.io.File) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 10 with ExitCode

use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.

the class MZminePreferences method showSetupDialog.

@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
    ExitCode retVal = super.showSetupDialog(parent, valueCheckRequired);
    if (retVal == ExitCode.OK) {
        // Update proxy settings
        updateSystemProxySettings();
        // Repaint windows to update number formats
        MZmineCore.getDesktop().getMainWindow().repaint();
    }
    return retVal;
}
Also used : ExitCode(net.sf.mzmine.util.ExitCode)

Aggregations

ExitCode (net.sf.mzmine.util.ExitCode)32 ParameterSet (net.sf.mzmine.parameters.ParameterSet)19 Window (java.awt.Window)7 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)7 PeakList (net.sf.mzmine.datamodel.PeakList)6 SimpleParameterSet (net.sf.mzmine.parameters.impl.SimpleParameterSet)6 File (java.io.File)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)4 Scan (net.sf.mzmine.datamodel.Scan)4 StringParameter (net.sf.mzmine.parameters.parametertypes.StringParameter)4 PeakListsParameter (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter)4 Task (net.sf.mzmine.taskcontrol.Task)4 ArrayList (java.util.ArrayList)3 Feature (net.sf.mzmine.datamodel.Feature)3 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)3 MZmineProject (net.sf.mzmine.datamodel.MZmineProject)3 MZmineProcessingModule (net.sf.mzmine.modules.MZmineProcessingModule)3 Parameter (net.sf.mzmine.parameters.Parameter)3 RawDataFilesParameter (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)3 BufferedWriter (java.io.BufferedWriter)2