Search in sources :

Example 41 with SimpleDataPoint

use of net.sf.mzmine.datamodel.impl.SimpleDataPoint in project mzmine2 by mzmine.

the class AgilentCsvReadTask method run.

/**
 * Reads the file.
 */
public void run() {
    setStatus(TaskStatus.PROCESSING);
    Scanner scanner;
    try {
        scanner = new Scanner(this.file);
        this.dataSource = this.getMetaData(scanner, "file name");
        String[] range = this.getMetaData(scanner, "mass range").split(",");
        newMZmineFile.setMZRange(1, Range.closed(Double.parseDouble(range[0]), Double.parseDouble(range[1])));
        range = this.getMetaData(scanner, "time range").split(",");
        newMZmineFile.setRTRange(1, Range.closed(Double.parseDouble(range[0]), Double.parseDouble(range[1])));
        totalScans = Integer.parseInt(this.getMetaData(scanner, "number of spectra"));
        // advance to the spectrum data...
        while (!scanner.nextLine().trim().equals("[spectra]")) {
        }
        scanner.useDelimiter(",");
        for (parsedScans = 0; parsedScans < totalScans; parsedScans++) {
            if (isCanceled()) {
                return;
            }
            // if the task is canceled.
            double retentionTime = scanner.nextDouble();
            // not sure about this value
            int msLevel = scanner.nextInt();
            scanner.next();
            scanner.next();
            int charge = (scanner.next().equals("+") ? 1 : -1);
            scanner.next();
            int spectrumSize = scanner.nextInt();
            DataPoint[] dataPoints = new DataPoint[spectrumSize];
            for (int j = 0; j < spectrumSize; j++) {
                dataPoints[j] = new SimpleDataPoint(scanner.nextDouble(), scanner.nextDouble());
            }
            newMZmineFile.addScan(new SimpleScan(null, parsedScans + 1, msLevel, retentionTime, 0.0, charge, null, dataPoints, ScanUtils.detectSpectrumType(dataPoints), PolarityType.UNKNOWN, "", null));
            scanner.nextLine();
        }
        finalRawDataFile = newMZmineFile.finishWriting();
        project.addFile(finalRawDataFile);
    } catch (Exception e) {
        setErrorMessage(e.getMessage());
        this.setStatus(TaskStatus.ERROR);
        return;
    }
    this.setStatus(TaskStatus.FINISHED);
}
Also used : Scanner(java.util.Scanner) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) SimpleScan(net.sf.mzmine.datamodel.impl.SimpleScan) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Example 42 with SimpleDataPoint

use of net.sf.mzmine.datamodel.impl.SimpleDataPoint in project mzmine2 by mzmine.

the class WaveletMassDetector method getMzPeaks.

/**
 * This function searches for maximums from wavelet data points
 */
private DataPoint[] getMzPeaks(double noiseLevel, DataPoint[] originalDataPoints, DataPoint[] waveletDataPoints) {
    TreeSet<DataPoint> mzPeaks = new TreeSet<DataPoint>(new DataPointSorter(SortingProperty.MZ, SortingDirection.Ascending));
    Vector<DataPoint> rawDataPoints = new Vector<DataPoint>();
    int peakMaxInd = 0;
    int stopInd = waveletDataPoints.length - 1;
    for (int ind = 0; ind <= stopInd; ind++) {
        while ((ind <= stopInd) && (waveletDataPoints[ind].getIntensity() == 0)) {
            ind++;
        }
        peakMaxInd = ind;
        if (ind >= stopInd) {
            break;
        }
        // While peak is on
        while ((ind <= stopInd) && (waveletDataPoints[ind].getIntensity() > 0)) {
            // Check if this is the maximum point of the peak
            if (waveletDataPoints[ind].getIntensity() > waveletDataPoints[peakMaxInd].getIntensity()) {
                peakMaxInd = ind;
            }
            rawDataPoints.add(originalDataPoints[ind]);
            ind++;
        }
        if (ind >= stopInd) {
            break;
        }
        rawDataPoints.add(originalDataPoints[ind]);
        if (originalDataPoints[peakMaxInd].getIntensity() > noiseLevel) {
            SimpleDataPoint peakDataPoint = new SimpleDataPoint(originalDataPoints[peakMaxInd].getMZ(), calcAproxIntensity(rawDataPoints));
            mzPeaks.add(peakDataPoint);
        }
        rawDataPoints.clear();
    }
    return mzPeaks.toArray(new DataPoint[0]);
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) TreeSet(java.util.TreeSet) DataPointSorter(net.sf.mzmine.util.DataPointSorter) Vector(java.util.Vector) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 43 with SimpleDataPoint

use of net.sf.mzmine.datamodel.impl.SimpleDataPoint in project mzmine2 by mzmine.

the class GridMassTask method addMaxDatumFromScans.

int addMaxDatumFromScans(SpotByProbes s, Chromatogram peak) {
    int i, j;
    int adds = 0;
    for (i = s.minScan; i <= s.maxScan; i++) {
        Datum[] di = roi[i];
        if (di != null && di.length > 0) {
            Datum max = new Datum(new SimpleDataPoint(0, -1), 0, new SimpleDataPoint(0, -1));
            int idx = findFirstMass(s.minMZ, di);
            for (j = idx; j < di.length && di[j].mz <= s.maxMZ; j++) {
                Datum d = di[j];
                if (d.spotId == s.spotId) {
                    if (d.intensity > max.intensity && d.mz >= s.minMZ && d.intensity > minimumHeight) {
                        max = d;
                    }
                }
            }
            if (max.intensity > 0) {
                adds++;
                peak.addMzPeak(scans[i].getScanNumber(), new SimpleDataPoint(max.mzOriginal, max.intensityOriginal));
            }
        }
    }
    return adds;
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Example 44 with SimpleDataPoint

use of net.sf.mzmine.datamodel.impl.SimpleDataPoint in project mzmine2 by mzmine.

the class TwoDDataSet method getCentroidedDataPointsInRTMZRange.

// Sets the private list to contain the rt values for each data point scan of scans that fall in
// the user
// range. returns an array of the data points but not the rt.
ArrayList getCentroidedDataPointsInRTMZRange(Range<Double> rtRange, Range<Double> mzRange) {
    ArrayList<DataPoint> dataPointsInRanges = new ArrayList<DataPoint>();
    ArrayList rtInRange = new ArrayList();
    curMaxIntensity = 0.0;
    double[] searchRetentionTimes = retentionTimes;
    if (processedScans < totalScans) {
        searchRetentionTimes = new double[processedScans];
        System.arraycopy(retentionTimes, 0, searchRetentionTimes, 0, searchRetentionTimes.length);
    }
    // Find the rt of the scan at the bottom of our rtRange
    int startScanIndex = Arrays.binarySearch(searchRetentionTimes, rtRange.lowerEndpoint());
    // a couple of checks
    if (startScanIndex < 0) {
        startScanIndex = (startScanIndex * -1) - 1;
    }
    if (startScanIndex >= searchRetentionTimes.length) {
        startScanIndex = 0;
    }
    for (int scanIndex = startScanIndex; ((scanIndex < searchRetentionTimes.length) && (searchRetentionTimes[scanIndex] <= rtRange.upperEndpoint())); scanIndex++) {
        // get the list of data points
        DataPoint[] dataPoints = dataPointMatrix[scanIndex].get();
        // Binary search for the mz values in the range you want
        DataPoint searchMZ = new SimpleDataPoint(mzRange.lowerEndpoint(), 0);
        int startMZIndex = Arrays.binarySearch(dataPoints, searchMZ, new DataPointSorter(SortingProperty.MZ, SortingDirection.Ascending));
        if (startMZIndex < 0)
            startMZIndex = (startMZIndex * -1) - 1;
        if (startMZIndex >= dataPoints.length)
            startMZIndex = 0;
        for (int mzIndex = startMZIndex; ((mzIndex < dataPoints.length) && (dataPoints[mzIndex].getMZ() <= mzRange.upperEndpoint())); mzIndex++) {
            DataPoint curFoundDataPoint;
            curFoundDataPoint = dataPoints[mzIndex];
            // System.out.println("curFoundDataPoint.getMZ()");
            // System.out.println(curFoundDataPoint.getMZ());
            dataPointsInRanges.add(curFoundDataPoint);
            Double toAddRt = new Double(searchRetentionTimes[scanIndex]);
            rtInRange.add(toAddRt);
            double curIntensity = curFoundDataPoint.getIntensity();
            if (curIntensity > curMaxIntensity)
                curMaxIntensity = curIntensity;
        }
    }
    rtValuesInUserRange = rtInRange;
    return dataPointsInRanges;
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) ArrayList(java.util.ArrayList) DataPointSorter(net.sf.mzmine.util.DataPointSorter) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Example 45 with SimpleDataPoint

use of net.sf.mzmine.datamodel.impl.SimpleDataPoint in project mzmine2 by mzmine.

the class TwoDDataSet method upperEndpointIntensity.

private double upperEndpointIntensity(DataPoint[] dataPoints, Range<Double> mzRange, PlotMode plotMode) {
    double maxIntensity = 0;
    DataPoint searchMZ = new SimpleDataPoint(mzRange.lowerEndpoint(), 0);
    int startMZIndex = Arrays.binarySearch(dataPoints, searchMZ, new DataPointSorter(SortingProperty.MZ, SortingDirection.Ascending));
    if (startMZIndex < 0)
        startMZIndex = (startMZIndex * -1) - 1;
    if (startMZIndex >= dataPoints.length)
        return 0;
    if (dataPoints[startMZIndex].getMZ() > mzRange.upperEndpoint()) {
        if (plotMode != PlotMode.CENTROID) {
            if (startMZIndex == 0)
                return 0;
            if (startMZIndex == dataPoints.length - 1)
                return dataPoints[startMZIndex - 1].getIntensity();
            // find which data point is closer
            double diffNext = dataPoints[startMZIndex].getMZ() - mzRange.upperEndpoint();
            double diffPrev = mzRange.lowerEndpoint() - dataPoints[startMZIndex - 1].getMZ();
            if (diffPrev < diffNext)
                return dataPoints[startMZIndex - 1].getIntensity();
            else
                return dataPoints[startMZIndex].getIntensity();
        } else {
            return 0;
        }
    }
    for (int mzIndex = startMZIndex; ((mzIndex < dataPoints.length) && (dataPoints[mzIndex].getMZ() <= mzRange.upperEndpoint())); mzIndex++) {
        if (dataPoints[mzIndex].getIntensity() > maxIntensity)
            maxIntensity = dataPoints[mzIndex].getIntensity();
    }
    return maxIntensity;
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPointSorter(net.sf.mzmine.util.DataPointSorter) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Aggregations

SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)58 DataPoint (net.sf.mzmine.datamodel.DataPoint)56 Scan (net.sf.mzmine.datamodel.Scan)15 ArrayList (java.util.ArrayList)13 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)13 SimpleScan (net.sf.mzmine.datamodel.impl.SimpleScan)12 IOException (java.io.IOException)11 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)10 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)10 Feature (net.sf.mzmine.datamodel.Feature)8 HashMap (java.util.HashMap)7 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)7 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)6 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)6 SimplePeakIdentity (net.sf.mzmine.datamodel.impl.SimplePeakIdentity)5 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)5 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 DataInputStream (java.io.DataInputStream)4 Vector (java.util.Vector)4