Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #545 from SteffenHeu/SingleMassListProcessing
Browse files Browse the repository at this point in the history
DataPoint/Spectra processing
  • Loading branch information
tomas-pluskal authored Jun 2, 2019
2 parents c19dd13 + a4cb8db commit 30505d6
Show file tree
Hide file tree
Showing 60 changed files with 4,450 additions and 39 deletions.
Binary file added src/main/icons/btnspectraprocessing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/main/java/net/sf/mzmine/main/MZmineModulesList.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
import net.sf.mzmine.modules.visualization.scatterplot.ScatterPlotVisualizerModule;
import net.sf.mzmine.modules.visualization.spectra.msms.MsMsVisualizerModule;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerModule;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.identification.sumformulaprediction.DPPSumFormulaPredictionModule;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.isotopes.deisotoper.DPPIsotopeGrouperModule;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.massdetection.DPPMassDetectionModule;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.spectraidentification.customdatabase.CustomDBSpectraSearchModule;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.spectraidentification.lipidsearch.LipidSpectraSearchModule;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.spectraidentification.onlinedatabase.OnlineDBSpectraSearchModule;
Expand Down Expand Up @@ -214,7 +218,9 @@ public class MZmineModulesList {
// all other regular MZmineRunnableModule (not MZmineProcessingModule) NOT LISTED IN MENU
SpectraIdentificationSpectralDatabaseModule.class, LibrarySubmitModule.class,
CustomDBSpectraSearchModule.class, LipidSpectraSearchModule.class,
OnlineDBSpectraSearchModule.class, SumFormulaSpectraSearchModule.class
OnlineDBSpectraSearchModule.class, SumFormulaSpectraSearchModule.class,

// Data point processing
DataPointProcessingManager.class, DPPMassDetectionModule.class, DPPSumFormulaPredictionModule.class, DPPIsotopeGrouperModule.class
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ private void searchMsmsFragments(PeakListRow row, double lipidIonMass, LipidIden
massDetector = new CentroidMassDetector();
CentroidMassDetectorParameters parametersMSMS = new CentroidMassDetectorParameters();
CentroidMassDetectorParameters.noiseLevel.setValue(noiseLevelMSMS);
massList = massDetector.getMassValues(msmsScan, parametersMSMS);
massList = massDetector.getMassValues(msmsScan.getDataPoints(), parametersMSMS);
} else {
massDetector = new ExactMassDetector();
ExactMassDetectorParameters parametersMSMS = new ExactMassDetectorParameters();
ExactMassDetectorParameters.noiseLevel.setValue(noiseLevelMSMS);
massList = massDetector.getMassValues(msmsScan, parametersMSMS);
massList = massDetector.getMassValues(msmsScan.getDataPoints(), parametersMSMS);
}
}
MSMSLipidTools msmsLipidTools = new MSMSLipidTools();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public interface MassDetector extends MZmineModule {
/**
* Returns mass and intensity values detected in given scan
*/
public DataPoint[] getMassValues(DataPoint[] dp, ParameterSet parameters);

public DataPoint[] getMassValues(Scan scan, ParameterSet parameters);

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@
public class CentroidMassDetector implements MassDetector {

public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
return getMassValues(scan.getDataPoints(), parameters);
}

public DataPoint[] getMassValues(DataPoint dataPoints[], ParameterSet parameters) {

double noiseLevel =
parameters.getParameter(CentroidMassDetectorParameters.noiseLevel).getValue();

ArrayList<DataPoint> mzPeaks = new ArrayList<DataPoint>();

DataPoint dataPoints[] = scan.getDataPoints();

// Find possible mzPeaks
for (int j = 0; j < dataPoints.length; j++) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@

public class ExactMassDetector implements MassDetector {

public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
return getMassValues(scan.getDataPoints(), parameters);
}

/**
* @see net.sf.mzmine.modules.peakpicking.threestep.massdetection.MassDetector#getMassValues(net.sf.mzmine.datamodel.Scan)
*/
public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
public DataPoint[] getMassValues(DataPoint dataPoints[], ParameterSet parameters) {

double noiseLevel = parameters.getParameter(ExactMassDetectorParameters.noiseLevel).getValue();

Expand All @@ -50,7 +54,7 @@ public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
new DataPointSorter(SortingProperty.Intensity, SortingDirection.Descending));

// First get all candidate peaks (local maximum)
getLocalMaxima(scan, candidatePeaks, noiseLevel);
getLocalMaxima(dataPoints, candidatePeaks, noiseLevel);

// We calculate the exact mass for each peak,
// starting with biggest intensity peak and so on
Expand Down Expand Up @@ -83,10 +87,9 @@ public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
* @param scan
* @return
*/
private void getLocalMaxima(Scan scan, TreeSet<ExactMzDataPoint> candidatePeaks,
private void getLocalMaxima(DataPoint scanDataPoints[], TreeSet<ExactMzDataPoint> candidatePeaks,
double noiseLevel) {

DataPoint[] scanDataPoints = scan.getDataPoints();
if (scanDataPoints.length == 0)
return;
DataPoint localMaximum = scanDataPoints[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@
* This class detects all local maxima in a given scan.
*/
public class LocalMaxMassDetector implements MassDetector {

public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
return getMassValues(scan.getDataPoints(), parameters);
}

public DataPoint[] getMassValues(DataPoint dataPoints[], ParameterSet parameters) {

double noiseLevel =
parameters.getParameter(LocalMaxMassDetectorParameters.noiseLevel).getValue();

// List of found mz peaks
ArrayList<DataPoint> mzPeaks = new ArrayList<DataPoint>();

DataPoint dataPoints[] = scan.getDataPoints();

// All data points of current m/z peak

// Top data point of current m/z peak
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
public class RecursiveMassDetector implements MassDetector {

public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
return getMassValues(scan.getDataPoints(), parameters);
}

public DataPoint[] getMassValues(DataPoint dataPoints[], ParameterSet parameters) {

double noiseLevel =
parameters.getParameter(RecursiveMassDetectorParameters.noiseLevel).getValue();
Expand All @@ -42,7 +46,6 @@ public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
double maximumMZPeakWidth =
parameters.getParameter(RecursiveMassDetectorParameters.maximumMZPeakWidth).getValue();

DataPoint dataPoints[] = scan.getDataPoints();
TreeSet<DataPoint> mzPeaks =
new TreeSet<DataPoint>(new DataPointSorter(SortingProperty.MZ, SortingDirection.Ascending));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
* to detect possible peaks in the original raw datapoints.
*/
public class WaveletMassDetector implements MassDetector {

public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
return getMassValues(scan.getDataPoints(), parameters);
}

/**
* Parameters of the wavelet, NPOINTS is the number of wavelet values to use The WAVELET_ESL &
Expand All @@ -47,15 +51,13 @@ public class WaveletMassDetector implements MassDetector {
private static final int WAVELET_ESL = -5;
private static final int WAVELET_ESR = 5;

public DataPoint[] getMassValues(Scan scan, ParameterSet parameters) {
public DataPoint[] getMassValues(DataPoint originalDataPoints[] , ParameterSet parameters) {
double noiseLevel =
parameters.getParameter(WaveletMassDetectorParameters.noiseLevel).getValue();
int scaleLevel = parameters.getParameter(WaveletMassDetectorParameters.scaleLevel).getValue();
double waveletWindow =
parameters.getParameter(WaveletMassDetectorParameters.waveletWindow).getValue();

DataPoint originalDataPoints[] = scan.getDataPoints();

DataPoint waveletDataPoints[] = performCWT(originalDataPoints, waveletWindow, scaleLevel);

DataPoint mzPeaks[] = getMzPeaks(noiseLevel, originalDataPoints, waveletDataPoints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@
import java.awt.Color;
import java.awt.Font;
import java.util.logging.Logger;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.DefaultMutableTreeNode;

import net.sf.mzmine.datamodel.PeakList;
import net.sf.mzmine.datamodel.RawDataFile;
import net.sf.mzmine.main.MZmineCore;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager;
import net.sf.mzmine.parameters.ParameterSet;
import net.sf.mzmine.util.GUIUtils;

/**
Expand All @@ -56,6 +57,8 @@ class SpectraBottomPanel extends JPanel implements TreeModelListener {
private JPanel topPanel, bottomPanel;
private JComboBox<String> msmsSelector;
private JComboBox<PeakList> peakListSelector;
private JCheckBox processingCbx;
private JButton processingParametersBtn ;

private RawDataFile dataFile;
private SpectraVisualizerWindow masterFrame;
Expand Down Expand Up @@ -97,6 +100,19 @@ class SpectraBottomPanel extends JPanel implements TreeModelListener {
peakListSelector.setActionCommand("PEAKLIST_CHANGE");
topPanel.add(peakListSelector);


processingCbx = GUIUtils.addCheckbox(topPanel, "Enable Processing", masterFrame,
"ENABLE_PROCESSING", "Enables quick scan processing.");
processingCbx.setBackground(Color.white);
processingCbx.setFont(smallFont);
updateProcessingCheckbox();

processingParametersBtn = GUIUtils.addButton(topPanel, "Spectra processing", null,
masterFrame, "SET_PROCESSING_PARAMETERS", "Set the parameters for quick spectra processing.");
processingParametersBtn.setBackground(Color.white);
processingParametersBtn.setFont(smallFont);
updateProcessingButton();

topPanel.add(Box.createHorizontalGlue());

JButton nextScanBtn = GUIUtils.addButton(topPanel, rightArrow, null, masterFrame, "NEXT_SCAN");
Expand Down Expand Up @@ -214,4 +230,11 @@ public void treeStructureChanged(TreeModelEvent event) {
rebuildPeakListSelector();
}

public void updateProcessingCheckbox() {
processingCbx.setSelected(DataPointProcessingManager.getInst().isEnabled());
}

public void updateProcessingButton() {
processingParametersBtn.setEnabled(DataPointProcessingManager.getInst().isEnabled());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.block.BlockBorder;
import org.jfree.chart.labels.XYItemLabelGenerator;
import org.jfree.chart.plot.DatasetRenderingOrder;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
Expand All @@ -47,13 +48,15 @@
import net.sf.mzmine.datamodel.MassSpectrumType;
import net.sf.mzmine.datamodel.Scan;
import net.sf.mzmine.main.MZmineCore;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingController;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.DataPointProcessingManager;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datapointprocessing.datamodel.results.DPPResultsDataSet;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.IsotopesDataSet;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.PeakListDataSet;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.ContinuousRenderer;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.PeakRenderer;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.SpectraItemLabelGenerator;
import net.sf.mzmine.modules.visualization.spectra.simplespectra.spectraidentification.SpectraDatabaseSearchLabelGenerator;
import net.sf.mzmine.util.GUIUtils;
import net.sf.mzmine.util.SaveImage;
import net.sf.mzmine.util.SaveImage.FileType;
Expand Down Expand Up @@ -94,7 +97,11 @@ public class SpectraPlot extends EChartPanel {
// increasing even when we remove old data sets
private int numOfDataSets = 0;

public SpectraPlot(ActionListener masterPlot) {
// Spectra processing
DataPointProcessingController controller;
private boolean processingAllowed;

public SpectraPlot(ActionListener masterPlot, boolean processingAllowed) {

super(ChartFactory.createXYLineChart("", // title
"m/z", // x-axis label
Expand Down Expand Up @@ -217,6 +224,13 @@ public SpectraPlot(ActionListener masterPlot) {
ZoomHistory history = getZoomHistory();
if (history != null)
history.clear();

// set processingAllowed
setProcessingAllowed(processingAllowed);
}

public SpectraPlot(ActionListener masterPlot) {
this(masterPlot, false);
}

@Override
Expand Down Expand Up @@ -376,6 +390,12 @@ public void mouseClicked(MouseEvent event) {
}

public synchronized void removeAllDataSets() {

// if the data sets are removed, we have to cancel the tasks.
if (controller != null)
controller.cancelTasks();
controller = null;

for (int i = 0; i < plot.getDatasetCount(); i++) {
plot.setDataset(i, null);
}
Expand Down Expand Up @@ -410,11 +430,13 @@ public synchronized void addDataSet(XYDataset dataSet, Color color, boolean tran
plot.setRenderer(numOfDataSets, newRenderer);
numOfDataSets++;

if (dataSet instanceof ScanDataSet)
checkAndRunController();
}

// add Dataset with label generator
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency,
SpectraDatabaseSearchLabelGenerator labelGenerator) {
XYItemLabelGenerator labelGenerator) {

XYItemRenderer newRenderer;

Expand Down Expand Up @@ -445,6 +467,8 @@ public synchronized void addDataSet(XYDataset dataSet, Color color, boolean tran
plot.setRenderer(numOfDataSets, newRenderer);
numOfDataSets++;

if (dataSet instanceof ScanDataSet)
checkAndRunController();
}


Expand All @@ -457,7 +481,7 @@ public synchronized void removePeakListDataSets() {
}
}

ScanDataSet getMainScanDataSet() {
public ScanDataSet getMainScanDataSet() {
for (int i = 0; i < plot.getDatasetCount(); i++) {
XYDataset dataSet = plot.getDataset(i);
if (dataSet instanceof ScanDataSet) {
Expand All @@ -467,4 +491,50 @@ ScanDataSet getMainScanDataSet() {
return null;
}

/**
* Checks if the spectra processing is enabled & allowed and executes the controller if it is.
* Processing is forbidden for instances of ParameterSetupDialogWithScanPreviews
*/
public void checkAndRunController() {

// if controller != null, processing on the current spectra has already been executed. When
// loading a new spectrum, the controller is set to null in removeAllDataSets()
DataPointProcessingManager inst = DataPointProcessingManager.getInst();

if (!isProcessingAllowed() || !inst.isEnabled())
return;

if(controller != null)
controller = null;

// if a controller is re-run then delete previous results
removeDataPointProcessingResultDataSets();

// if enabled, do the data point processing as set up by the user
XYDataset dataSet = getMainScanDataSet();
if (dataSet instanceof ScanDataSet) {

controller = new DataPointProcessingController(inst.getProcessingQueue(), this,
getMainScanDataSet().getDataPoints());
inst.addController(controller);
}
}

public boolean isProcessingAllowed() {
return processingAllowed;
}

public void setProcessingAllowed(boolean processingAllowed) {
this.processingAllowed = processingAllowed;
}

public void removeDataPointProcessingResultDataSets() {
for (int i = 0; i < plot.getDatasetCount(); i++) {
XYDataset dataSet = plot.getDataset(i);
if (dataSet instanceof DPPResultsDataSet) {
plot.setDataset(i, null);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static SpectraVisualizerWindow showNewSpectrumWindow(RawDataFile dataFile
return null;
}

SpectraVisualizerWindow newWindow = new SpectraVisualizerWindow(dataFile);
SpectraVisualizerWindow newWindow = new SpectraVisualizerWindow(dataFile, true);
newWindow.loadRawData(scan);

if (peak != null)
Expand Down
Loading

0 comments on commit 30505d6

Please sign in to comment.