Skip to content

Commit 4fd49b0

Browse files
committed
Fix file identifier always reporting zero matches.
1 parent b61efd4 commit 4fd49b0

File tree

1 file changed

+16
-9
lines changed
  • chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.identifier.supplier.file/src/org/eclipse/chemclipse/chromatogram/xxd/identifier/supplier/file/identifier

1 file changed

+16
-9
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2015, 2025 Lablicate GmbH.
2+
* Copyright (c) 2015, 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
@@ -33,6 +33,7 @@
3333
import org.eclipse.chemclipse.model.identifier.DeltaCalculationSupport;
3434
import org.eclipse.chemclipse.model.identifier.IComparisonResult;
3535
import org.eclipse.chemclipse.model.identifier.IIdentificationTarget;
36+
import org.eclipse.chemclipse.model.identifier.IPeakIdentificationResult;
3637
import org.eclipse.chemclipse.model.identifier.IPeakIdentificationResults;
3738
import org.eclipse.chemclipse.model.identifier.MatchConstraints;
3839
import org.eclipse.chemclipse.model.identifier.PeakIdentificationResults;
@@ -46,6 +47,7 @@
4647
import org.eclipse.chemclipse.msd.model.core.IPeakMSD;
4748
import org.eclipse.chemclipse.msd.model.core.IScanMSD;
4849
import org.eclipse.chemclipse.msd.model.implementation.MassSpectra;
50+
import org.eclipse.chemclipse.msd.model.implementation.PeakIdentificationResult;
4951
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
5052
import org.eclipse.chemclipse.support.settings.UserManagement;
5153
import org.eclipse.chemclipse.support.text.ValueFormat;
@@ -91,9 +93,10 @@ public IMassSpectra runIdentification(List<IScanMSD> massSpectraList, ILibraryId
9193
* Load the mass spectra database only if the raw file or its content has changed.
9294
*/
9395
List<String> files = extractFiles(fileIdentifierSettings.getMassSpectraFiles());
96+
IPeakIdentificationResults identificationResults = new PeakIdentificationResults();
9497
Map<String, IMassSpectra> databases = databasesCache.getDatabases(files, monitor);
9598
for(Map.Entry<String, IMassSpectra> database : databases.entrySet()) {
96-
compareMassSpectraAgainstDatabase(massSpectra.getList(), database.getValue().getList(), fileIdentifierSettings, identifier, database.getKey(), monitor);
99+
compareMassSpectraAgainstDatabase(massSpectra.getList(), database.getValue().getList(), fileIdentifierSettings, identifier, database.getKey(), identificationResults, monitor);
97100
}
98101

99102
return massSpectra;
@@ -126,7 +129,7 @@ public IPeakIdentificationResults runPeakIdentification(List<? extends IPeakMSD>
126129
* The LibraryService uses the identifier to get a mass spectrum of a given target.
127130
* It would then use this plugin instead of the plugin who used this identifier.
128131
*/
129-
IPeakIdentificationResults identificationResults = new PeakIdentificationResults();
132+
130133
String identifier = IDENTIFIER;
131134
String alternateIdentifierId = peakIdentifierSettings.getAlternateIdentifierId();
132135
if(alternateIdentifierId != null && !alternateIdentifierId.isEmpty()) {
@@ -137,8 +140,9 @@ public IPeakIdentificationResults runPeakIdentification(List<? extends IPeakMSD>
137140
*/
138141
List<String> files = extractFiles(peakIdentifierSettings.getMassSpectraFiles());
139142
Map<String, IMassSpectra> databases = databasesCache.getDatabases(files, monitor);
143+
IPeakIdentificationResults identificationResults = new PeakIdentificationResults();
140144
for(Map.Entry<String, IMassSpectra> database : databases.entrySet()) {
141-
comparePeaksAgainstDatabase(peaksToIdentify, database.getValue().getList(), peakIdentifierSettings, identifier, database.getKey(), monitor);
145+
comparePeaksAgainstDatabase(peaksToIdentify, database.getValue().getList(), peakIdentifierSettings, identifier, database.getKey(), identificationResults, monitor);
142146
}
143147

144148
return identificationResults;
@@ -195,17 +199,17 @@ public DatabasesCache getDatabasesCache() {
195199
return databasesCache;
196200
}
197201

198-
public static int compareMassSpectraAgainstDatabase(List<? extends IScanMSD> unknownList, List<? extends IScanMSD> references, ILibraryIdentifierSettings fileIdentifierSettings, String identifier, String databaseName, IProgressMonitor monitor) {
202+
public static int compareMassSpectraAgainstDatabase(List<? extends IScanMSD> unknownList, List<? extends IScanMSD> references, ILibraryIdentifierSettings fileIdentifierSettings, String identifier, String databaseName, IPeakIdentificationResults identificationResults, IProgressMonitor monitor) {
199203

200-
return compareAgainstDatabase(unknownList, scan -> scan, references, fileIdentifierSettings, identifier, databaseName, monitor);
204+
return compareAgainstDatabase(unknownList, scan -> scan, references, fileIdentifierSettings, identifier, databaseName, identificationResults, monitor);
201205
}
202206

203-
public static int comparePeaksAgainstDatabase(List<? extends IPeakMSD> unknownList, List<IScanMSD> references, PeakIdentifierSettings fileIdentifierSettings, String identifier, String databaseName, IProgressMonitor monitor) {
207+
public static int comparePeaksAgainstDatabase(List<? extends IPeakMSD> unknownList, List<IScanMSD> references, PeakIdentifierSettings fileIdentifierSettings, String identifier, String databaseName, IPeakIdentificationResults identificationResults, IProgressMonitor monitor) {
204208

205-
return compareAgainstDatabase(unknownList, peak -> peak.getPeakModel().getPeakMassSpectrum(), references, fileIdentifierSettings, identifier, databaseName, monitor);
209+
return compareAgainstDatabase(unknownList, peak -> peak.getPeakModel().getPeakMassSpectrum(), references, fileIdentifierSettings, identifier, databaseName, identificationResults, monitor);
206210
}
207211

208-
private static <T> int compareAgainstDatabase(Collection<T> unknownList, Function<T, IScanMSD> extractor, List<? extends IScanMSD> references, IFileIdentifierSettings fileIdentifierSettings, String identifier, String databaseName, IProgressMonitor monitor) {
212+
private static <T> int compareAgainstDatabase(Collection<T> unknownList, Function<T, IScanMSD> extractor, List<? extends IScanMSD> references, IFileIdentifierSettings fileIdentifierSettings, String identifier, String databaseName, IPeakIdentificationResults identificationResults, IProgressMonitor monitor) {
209213

210214
int matched = 0;
211215
long start = System.currentTimeMillis();
@@ -236,12 +240,15 @@ private static <T> int compareAgainstDatabase(Collection<T> unknownList, Functio
236240
List<IComparisonResult> resultList = new ArrayList<>(matches.keySet());
237241
Collections.sort(resultList, RESULT_COMPARATOR);
238242
int size = Math.min(fileIdentifierSettings.getNumberOfTargets(), matches.size());
243+
IPeakIdentificationResult identificationResult = new PeakIdentificationResult();
239244
for(int i = 0; i < size; i++) {
240245
IComparisonResult comparisonResult = resultList.get(i);
241246
IIdentificationTarget massSpectrumTarget = TARGETBUILDER.getMassSpectrumTarget(matches.get(comparisonResult), comparisonResult, identifier, databaseName);
242247
massSpectrumTarget.getLibraryInformation().setMiscellaneous(comparatorName); // e.g. Cosine, Cosine Binary (0|1), ...
243248
unknown.getTargets().add(massSpectrumTarget);
249+
identificationResult.add(massSpectrumTarget);
244250
}
251+
identificationResults.add(identificationResult);
245252
}
246253

247254
count++;

0 commit comments

Comments
 (0)