Search in sources :

Example 1 with ChromatogramTICDataSet

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;
    }
}
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)

Aggregations

JComboBox (javax.swing.JComboBox)1 JFormattedTextField (javax.swing.JFormattedTextField)1 DataPoint (net.sf.mzmine.datamodel.DataPoint)1 Feature (net.sf.mzmine.datamodel.Feature)1 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)1 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1 ChromatogramTICDataSet (net.sf.mzmine.modules.peaklistmethods.peakpicking.deconvolution.ChromatogramTICDataSet)1 PeakDataSet (net.sf.mzmine.modules.visualization.tic.PeakDataSet)1