Skip to content

Commit fe6f97c

Browse files
authored
Merge pull request #2689 from Mailaender/number-unknowns
Fix number of peaks marked as unknown message
2 parents 6317abc + ec4b21b commit fe6f97c

File tree

5 files changed

+42
-23
lines changed
  • chemclipse/plugins
    • org.eclipse.chemclipse.chromatogram.csd.identifier/src/org/eclipse/chemclipse/chromatogram/csd/identifier/support
    • org.eclipse.chemclipse.chromatogram.wsd.identifier/src/org/eclipse/chemclipse/chromatogram/wsd/identifier/support
    • org.eclipse.chemclipse.chromatogram.xxd.identifier.supplier.file/src/org/eclipse/chemclipse/chromatogram/xxd/identifier/supplier/file
    • org.eclipse.chemclipse.msd.identifier/src/org/eclipse/chemclipse/msd/identifier/support

5 files changed

+42
-23
lines changed

chemclipse/plugins/org.eclipse.chemclipse.chromatogram.csd.identifier/src/org/eclipse/chemclipse/chromatogram/csd/identifier/support/TargetBuilderCSD.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2016, 2025 Lablicate GmbH.
2+
* Copyright (c) 2016, 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
@@ -28,19 +28,21 @@ public class TargetBuilderCSD {
2828

2929
private static final Logger logger = Logger.getLogger(TargetBuilderCSD.class);
3030

31-
public void setPeakTargetUnknown(IPeakCSD peakCSD, String identifier, TargetUnknownSettings targetUnknownSettings) {
31+
public IIdentificationTarget setPeakTargetUnknown(IPeakCSD peakCSD, String identifier, TargetUnknownSettings targetUnknownSettings) {
3232

33+
IIdentificationTarget identificationTarget = null;
3334
try {
3435
IScan scan = peakCSD.getPeakModel().getPeakMaximum();
3536
if(scan instanceof IScanCSD unknown) {
3637
ILibraryInformation libraryInformation = UnknownTargetBuilder.getLibraryInformationUnknown(unknown, targetUnknownSettings, "");
3738
IComparisonResult comparisonResult = UnknownTargetBuilder.getComparisonResultUnknown(targetUnknownSettings.getMatchQuality());
38-
IIdentificationTarget peakTarget = new IdentificationTarget(libraryInformation, comparisonResult);
39-
peakTarget.setIdentifier(identifier);
40-
peakCSD.getTargets().add(peakTarget);
39+
identificationTarget = new IdentificationTarget(libraryInformation, comparisonResult);
40+
identificationTarget.setIdentifier(identifier);
41+
peakCSD.getTargets().add(identificationTarget);
4142
}
4243
} catch(ReferenceMustNotBeNullException e) {
4344
logger.warn(e);
4445
}
46+
return identificationTarget;
4547
}
4648
}

chemclipse/plugins/org.eclipse.chemclipse.chromatogram.wsd.identifier/src/org/eclipse/chemclipse/chromatogram/wsd/identifier/support/TargetBuilderWSD.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2016, 2025 Lablicate GmbH.
2+
* Copyright (c) 2016, 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
@@ -35,21 +35,23 @@ public class TargetBuilderWSD {
3535

3636
private static final Logger logger = Logger.getLogger(TargetBuilderWSD.class);
3737

38-
public void setPeakTargetUnknown(IPeakWSD peakWSD, String identifier, TargetUnknownSettings targetUnknownSettings) {
38+
public IIdentificationTarget setPeakTargetUnknown(IPeakWSD peakWSD, String identifier, TargetUnknownSettings targetUnknownSettings) {
3939

40+
IIdentificationTarget identificationTarget = null;
4041
try {
4142
IScan scan = peakWSD.getPeakModel().getPeakMaximum();
4243
if(scan instanceof IScanWSD unknown) {
4344
String traces = extractTraces(unknown, targetUnknownSettings);
4445
ILibraryInformation libraryInformation = UnknownTargetBuilder.getLibraryInformationUnknown(unknown, targetUnknownSettings, traces);
4546
IComparisonResult comparisonResult = UnknownTargetBuilder.getComparisonResultUnknown(targetUnknownSettings.getMatchQuality());
46-
IIdentificationTarget peakTarget = new IdentificationTarget(libraryInformation, comparisonResult);
47-
peakTarget.setIdentifier(identifier);
48-
peakWSD.getTargets().add(peakTarget);
47+
identificationTarget = new IdentificationTarget(libraryInformation, comparisonResult);
48+
identificationTarget.setIdentifier(identifier);
49+
peakWSD.getTargets().add(identificationTarget);
4950
}
5051
} catch(ReferenceMustNotBeNullException e) {
5152
logger.warn(e);
5253
}
54+
return identificationTarget;
5355
}
5456

5557
public void setWaveSpectrumTargetUnknown(IScanWSD unknown, String identifier, TargetUnknownSettings targetUnknownSettings) {

chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.identifier.supplier.file/src/org/eclipse/chemclipse/chromatogram/xxd/identifier/supplier/file/core/PeakIdentifierUnknown.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2019, 2025 Lablicate GmbH.
2+
* Copyright (c) 2019, 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
@@ -28,7 +28,6 @@
2828
import org.eclipse.chemclipse.csd.model.core.IPeakCSD;
2929
import org.eclipse.chemclipse.model.core.IPeak;
3030
import org.eclipse.chemclipse.model.identifier.IPeakIdentificationResults;
31-
import org.eclipse.chemclipse.model.identifier.PeakIdentificationResults;
3231
import org.eclipse.chemclipse.model.targets.TargetUnknownSettings;
3332
import org.eclipse.chemclipse.msd.model.core.IPeakMSD;
3433
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
@@ -80,8 +79,7 @@ private IProcessingInfo<IPeakIdentificationResults> runIdentification(List<? ext
8079
TargetUnknownSettings targetUnknownSettings = UnknownSettingsSupport.getTargetUnknownSettings(unknownSettings);
8180
float limitMatchFactor = unknownSettings.getLimitMatchFactor();
8281
UnknownIdentifier unknownIdentifier = new UnknownIdentifier();
83-
unknownIdentifier.runIdentificationPeak(peaks, limitMatchFactor, targetUnknownSettings);
84-
IPeakIdentificationResults peakIdentificationResults = new PeakIdentificationResults();
82+
IPeakIdentificationResults peakIdentificationResults = unknownIdentifier.runIdentificationPeak(peaks, limitMatchFactor, targetUnknownSettings);
8583
processingInfo.setProcessingResult(peakIdentificationResults);
8684
int results = peakIdentificationResults.getIdentificationResults().size();
8785
processingInfo.addInfoMessage(UnknownIdentifier.IDENTIFIER, MessageFormat.format("{0} peaks have been marked as unknown.", results));

chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.identifier.supplier.file/src/org/eclipse/chemclipse/chromatogram/xxd/identifier/supplier/file/identifier/UnknownIdentifier.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2019, 2025 Lablicate GmbH.
2+
* Copyright (c) 2019, 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
@@ -19,6 +19,11 @@
1919
import org.eclipse.chemclipse.csd.model.core.IPeakCSD;
2020
import org.eclipse.chemclipse.model.core.IPeak;
2121
import org.eclipse.chemclipse.model.core.IScan;
22+
import org.eclipse.chemclipse.model.identifier.IIdentificationResult;
23+
import org.eclipse.chemclipse.model.identifier.IIdentificationTarget;
24+
import org.eclipse.chemclipse.model.identifier.IPeakIdentificationResults;
25+
import org.eclipse.chemclipse.model.identifier.PeakIdentificationResults;
26+
import org.eclipse.chemclipse.model.implementation.IdentificationResult;
2227
import org.eclipse.chemclipse.model.support.LimitSupport;
2328
import org.eclipse.chemclipse.model.targets.TargetUnknownSettings;
2429
import org.eclipse.chemclipse.msd.identifier.support.TargetBuilderMSD;
@@ -35,19 +40,29 @@ public class UnknownIdentifier {
3540
private static final TargetBuilderCSD TARGETBUILDER_CSD = new TargetBuilderCSD();
3641
private static final TargetBuilderWSD TARGETBUILDER_WSD = new TargetBuilderWSD();
3742

38-
public void runIdentificationPeak(List<? extends IPeak> peaks, float limitMatchFactor, TargetUnknownSettings targetUnknownSettings) {
43+
public IPeakIdentificationResults runIdentificationPeak(List<? extends IPeak> peaks, float limitMatchFactor, TargetUnknownSettings targetUnknownSettings) {
44+
45+
IPeakIdentificationResults peakIdentificationResults = new PeakIdentificationResults();
3946

4047
for(IPeak peak : peaks) {
48+
IIdentificationResult identificationResult = new IdentificationResult();
4149
if(LimitSupport.doIdentify(peak.getTargets(), limitMatchFactor)) {
50+
IIdentificationTarget identificationTarget = null;
4251
if(peak instanceof IPeakMSD peakMSD) {
43-
TARGETBUILDER_MSD.setPeakTargetUnknown(peakMSD, IDENTIFIER, targetUnknownSettings);
52+
identificationTarget = TARGETBUILDER_MSD.setPeakTargetUnknown(peakMSD, IDENTIFIER, targetUnknownSettings);
4453
} else if(peak instanceof IPeakCSD peakCSD) {
45-
TARGETBUILDER_CSD.setPeakTargetUnknown(peakCSD, IDENTIFIER, targetUnknownSettings);
54+
identificationTarget = TARGETBUILDER_CSD.setPeakTargetUnknown(peakCSD, IDENTIFIER, targetUnknownSettings);
4655
} else if(peak instanceof IPeakWSD peakWSD) {
47-
TARGETBUILDER_WSD.setPeakTargetUnknown(peakWSD, IDENTIFIER, targetUnknownSettings);
56+
identificationTarget = TARGETBUILDER_WSD.setPeakTargetUnknown(peakWSD, IDENTIFIER, targetUnknownSettings);
57+
}
58+
if(identificationTarget != null) {
59+
identificationResult.add(identificationTarget);
4860
}
4961
}
62+
peakIdentificationResults.add(identificationResult);
5063
}
64+
65+
return peakIdentificationResults;
5166
}
5267

5368
public void runIdentificationScan(List<? extends IScan> spectraList, float limitMatchFactor, TargetUnknownSettings targetUnknownSettings) {

chemclipse/plugins/org.eclipse.chemclipse.msd.identifier/src/org/eclipse/chemclipse/msd/identifier/support/TargetBuilderMSD.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,21 @@ public IIdentificationTarget getPeakTarget(IScanMSD reference, IComparisonResult
7272
return peakTarget;
7373
}
7474

75-
public void setPeakTargetUnknown(IPeakMSD peakMSD, String identifier, TargetUnknownSettings targetUnknownSettings) {
75+
public IIdentificationTarget setPeakTargetUnknown(IPeakMSD peakMSD, String identifier, TargetUnknownSettings targetUnknownSettings) {
7676

77+
IIdentificationTarget identificationTarget = null;
7778
try {
7879
IScanMSD unknown = peakMSD.getExtractedMassSpectrum();
7980
String traces = extractTraces(unknown, targetUnknownSettings);
8081
ILibraryInformation libraryInformation = UnknownTargetBuilder.getLibraryInformationUnknown(unknown, targetUnknownSettings, traces);
8182
IComparisonResult comparisonResult = UnknownTargetBuilder.getComparisonResultUnknown(targetUnknownSettings.getMatchQuality());
82-
IIdentificationTarget peakTarget = new IdentificationTarget(libraryInformation, comparisonResult);
83-
peakTarget.setIdentifier(identifier);
84-
peakMSD.getTargets().add(peakTarget);
83+
identificationTarget = new IdentificationTarget(libraryInformation, comparisonResult);
84+
identificationTarget.setIdentifier(identifier);
85+
peakMSD.getTargets().add(identificationTarget);
8586
} catch(ReferenceMustNotBeNullException e) {
8687
logger.warn(e);
8788
}
89+
return identificationTarget;
8890
}
8991

9092
public IIdentificationTarget getMassSpectrumTarget(IScanMSD reference, IComparisonResult comparisonResult, String identifier) {

0 commit comments

Comments
 (0)