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