use of net.sf.mzmine.modules.peaklistmethods.peakpicking.deconvolution.ChromatogramTICDataSet in project mzmine2 by mzmine.
the class ShapeModelerSetupDialog method loadPreviewPeak.
private void loadPreviewPeak() {
PeakListRow previewRow = (PeakListRow) comboPeak.getSelectedItem();
if (previewRow == null)
return;
logger.finest("Loading new preview peak " + previewRow);
Feature previewPeak = previewRow.getPeaks()[0];
ticPlot.removeAllTICDataSets();
// Load the intensities into array
RawDataFile dataFile = previewPeak.getDataFile();
int[] scanNumbers = previewPeak.getScanNumbers();
double[] retentionTimes = new double[scanNumbers.length];
for (int i = 0; i < scanNumbers.length; i++) retentionTimes[i] = dataFile.getScan(scanNumbers[i]).getRetentionTime();
double[] intensities = new double[scanNumbers.length];
for (int i = 0; i < scanNumbers.length; i++) {
DataPoint dp = previewPeak.getDataPoint(scanNumbers[i]);
if (dp != null)
intensities[i] = dp.getIntensity();
else
intensities[i] = 0;
}
// Create shape model
updateParameterSetFromComponents();
JComboBox<?> component = (JComboBox<?>) getComponentForParameter(ShapeModelerParameters.shapeModelerType);
ShapeModel model = (ShapeModel) component.getSelectedItem();
JFormattedTextField resolutionField = (JFormattedTextField) getComponentForParameter(ShapeModelerParameters.massResolution);
double resolution = ((Number) resolutionField.getValue()).doubleValue();
try {
Class<?> shapeModelClass = model.getModelClass();
Constructor<?> shapeModelConstruct = shapeModelClass.getConstructors()[0];
// shapePeakModel(ChromatographicPeak originalDetectedShape, int[]
// scanNumbers,
// double[] intensities, double[] retentionTimes, double resolution)
Feature shapePeak = (Feature) shapeModelConstruct.newInstance(previewPeak, scanNumbers, intensities, retentionTimes, resolution);
PeakDataSet peakDataSet = new PeakDataSet(shapePeak);
ticPlot.addPeakDataset(peakDataSet);
ticDataset = new ChromatogramTICDataSet(previewRow.getPeaks()[0]);
ticPlot.addTICDataset(ticDataset);
// Set auto range to axes
ticPlot.getXYPlot().getDomainAxis().setAutoRange(true);
ticPlot.getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
ticPlot.getXYPlot().getRangeAxis().setAutoRange(true);
ticPlot.getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
} catch (Exception e) {
String message = "Error trying to make an instance of Peak Builder " + model;
MZmineCore.getDesktop().displayErrorMessage(this, message);
logger.severe(message);
e.printStackTrace();
return;
}
}
Aggregations