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);
}
}
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);
}
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();
}
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;
}
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));
}
}
Aggregations