use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet in project mzmine2 by mzmine.
the class ScanSelectPanel method createChart.
/**
* Create chart of selected scan
*/
public void createChart() {
setValidSelection(false);
pnChart.removeAll();
if (scans != null && !scans.isEmpty()) {
if (spectrumPlot == null) {
spectrumPlot = new SpectraPlot(this, false);
if (listener != null)
// chart has changed
listener.accept(spectrumPlot);
}
spectrumPlot.removeAllDataSets();
DataPointsDataSet data = new DataPointsDataSet("Data", getFilteredDataPoints());
// green
spectrumPlot.addDataSet(data, colorUsedData, false);
if (showRemovedData) {
// orange
DataPointsDataSet dataRemoved = new DataPointsDataSet("Removed", getFilteredDataPointsRemoved());
spectrumPlot.addDataSet(dataRemoved, colorRemovedData, false);
}
spectrumPlot.getChart().getLegend().setVisible(showLegend);
spectrumPlot.setMaximumSize(new Dimension(chartSize.width, 10000));
spectrumPlot.setPreferredSize(chartSize);
pnChart.add(spectrumPlot, BorderLayout.CENTER);
Scan scan = scans.get(selectedScanI);
analyzeScan(scan);
applySelectionState();
setValidSelection(true);
} else {
// add error label
JLabel error = new JLabel(MessageFormat.format("NO MS2 SPECTRA: 0 of {0} match the minimum criteria", getTotalScans()));
error.setFont(new Font("Tahoma", Font.BOLD, 13));
error.setHorizontalAlignment(SwingConstants.CENTER);
error.setForeground(new Color(220, 20, 60));
pnChart.add(error, BorderLayout.CENTER);
//
}
// set next and prev button enabled
btnPrev.setEnabled(selectedScanI - 1 >= 0);
btnNext.setEnabled(scans != null && selectedScanI + 1 < scans.size());
revalidate();
repaint();
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet in project mzmine2 by mzmine.
the class SpectraIdentificationLipidSearchTask method run.
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
// create mass list for scan
DataPoint[] massList = null;
ArrayList<DataPoint> massListAnnotated = new ArrayList<>();
MassDetector massDetector = null;
ArrayList<String> allCompoundIDs = new ArrayList<>();
// Create a new mass list for MS/MS scan. Check if sprectrum is profile or centroid mode
if (currentScan.getSpectrumType() == MassSpectrumType.CENTROIDED) {
massDetector = new CentroidMassDetector();
CentroidMassDetectorParameters parameters = new CentroidMassDetectorParameters();
CentroidMassDetectorParameters.noiseLevel.setValue(noiseLevel);
massList = massDetector.getMassValues(currentScan.getDataPoints(), parameters);
} else {
massDetector = new ExactMassDetector();
ExactMassDetectorParameters parameters = new ExactMassDetectorParameters();
ExactMassDetectorParameters.noiseLevel.setValue(noiseLevel);
massList = massDetector.getMassValues(currentScan.getDataPoints(), parameters);
}
totalSteps = massList.length;
// loop through every peak in mass list
if (getStatus() != TaskStatus.PROCESSING) {
return;
}
// Check if lipids should be modified
if (searchForModifications == true) {
lipidModificationMasses = getLipidModificationMasses(lipidModification);
}
// Calculate how many possible lipids we will try
totalSteps = (((maxChainLength - minChainLength + 1) * (maxDoubleBonds - minDoubleBonds + 1)) * selectedLipids.length);
// Combine Strings
String annotation = "";
// Try all combinations of fatty acid lengths and double bonds
for (int j = 0; j < selectedLipids.length; j++) {
int numberOfAcylChains = selectedLipids[j].getNumberOfAcylChains();
int numberOfAlkylChains = selectedLipids[j].getNumberofAlkyChains();
for (int chainLength = minChainLength; chainLength <= maxChainLength; chainLength++) {
for (int chainDoubleBonds = minDoubleBonds; chainDoubleBonds <= maxDoubleBonds; chainDoubleBonds++) {
for (int i = 0; i < massList.length; i++) {
searchedMass = massList[i].getMZ();
// Task canceled?
if (isCanceled())
return;
// than minimal length, skip this lipid
if (((chainLength > 0) && (chainLength < minChainLength))) {
continue;
}
// doesn't make sense, so let's skip such lipids
if (((chainDoubleBonds > 0) && (chainDoubleBonds > chainLength - 1))) {
continue;
}
// Prepare a lipid instance
LipidIdentity lipidChain = new LipidIdentity(selectedLipids[j], chainLength, chainDoubleBonds, numberOfAcylChains, numberOfAlkylChains);
annotation = findPossibleLipid(lipidChain, searchedMass);
if (annotation != "") {
allCompoundIDs.add(annotation);
massListAnnotated.add(massList[i]);
}
annotation = findPossibleLipidModification(lipidChain, searchedMass);
if (annotation != "") {
allCompoundIDs.add(annotation);
massListAnnotated.add(massList[i]);
}
}
finishedSteps++;
}
}
}
// new mass list
DataPoint[] annotatedMassList = new DataPoint[massListAnnotated.size()];
massListAnnotated.toArray(annotatedMassList);
String[] annotations = new String[annotatedMassList.length];
allCompoundIDs.toArray(annotations);
DataPointsDataSet detectedCompoundsDataset = new DataPointsDataSet("Detected compounds", annotatedMassList);
// Add label generator for the dataset
SpectraDatabaseSearchLabelGenerator labelGenerator = new SpectraDatabaseSearchLabelGenerator(annotations, spectraPlot);
spectraPlot.addDataSet(detectedCompoundsDataset, Color.orange, true, labelGenerator);
spectraPlot.getXYPlot().getRenderer().setSeriesItemLabelGenerator(spectraPlot.getXYPlot().getSeriesCount(), labelGenerator);
spectraPlot.getXYPlot().getRenderer().setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.TOP_LEFT, TextAnchor.BOTTOM_CENTER, 0.0), true);
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet in project mzmine2 by mzmine.
the class ShoulderPeaksFilterSetupDialog method loadPreview.
/**
* This function set all the information into the plot chart
*
* @param scanNumber
*/
protected void loadPreview(SpectraPlot spectrumPlot, Scan previewScan) {
// Remove previous data sets
spectrumPlot.removeAllDataSets();
// Add scan data set
ScanDataSet scanDataSet = new ScanDataSet(previewScan);
spectrumPlot.addDataSet(scanDataSet, SpectraVisualizerWindow.scanColor, false);
// If the scan is centroided, switch to centroid mode
spectrumPlot.setPlotMode(previewScan.getSpectrumType());
// If the parameters are not complete, exit
ArrayList<String> errors = new ArrayList<String>();
boolean paramsOK = parameters.checkParameterValues(errors);
if (!paramsOK)
return;
// Get mass list
String massListName = parameters.getParameter(ShoulderPeaksFilterParameters.massList).getValue();
MassList massList = previewScan.getMassList(massListName);
if (massList == null)
return;
// Perform filtering
DataPoint[] mzValues = massList.getDataPoints();
DataPoint[] remainingMzValues = ShoulderPeaksFilter.filterMassValues(mzValues, parameters);
Vector<DataPoint> removedPeaks = new Vector<DataPoint>();
removedPeaks.addAll(Arrays.asList(mzValues));
removedPeaks.removeAll(Arrays.asList(remainingMzValues));
DataPoint[] removedMzValues = removedPeaks.toArray(new DataPoint[0]);
// Add mass list data sets
DataPointsDataSet removedPeaksDataSet = new DataPointsDataSet("Removed peaks", removedMzValues);
DataPointsDataSet remainingPeaksDataSet = new DataPointsDataSet("Remaining peaks", remainingMzValues);
spectrumPlot.addDataSet(removedPeaksDataSet, removedPeaksColor, false);
spectrumPlot.addDataSet(remainingPeaksDataSet, SpectraVisualizerWindow.peaksColor, false);
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet 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);
}
use of net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet in project mzmine2 by mzmine.
the class SpectraIdentificationOnlineDatabaseTask method run.
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
// create mass list for scan
DataPoint[] massList = null;
ArrayList<DataPoint> massListAnnotated = new ArrayList<>();
MassDetector massDetector = null;
ArrayList<String> allCompoundIDs = new ArrayList<>();
// Create a new mass list for MS/MS scan. Check if sprectrum is profile or centroid mode
if (currentScan.getSpectrumType() == MassSpectrumType.CENTROIDED) {
massDetector = new CentroidMassDetector();
CentroidMassDetectorParameters parameters = new CentroidMassDetectorParameters();
CentroidMassDetectorParameters.noiseLevel.setValue(noiseLevel);
massList = massDetector.getMassValues(currentScan.getDataPoints(), parameters);
} else {
massDetector = new ExactMassDetector();
ExactMassDetectorParameters parameters = new ExactMassDetectorParameters();
ExactMassDetectorParameters.noiseLevel.setValue(noiseLevel);
massList = massDetector.getMassValues(currentScan.getDataPoints(), parameters);
}
numItems = massList.length;
for (int i = 0; i < massList.length; i++) {
// loop through every peak in mass list
if (getStatus() != TaskStatus.PROCESSING) {
return;
}
searchedMass = massList[i].getMZ() - ionType.getAddedMass();
try {
// find candidate compounds
String[] compoundIDs = gateway.findCompounds(searchedMass, mzTolerance, 1, db.getParameterSet());
// Combine strings
String annotation = "";
// max number of compounds to top three for visualization
int counter = 0;
for (int j = 0; !isCanceled() && j < compoundIDs.length; j++) {
final DBCompound compound = gateway.getCompound(compoundIDs[j], db.getParameterSet());
// In case we failed to retrieve data, skip this compound
if (compound == null)
continue;
if (counter < 3) {
int number = counter + 1;
annotation = annotation + " " + number + ". " + compound.getName();
counter++;
}
}
if (annotation != "") {
allCompoundIDs.add(annotation);
massListAnnotated.add(massList[i]);
}
} catch (Exception e) {
e.printStackTrace();
logger.log(Level.WARNING, "Could not connect to " + db, e);
setStatus(TaskStatus.ERROR);
setErrorMessage("Could not connect to " + db + ": " + ExceptionUtils.exceptionToString(e));
return;
}
finishedItems++;
}
// new mass list
DataPoint[] annotatedMassList = new DataPoint[massListAnnotated.size()];
massListAnnotated.toArray(annotatedMassList);
String[] annotations = new String[annotatedMassList.length];
allCompoundIDs.toArray(annotations);
DataPointsDataSet detectedCompoundsDataset = new DataPointsDataSet("Detected compounds", annotatedMassList);
// Add label generator for the dataset
SpectraDatabaseSearchLabelGenerator labelGenerator = new SpectraDatabaseSearchLabelGenerator(annotations, spectraPlot);
spectraPlot.addDataSet(detectedCompoundsDataset, Color.orange, true, labelGenerator);
spectraPlot.getXYPlot().getRenderer().setSeriesItemLabelGenerator(spectraPlot.getXYPlot().getSeriesCount(), labelGenerator);
spectraPlot.getXYPlot().getRenderer().setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.TOP_LEFT, TextAnchor.BOTTOM_CENTER, 0.0), true);
setStatus(TaskStatus.FINISHED);
}
Aggregations