From d15a4b2e709ba900fb197f3c2c6c6b3906b8378a Mon Sep 17 00:00:00 2001 From: Yuki Matsuzawa Date: Wed, 13 Nov 2024 14:14:26 +0900 Subject: [PATCH] Fix identification setting for msfinder database --- .../Model/Setting/IdentifySettingModel.cs | 19 ++++++++++++++----- .../Model/Setting/MethodSettingModel.cs | 3 +-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/MSDIAL5/MsdialGuiApp/Model/Setting/IdentifySettingModel.cs b/src/MSDIAL5/MsdialGuiApp/Model/Setting/IdentifySettingModel.cs index 014ec9a94..7d9c482a2 100644 --- a/src/MSDIAL5/MsdialGuiApp/Model/Setting/IdentifySettingModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/Model/Setting/IdentifySettingModel.cs @@ -7,6 +7,7 @@ using CompMs.MsdialCore.DataObj; using CompMs.MsdialCore.Parameter; using Reactive.Bindings.Notifiers; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -49,10 +50,15 @@ private static void Restore( where TDataBase : IReferenceDataBase { foreach (var dataBase in items) { - var dbModel = new DataBaseSettingModel(parameter, dataBase.DataBase); - dataBaseModels.Add(dbModel); - foreach (var pair in dataBase.Pairs) { - annotatorModels.Add((pair.AnnotationQueryFactory.Priority, annotatorFactory.Create(dbModel, pair.AnnotatorID, pair.AnnotationQueryFactory.PrepareParameter()))); + try { + var dbModel = new DataBaseSettingModel(parameter, dataBase.DataBase); + foreach (var pair in dataBase.Pairs) { + annotatorModels.Add((pair.AnnotationQueryFactory.Priority, annotatorFactory.Create(dbModel, pair.AnnotatorID, pair.AnnotationQueryFactory.PrepareParameter()))); + } + dataBaseModels.Add(dbModel); + } + catch (NotSupportedException) { + // Skip if unsupported database } } } @@ -113,7 +119,10 @@ public void RemoveDataBase(DataBaseSettingModel db) { } public IAnnotatorSettingModel? AddAnnotator(DataBaseSettingModel db) { - if (!(db is null)) { + if (db is not null) { + if (db.DBSource == DataBaseSource.MsFinder) { + return null; + } var annotatorModel = annotatorFactory.Create(db, $"{db.DataBaseID}_{serialNumber++}", null); lock (annotatorLock) { AnnotatorModels.Add(annotatorModel); diff --git a/src/MSDIAL5/MsdialGuiApp/Model/Setting/MethodSettingModel.cs b/src/MSDIAL5/MsdialGuiApp/Model/Setting/MethodSettingModel.cs index 549af6a8b..aadd994cf 100644 --- a/src/MSDIAL5/MsdialGuiApp/Model/Setting/MethodSettingModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/Model/Setting/MethodSettingModel.cs @@ -81,9 +81,8 @@ public async Task TryRunAsync(CancellationToken token) { if (Option.HasFlag(ProcessOption.Identification)) { if (IdentifySettingModel != null) { if (!IdentifySettingModel.IsReadOnly ) { - Storage.DataBaseMapper = new DataBaseMapper(); Storage.DataBases = IdentifySettingModel.Create(Storage.DataBaseMapper); - Storage.DataBases.SetDataBaseMapper(Storage.DataBaseMapper); + Storage.DataBaseMapper = Storage.DataBases.CreateDataBaseMapper(); } } if (!(AdductIonSettingModel is null || AdductIonSettingModel.TryCommit())) {