bestFitPeaks = fittedPeaks;
}
}
PeakListRow oldRow = peakList.getPeakRow(aPeak);
assert bestFitPeaks != null;
// Verify the number of detected isotopes. If there is only one
// isotope, we skip this left the original peak in the peak list.
if (bestFitPeaks.size() == 1) {
deisotopedPeakList.addRow(oldRow);
processedPeaks++;
continue;
}
// Convert the peak pattern to array
ChromatographicPeak originalPeaks[] = bestFitPeaks
.toArray(new ChromatographicPeak[0]);
// Create a new SimpleIsotopePattern
DataPoint isotopes[] = new DataPoint[bestFitPeaks.size()];
for (int i = 0; i < isotopes.length; i++) {
ChromatographicPeak p = originalPeaks[i];
isotopes[i] = new SimpleDataPoint(p.getMZ(), p.getHeight());
}
SimpleIsotopePattern newPattern = new SimpleIsotopePattern(
isotopes, IsotopePatternStatus.DETECTED, aPeak.toString());
// Depending on user's choice, we leave either the most intenst, or
// the lowest m/z peak
if (chooseMostIntense) {
Arrays.sort(originalPeaks, new PeakSorter(
SortingProperty.Height, SortingDirection.Descending));
} else {
Arrays.sort(originalPeaks, new PeakSorter(SortingProperty.MZ,
SortingDirection.Ascending));
}
ChromatographicPeak newPeak = new SimpleChromatographicPeak(
originalPeaks[0]);
newPeak.setIsotopePattern(newPattern);
newPeak.setCharge(bestFitCharge);
// Keep old ID
int oldID = oldRow.getID();
SimplePeakListRow newRow = new SimplePeakListRow(oldID);
PeakUtils.copyPeakListRowProperties(oldRow, newRow);
newRow.addPeak(dataFile, newPeak);
deisotopedPeakList.addRow(newRow);