Skip to content

Make "Searched adduct ions" in a console method file take effect - #815

Merged
YukiMatsuzawa merged 5 commits into
masterfrom
claude/console-searched-adducts-included
Sep 29, 2026
Merged

YukiMatsuzawa merged 5 commits into
masterfrom
claude/console-searched-adducts-included

Conversation

@YukiMatsuzawa

@YukiMatsuzawa YukiMatsuzawa commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ This changes results

Method files that listed adducts beyond the proton adduct were silently searched with [M+H]+ (Positive) or [M-H]- (Negative) only. After this change, the listed adducts are searched. Console reanalyses of such method files will get different adduct assignments and peak-character links than before.

Bug

ConfigParser.ReadCommonParameter's searched adduct ions arm filled param.SearchedAdductIons with AdductIon.GetAdductIon(...). That returns a shared instance from the static cache, and its IsIncluded is false. PeakCharacterEstimator.SearchedAdductInitialize (both the MsdialCore and the DIMS copy) keeps only IsIncluded adducts and falls back to the proton adduct when none are left. Only the GUI's AdductIonSettingModel ever set the flag. So Searched adduct ions: [M+H]+,[M+Na]+,[M+NH4]+ ran with [M+H]+ alone, and the method-file key report still recorded the key as applied.

Fix

  • The arm now calls a new SearchedAdductIons helper. It sets IsIncluded = true directly on the adducts GetAdductIon returns. These are the shared cached instances, so the flag stays set for later callers in the same process. The GUI's AdductIonSettingModel already sets the flag this way, and a console run reads one method file per process.
  • Entries that fail FormatCheck are still dropped. Entries are now trimmed, so [M+H]+, [M+Na]+ keeps both.
  • If no listed adduct can be read, the key is reported as MethodKeyOutcome.UnusableValue and the built-in list is kept, following the file's documented convention.

Other readers

ReadForGcms, ReadForDimsParameter, ReadForImmsParameter and ReadForLcImMsParameter all send this key through ReadCommonParameter, so this one change fixes them all. No other place in the console builds SearchedAdductIons.

Tests (ConfigParserTests)

  • Adducts read from a method file are IsIncluded, and the key report stays silent.
  • The stored adducts are the shared GetAdductIon instances, now marked IsIncluded.
  • A mistyped entry is dropped and the rest are kept.
  • A list where nothing parses is reported as UnusableValue.
  • PeakCharacterEstimator.Process searches exactly the listed adducts.

Verification

  • dotnet test tests/MSDIAL5/MsdialCoreTestAppTests/MsdialCoreTestAppTests.csproj: 68/68 passed (after merging the latest master)
  • dotnet build tests/MSDIAL5/MsdialCoreTestApp/MsdialCoreTestApp.csproj: net472, net48 and net8 build with 0 errors

🤖 Generated with Claude Code

YukiMatsuzawa and others added 5 commits September 28, 2026 18:36
The console reader stored AdductIon.GetAdductIon's shared cached instances,
whose IsIncluded is false. PeakCharacterEstimator keeps only included adducts
and otherwise falls back to [M+H]+ / [M-H]-, so every console run searched the
proton adduct alone whatever the method file listed, while the method-file key
report said the key had been applied.

The reader now stores included copies (never mutating the shared cache),
trims each entry, still drops entries that fail FormatCheck, and reports the
value as unusable when none of the listed adducts can be read.

This changes results for method files that list adducts other than the
proton adduct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ched-adducts-included

# Conflicts:
#	tests/MSDIAL5/MsdialCoreTestAppTests/Parser/ConfigParserTests.cs
…ched-adducts-included

# Conflicts:
#	tests/MSDIAL5/MsdialCoreTestAppTests/Parser/ConfigParserTests.cs
The console reader no longer builds AdductIon instances of its own. It stores
GetAdductIon's shared instances and sets IsIncluded on them, as the GUI's
AdductIonSettingModel already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@YukiMatsuzawa
YukiMatsuzawa merged commit c471463 into master Sep 29, 2026
1 check passed
@YukiMatsuzawa
YukiMatsuzawa deleted the claude/console-searched-adducts-included branch September 29, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant