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
3333import org .eclipse .chemclipse .model .identifier .DeltaCalculationSupport ;
3434import org .eclipse .chemclipse .model .identifier .IComparisonResult ;
3535import org .eclipse .chemclipse .model .identifier .IIdentificationTarget ;
36+ import org .eclipse .chemclipse .model .identifier .IPeakIdentificationResult ;
3637import org .eclipse .chemclipse .model .identifier .IPeakIdentificationResults ;
3738import org .eclipse .chemclipse .model .identifier .MatchConstraints ;
3839import org .eclipse .chemclipse .model .identifier .PeakIdentificationResults ;
4647import org .eclipse .chemclipse .msd .model .core .IPeakMSD ;
4748import org .eclipse .chemclipse .msd .model .core .IScanMSD ;
4849import org .eclipse .chemclipse .msd .model .implementation .MassSpectra ;
50+ import org .eclipse .chemclipse .msd .model .implementation .PeakIdentificationResult ;
4951import org .eclipse .chemclipse .processing .core .IProcessingInfo ;
5052import org .eclipse .chemclipse .support .settings .UserManagement ;
5153import 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