Search in sources :

Example 26 with ExitCode

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

the class MsMsVisualizerWindow method actionPerformed.

/**
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals("SHOW_SPECTRUM")) {
        CursorPosition pos = getCursorPosition();
        if (pos != null) {
            SpectraVisualizerModule.showNewSpectrumWindow(pos.getDataFile(), pos.getScanNumber());
        }
    }
    if (command.equals("SETUP_AXES")) {
        AxesSetupDialog dialog = new AxesSetupDialog(this, IDAPlot.getXYPlot());
        dialog.setVisible(true);
    }
    if (command.equals("SHOW_DATA_POINTS")) {
        IDAPlot.switchDataPointsVisible();
    }
    if (command.equals("SWITCH_TOOLTIPS")) {
        if (tooltipMode) {
            IDAPlot.showPeaksTooltips(false);
            toolBar.setTooltipButton(false);
            tooltipMode = false;
        } else {
            IDAPlot.showPeaksTooltips(true);
            toolBar.setTooltipButton(true);
            tooltipMode = true;
        }
    }
    if (command.equals("FIND_SPECTRA")) {
        // Parameters
        final DoubleParameter inputMZ = new DoubleParameter("Ion m/z", "m/z value of ion to search for.");
        final MZToleranceParameter inputMZTolerance = new MZToleranceParameter();
        final DoubleParameter inputIntensity = new DoubleParameter("Min. ion intensity", "Only ions with intensities above this value will be searched for.");
        final BooleanParameter inputNL = new BooleanParameter("Neutral Loss", "If selected, the ion to be searched for will be a neutral loss ion.\nIn this case, only ions above the min. intensity will be examined.", false);
        final ComboParameter<Colors> inputColors = new ComboParameter<Colors>("Color", "The color which the data points will be marked with.", Colors.values());
        Parameter<?>[] parameters = new Parameter<?>[5];
        parameters[0] = inputMZ;
        parameters[1] = inputMZTolerance;
        parameters[2] = inputIntensity;
        parameters[3] = inputNL;
        parameters[4] = inputColors;
        final ParameterSet parametersSearch = new SimpleParameterSet(parameters);
        ExitCode exitCode = parametersSearch.showSetupDialog(this, true);
        if (exitCode != ExitCode.OK)
            return;
        double searchMZ = parametersSearch.getParameter(inputMZ).getValue();
        MZTolerance searchMZTolerance = parametersSearch.getParameter(inputMZTolerance).getValue();
        double minIntensity = parametersSearch.getParameter(inputIntensity).getValue();
        boolean neutralLoss = parametersSearch.getParameter(inputNL).getValue();
        Color highligtColor = Color.red;
        ;
        if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.green)) {
            highligtColor = Color.green;
        }
        if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.blue)) {
            highligtColor = Color.blue;
        }
        // Find and highlight spectra with specific ion
        dataset.highlightSpectra(searchMZ, searchMZTolerance, minIntensity, neutralLoss, highligtColor);
        // Add legend entry
        LegendItemCollection chartLegend = IDAPlot.getXYPlot().getLegendItems();
        chartLegend.add(new LegendItem("Ion: " + searchMZ, "", "MS/MS spectra which contain the " + searchMZ + " ion\nTolerance: " + searchMZTolerance.toString() + "\nMin intensity: " + minIntensity, "", new Ellipse2D.Double(0, 0, 7, 7), highligtColor));
        IDAPlot.getXYPlot().setFixedLegendItems(chartLegend);
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) MZTolerance(net.sf.mzmine.parameters.parametertypes.tolerances.MZTolerance) DoubleParameter(net.sf.mzmine.parameters.parametertypes.DoubleParameter) MZToleranceParameter(net.sf.mzmine.parameters.parametertypes.tolerances.MZToleranceParameter) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) LegendItemCollection(org.jfree.chart.LegendItemCollection) ExitCode(net.sf.mzmine.util.ExitCode) Color(java.awt.Color) BooleanParameter(net.sf.mzmine.parameters.parametertypes.BooleanParameter) AxesSetupDialog(net.sf.mzmine.util.dialogs.AxesSetupDialog) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter) LegendItem(org.jfree.chart.LegendItem) Parameter(net.sf.mzmine.parameters.Parameter) WindowSettingsParameter(net.sf.mzmine.parameters.parametertypes.WindowSettingsParameter) DoubleParameter(net.sf.mzmine.parameters.parametertypes.DoubleParameter) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter) BooleanParameter(net.sf.mzmine.parameters.parametertypes.BooleanParameter) MZToleranceParameter(net.sf.mzmine.parameters.parametertypes.tolerances.MZToleranceParameter) CursorPosition(net.sf.mzmine.modules.visualization.tic.CursorPosition)

Example 27 with ExitCode

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

the class MsMsVisualizerModule method showIDAVisualizerSetupDialog.

public static void showIDAVisualizerSetupDialog(RawDataFile dataFile, Range<Double> mzRange, Range<Double> rtRange, IntensityType intensityType, NormalizationType normalizationType, Double minPeakInt) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(MsMsVisualizerModule.class);
    parameters.getParameter(MsMsParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, new RawDataFile[] { dataFile });
    if (rtRange != null)
        parameters.getParameter(MsMsParameters.retentionTimeRange).setValue(rtRange);
    if (mzRange != null)
        parameters.getParameter(MsMsParameters.mzRange).setValue(mzRange);
    if (intensityType != null)
        parameters.getParameter(MsMsParameters.intensityType).setValue(intensityType);
    if (normalizationType != null)
        parameters.getParameter(MsMsParameters.normalizationType).setValue(normalizationType);
    if (!Double.isNaN(minPeakInt))
        parameters.getParameter(MsMsParameters.minPeakInt).setValue(minPeakInt);
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return;
    rtRange = parameters.getParameter(MsMsParameters.retentionTimeRange).getValue();
    mzRange = parameters.getParameter(MsMsParameters.mzRange).getValue();
    intensityType = parameters.getParameter(MsMsParameters.intensityType).getValue();
    normalizationType = parameters.getParameter(MsMsParameters.normalizationType).getValue();
    minPeakInt = parameters.getParameter(MsMsParameters.minPeakInt).getValue();
    MsMsVisualizerWindow newWindow = new MsMsVisualizerWindow(dataFile, rtRange, mzRange, intensityType, normalizationType, minPeakInt, parameters);
    newWindow.setVisible(true);
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ExitCode(net.sf.mzmine.util.ExitCode)

Example 28 with ExitCode

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

the class ParameterSetComponent method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == btnChange) {
        if (parameters == null)
            return;
        ExitCode exitCode = parameters.showSetupDialog(null, true);
        if (exitCode != ExitCode.OK)
            return;
    }
    updateLabel();
}
Also used : ExitCode(net.sf.mzmine.util.ExitCode)

Example 29 with ExitCode

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

the class IsotopePatternCalculator method showIsotopePredictionDialog.

public static IsotopePattern showIsotopePredictionDialog(Window parent, boolean valueCheckRequired) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(IsotopePatternCalculator.class);
    ExitCode exitCode = parameters.showSetupDialog(parent, valueCheckRequired);
    if (exitCode != ExitCode.OK)
        return null;
    String formula = parameters.getParameter(IsotopePatternCalculatorParameters.formula).getValue();
    int charge = parameters.getParameter(IsotopePatternCalculatorParameters.charge).getValue();
    PolarityType polarity = parameters.getParameter(IsotopePatternCalculatorParameters.polarity).getValue();
    double minAbundance = parameters.getParameter(IsotopePatternCalculatorParameters.minAbundance).getValue();
    try {
        IsotopePattern predictedPattern = calculateIsotopePattern(formula, minAbundance, charge, polarity);
        return predictedPattern;
    } catch (Exception e) {
        MZmineCore.getDesktop().displayException(MZmineCore.getDesktop().getMainWindow(), e);
    }
    return null;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) PolarityType(net.sf.mzmine.datamodel.PolarityType) ExitCode(net.sf.mzmine.util.ExitCode) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern) SimpleIsotopePattern(net.sf.mzmine.datamodel.impl.SimpleIsotopePattern) ExtendedIsotopePattern(net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Example 30 with ExitCode

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

the class IsotopePatternExportModule method exportIsotopePattern.

public static void exportIsotopePattern(PeakListRow row) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(IsotopePatternExportModule.class);
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return;
    File outputFile = parameters.getParameter(IsotopePatternExportParameters.outputFile).getValue();
    if (outputFile == null)
        return;
    IsotopePattern pattern = row.getBestIsotopePattern();
    DataPoint[] isotopes;
    if (pattern != null) {
        isotopes = pattern.getDataPoints();
    } else {
        isotopes = new DataPoint[1];
        Feature bestPeak = row.getBestPeak();
        isotopes[0] = new SimpleDataPoint(bestPeak.getMZ(), bestPeak.getHeight());
    }
    try {
        FileWriter fileWriter = new FileWriter(outputFile);
        BufferedWriter writer = new BufferedWriter(fileWriter);
        for (DataPoint isotope : isotopes) {
            writer.write(isotope.getMZ() + " " + isotope.getIntensity());
            writer.newLine();
        }
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error writing to file " + outputFile + ": " + ExceptionUtils.exceptionToString(e));
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) ExitCode(net.sf.mzmine.util.ExitCode) FileWriter(java.io.FileWriter) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern) File(java.io.File) Feature(net.sf.mzmine.datamodel.Feature) BufferedWriter(java.io.BufferedWriter)

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