Search in sources :

Example 91 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class TwoDDataSet method run.

@Override
public void run() {
    status = TaskStatus.PROCESSING;
    for (int index = 0; index < totalScans; index++) {
        // Cancel?
        if (status == TaskStatus.CANCELED)
            return;
        Scan scan = scans[index];
        DataPoint scanBasePeak = scan.getHighestDataPoint();
        retentionTimes[index] = scan.getRetentionTime();
        basePeaks[index] = (scanBasePeak == null ? 0 : scanBasePeak.getIntensity());
        DataPoint[] scanDataPoints = scan.getDataPoints();
        dataPointMatrix[index] = new SoftReference<DataPoint[]>(scanDataPoints);
        processedScans++;
    }
    fireDatasetChanged();
    status = TaskStatus.FINISHED;
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) Scan(net.sf.mzmine.datamodel.Scan) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Example 92 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class ParameterSetupDialogWithScanPreview method updateTitle.

private void updateTitle(Scan currentScan) {
    // Formats
    NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat();
    NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
    NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
    // Set window and plot titles
    String title = "[" + previewDataFile.getName() + "] scan #" + currentScan.getScanNumber();
    String subTitle = "MS" + currentScan.getMSLevel() + ", RT " + rtFormat.format(currentScan.getRetentionTime());
    DataPoint basePeak = currentScan.getHighestDataPoint();
    if (basePeak != null) {
        subTitle += ", base peak: " + mzFormat.format(basePeak.getMZ()) + " m/z (" + intensityFormat.format(basePeak.getIntensity()) + ")";
    }
    spectrumPlot.setTitle(title, subTitle);
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) NumberFormat(java.text.NumberFormat)

Example 93 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class CombinedXICComponent method paint.

public void paint(Graphics g) {
    super.paint(g);
    // use Graphics2D for antialiasing
    Graphics2D g2 = (Graphics2D) g;
    // turn on antialiasing
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    // get canvas size
    Dimension size = getSize();
    int colorIndex = 0;
    for (Feature peak : peaks) {
        // set color for current XIC
        g2.setColor(plotColors[colorIndex]);
        colorIndex = (colorIndex + 1) % plotColors.length;
        // if we have no data, just return
        if ((peak == null) || (peak.getScanNumbers().length == 0))
            continue;
        // get scan numbers, one data point per each scan
        int[] scanNumbers = peak.getScanNumbers();
        // for each datapoint, find [X:Y] coordinates of its point in
        // painted image
        int[] xValues = new int[scanNumbers.length + 2];
        int[] yValues = new int[scanNumbers.length + 2];
        // find one datapoint with maximum intensity in each scan
        for (int i = 0; i < scanNumbers.length; i++) {
            double dataPointIntensity = 0;
            DataPoint dataPoint = peak.getDataPoint(scanNumbers[i]);
            if (dataPoint != null)
                dataPointIntensity = dataPoint.getIntensity();
            // get retention time (X value)
            double retentionTime = peak.getDataFile().getScan(scanNumbers[i]).getRetentionTime();
            // calculate [X:Y] coordinates
            xValues[i + 1] = (int) Math.floor((retentionTime - rtRange.lowerEndpoint()) / (rtRange.upperEndpoint() - rtRange.lowerEndpoint()) * (size.width - 1));
            yValues[i + 1] = size.height - (int) Math.floor(dataPointIntensity / maxIntensity * (size.height - 1));
        }
        // add first point
        xValues[0] = xValues[1];
        yValues[0] = size.height - 1;
        // add terminal point
        xValues[xValues.length - 1] = xValues[xValues.length - 2];
        yValues[yValues.length - 1] = size.height - 1;
        // draw the peak shape
        g2.drawPolyline(xValues, yValues, xValues.length);
    }
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) Dimension(java.awt.Dimension) Feature(net.sf.mzmine.datamodel.Feature) DataPoint(net.sf.mzmine.datamodel.DataPoint) Graphics2D(java.awt.Graphics2D)

Example 94 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class ScanUtils method decodeDataPointsFromBytes.

public static DataPoint[] decodeDataPointsFromBytes(byte[] bytes) {
    // each double is 8 bytes and we need one for m/z and one for intensity
    int dpCount = bytes.length / 2 / 8;
    // make a data input stream
    ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);
    DataInputStream peakStream = new DataInputStream(byteStream);
    DataPoint[] dataPoints = new DataPoint[dpCount];
    for (int i = 0; i < dataPoints.length; i++) {
        try {
            double mz = peakStream.readDouble();
            double intensity = peakStream.readDouble();
            dataPoints[i] = new SimpleDataPoint(mz, intensity);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return dataPoints;
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) ByteArrayInputStream(java.io.ByteArrayInputStream) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Example 95 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class ScanUtils method listAllScans.

/**
 * List of all scans with n signals >= noiseLevel in the specified or first massList, if none was
 * specified
 *
 * @param massListName the name or null/empty to always use the first masslist
 * @param noiseLevel
 * @param minNumberOfSignals
 * @return
 */
@Nonnull
public static List<Scan> listAllScans(Scan[] scans, @Nullable String massListName, double noiseLevel, int minNumberOfSignals) throws MissingMassListException {
    List<Scan> filtered = new ArrayList<>();
    for (Scan scan : scans) {
        // find mass list: with name or first
        final MassList massList = getMassListOrFirst(scan, massListName);
        if (massList == null)
            throw new MissingMassListException("", massListName);
        // minimum number of signals >= noiseLevel
        int signals = 0;
        for (DataPoint dp : massList.getDataPoints()) if (dp.getIntensity() >= noiseLevel)
            signals++;
        if (signals >= minNumberOfSignals)
            filtered.add(scan);
    }
    return filtered;
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) ArrayList(java.util.ArrayList) Scan(net.sf.mzmine.datamodel.Scan) MassList(net.sf.mzmine.datamodel.MassList) MissingMassListException(net.sf.mzmine.util.exceptions.MissingMassListException) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) Nonnull(javax.annotation.Nonnull)

Aggregations

DataPoint (net.sf.mzmine.datamodel.DataPoint)214 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)98 Scan (net.sf.mzmine.datamodel.Scan)64 ArrayList (java.util.ArrayList)50 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)44 Feature (net.sf.mzmine.datamodel.Feature)27 MassList (net.sf.mzmine.datamodel.MassList)24 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)22 IOException (java.io.IOException)20 SimpleScan (net.sf.mzmine.datamodel.impl.SimpleScan)18 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)17 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)16 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)15 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)15 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)12 DataPointSorter (net.sf.mzmine.util.DataPointSorter)12 HashMap (java.util.HashMap)10 Vector (java.util.Vector)10 Range (com.google.common.collect.Range)8 TreeMap (java.util.TreeMap)8