resolved alignment issue
@@ -40,6 +40,8 @@ import io.github.mzmine.datamodel.features.FeatureListRow;
import io.github.mzmine.datamodel.features.ModularFeature;
import io.github.mzmine.datamodel.features.ModularFeatureList;
import io.github.mzmine.datamodel.impl.SimpleDataPoint;
+
+import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.NavigableMap;
@@ -94,19 +96,33 @@ public class ADAPInterface {
// Retrieve scan numbers
Scan representativeScan = null;
- Scan[] scanNumbers = new Scan[chromatogram.length];
+ double maxIntensity = 0.0;
+ List<Scan> scanNumbers = new ArrayList<>(chromatogram.length);
int count = 0;
- for (Scan num : file.getScans()) {
- double retTime = num.getRetentionTime();
- Double intensity = chromatogram.getIntensity(retTime, false);
- if (intensity != null) {
- scanNumbers[count++] = num;
- }
- if (retTime == peak.getRetTime()) {
- representativeScan = num;
+ double startRetTime = chromatogram.getFirstRetTime();
+ double endRetTime = chromatogram.getLastRetTimes();
+ for (Scan scan : file.getScans()) {
+ double retTime = scan.getRetentionTime();
+ if (retTime < startRetTime || retTime > endRetTime) continue;
+
+// Double intensity = chromatogram.getIntensity(retTime, false);
+//
+// if (intensity != null) {
+ scanNumbers.add(scan);
+// scanNumbers[count++] = num;
+// }
+ double intensity = chromatogram.getIntensity(retTime, true);
+
+ if (intensity > maxIntensity) {
+ representativeScan = scan;
+ maxIntensity = intensity;
}
+
+ if (scanNumbers.size() == chromatogram.length)
+ break;
}
+
// Calculate peak area
double area = 0.0;
for (int i = 1; i < chromatogram.length; ++i) {
@@ -116,14 +132,23 @@ public class ADAPInterface {
}
// Create array of DataPoints
- DataPoint[] dataPoints = new DataPoint[chromatogram.length];
- count = 0;
- for (double intensity : chromatogram.ys) {
- dataPoints[count++] = new SimpleDataPoint(peak.getMZ(), intensity);
+ DataPoint[] dataPoints = new DataPoint[scanNumbers.size()];
+ for (int i = 0; i < scanNumbers.size(); ++i) {
+ Scan scan = scanNumbers.get(i);
+ double retTime = scan.getRetentionTime();
+ double intensity = chromatogram.getIntensity(retTime, true);
+ dataPoints[i] = new SimpleDataPoint(retTime, intensity);
}
+// DataPoint[] dataPoints = new DataPoint[chromatogram.length];
+// count = 0;
+// for (double intensity : chromatogram.ys) {
+// dataPoints[count++] = new SimpleDataPoint(peak.getMZ(), intensity);
+// }
+
+ Scan[] scanNumbersArr = scanNumbers.toArray(new Scan[0]);
return new ModularFeature(featureList, file, peak.getMZ(), (float) peak.getRetTime(),
- (float) peak.getIntensity(), (float) area, scanNumbers, dataPoints, FeatureStatus.ESTIMATED,
+ (float) peak.getIntensity(), (float) area, scanNumbersArr, dataPoints, FeatureStatus.ESTIMATED,
representativeScan, List.of(),
Range.closed((float) peak.getFirstRetTime(), (float) peak.getLastRetTime()),
Range.closed(peak.getMZ() - 0.01, peak.getMZ() + 0.01),
@@ -151,3 +176,4 @@ public class ADAPInterface {
return peakToFeature(featureList, file, betterPeak);
}
}
+
