Skip to content

Commit

Permalink
Fix identification setting for msfinder database
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiMatsuzawa committed Nov 13, 2024
1 parent 3262f14 commit d15a4b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 14 additions & 5 deletions src/MSDIAL5/MsdialGuiApp/Model/Setting/IdentifySettingModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,10 +50,15 @@ private static void Restore<TDataBase>(
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
}
}
}
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/MSDIAL5/MsdialGuiApp/Model/Setting/MethodSettingModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ public async Task<bool> 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())) {
Expand Down

0 comments on commit d15a4b2

Please sign in to comment.