Search in sources :

Example 1 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.

the class RTScore method calculateScore.

public double calculateScore(AlignmentPath path, PeakListRow peak, ParameterSet parameters) {
    try {
        rtTolerance = parameters.getParameter(PathAlignerParameters.RTTolerance).getValue();
        mzTolerance = parameters.getParameter(PathAlignerParameters.MZTolerance).getValue();
        Range<Double> rtRange = rtTolerance.getToleranceRange(path.getRT());
        Range<Double> mzRange = mzTolerance.getToleranceRange(path.getMZ());
        if (!rtRange.contains(peak.getAverageRT()) || !mzRange.contains(peak.getAverageMZ())) {
            return WORST_SCORE;
        }
        double mzDiff = Math.abs(path.getMZ() - peak.getAverageMZ());
        double rtDiff = Math.abs(path.getRT() - peak.getAverageRT());
        double score = ((mzDiff / (RangeUtils.rangeLength(mzRange) / 2.0))) + ((rtDiff / (RangeUtils.rangeLength(rtRange) / 2.0)));
        if (parameters.getParameter(PathAlignerParameters.SameChargeRequired).getValue()) {
            if (!PeakUtils.compareChargeState(path.convertToAlignmentRow(0), peak)) {
                return WORST_SCORE;
            }
        }
        if (parameters.getParameter(PathAlignerParameters.SameIDRequired).getValue()) {
            if (!PeakUtils.compareIdentities(path.convertToAlignmentRow(0), peak)) {
                return WORST_SCORE;
            }
        }
        if (parameters.getParameter(PathAlignerParameters.compareIsotopePattern).getValue()) {
            IsotopePattern ip1 = path.convertToAlignmentRow(0).getBestIsotopePattern();
            IsotopePattern ip2 = peak.getBestIsotopePattern();
            if ((ip1 != null) && (ip2 != null)) {
                ParameterSet isotopeParams = parameters.getParameter(PathAlignerParameters.compareIsotopePattern).getEmbeddedParameters();
                if (!IsotopePatternScoreCalculator.checkMatch(ip1, ip2, isotopeParams)) {
                    return WORST_SCORE;
                }
            }
        }
        return score;
    } catch (NullPointerException e) {
        e.printStackTrace();
        return WORST_SCORE;
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern)

Example 2 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.

the class BaselineCorrector method collectCommonParameters.

/**
 * Getting general parameters (common to all the correctors).
 *
 * @param generalParameters The parameters common to all methods (grabbed from
 *        "BaselineCorrectionParameters")
 */
public void collectCommonParameters(final ParameterSet parameters) {
    ParameterSet generalParameters;
    if (parameters != null) {
        generalParameters = parameters;
    } else if (BaselineCorrectionParameters.getBaselineCorrectionParameters() == null) {
        generalParameters = MZmineCore.getConfiguration().getModuleParameters(BaselineCorrectionModule.class);
    } else {
        generalParameters = BaselineCorrectionParameters.getBaselineCorrectionParameters();
    }
    // Get common parameters.
    rEgineType = generalParameters.getParameter(BaselineCorrectionParameters.RENGINE_TYPE).getValue();
    suffix = generalParameters.getParameter(BaselineCorrectionParameters.SUFFIX).getValue();
    chromatogramType = generalParameters.getParameter(BaselineCorrectionParameters.CHROMOTAGRAM_TYPE).getValue();
    binWidth = generalParameters.getParameter(BaselineCorrectionParameters.MZ_BIN_WIDTH).getValue();
    useBins = generalParameters.getParameter(BaselineCorrectionParameters.USE_MZ_BINS).getValue();
    msLevel = generalParameters.getParameter(BaselineCorrectionParameters.MS_LEVEL).getValue();
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet)

Example 3 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet 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 4 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.

the class BatchQueue method loadFromXml.

/**
 * De-serialize from XML.
 *
 * @param xmlElement the element that holds the XML.
 * @return the de-serialized value.
 */
public static BatchQueue loadFromXml(final Element xmlElement) {
    // Set the parameter choice for the RowsFilterModule
    String[] choices;
    choices = new String[1];
    choices[0] = "No parameters defined";
    MZmineCore.getConfiguration().getModuleParameters(RowsFilterModule.class).getParameter(RowsFilterParameters.GROUPSPARAMETER).setChoices(choices);
    // Create an empty queue.
    final BatchQueue queue = new BatchQueue();
    // Get the loaded modules.
    final Collection<MZmineModule> allModules = MZmineCore.getAllModules();
    // Process the batch step elements.
    final NodeList nodes = xmlElement.getElementsByTagName(BATCH_STEP_ELEMENT);
    final int nodesLength = nodes.getLength();
    for (int i = 0; i < nodesLength; i++) {
        final Element stepElement = (Element) nodes.item(i);
        final String methodName = stepElement.getAttribute(METHOD_ELEMENT);
        // Find a matching module.
        for (final MZmineModule module : allModules) {
            if (module instanceof MZmineProcessingModule && module.getClass().getName().equals(methodName)) {
                // Get parameters and add step to queue.
                final ParameterSet parameterSet = MZmineCore.getConfiguration().getModuleParameters(module.getClass());
                final ParameterSet methodParams = parameterSet.cloneParameterSet();
                methodParams.loadValuesFromXML(stepElement);
                queue.add(new MZmineProcessingStepImpl<MZmineProcessingModule>((MZmineProcessingModule) module, methodParams));
                break;
            }
        }
    }
    return queue;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) MZmineProcessingModule(net.sf.mzmine.modules.MZmineProcessingModule) MZmineModule(net.sf.mzmine.modules.MZmineModule)

Example 5 with ParameterSet

use of net.sf.mzmine.parameters.ParameterSet 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)

Aggregations

ParameterSet (net.sf.mzmine.parameters.ParameterSet)53 ExitCode (net.sf.mzmine.util.ExitCode)19 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)11 File (java.io.File)9 ArrayList (java.util.ArrayList)8 SimpleParameterSet (net.sf.mzmine.parameters.impl.SimpleParameterSet)8 Task (net.sf.mzmine.taskcontrol.Task)8 Element (org.w3c.dom.Element)8 PeakList (net.sf.mzmine.datamodel.PeakList)6 MZmineModule (net.sf.mzmine.modules.MZmineModule)6 Document (org.w3c.dom.Document)6 IOException (java.io.IOException)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)5 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)5 Scan (net.sf.mzmine.datamodel.Scan)5 MZmineProcessingModule (net.sf.mzmine.modules.MZmineProcessingModule)5 Nonnull (javax.annotation.Nonnull)4 Feature (net.sf.mzmine.datamodel.Feature)4 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)4 PeakListsParameter (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter)4