Search in sources :

Example 11 with DataPointSorter

use of net.sf.mzmine.util.DataPointSorter 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 12 with DataPointSorter

use of net.sf.mzmine.util.DataPointSorter 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

DataPointSorter (net.sf.mzmine.util.DataPointSorter)12 DataPoint (net.sf.mzmine.datamodel.DataPoint)11 TreeSet (java.util.TreeSet)4 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)4 ArrayList (java.util.ArrayList)3 LinkedHashSet (java.util.LinkedHashSet)2 MZTolerance (net.sf.mzmine.parameters.parametertypes.tolerances.MZTolerance)2 Range (com.google.common.collect.Range)1 Vector (java.util.Vector)1 Feature (net.sf.mzmine.datamodel.Feature)1 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1 MassList (net.sf.mzmine.datamodel.MassList)1 Scan (net.sf.mzmine.datamodel.Scan)1 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)1 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)1 PeakSorter (net.sf.mzmine.util.PeakSorter)1