Skip to content

Commit

Permalink
Fixed #154 - Standards Assigner - Traces for Identification
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Oct 10, 2021
1 parent 255e9cf commit 72be80b
Show file tree
Hide file tree
Showing 23 changed files with 287 additions and 117 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Lablicate GmbH.
* Copyright (c) 2019, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -59,4 +59,9 @@ public void test6() {

assertEquals(1.0d, setting.getResponseFactor());
}
}

public void test7() {

assertEquals("", setting.getTracesIdentification());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Lablicate GmbH.
* Copyright (c) 2019, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -64,4 +64,10 @@ public void test6() {
setting.setResponseFactor(0.98d);
assertEquals(0.98d, setting.getResponseFactor());
}
}

public void test7() {

setting.setTracesIdentification("104 103");
assertEquals("104 103", setting.getTracesIdentification());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Philip Wenig - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.process.supplier.templates.util;

import org.eclipse.chemclipse.model.core.IPeak;
import org.eclipse.chemclipse.model.implementation.Peak;

import junit.framework.TestCase;

public class TraceUtil_1_Test extends TestCase {

private TracesUtil tracesUtil = new TracesUtil();
private IPeak peak = new Peak();

@Override
protected void setUp() throws Exception {

super.setUp();
}

@Override
protected void tearDown() throws Exception {

super.tearDown();
}

public void test1() {

assertFalse(tracesUtil.isTraceMatch(null, null));
}

public void test2() {

assertFalse(tracesUtil.isTraceMatch(null, ""));
}

public void test3() {

assertTrue(tracesUtil.isTraceMatch(peak, null));
}

public void test4() {

assertTrue(tracesUtil.isTraceMatch(peak, ""));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2019 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -47,6 +47,9 @@ public int compare(Viewer viewer, Object e1, Object e2) {
case 5:
sortOrder = Double.compare(setting2.getResponseFactor(), setting1.getResponseFactor());
break;
case 6:
sortOrder = setting2.getTracesIdentification().compareTo(setting1.getTracesIdentification());
break;
default:
sortOrder = 0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2019 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -25,6 +25,7 @@ public class StandardsAssignerEditingSupport extends EditingSupport {
private String column;

public StandardsAssignerEditingSupport(ExtendedTableViewer tableViewer, String column) {

super(tableViewer);
this.column = column;
this.cellEditor = new TextCellEditor(tableViewer.getTable());
Expand Down Expand Up @@ -62,6 +63,8 @@ protected Object getValue(Object element) {
return setting.getConcentrationUnit();
case StandardsAssignerLabelProvider.RESPONSE_FACTOR:
return Double.toString(setting.getResponseFactor());
case StandardsAssignerLabelProvider.TRACES_IDENTIFICATION:
return setting.getTracesIdentification();
}
}
return false;
Expand Down Expand Up @@ -115,6 +118,9 @@ protected void setValue(Object element, Object value) {
}
}
break;
case StandardsAssignerLabelProvider.TRACES_IDENTIFICATION:
setting.setTracesIdentification(((String)value).trim());
break;
}
tableViewer.refresh();
}
Expand All @@ -130,4 +136,4 @@ private double convertValue(Object value) {
}
return result;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -38,11 +38,13 @@ public boolean select(Viewer viewer, Object parentElement, Object element) {
AssignerStandard setting = (AssignerStandard)element;
String name = setting.getName();
String concentrationUnit = setting.getConcentrationUnit();
String tracesIdentification = setting.getTracesIdentification();
//
if(!caseSensitive) {
searchText = searchText.toLowerCase();
name = name.toLowerCase();
concentrationUnit = concentrationUnit.toLowerCase();
tracesIdentification = tracesIdentification.toLowerCase();
}
//
if(name.contains(searchText)) {
Expand All @@ -52,8 +54,12 @@ public boolean select(Viewer viewer, Object parentElement, Object element) {
if(concentrationUnit.contains(searchText)) {
return true;
}
//
if(tracesIdentification.contains(searchText)) {
return true;
}
}
//
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -26,6 +26,7 @@ public class StandardsAssignerInputValidator implements IInputValidator {
private Set<String> names = new HashSet<>();

public StandardsAssignerInputValidator(Set<String> names) {

if(names != null) {
this.names = names;
}
Expand All @@ -46,4 +47,4 @@ public String isValid(String target) {
}
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -29,6 +29,7 @@ public class StandardsAssignerLabelProvider extends AbstractChemClipseLabelProvi
public static final String CONCENTRATION = "Concentration";
public static final String CONCENTRATION_UNIT = "Concentration Unit";
public static final String RESPONSE_FACTOR = "Response Factor";
public static final String TRACES_IDENTIFICATION = "Traces Identification";
//
private DecimalFormat decimalFormat = ValueFormat.getDecimalFormatEnglish("0.0##");
//
Expand All @@ -38,15 +39,17 @@ public class StandardsAssignerLabelProvider extends AbstractChemClipseLabelProvi
STOP_RETENTION_TIME, //
CONCENTRATION, //
CONCENTRATION_UNIT, //
RESPONSE_FACTOR//
RESPONSE_FACTOR, //
TRACES_IDENTIFICATION //
};
public static final int[] BOUNDS = { //
200, //
100, //
100, //
50, //
50, //
50 //
50, //
100 //
};

@Override
Expand Down Expand Up @@ -83,6 +86,9 @@ public String getColumnText(Object element, int columnIndex) {
case 5:
text = decimalFormat.format(setting.getResponseFactor());
break;
case 6:
text = setting.getTracesIdentification();
break;
default:
text = "n.v.";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 Lablicate GmbH.
* Copyright (c) 2020, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -36,6 +36,7 @@ public PageExportAssigner() {
*/
public void createFieldEditors() {

addField(new IntegerFieldEditor(PreferenceSupplier.P_EXPORT_NUMBER_TRACES_ASSIGNER, "Number Traces for Identification (0 = TIC)", PreferenceSupplier.MIN_NUMBER_TRACES, PreferenceSupplier.MAX_NUMBER_TRACES, getFieldEditorParent()));
addField(new IntegerFieldEditor(PreferenceSupplier.P_EXPORT_DELTA_LEFT_MILLISECONDS_STANDARDS, "Delta Left [ms]", PreferenceSupplier.MIN_DELTA_MILLISECONDS, PreferenceSupplier.MAX_DELTA_MILLISECONDS, getFieldEditorParent()));
addField(new IntegerFieldEditor(PreferenceSupplier.P_EXPORT_DELTA_RIGHT_MILLISECONDS_STANDARDS, "Delta Right [ms]", PreferenceSupplier.MIN_DELTA_MILLISECONDS, PreferenceSupplier.MAX_DELTA_MILLISECONDS, getFieldEditorParent()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -34,6 +34,7 @@ public class StandardsAssignerListUI extends ExtendedTableViewer {
private StandardsAssignerFilter listFilter = new StandardsAssignerFilter();

public StandardsAssignerListUI(Composite parent, int style) {

super(parent, style);
createColumns();
}
Expand Down Expand Up @@ -70,4 +71,4 @@ private void setEditingSupport() {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Lablicate GmbH.
* Copyright (c) 2019, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -26,4 +26,4 @@ public int compare(AssignerStandard setting1, AssignerStandard setting2) {
}
return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ public IProcessingInfo<File> convert(File file, IChromatogram<? extends IPeak> c
float retentionIndex = peak.getPeakModel().getPeakMaximum().getRetentionIndex();
IdentificationTargetComparator identificationTargetComparator = new IdentificationTargetComparator(retentionIndex);
IIdentificationTarget identificationTarget = IIdentificationTarget.getBestIdentificationTarget(peak.getTargets(), identificationTargetComparator);
//
if(identificationTarget != null) {
detectorSetting.setName(identificationTarget.getLibraryInformation().getName());
} else {
detectorSetting.setName("");
}
detectorSetting.setName(identificationTarget != null ? identificationTarget.getLibraryInformation().getName() : "");
detectorSettings.add(detectorSetting);
}
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 Lablicate GmbH.
* Copyright (c) 2019, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -39,6 +39,7 @@ public IProcessingInfo<File> convert(File file, IChromatogram<? extends IPeak> c
List<? extends IPeak> peaks = chromatogram.getPeaks();
AssignerStandards assignerStandards = new AssignerStandards();
//
int numberTraces = PreferenceSupplier.getExportNumberTracesAssigner();
int deltaLeft = PreferenceSupplier.getExportDeltaLeftMillisecondsStandards();
int deltaRight = PreferenceSupplier.getExportDeltaRightMillisecondsStandards();
//
Expand All @@ -54,6 +55,7 @@ public IProcessingInfo<File> convert(File file, IChromatogram<? extends IPeak> c
assignerStandard.setConcentration(internalStandard.getConcentration());
assignerStandard.setConcentrationUnit(internalStandard.getConcentrationUnit());
assignerStandard.setResponseFactor(internalStandard.getResponseFactor());
assignerStandard.setTracesIdentification(extractTraces(peak, numberTraces));
assignerStandards.add(assignerStandard);
}
}
Expand All @@ -65,4 +67,4 @@ public IProcessingInfo<File> convert(File file, IChromatogram<? extends IPeak> c
processingInfo.addInfoMessage(DESCRIPTION, "The standards template has been exported successfully.");
return processingInfo;
}
}
}
Loading

0 comments on commit 72be80b

Please sign in to comment.