Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Lablicate GmbH.
* Copyright (c) 2025, 2026 Lablicate GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -34,7 +34,11 @@ public static boolean isMatchPeak(IPeak peak, CoordinateOption coordinateOption,
public static boolean isMatchScan(IScan scan, CoordinateOption coordinateOption, RangeOption rangeOption, double coordinateValue) {

if(scan != null) {
double targetValue = 0;
/*
* Use -1 as 0 is a valid retention time,
* in most cases when GC-FID is used.
*/
double targetValue = -1;
switch(coordinateOption) {
case RETENTION_TIME_MS:
targetValue = scan.getRetentionTime();
Expand All @@ -43,15 +47,22 @@ public static boolean isMatchScan(IScan scan, CoordinateOption coordinateOption,
targetValue = scan.getRetentionTime() / IChromatogramOverview.MINUTE_CORRELATION_FACTOR;
break;
case RETENTION_INDEX:
targetValue = scan.getRetentionIndex();
/*
* The retention index is 0 by default if not set.
* Allowing 0 could lead to an empty chromatogram.
*/
double retentionIndex = scan.getRetentionIndex();
if(retentionIndex > 0) {
targetValue = retentionIndex;
}
break;
default:
break;
}
/*
* Validate
*/
if(targetValue > 0) {
if(targetValue > -1) {
return isMatch(targetValue, rangeOption, coordinateValue);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2026 Lablicate GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.xxd.filter.core;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.chemclipse.model.core.IScan;
import org.eclipse.chemclipse.xxd.filter.model.CoordinateOption;
import org.eclipse.chemclipse.xxd.filter.model.RangeOption;
import org.junit.jupiter.api.Test;

public class CoordinateEvaluator_6_Test extends CoordinateEvaluatorTestCase {

@Test
public void test1() {

IScan scan = createScan(0, 0);
assertTrue(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_TIME_MS, RangeOption.LOWER, 1000));
}

@Test
public void test2() {

IScan scan = createScan(0, 0);
assertTrue(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_TIME_MIN, RangeOption.LOWER, 1));
}

@Test
public void test3() {

IScan scan = createScan(0, 0);
assertFalse(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_INDEX, RangeOption.LOWER, 1));
}

@Test
public void test4() {

IScan scan = createScan(0, 1);
assertFalse(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_INDEX, RangeOption.LOWER, 1));
}

@Test
public void test5() {

IScan scan = createScan(0, 1);
assertTrue(CoordinateEvaluator.isMatchScan(scan, CoordinateOption.RETENTION_INDEX, RangeOption.LOWER, 2));
}
}