Search in sources :

Example 26 with PeakListRow

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;
    }
}
Also used : PeakDataSet(net.sf.mzmine.modules.visualization.tic.PeakDataSet) JComboBox(javax.swing.JComboBox) JFormattedTextField(javax.swing.JFormattedTextField) ChromatogramTICDataSet(net.sf.mzmine.modules.peaklistmethods.peakpicking.deconvolution.ChromatogramTICDataSet) Feature(net.sf.mzmine.datamodel.Feature) DataPoint(net.sf.mzmine.datamodel.DataPoint) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 27 with PeakListRow

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();
}
Also used : JPanel(javax.swing.JPanel) TICToolBar(net.sf.mzmine.modules.visualization.tic.TICToolBar) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JSeparator(javax.swing.JSeparator) JCheckBox(javax.swing.JCheckBox) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) BorderLayout(java.awt.BorderLayout) PeakList(net.sf.mzmine.datamodel.PeakList) TICPlot(net.sf.mzmine.modules.visualization.tic.TICPlot)

Example 28 with PeakListRow

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;
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) PeakSummaryComponent(net.sf.mzmine.util.components.PeakSummaryComponent)

Example 29 with PeakListRow

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();
    }
}
Also used : PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) PeakListRow(net.sf.mzmine.datamodel.PeakListRow)

Example 30 with PeakListRow

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();
            }
        }
    }
}
Also used : Feature(net.sf.mzmine.datamodel.Feature) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) Vector(java.util.Vector)

Aggregations

PeakListRow (net.sf.mzmine.datamodel.PeakListRow)148 Feature (net.sf.mzmine.datamodel.Feature)71 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)55 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)54 PeakList (net.sf.mzmine.datamodel.PeakList)44 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)39 ArrayList (java.util.ArrayList)31 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)31 DataPoint (net.sf.mzmine.datamodel.DataPoint)29 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)26 Scan (net.sf.mzmine.datamodel.Scan)25 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)20 PeakListRowSorter (net.sf.mzmine.util.PeakListRowSorter)17 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)13 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)12 HashMap (java.util.HashMap)11 Vector (java.util.Vector)11 ParameterSet (net.sf.mzmine.parameters.ParameterSet)11 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)10 MassList (net.sf.mzmine.datamodel.MassList)10