use of net.sf.mzmine.datamodel.PeakListRow 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;
}
}
use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class PeakResolverSetupDialog method addDialogComponents.
/**
* This function add all the additional components for this dialog over the original
* ParameterSetupDialog.
*/
@Override
protected void addDialogComponents() {
super.addDialogComponents();
final PeakList[] peakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
// Elements of panel.
preview = new JCheckBox("Show preview");
preview.addActionListener(this);
preview.setHorizontalAlignment(SwingConstants.CENTER);
preview.setEnabled(peakLists.length > 0);
// Preview panel.
final JPanel previewPanel = new JPanel(new BorderLayout());
previewPanel.add(new JSeparator(), BorderLayout.NORTH);
previewPanel.add(preview, BorderLayout.CENTER);
previewPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
// Feature list combo-box.
comboPeakList = new JComboBox<PeakList>();
comboPeakList.setFont(COMBO_FONT);
for (final PeakList peakList : peakLists) {
if (peakList.getNumberOfRawDataFiles() == 1) {
comboPeakList.addItem(peakList);
}
}
comboPeakList.addActionListener(this);
// Peaks combo box.
comboPeak = new JComboBox<PeakListRow>();
comboPeak.setFont(COMBO_FONT);
comboPeak.setRenderer(new PeakPreviewComboRenderer());
comboPeak.setPreferredSize(new Dimension(PREFERRED_PEAK_COMBO_WIDTH, comboPeak.getPreferredSize().height));
pnlLabelsFields = GUIUtils.makeTablePanel(2, 2, new JComponent[] { new JLabel("Feature list"), comboPeakList, new JLabel("Chromatogram"), comboPeak });
// Put all together.
pnlVisible = new JPanel(new BorderLayout());
pnlVisible.add(previewPanel, BorderLayout.NORTH);
// TIC plot.
ticPlot = new TICPlot(this);
ticPlot.setMinimumSize(MINIMUM_TIC_DIMENSIONS);
// Tool bar.
final TICToolBar toolBar = new TICToolBar(ticPlot);
toolBar.getComponentAtIndex(0).setVisible(false);
// Panel for XYPlot.
pnlPlotXY = new JPanel(new BorderLayout());
pnlPlotXY.setBackground(Color.white);
pnlPlotXY.add(ticPlot, BorderLayout.CENTER);
pnlPlotXY.add(toolBar, BorderLayout.EAST);
GUIUtils.addMarginAndBorder(pnlPlotXY, 10);
mainPanel.add(pnlVisible, 0, getNumberOfParameters() + 3, 2, 1, 0, 0, GridBagConstraints.HORIZONTAL);
// Layout and position.
updateBounds();
}
use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class ScatterPlotChart method getCustomToolTipComponent.
public JComponent getCustomToolTipComponent(MouseEvent event) {
String index = this.getToolTipText(event);
if (index == null) {
return null;
}
String[] indexSplit = index.split(":");
int series = Integer.parseInt(indexSplit[0]);
int item = Integer.parseInt(indexSplit[1]);
PeakListRow row = mainDataSet.getRow(series, item);
PeakSummaryComponent newSummary = new PeakSummaryComponent(row, peakList.getRawDataFiles(), true, true, true, true, false, ComponentToolTipManager.bg);
double xValue = mainDataSet.getXValue(series, item);
double yValue = mainDataSet.getYValue(series, item);
newSummary.setRatio(xValue, yValue);
return newSummary;
}
use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class ScatterPlotItemLabelGenerator method generateLabel.
/**
* @see org.jfree.chart.labels.XYItemLabelGenerator#generateLabel(org.jfree.data.xy.XYDataset,
* int, int)
*/
public String generateLabel(XYDataset dataSet, int series, int item) {
ScatterPlotDataSet scatterDataSet = (ScatterPlotDataSet) dataSet;
PeakListRow row = scatterDataSet.getRow(series, item);
PeakIdentity identity = row.getPreferredPeakIdentity();
if (identity != null) {
return identity.getName();
} else {
return row.toString();
}
}
use of net.sf.mzmine.datamodel.PeakListRow in project mzmine2 by mzmine.
the class PeakFinderTask method fillList.
public void fillList(boolean masterList) {
for (int i = 0; i < peakList.getNumberOfRawDataFiles(); i++) {
if (i != masterSample) {
RawDataFile datafile1;
RawDataFile datafile2;
if (masterList) {
datafile1 = peakList.getRawDataFile(masterSample);
datafile2 = peakList.getRawDataFile(i);
} else {
datafile1 = peakList.getRawDataFile(i);
datafile2 = peakList.getRawDataFile(masterSample);
}
RegressionInfo info = new RegressionInfo();
for (PeakListRow row : peakList.getRows()) {
Feature peaki = row.getPeak(datafile1);
Feature peake = row.getPeak(datafile2);
if (peaki != null && peake != null) {
info.addData(peake.getRT(), peaki.getRT());
}
}
info.setFunction();
// Canceled?
if (isCanceled()) {
return;
}
Vector<Gap> gaps = new Vector<Gap>();
// if necessary
for (int row = 0; row < peakList.getNumberOfRows(); row++) {
PeakListRow sourceRow = peakList.getRow(row);
PeakListRow newRow = processedPeakList.getRow(row);
Feature sourcePeak = sourceRow.getPeak(datafile1);
if (sourcePeak == null) {
// Create a new gap
double mz = sourceRow.getAverageMZ();
double rt2 = -1;
if (!masterList) {
if (processedPeakList.getRow(row).getPeak(datafile2) != null) {
rt2 = processedPeakList.getRow(row).getPeak(datafile2).getRT();
}
} else {
if (peakList.getRow(row).getPeak(datafile2) != null) {
rt2 = peakList.getRow(row).getPeak(datafile2).getRT();
}
}
if (rt2 > -1) {
double rt = info.predict(rt2);
if (rt != -1) {
Range<Double> mzRange = mzTolerance.getToleranceRange(mz);
Range<Double> rtRange = rtTolerance.getToleranceRange(rt);
Gap newGap = new Gap(newRow, datafile1, mzRange, rtRange, intTolerance);
gaps.add(newGap);
}
}
} else {
newRow.addPeak(datafile1, sourcePeak);
}
}
// Stop processing this file if there are no gaps
if (gaps.size() == 0) {
processedScans.addAndGet(datafile1.getNumOfScans());
continue;
}
// Get all scans of this data file
int[] scanNumbers = datafile1.getScanNumbers(1);
// Process each scan
for (int scanNumber : scanNumbers) {
// Canceled?
if (isCanceled()) {
return;
}
// Get the scan
Scan scan = datafile1.getScan(scanNumber);
// Feed this scan to all gaps
for (Gap gap : gaps) {
gap.offerNextScan(scan);
}
processedScans.incrementAndGet();
}
// Finalize gaps
for (Gap gap : gaps) {
gap.noMoreOffers();
}
}
}
}
Aggregations