use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class SiriusExportModule method exportSinglePeakList.
public static void exportSinglePeakList(PeakListRow row) {
try {
ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(SiriusExportModule.class);
ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
if (exitCode != ExitCode.OK)
return;
// Open file
final SiriusExportTask task = new SiriusExportTask(parameters);
task.runSingleRow(row);
} catch (Exception e) {
e.printStackTrace();
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error while exporting feature to SIRIUS: " + ExceptionUtils.exceptionToString(e));
}
}
use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class SiriusExportModule method exportSingleRows.
public static void exportSingleRows(PeakListRow[] row) {
try {
ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(SiriusExportModule.class);
ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
if (exitCode != ExitCode.OK)
return;
// Open file
final SiriusExportTask task = new SiriusExportTask(parameters);
task.runSingleRows(row);
} catch (Exception e) {
e.printStackTrace();
MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error while exporting feature to SIRIUS: " + ExceptionUtils.exceptionToString(e));
}
}
use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class DeconvolutionModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull final ParameterSet parameters, @Nonnull final Collection<Task> tasks) {
PeakList[] peakLists = parameters.getParameter(DeconvolutionParameters.PEAK_LISTS).getValue().getMatchingPeakLists();
// function to calculate center mz
CenterFunction mzCenterFunction = parameters.getParameter(DeconvolutionParameters.MZ_CENTER_FUNCTION).getValue();
// use a LOG weighted, noise corrected, maximum weight capped function
if (mzCenterFunction.getMeasure().equals(CenterMeasure.AUTO)) {
// data point with lowest intensity
// weight = LOG(value) - LOG(noise) (maxed to maxWeight)
double noise = Arrays.stream(peakLists).flatMap(pkl -> Arrays.stream(pkl.getRows())).map(r -> r.getPeaks()[0]).mapToDouble(peak -> peak.getRawDataPointsIntensityRange().lowerEndpoint()).filter(v -> v != 0).min().orElse(0);
// maxWeight 4 corresponds to a linear range of 4 orders of magnitude
// everything higher than this will be capped to this weight
// do not overestimate influence of very high data points on mass accuracy
double maxWeight = 4;
// use a LOG weighted, noise corrected, maximum weight capped function
mzCenterFunction = new CenterFunction(CenterMeasure.AVG, Weighting.LOG10, noise, maxWeight);
}
for (final PeakList peakList : peakLists) {
tasks.add(new DeconvolutionTask(project, peakList, parameters, mzCenterFunction));
}
return ExitCode.OK;
}
use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class MzRangeFormulaCalculatorModule method showRangeCalculationDialog.
/**
* Shows the calculation dialog and returns the calculated m/z range. May return null in case user
* clicked Cancel.
*/
@Nullable
public static Range<Double> showRangeCalculationDialog() {
ParameterSet myParameters = MZmineCore.getConfiguration().getModuleParameters(MzRangeFormulaCalculatorModule.class);
if (myParameters == null)
return null;
ExitCode exitCode = myParameters.showSetupDialog(null, true);
if (exitCode != ExitCode.OK)
return null;
return getMzRangeFromFormula(myParameters);
}
use of net.sf.mzmine.util.ExitCode in project mzmine2 by mzmine.
the class SpectraVisualizerWindow method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("PEAKLIST_CHANGE")) {
// If no scan is loaded yet, ignore
if (currentScan == null)
return;
PeakList selectedPeakList = bottomPanel.getSelectedPeakList();
loadPeaks(selectedPeakList);
}
if (command.equals("PREVIOUS_SCAN")) {
if (dataFile == null)
return;
int msLevel = currentScan.getMSLevel();
int[] scanNumbers = dataFile.getScanNumbers(msLevel);
int scanIndex = Arrays.binarySearch(scanNumbers, currentScan.getScanNumber());
if (scanIndex > 0) {
final int prevScanIndex = scanNumbers[scanIndex - 1];
Runnable newThreadRunnable = new Runnable() {
@Override
public void run() {
loadRawData(dataFile.getScan(prevScanIndex));
}
};
Thread newThread = new Thread(newThreadRunnable);
newThread.start();
}
}
if (command.equals("NEXT_SCAN")) {
if (dataFile == null)
return;
int msLevel = currentScan.getMSLevel();
int[] scanNumbers = dataFile.getScanNumbers(msLevel);
int scanIndex = Arrays.binarySearch(scanNumbers, currentScan.getScanNumber());
if (scanIndex < (scanNumbers.length - 1)) {
final int nextScanIndex = scanNumbers[scanIndex + 1];
Runnable newThreadRunnable = new Runnable() {
@Override
public void run() {
loadRawData(dataFile.getScan(nextScanIndex));
}
};
Thread newThread = new Thread(newThreadRunnable);
newThread.start();
}
}
if (command.equals("SHOW_MSMS")) {
String selectedScanString = (String) bottomPanel.getMSMSSelector().getSelectedItem();
if (selectedScanString == null)
return;
int sharpIndex = selectedScanString.indexOf('#');
int commaIndex = selectedScanString.indexOf(',');
selectedScanString = selectedScanString.substring(sharpIndex + 1, commaIndex);
int selectedScan = Integer.valueOf(selectedScanString);
SpectraVisualizerModule.showNewSpectrumWindow(dataFile, selectedScan);
}
if (command.equals("TOGGLE_PLOT_MODE")) {
if (spectrumPlot.getPlotMode() == MassSpectrumType.CENTROIDED) {
spectrumPlot.setPlotMode(MassSpectrumType.PROFILE);
toolBar.setCentroidButton(MassSpectrumType.PROFILE);
} else {
spectrumPlot.setPlotMode(MassSpectrumType.CENTROIDED);
toolBar.setCentroidButton(MassSpectrumType.CENTROIDED);
}
}
if (command.equals("SHOW_DATA_POINTS")) {
spectrumPlot.switchDataPointsVisible();
}
if (command.equals("SHOW_ANNOTATIONS")) {
spectrumPlot.switchItemLabelsVisible();
}
if (command.equals("SHOW_PICKED_PEAKS")) {
spectrumPlot.switchPickedPeaksVisible();
}
if (command.equals("SHOW_ISOTOPE_PEAKS")) {
spectrumPlot.switchIsotopePeaksVisible();
}
if (command.equals("SETUP_AXES")) {
AxesSetupDialog dialog = new AxesSetupDialog(this, spectrumPlot.getXYPlot());
dialog.setVisible(true);
}
// library entry creation
if (command.equals("CREATE_LIBRARY_ENTRY")) {
// open window with all selected rows
MSMSLibrarySubmissionWindow libraryWindow = new MSMSLibrarySubmissionWindow();
libraryWindow.setData(currentScan);
libraryWindow.setVisible(true);
}
if (command.equals("EXPORT_SPECTRA")) {
ExportScansModule.showSetupDialog(currentScan);
}
if (command.equals("ADD_ISOTOPE_PATTERN")) {
IsotopePattern newPattern = IsotopePatternCalculator.showIsotopePredictionDialog(this, true);
if (newPattern == null)
return;
loadIsotopes(newPattern);
}
if ((command.equals("ZOOM_IN")) || (command.equals("ZOOM_IN_BOTH_COMMAND"))) {
spectrumPlot.getXYPlot().getDomainAxis().resizeRange(1 / zoomCoefficient);
}
if ((command.equals("ZOOM_OUT")) || (command.equals("ZOOM_OUT_BOTH_COMMAND"))) {
spectrumPlot.getXYPlot().getDomainAxis().resizeRange(zoomCoefficient);
}
if (command.equals("SET_SAME_RANGE")) {
// Get current axes range
NumberAxis xAxis = (NumberAxis) spectrumPlot.getXYPlot().getDomainAxis();
NumberAxis yAxis = (NumberAxis) spectrumPlot.getXYPlot().getRangeAxis();
double xMin = xAxis.getRange().getLowerBound();
double xMax = xAxis.getRange().getUpperBound();
double xTick = xAxis.getTickUnit().getSize();
double yMin = yAxis.getRange().getLowerBound();
double yMax = yAxis.getRange().getUpperBound();
double yTick = yAxis.getTickUnit().getSize();
// Get all frames of my class
Window[] spectraFrames = JFrame.getWindows();
// Set the range of these frames
for (Window frame : spectraFrames) {
if (!(frame instanceof SpectraVisualizerWindow))
continue;
SpectraVisualizerWindow spectraFrame = (SpectraVisualizerWindow) frame;
spectraFrame.setAxesRange(xMin, xMax, xTick, yMin, yMax, yTick);
}
}
if (command.equals("ONLINEDATABASESEARCH")) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
OnlineDBSpectraSearchModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
}
});
}
if (command.equals("CUSTOMDATABASESEARCH")) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
CustomDBSpectraSearchModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
}
});
}
if (command.equals("LIPIDSEARCH")) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
LipidSpectraSearchModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
}
});
}
if (command.equals("SUMFORMULA")) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
SumFormulaSpectraSearchModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
}
});
}
if (command.equals("SPECTRALDATABASESEARCH")) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
SpectraIdentificationSpectralDatabaseModule.showSpectraIdentificationDialog(currentScan, spectrumPlot);
}
});
}
if (command.equals("SET_PROCESSING_PARAMETERS")) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!dppmWindowOpen) {
dppmWindowOpen = true;
ExitCode exitCode = DataPointProcessingManager.getInst().getParameters().showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
dppmWindowOpen = false;
if (exitCode == ExitCode.OK && DataPointProcessingManager.getInst().isEnabled()) {
// if processing was run before, this removes the previous results.
getSpectrumPlot().removeDataPointProcessingResultDataSets();
getSpectrumPlot().checkAndRunController();
}
}
}
});
}
if (command.equals("ENABLE_PROCESSING")) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
DataPointProcessingManager inst = DataPointProcessingManager.getInst();
inst.setEnabled(!inst.isEnabled());
bottomPanel.updateProcessingButton();
getSpectrumPlot().checkAndRunController();
// if the tick is removed, set the data back to default
if (!inst.isEnabled()) {
getSpectrumPlot().removeDataPointProcessingResultDataSets();
// loadRawData(currentScan);
}
}
});
}
}
Aggregations