Search in sources :

Example 1 with RawDataFilesParameter

use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter in project mzmine2 by mzmine.

the class MZRangeComponent method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == setAutoButton) {
        RawDataFile[] currentFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
        ScanSelection scanSelection = new ScanSelection();
        try {
            ParameterSetupDialog setupDialog = (ParameterSetupDialog) SwingUtilities.getWindowAncestor(this);
            RawDataFilesComponent rdc = (RawDataFilesComponent) setupDialog.getComponentForParameter(new RawDataFilesParameter());
            if (rdc != null) {
                RawDataFile[] matchingFiles = rdc.getValue().getMatchingRawDataFiles();
                if (matchingFiles.length > 0)
                    currentFiles = matchingFiles;
            }
            ScanSelectionComponent ssc = (ScanSelectionComponent) setupDialog.getComponentForParameter(new ScanSelectionParameter());
            if (ssc != null)
                scanSelection = ssc.getValue();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Range<Double> mzRange = null;
        for (RawDataFile file : currentFiles) {
            Scan[] scans = scanSelection.getMatchingScans(file);
            for (Scan s : scans) {
                Range<Double> scanRange = s.getDataPointMZRange();
                if (scanRange == null)
                    continue;
                if (mzRange == null)
                    mzRange = scanRange;
                else
                    mzRange = mzRange.span(scanRange);
            }
        }
        if (mzRange != null)
            setValue(mzRange);
    }
    if (src == fromMassButton) {
        Range<Double> mzRange = MzRangeMassCalculatorModule.showRangeCalculationDialog();
        if (mzRange != null)
            setValue(mzRange);
    }
    if (src == fromFormulaButton) {
        Range<Double> mzRange = MzRangeFormulaCalculatorModule.showRangeCalculationDialog();
        if (mzRange != null)
            setValue(mzRange);
    }
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) ScanSelectionParameter(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionParameter) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog) RawDataFilesComponent(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesComponent) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) ScanSelectionComponent(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionComponent) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 2 with RawDataFilesParameter

use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter in project mzmine2 by mzmine.

the class ADAP3DModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    RawDataFile[] dataFiles = parameters.getParameter(new RawDataFilesParameter()).getValue().getMatchingRawDataFiles();
    for (int i = 0; i < dataFiles.length; i++) {
        Task newTask = new ADAP3DTask(project, dataFiles[i], parameters.cloneParameterSet());
        tasks.add(newTask);
    }
    return ExitCode.OK;
}
Also used : Task(net.sf.mzmine.taskcontrol.Task) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter) Nonnull(javax.annotation.Nonnull)

Example 3 with RawDataFilesParameter

use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter in project mzmine2 by mzmine.

the class GridMassModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    RawDataFile[] dataFiles = parameters.getParameter(new RawDataFilesParameter()).getValue().getMatchingRawDataFiles();
    for (int i = 0; i < dataFiles.length; i++) {
        Task newTask = new GridMassTask(project, dataFiles[i], parameters.cloneParameterSet());
        tasks.add(newTask);
    }
    return ExitCode.OK;
}
Also used : Task(net.sf.mzmine.taskcontrol.Task) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter) Nonnull(javax.annotation.Nonnull)

Example 4 with RawDataFilesParameter

use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter 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 5 with RawDataFilesParameter

use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter in project mzmine2 by mzmine.

the class BatchQueueParameter method checkValue.

@Override
public boolean checkValue(final Collection<String> errorMessages) {
    boolean allParamsOK = true;
    if (value == null) {
        // Parameters not set.
        errorMessages.add(getName() + " is not set");
        allParamsOK = false;
    } else {
        // Check each step.
        for (final MZmineProcessingStep<?> batchStep : value) {
            // Check step's parameters.
            final ParameterSet params = batchStep.getParameterSet();
            if (params == null)
                continue;
            for (final Parameter<?> parameter : params.getParameters()) {
                // Ignore the raw data files and feature lists parameters
                if (!(parameter instanceof RawDataFilesParameter) && !(parameter instanceof PeakListsParameter) && !parameter.checkValue(errorMessages)) {
                    allParamsOK = false;
                }
            }
        }
    }
    return allParamsOK;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) PeakListsParameter(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Aggregations

RawDataFilesParameter (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)10 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)8 Task (net.sf.mzmine.taskcontrol.Task)6 Nonnull (javax.annotation.Nonnull)4 ParameterSet (net.sf.mzmine.parameters.ParameterSet)4 PeakListsParameter (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter)4 ExitCode (net.sf.mzmine.util.ExitCode)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 PeakList (net.sf.mzmine.datamodel.PeakList)2 MZmineProcessingModule (net.sf.mzmine.modules.MZmineProcessingModule)2 ParameterSetupDialog (net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)2 PeakListsSelection (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsSelection)2 RawDataFilesComponent (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesComponent)2 RawDataFilesSelection (net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection)2 Window (java.awt.Window)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 JFileChooser (javax.swing.JFileChooser)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1