Skip to content

Add molecule structure preview to the Compound search window - #839

Merged
YukiMatsuzawa merged 1 commit into
systemsomicslab:masterfrom
QizhiSu:feat/candidates-structure-viewer
Oct 21, 2026
Merged

YukiMatsuzawa merged 1 commit into
systemsomicslab:masterfrom
QizhiSu:feat/candidates-structure-viewer

Conversation

@QizhiSu

@QizhiSu QizhiSu commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

The Compound search window shows the detailed match info of the library row the user picks — scores, spectrum — but no structure preview. The main window's Structure tab only covers the representative match, so the candidates in the table cannot be compared by structure.

The existing two-column layout has no room for a preview without squeezing the Properties panel, so the window is reshaped as two rows: the top row keeps the controls, info panels, structure preview, and Properties; the bottom row puts the library table and the spectrum mirror plot side by side (table widened, spectrum narrowed).

What changes

  • ViewModel/Search/CompoundSearchVM.cs — the non-generic base VM holds a MoleculeStructureModel, subscribed to SelectedCompound, exposed as StructureViewModel. All six per-platform VMs (Gcms Analysis/Alignment, Lcms, Dims, Imms, Lcimms) inherit it together.
    • Unlike the analysis/alignment models, ICompoundSearchModel has no natural owner for an annotated molecule, so the model lives on the VM here.
  • Six View/*/*CompoundSearchView.xaml — two-row outer grid as described above, with MoleculeStructureView bound to StructureViewModel in the top middle, and the three info panels switched from WrapPanel to an explicit grid so they always sit side by side. GcmsAnalysisCompoundSearchView keeps its original two info panels (File + Spectrum); the other five keep three (File + Peak + Annotation).

Tests

  • dotnet build src/MSDIAL5/MsdialGuiApp/MsdialGuiApp.csproj /p:Configuration="Debug vendor unsupported" builds with 0 errors on net48 and net472.
  • Manually verified on Windows, GC/MS only: the structure preview renders, follows the row selection, and falls back to "No available structure." for rows without SMILES. The other five platforms use the same VM base class and a similar XAML structure but were not exercised manually.

Out of scope

  • No automated tests: MsdialGuiAppTests does not cover the CompoundSearchVM family, and MoleculeStructureViewModel wraps NCDK DepictionGenerator, which is not practical to drive headlessly.
  • An earlier draft put the preview in the main view's Candidates tab; that is reverted before this commit.
  • Lifting MoleculeStructureModel from the VM into ICompoundSearchModel (the way GcmsAnalysisModel holds one) would let future search windows share a cache, but is a separate change.

AI assistance was used to develop this contribution. I provided the requirements and manually tested the GC/MS compound-search behavior on Windows. Build results and the limits of manual test coverage are documented above. I take responsibility for the submitted changes.

The Compound search window (opened on a double-click of a peak in
analysis or alignment) shows the detailed match info (Selected Library
ID, similarity scores) for the row selected in the library table but
has no structure preview. Each platform reuses the same
MoleculeStructureView the main window's Structure tab uses, so the
preview just needs an SMILES-bearing source and a place to sit.

* ViewModel/Search/CompoundSearchVM.cs: a single
  MoleculeStructureModel is held by the base VM, subscribed to
  SelectedCompound, and exposed as StructureViewModel for the views.
  Placed on the non-generic CompoundSearchVM so the six per-platform
  VMs (Gcms Analysis/Alignment, Lcms, Dims, Imms, Lcimms) pick it up
  together. MoleculeStructureModel is held by the VM here rather than
  the ICompoundSearchModel model because the model has no natural
  owner for an 'annotated molecule' the way GcmsAnalysisModel does;
  the per-search-window lifetime is short and the 20-entry LRU cache
  is recreated on demand.

* View/{Gcms,GcmsAlignment,Lcms,Dims,Imms,Lcimms}*CompoundSearchView.xaml:
  rewrite the outer grid as two rows. Row 1 is the existing controls,
  info panels, properties, plus the new MoleculeStructureView (no
  border) in a middle column. Row 2 moves the library table and the
  spectrum mirror plot side by side, with the table widened to 5*
  and the spectrum narrowed to 2*. The three info panels (File, Peak,
  Annotation) become an explicit three-column grid instead of a
  WrapPanel. GcmsAnalysis keeps the original two panels (File +
  Spectrum) to match the existing template set.

Verified: 'dotnet build src/MSDIAL5/MsdialGuiApp/MsdialGuiApp.csproj
/p:Configuration="Debug vendor unsupported" --framework net48' builds
with 0 errors. The behavior was checked manually in
'Debug vendor unsupported' net48 on Windows by opening a GC/MS
project, double-clicking an annotated peak, and confirming that the
structure preview renders, follows the row selection, and falls
back to 'No available structure.' when the row has no SMILES.

Out of scope: no automated tests. MoleculeStructureViewModel is a
thin wrapper over MoleculeStructureModel around NCDK DepictionGenerator
which is hard to drive headlessly on a non-Windows runner, and
MsdialGuiAppTests does not currently cover the CompoundSearchVM
family. The new StructureViewModel property is read-only and has the
same Disposables-bound lifetime as the surrounding VM, so manual
verification on Windows is the appropriate gate here, the same as
the rest of the GUI in this project.
@YukiMatsuzawa

Copy link
Copy Markdown
Contributor

Thank you for your contribution! I’ll merge this after testing it.

@YukiMatsuzawa
YukiMatsuzawa merged commit 37021d7 into systemsomicslab:master Oct 21, 2026
1 check passed
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.

2 participants