RawDataFile rawFile = oldPeak.getDataFile();
ExtendedPeak newPeak = new ExtendedPeak(rawFile);
int totalScanNumber = rawFile.getNumOfScans();
Range mzRange = mzTolerance.getToleranceRange(oldPeak.getMZ());
Scan scan;
DataPoint dataPoint;
// Look for dataPoint related to this peak to the left
int scanNumber = originScanNumber;
scanNumber--;
while (scanNumber > 0) {
scan = rawFile.getScan(scanNumber);
if (scan == null) {
scanNumber--;
continue;
}
if (scan.getMSLevel() != 1) {
scanNumber--;
continue;
}
dataPoint = ScanUtils.findBasePeak(scan, mzRange);
if (dataPoint == null)
break;
if (dataPoint.getIntensity() < minimumHeight)
break;
newPeak.addMzPeak(scanNumber, dataPoint);
if (dataPoint.getIntensity() > maxHeight)
maxHeight = dataPoint.getIntensity();
scanNumber--;
}
// Add original dataPoint
newPeak.addMzPeak(originScanNumber,
oldPeak.getDataPoint(originScanNumber));
// Look to the right
scanNumber = originScanNumber;
scanNumber++;
while (scanNumber <= totalScanNumber) {
scan = rawFile.getScan(scanNumber);
if (scan == null) {
scanNumber++;
continue;
}
if (scan.getMSLevel() != 1) {
scanNumber++;
continue;
}
dataPoint = ScanUtils.findBasePeak(scan, mzRange);
if (dataPoint == null)
break;
if (dataPoint.getIntensity() < minimumHeight)
break;
newPeak.addMzPeak(scanNumber, dataPoint);
if (dataPoint.getIntensity() > maxHeight)
maxHeight = dataPoint.getIntensity();
scanNumber++;
}