Added link to LIPIDMAPS to search and display lipid information#599
Added link to LIPIDMAPS to search and display lipid information#599
Conversation
Introduce the `LipidmapsRestAPIHandler` class to facilitate asynchronous retrieval of lipid information from the LipidMaps database via REST API calls. Implement methods for constructing request URIs, sending HTTP requests, and processing JSON responses. Include a private `LipidAbbreviation` class to represent lipid abbreviations with relevant properties.
Introduces the `LipidmapsLinkItem` class to encapsulate a URI and lipid name from the LIPIDMAPS database. The class features an immutable design with a constructor for initialization and public properties for accessing the URI and lipid name.
Introduces the `LipidmapsLinksModel` class in the `CompMs.App.Msdial.Model.Information` namespace. This class manages the retrieval and observation of lipid data from the LIPIDMAPS database using the `LipidmapsRestAPIHandler`. It tracks the state of retrieved items and the retrieval process, utilizing reactive programming concepts for asynchronous data handling.
Introduces the `LipidmapsLinkViewModel` class in the `CompMs.App.Msdial.ViewModel.Information` namespace. This class manages a private `LipidmapsLinksModel` instance and exposes a read-only property `CurrentItems` as a `ReadOnlyReactivePropertySlim` for reactive data binding.
Updated `LipidmapsRestAPIHandler.cs` to improve lipid data retrieval from the LIPID MAPS API. Key changes include: - Corrected `_compoundAbbrev` endpoint for lipid abbreviations. - Added `Deserialize` method for JSON response handling. - Refactored `RetrieveLipidsAsync` to utilize `Deserialize` and introduced `GetLipidNameAndAnnotationLevel` for better lipid name processing. - Adjusted request URI construction logic for accuracy. - Simplified error handling to return an empty array on exceptions. - Enhanced comments and documentation for clarity.
Changed the parameter in `_handler.RetrieveLipidsAsync` from `m.InChIKey` to `m.Name`. Removed the immediate completion of the observer to allow for ongoing data emission.
This commit introduces a new UserControl named `LipidmapsLinkView` that features a data-bound `ItemsControl` for displaying `LipidmapsLinkItem` objects. Each item includes a `Hyperlink` that navigates to a specified URI when clicked. The code-behind file is updated to handle hyperlink navigation, allowing users to open links in their default web browser, thereby enhancing the application's interactivity with lipid maps.
This commit introduces a new feature for lipidomics in the `LcmsAlignmentModel` and `LcmsAnalysisModel` classes by adding a `LipidmapsLinksModel` property. It initializes this model when the target omics is set to lipidomics, utilizing a `LipidmapsRestAPIHandler`. The `LipidmapsLinkViewModel` is also integrated into the view models and XAML templates, enabling the display of database links in the UI. Additionally, the handling of peak detail view models is refactored to conditionally include the new lipid maps links model, improving functionality and user experience for lipidomics data.
This commit introduces support for handling lipidomics data through the addition of `LipidmapsLinksModel` and `LipidmapsRestAPIHandler`. Key changes include: - Conditional handling of `MoleculeStructureModel` based on target omics type, with the property now nullable. - Introduction of `LipidmapsLinkViewModel` for displaying database links in the UI. - Refactoring of `PeakDetailViewModels` to dynamically include `LipidmapsLinkViewModel` when applicable. - Integration of `LipidmapsLinksModel` into view models for reactive UI updates. These enhancements improve the application's capability to manage lipidomics data and ensure the UI accurately reflects the underlying data model.
Refactor the `LipidmapsLinksModel` constructor to accept an observable sequence of `MsScanMatchResult?` instead of `IMoleculeProperty?`. Modify the `Target` parameter to select the `Representative` property from `MatchResultsModel` for improved data specificity. These changes are applied across Dims, Gcms, Imms, Lcimms, and Lcms model files. Additionally, update `using` directives in `LipidmapsLinksModel.cs` to include `CompMs.Common.DataObj.Result`.
Modified the `RowDefinition` height from `Auto` to a fixed value of `235` in multiple XAML files: `DimsMainView.xaml`, `GcmsMainView.xaml`, `ImmsMainView.xaml`, `LcimmsMainView.xaml`, and `LcmsMainView.xaml`. In `LipidmapsLinkView.xaml`, replaced a `Grid` with a `ScrollViewer` to enable vertical scrolling for the `ItemsControl`.
Updated LipidmapsRestAPIHandler to include a new static string for the PubChem compound page URL. Modified RetrieveLipidsAsync to return a tuple with lipid name, LIPIDMAPS page URI, and PubChem page URI. Enhanced LipidAbbreviation class to include systematic name and PubChem CID properties, and updated deserialization logic accordingly. Refactored LipidmapsLinkItem constructor to accept URIs for both LIPIDMAPS and PubChem links. Updated LipidmapsLinksModel to utilize the new constructor for creating LipidmapsLinkItem instances.
Updated the API request path in `LipidmapsRestAPIHandler.cs` to use `pubchem_cid` instead of `pubchem_id`. Improved null safety in `LipidmapsLinksModel.cs` by using the null-conditional operator for the `Name` property. Enhanced the UI in `LipidmapsLinkView.xaml` to provide clearer context for hyperlinks by adding source indicators for LIPIDMAPS and PubChem.
Added handling for null `Name` properties in molecules. When a molecule's name is null, `_currentItems.OnNext([]);` is called to update the current items to an empty list. This change is part of an observable sequence that indicates no items are present and that retrieval is in progress.
Updated LipidmapsLinksModel to use backing fields for Retrieving and HasItems properties, improving data binding. Restructured LipidmapsLinkView.xaml to include a Grid layout with enhanced item display and a message for no links. Introduced LoadingControlStyle for a loading animation when data is being retrieved. Updated LipidmapsLinkViewModel to observe changes in Retrieving and HasItems, enabling reactive UI updates.
Set Focusable to False to improve keyboard focus management.
Refactor `TextBlock` elements in multiple XAML files to use more concise text. Added tooltips for better context: - "Basic peak property" changed to "Peak" - "Compound detail" changed to "Compound" - "Database links" changed to "Links"
There was a problem hiding this comment.
Pull Request Overview
This PR integrates LIPIDMAPS links into the application by adding REST handling, models, view models, and UI templates to display lipid database links alongside existing peak detail pages.
- Introduced
LipidmapsRestAPIHandler,LipidmapsLinksModel,LipidmapsLinkItem, andLipidmapsLinkViewModelfor asynchronous retrieval and presentation of lipid links. - Updated all Analysis/Alignment view models to build
PeakDetailViewModelslists that includeLipidmapsLinkViewModelwhen lipidomics data is available. - Modified main views and styles (XAML) to add a loading indicator style and new data templates for lipid link views.
Reviewed Changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/MSDIAL5/MsdialCore/Algorithm/LipidmapsRestAPIHandler.cs | New REST handler for LIPIDMAPS API calls |
| src/MSDIAL5/MsdialGuiApp/Model/Information/LipidmapsLinksModel.cs | New model managing retrieval and state for lipid links |
| src/MSDIAL5/MsdialGuiApp/Model/Information/LipidmapsLinkItem.cs | Immutable data class for individual lipid link entries |
| src/MSDIAL5/MsdialGuiApp/ViewModel/Information/LipidmapsLinkViewModel.cs | New view model exposing link items and retrieval state |
| src/MSDIAL5/MsdialGuiApp/View/Information/LipidmapsLinkView.xaml[.cs] | New view and code-behind for displaying lipid links and handling hyperlink navigation |
| src/MSDIAL5/MsdialGuiApp/View/MainWindowStyle.xaml | Added LoadingControlStyle for animated loading indicator |
src/MSDIAL5/MsdialGuiApp/View/Lcms/LcmsMainView.xaml (and other *MainView.xaml files) |
Updated row height, inserted lipid link data templates, and tooltips in all main views |
| src/MSDIAL5/MsdialGuiApp/ViewModel/Lcms/LcmsAnalysisViewModel.cs (and other view model files) | Refactored PeakDetailViewModels to build a list and include LipidmapsLinkViewModel when available |
| src/MSDIAL5/MsdialGuiApp/Model/Lcms/LcmsAnalysisModel.cs (and other model files) | Conditionally instantiate LipidmapsLinksModel when target omics is lipidomics |
Comments suppressed due to low confidence (2)
src/MSDIAL5/MsdialGuiApp/ViewModel/Lcimms/LcimmsAnalysisViewModel.cs:121
- [nitpick] The variable name
matchResultCandidateViewModel(singular) is inconsistent with the classMatchResultCandidatesViewModeland other view models using the plural form. Rename tomatchResultCandidatesViewModelfor consistency.
var matchResultCandidateViewModel = new MatchResultCandidatesViewModel(model.MatchResultCandidatesModel).AddTo(Disposables);
src/MSDIAL5/MsdialCore/Algorithm/LipidmapsRestAPIHandler.cs:47
- This new API handler method lacks unit tests to verify successful retrieval, error fallback, and edge cases. Adding tests for
RetrieveLipidsAsyncand its JSON deserialization paths will improve reliability.
public async Task<(string? LipidName, Uri? LipidmapsPage, Uri? PubChemPage)[]> RetrieveLipidsAsync(string rawlipid, CancellationToken token) {
| } | ||
|
|
||
| private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) { | ||
| System.Diagnostics.Process.Start(e.Uri.ToString()); |
There was a problem hiding this comment.
On .NET Core/5+, Process.Start(string) may throw an exception if UseShellExecute is false by default. Consider using:
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri) { UseShellExecute = true });| System.Diagnostics.Process.Start(e.Uri.ToString()); | |
| System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(e.Uri.ToString()) { UseShellExecute = true }); |
| PeakDetailViewModels = new ViewModelBase[] { PeakInformationViewModel, CompoundDetailViewModel, matchResultCandidatesViewModel, }; | ||
| } | ||
| else { | ||
| var peakDetailViewModels = new List<ViewModelBase> { PeakInformationViewModel, CompoundDetailViewModel, }; |
There was a problem hiding this comment.
This pattern of building peakDetailViewModels is duplicated across many Analysis/Alignment view models. Consider extracting a helper method or base class to reduce duplication and ease future maintenance.
| <Grid Grid.Column="1"> | ||
| <Grid.RowDefinitions> | ||
| <RowDefinition Height="Auto" MinHeight="235" /> | ||
| <RowDefinition Height="235" MinHeight="235" /> |
There was a problem hiding this comment.
[nitpick] The fixed height of 235 is a magic number. Consider using a named resource or a MinHeight plus Auto sizing for adaptability across different layouts.
PR Classification
New feature to enhance lipid data retrieval and display in the application.
PR Summary
This pull request introduces functionality for interacting with the LIPIDMAPS database, allowing for the retrieval and display of lipid information within the application. Key changes include: