Skip to content

Commit 7528568

Browse files
authored
Merge pull request #2758 from eselmeister/FixDeleteRangeFilter
Fix to include also the first scan in case the retention time is 0.
2 parents 64794d0 + a280816 commit 7528568

File tree

2 files changed

+74
-4
lines changed

2 files changed

+74
-4
lines changed

chemclipse/plugins/org.eclipse.chemclipse.xxd.filter/src/org/eclipse/chemclipse/xxd/filter/core/CoordinateEvaluator.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2025 Lablicate GmbH.
2+
* Copyright (c) 2025, 2026 Lablicate GmbH.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -34,7 +34,11 @@ public static boolean isMatchPeak(IPeak peak, CoordinateOption coordinateOption,
3434
public static boolean isMatchScan(IScan scan, CoordinateOption coordinateOption, RangeOption rangeOption, double coordinateValue) {
3535

3636
if(scan != null) {
37-
double targetValue = 0;
37+
/*
38+
* Use -1 as 0 is a valid retention time,
39+
* in most cases when GC-FID is used.
40+
*/
41+
double targetValue = -1;
3842
switch(coordinateOption) {
3943
case RETENTION_TIME_MS:
4044
targetValue = scan.getRetentionTime();
@@ -43,15 +47,22 @@ public static boolean isMatchScan(IScan scan, CoordinateOption coordinateOption,
4347
targetValue = scan.getRetentionTime() / IChromatogramOverview.MINUTE_CORRELATION_FACTOR;
4448
break;
4549
case RETENTION_INDEX:
46-
targetValue = scan.getRetentionIndex();
50+
/*
51+
* The retention index is 0 by default if not set.
52+
* Allowing 0 could lead to an empty chromatogram.
53+
*/
54+
double retentionIndex = scan.getRetentionIndex();
55+
if(retentionIndex > 0) {
56+
targetValue = retentionIndex;
57+
}
4758
break;
4859
default:
4960
break;
5061
}
5162
/*
5263
* Validate
5364
*/
54-
if(targetValue > 0) {
65+
if(targetValue > -1) {
5566
return isMatch(targetValue, rangeOption, coordinateValue);
5667
}
5768
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Lablicate GmbH.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Philip Wenig - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.chemclipse.xxd.filter.core;
14+
15+
import static org.junit.jupiter.api.Assertions.assertFalse;
16+
import static org.junit.jupiter.api.Assertions.assertTrue;
17+
18+
import org.eclipse.chemclipse.model.core.IScan;
19+
import org.eclipse.chemclipse.xxd.filter.model.CoordinateOption;
20+
import org.eclipse.chemclipse.xxd.filter.model.RangeOption;
21+
import org.junit.jupiter.api.Test;
22+
23+
public class CoordinateEvaluator_6_Test extends CoordinateEvaluatorTestCase {
24+
25+
@Test
26+
public void test1() {
27+
28+
IScan scan = createScan(0, 0);
29+
assertTrue(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_TIME_MS, RangeOption.LOWER, 1000));
30+
}
31+
32+
@Test
33+
public void test2() {
34+
35+
IScan scan = createScan(0, 0);
36+
assertTrue(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_TIME_MIN, RangeOption.LOWER, 1));
37+
}
38+
39+
@Test
40+
public void test3() {
41+
42+
IScan scan = createScan(0, 0);
43+
assertFalse(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_INDEX, RangeOption.LOWER, 1));
44+
}
45+
46+
@Test
47+
public void test4() {
48+
49+
IScan scan = createScan(0, 1);
50+
assertFalse(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_INDEX, RangeOption.LOWER, 1));
51+
}
52+
53+
@Test
54+
public void test5() {
55+
56+
IScan scan = createScan(0, 1);
57+
assertTrue(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_INDEX, RangeOption.LOWER, 2));
58+
}
59+
}

0 commit comments

Comments
 (0)