use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.
the class SpectraVisualizerWindow method loadIsotopes.
public void loadIsotopes(IsotopePattern newPattern) {
// We need to find a normalization factor for the new isotope
// pattern, to show meaningful intensity range
double mz = newPattern.getHighestDataPoint().getMZ();
Range<Double> searchMZRange = Range.closed(mz - 0.5, mz + 0.5);
ScanDataSet scanDataSet = spectrumPlot.getMainScanDataSet();
double normalizationFactor = scanDataSet.getHighestIntensity(searchMZRange);
// whole scan as normalization factor.
if (normalizationFactor == 0) {
searchMZRange = Range.atLeast(0.0);
normalizationFactor = scanDataSet.getHighestIntensity(searchMZRange);
}
IsotopePattern normalizedPattern = IsotopePatternCalculator.normalizeIsotopePattern(newPattern, normalizationFactor);
Color newColor;
if (newPattern.getStatus() == IsotopePatternStatus.DETECTED)
newColor = detectedIsotopesColor;
else
newColor = predictedIsotopesColor;
IsotopesDataSet newDataSet = new IsotopesDataSet(normalizedPattern);
spectrumPlot.addDataSet(newDataSet, newColor, true);
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.
the class SpectraVisualizerWindow method loadRawData.
public void loadRawData(Scan scan) {
logger.finest("Loading scan #" + scan.getScanNumber() + " from " + dataFile + " for spectra visualizer");
spectrumDataSet = new ScanDataSet(scan);
this.currentScan = scan;
// If the plot mode has not been set yet, set it accordingly
if (spectrumPlot.getPlotMode() == null) {
spectrumPlot.setPlotMode(currentScan.getSpectrumType());
toolBar.setCentroidButton(currentScan.getSpectrumType());
}
// Clean up the MS/MS selector combo
final JComboBox<String> msmsSelector = bottomPanel.getMSMSSelector();
// We disable the MSMS selector first and then enable it again later
// after updating the items. If we skip this, the size of the
// selector may not be adjusted properly (timing issues?)
msmsSelector.setEnabled(false);
msmsSelector.removeAllItems();
boolean msmsVisible = false;
// Add parent scan to MS/MS selector combo
NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat();
NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
// Add all fragment scans to MS/MS selector combo
int[] fragmentScans = currentScan.getFragmentScanNumbers();
if (fragmentScans != null) {
for (int fragment : fragmentScans) {
Scan fragmentScan = dataFile.getScan(fragment);
if (fragmentScan == null)
continue;
final String itemText = "Fragment scan #" + fragment + ", RT: " + rtFormat.format(fragmentScan.getRetentionTime()) + ", precursor m/z: " + mzFormat.format(fragmentScan.getPrecursorMZ());
// Updating the combo in other than Swing thread may cause
// exception
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
msmsSelector.addItem(itemText);
}
});
msmsVisible = true;
}
}
msmsSelector.setEnabled(true);
// Update the visibility of MS/MS selection combo
bottomPanel.setMSMSSelectorVisible(msmsVisible);
// Set window and plot titles
String windowTitle = "Spectrum: [" + dataFile.getName() + "; scan #" + currentScan.getScanNumber() + "]";
String spectrumTitle = ScanUtils.scanToString(currentScan, true);
DataPoint basePeak = currentScan.getHighestDataPoint();
if (basePeak != null) {
spectrumTitle += ", base peak: " + mzFormat.format(basePeak.getMZ()) + " m/z (" + intensityFormat.format(basePeak.getIntensity()) + ")";
}
String spectrumSubtitle = null;
if (!Strings.isNullOrEmpty(currentScan.getScanDefinition())) {
spectrumSubtitle = "Scan definition: " + currentScan.getScanDefinition();
}
setTitle(windowTitle);
spectrumPlot.setTitle(spectrumTitle, spectrumSubtitle);
// Set plot data set
spectrumPlot.removeAllDataSets();
spectrumPlot.addDataSet(spectrumDataSet, scanColor, false);
// Reload feature list
bottomPanel.rebuildPeakListSelector();
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.
the class SpectraPlot method addDataSet.
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency) {
XYItemRenderer newRenderer;
if (dataSet instanceof ScanDataSet) {
ScanDataSet scanDataSet = (ScanDataSet) dataSet;
Scan scan = scanDataSet.getScan();
if (scan.getSpectrumType() == MassSpectrumType.CENTROIDED)
newRenderer = new PeakRenderer(color, transparency);
else {
newRenderer = new ContinuousRenderer(color, transparency);
((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
}
// Add label generator for the dataset
SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this);
newRenderer.setDefaultItemLabelGenerator(labelGenerator);
newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
newRenderer.setDefaultItemLabelPaint(labelsColor);
} else {
newRenderer = new PeakRenderer(color, transparency);
}
plot.setDataset(numOfDataSets, dataSet);
plot.setRenderer(numOfDataSets, newRenderer);
numOfDataSets++;
if (dataSet instanceof ScanDataSet)
checkAndRunController();
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.
the class SpectraPlot method checkAndRunController.
/**
* 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) {
Scan scan = ((ScanDataSet) dataSet).getScan();
MSLevel mslevel = inst.decideMSLevel(scan);
controller = new DataPointProcessingController(inst.getProcessingQueue(mslevel), this, getMainScanDataSet().getDataPoints());
inst.addController(controller);
}
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.ScanDataSet in project mzmine2 by mzmine.
the class MassDetectorSetupDialog method loadPreview.
protected void loadPreview(SpectraPlot spectrumPlot, Scan previewScan) {
ScanDataSet spectraDataSet = new ScanDataSet(previewScan);
// Set plot mode only if it hasn't been set before
// if the scan is centroided, switch to centroid mode
spectrumPlot.setPlotMode(previewScan.getSpectrumType());
spectrumPlot.removeAllDataSets();
spectrumPlot.addDataSet(spectraDataSet, SpectraVisualizerWindow.scanColor, false);
// If there is some illegal value, do not load the preview but just exit
ArrayList<String> errorMessages = new ArrayList<String>();
boolean paramsOK = parameterSet.checkParameterValues(errorMessages);
if (!paramsOK)
return;
DataPoint[] mzValues = massDetector.getMassValues(previewScan, parameters);
DataPointsDataSet peaksDataSet = new DataPointsDataSet("Detected peaks", mzValues);
spectrumPlot.addDataSet(peaksDataSet, SpectraVisualizerWindow.peaksColor, false);
}
Aggregations