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
Expand Up @@ -27,7 +27,7 @@ public class AbstractIdentifierDeltaPenaltyCalculationSettings extends AbstractI
private DeltaCalculation deltaCalculation = DeltaCalculation.NONE;
@JsonProperty(value = "Delta Window", defaultValue = "0")
@JsonPropertyDescription(value = "Identify the peak if the unknown is inside of the delta window (delta -/+).")
@FloatSettingsProperty(minValue = IDeltaCalculationSettings.MIN_DELTA_WINDOW, maxValue = IDeltaCalculationSettings.MAX_DELTA_WINDOW)
@FloatSettingsProperty(minValue = MIN_DELTA_WINDOW, maxValue = MAX_DELTA_WINDOW)
private float deltaWindow = 0.0f;
/**
* Penalty Calculation
Expand All @@ -37,12 +37,12 @@ public class AbstractIdentifierDeltaPenaltyCalculationSettings extends AbstractI
private PenaltyCalculation penaltyCalculation = PenaltyCalculation.NONE;
@JsonProperty(value = "Penalty Window", defaultValue = "0")
@JsonPropertyDescription(value = "The penalty window. The unit of the selected penalty calculation is used.")
@FloatSettingsProperty(minValue = IPenaltyCalculationSettings.MIN_PENALTY_WINDOW, maxValue = IPenaltyCalculationSettings.MAX_PENALTY_WINDOW)
@FloatSettingsProperty(minValue = MIN_PENALTY_WINDOW, maxValue = MAX_PENALTY_WINDOW)
private float penaltyWindow = 0.0f;
@JsonProperty(value = "Penalty Level Factor", defaultValue = "5.0")
@JsonPropertyDescription(value = "The penalty level factor.")
@FloatSettingsProperty(minValue = IPenaltyCalculationSettings.MIN_PENALTY_LEVEL_FACTOR, maxValue = IPenaltyCalculationSettings.MAX_PENALTY_LEVEL_FACTOR)
private float penaltyLevelFactor = IPenaltyCalculationSettings.DEF_PENALTY_LEVEL_FACTOR;
@FloatSettingsProperty(minValue = MIN_PENALTY_LEVEL_FACTOR, maxValue = MAX_PENALTY_LEVEL_FACTOR)
private float penaltyLevelFactor = DEF_PENALTY_LEVEL_FACTOR;
@JsonProperty(value = "Max Penalty", defaultValue = "20")
@JsonPropertyDescription(value = "The max penalty. Values between 0 (no penalty) and 100 (max penalty) are allowed.")
@FloatSettingsProperty(minValue = MIN_PENALTY_MATCH_FACTOR, maxValue = MAX_PENALTY_MATCH_FACTOR)
Expand Down Expand Up @@ -119,4 +119,4 @@ public void setMaxPenalty(float maxPenalty) {

this.maxPenalty = maxPenalty;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ public interface IIdentifierSettings extends IProcessSettings {
* @param limitMatchFactor
*/
void setLimitMatchFactor(float limitMatchFactor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ public interface IPenaltyCalculationSettings extends IProcessSettings {
float MIN_PENALTY_MATCH_FACTOR = 0.0f;
float MAX_PENALTY_MATCH_FACTOR = 100.0f;

/**
* Limit Match Factor
*
* @return float
*/
float getLimitMatchFactor();

/**
* Only identify the peak if no target is available with a match factor >= the limit.
*
* @param limitMatchFactor
*/
void setLimitMatchFactor(float limitMatchFactor);

/**
* Retention Time / Index Penalty Calculation
*/
Expand All @@ -64,4 +50,4 @@ public interface IPenaltyCalculationSettings extends IProcessSettings {
float getMaxPenalty();

void setMaxPenalty(float maxValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ public static double calculatePenalty(double valueUnknown, double valueReference
return (result > maxPenalty) ? maxPenalty : result;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Service-Component: OSGI-INF/org.eclipse.chemclipse.xxd.filter.chromatogram.Inten
OSGI-INF/org.eclipse.chemclipse.xxd.filter.peaks.AreaFilter.xml,
OSGI-INF/org.eclipse.chemclipse.xxd.filter.peaks.AreaPercentFilter.xml,
OSGI-INF/org.eclipse.chemclipse.xxd.filter.peaks.AsymmetryFilter.xml,
OSGI-INF/org.eclipse.chemclipse.xxd.filter.peaks.CalculatePenaltyFilter.xml,
OSGI-INF/org.eclipse.chemclipse.xxd.filter.peaks.ClassifiedPeaksFilter.xml,
OSGI-INF/org.eclipse.chemclipse.xxd.filter.peaks.DeleteIntegrationsFilter.xml,
OSGI-INF/org.eclipse.chemclipse.xxd.filter.peaks.DeletePeaksByModelFilter.xml,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.chemclipse.xxd.filter.peaks.CalculatePenaltyFilter">
<service>
<provide interface="org.eclipse.chemclipse.model.filter.IPeakFilter"/>
<provide interface="org.eclipse.chemclipse.processing.filter.Filter"/>
<provide interface="org.eclipse.chemclipse.processing.Processor"/>
</service>
<implementation class="org.eclipse.chemclipse.xxd.filter.peaks.CalculatePenaltyFilter"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2025 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.peaks;

import java.util.Collection;
import java.util.Set;

import org.eclipse.chemclipse.model.core.IPeak;
import org.eclipse.chemclipse.model.core.IPeakModel;
import org.eclipse.chemclipse.model.core.IScan;
import org.eclipse.chemclipse.model.filter.IPeakFilter;
import org.eclipse.chemclipse.model.identifier.IComparisonResult;
import org.eclipse.chemclipse.model.identifier.IIdentificationTarget;
import org.eclipse.chemclipse.model.identifier.ILibraryInformation;
import org.eclipse.chemclipse.model.identifier.PenaltyCalculationSupport;
import org.eclipse.chemclipse.model.selection.IChromatogramSelection;
import org.eclipse.chemclipse.processing.Processor;
import org.eclipse.chemclipse.processing.filter.Filter;
import org.eclipse.chemclipse.processing.supplier.ProcessExecutionContext;
import org.eclipse.chemclipse.xxd.filter.peaks.settings.PenaltyCalculatorFilterSettings;
import org.eclipse.core.runtime.SubMonitor;
import org.osgi.service.component.annotations.Component;

@Component(service = {IPeakFilter.class, Filter.class, Processor.class})
public class CalculatePenaltyFilter extends AbstractPeakFilter<PenaltyCalculatorFilterSettings> {

@Override
public String getName() {

return "Penalty Calculator";
}

@Override
public String getDescription() {

return "Calculate match penalties based on RT or RI deviations of unknown and library hit.";
}

@Override
public Class<PenaltyCalculatorFilterSettings> getConfigClass() {

return PenaltyCalculatorFilterSettings.class;
}

@Override
public void filterPeaks(IChromatogramSelection chromatogramSelection, PenaltyCalculatorFilterSettings configuration, ProcessExecutionContext context) throws IllegalArgumentException {

Collection<IPeak> peaks = getReadOnlyPeaks(chromatogramSelection);
if(configuration == null) {
configuration = createConfiguration(peaks);
}

SubMonitor subMonitor = SubMonitor.convert(context.getProgressMonitor(), peaks.size());
for(IPeak peak : peaks) {
Set<IIdentificationTarget> targets = peak.getTargets();
for(IIdentificationTarget identificationTarget : targets) {
IComparisonResult comparisonResult = identificationTarget.getComparisonResult();
ILibraryInformation libraryInformation = identificationTarget.getLibraryInformation();
IPeakModel peakModel = peak.getPeakModel();
IScan scan = peakModel.getPeakMaximum();
int retentionTimeUnknown = scan.getRetentionTime();
float retentionIndexUnknown = scan.getRetentionIndex();
int retentionTimeReference = libraryInformation.getRetentionTime();
float retentionIndexReference = libraryInformation.getRetentionIndex();
PenaltyCalculationSupport.applyPenalty(retentionTimeUnknown, retentionIndexUnknown, retentionTimeReference, retentionIndexReference, comparisonResult, configuration);
}
subMonitor.worked(1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.eclipse.chemclipse.processing.Processor;
import org.eclipse.chemclipse.processing.filter.Filter;
import org.eclipse.chemclipse.processing.supplier.ProcessExecutionContext;
import org.eclipse.chemclipse.xxd.filter.settings.DeleteTargetsFilterSettings;
import org.eclipse.chemclipse.xxd.filter.peaks.settings.DeleteTargetsFilterSettings;
import org.eclipse.chemclipse.xxd.filter.targets.TargetsFilter;
import org.eclipse.core.runtime.SubMonitor;
import org.osgi.service.component.annotations.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Contributors:
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.xxd.filter.settings;
package org.eclipse.chemclipse.xxd.filter.peaks.settings;

import org.eclipse.chemclipse.support.settings.StringSettingsProperty;
import org.eclipse.chemclipse.xxd.filter.support.TargetsDeleteOption;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*******************************************************************************
* Copyright (c) 2025 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.peaks.settings;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.model.identifier.IPenaltyCalculationSettings;
import org.eclipse.chemclipse.model.identifier.PenaltyCalculation;
import org.eclipse.chemclipse.support.literature.LiteratureReference;
import org.eclipse.chemclipse.support.settings.FloatSettingsProperty;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;

public class PenaltyCalculatorFilterSettings implements IPenaltyCalculationSettings {

private static final Logger logger = Logger.getLogger(PenaltyCalculatorFilterSettings.class);

@JsonProperty(value = "Penalty Calculation", defaultValue = "NONE")
@JsonPropertyDescription(value = "Select the strategy, how penalties are calculated.")
private PenaltyCalculation penaltyCalculation = PenaltyCalculation.NONE;
@JsonProperty(value = "Penalty Window", defaultValue = "0")
@JsonPropertyDescription(value = "The penalty window. The unit of the selected penalty calculation is used.")
@FloatSettingsProperty(minValue = IPenaltyCalculationSettings.MIN_PENALTY_WINDOW, maxValue = IPenaltyCalculationSettings.MAX_PENALTY_WINDOW)
private float penaltyWindow = 0.0f;
@JsonProperty(value = "Penalty Level Factor", defaultValue = "5.0")
@JsonPropertyDescription(value = "The penalty level factor.")
@FloatSettingsProperty(minValue = IPenaltyCalculationSettings.MIN_PENALTY_LEVEL_FACTOR, maxValue = IPenaltyCalculationSettings.MAX_PENALTY_LEVEL_FACTOR)
private float penaltyLevelFactor = IPenaltyCalculationSettings.DEF_PENALTY_LEVEL_FACTOR;
@JsonProperty(value = "Max Penalty", defaultValue = "20")
@JsonPropertyDescription(value = "The max penalty. Values between 0 (no penalty) and 100 (max penalty) are allowed.")
@FloatSettingsProperty(minValue = IPenaltyCalculationSettings.MIN_PENALTY_MATCH_FACTOR, maxValue = IPenaltyCalculationSettings.MAX_PENALTY_MATCH_FACTOR)
private float maxPenalty = IPenaltyCalculationSettings.DEF_PENALTY_MATCH_FACTOR;

@Override
public PenaltyCalculation getPenaltyCalculation() {

return penaltyCalculation;
}

@Override
public void setPenaltyCalculation(PenaltyCalculation penaltyCalculation) {

this.penaltyCalculation = penaltyCalculation;
}

@Override
public float getPenaltyWindow() {

return penaltyWindow;
}

@Override
public void setPenaltyWindow(float penaltyWindow) {

this.penaltyWindow = penaltyWindow;
}

@Override
public float getPenaltyLevelFactor() {

return penaltyLevelFactor;
}

@Override
public void setPenaltyLevelFactor(float penaltyLevelFactor) {

this.penaltyLevelFactor = penaltyLevelFactor;
}

@Override
public float getMaxPenalty() {

return maxPenalty;
}

@Override
public void setMaxPenalty(float maxPenalty) {

this.maxPenalty = maxPenalty;
}

@Override
public List<LiteratureReference> getLiteratureReferences() {

List<LiteratureReference> literatureReferences = new ArrayList<>();
literatureReferences.add(createLiteratureReference("S1044030599000471.ris", "10.1016/S1044-0305(99)00047-1"));
//
return literatureReferences;
}

private static LiteratureReference createLiteratureReference(String file, String doi) {

try {
return new LiteratureReference(new String(PenaltyCalculatorFilterSettings.class.getResourceAsStream(file).readAllBytes()));
} catch(Exception e) {
logger.warn(e);
return new LiteratureReference(doi);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TY - JOUR
T1 - An integrated method for spectrum extraction and compound identification from gas chromatography/mass spectrometry data
AU - Stein, S.E.
JO - Journal of the American Society for Mass Spectrometry
VL - 10
IS - 8
SP - 770
EP - 781
PY - 1999
DA - 1999/08/01/
SN - 1044-0305
DO - https://doi.org/10.1016/S1044-0305(99)00047-1
UR - https://www.sciencedirect.com/science/article/pii/S1044030599000471
AB - A method is presented for extracting individual component spectra from gas chromatography/mass spectrometry (GC/MS) data files and then using these spectra to identify target compounds by matching spectra in a reference library. It extends a published “model peak” approach which uses selected ion chromatograms as models for component shape. On the basis of this shape, individual mass spectral peak abundance profiles are extracted to produce a “purified” spectrum. In the present work, ion-counting noise is explicitly treated and a number of characteristic features of GC/MS data are taken into account. This allows spectrum extraction to be reliably performed down to very low signal levels and for overlapping components. A spectrum match factor for compound identification is developed that incorporates a number of new corrections, some of which employ information derived from chromatographic behavior. Test results suggest that the ability of this system to identify compounds is comparable to that of conventional analysis.
ER -
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.eclipse.chemclipse.processing.core.ProcessingMessage;
import org.eclipse.chemclipse.processing.filter.Filter;
import org.eclipse.chemclipse.processing.filter.FilterList;
import org.eclipse.chemclipse.xxd.filter.settings.DeleteTargetsFilterSettings;
import org.eclipse.chemclipse.xxd.filter.peaks.settings.DeleteTargetsFilterSettings;
import org.eclipse.chemclipse.xxd.filter.targets.TargetsFilter;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.eclipse.chemclipse.model.core.IScan;
import org.eclipse.chemclipse.model.core.ITargetSupplier;
import org.eclipse.chemclipse.model.identifier.IIdentificationTarget;
import org.eclipse.chemclipse.xxd.filter.settings.DeleteTargetsFilterSettings;
import org.eclipse.chemclipse.xxd.filter.peaks.settings.DeleteTargetsFilterSettings;

public class TargetsFilter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.eclipse.chemclipse.model.identifier.ILibraryInformation;
import org.eclipse.chemclipse.model.identifier.LibraryInformation;
import org.eclipse.chemclipse.model.implementation.IdentificationTarget;
import org.eclipse.chemclipse.xxd.filter.settings.DeleteTargetsFilterSettings;
import org.eclipse.chemclipse.xxd.filter.peaks.settings.DeleteTargetsFilterSettings;
import org.eclipse.chemclipse.xxd.filter.support.TargetsDeleteOption;

import junit.framework.TestCase;
Expand Down
Loading