Skip to content

Added GNPS exporter#596

Merged
YukiMatsuzawa merged 20 commits intomasterfrom
gnps_export
Sep 5, 2025
Merged

Added GNPS exporter#596
YukiMatsuzawa merged 20 commits intomasterfrom
gnps_export

Conversation

@htsugawa
Copy link
Copy Markdown
Contributor

@htsugawa htsugawa commented Jul 7, 2025

No description provided.

@htsugawa htsugawa requested review from YukiMatsuzawa and Copilot July 7, 2025 14:36

This comment was marked as outdated.

YukiMatsuzawa and others added 19 commits July 9, 2025 01:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Improved readability and maintainability of `AlignmentGnpsExporter.cs` by:
- Removing redundant property initializations.
- Simplifying null/empty checks for `spots` with pattern matching.
- Modularizing export logic into separate methods for GNPS tables, MGF files, and edge files.
- Replacing legacy edge export code with new methods for peak shape, ion correlation, in-source, and adduct edges.
- Adding static methods for building and exporting edges to reduce code duplication.
- Standardizing `using` statements for better resource management.
Updated the `AlignmentGnpsExporter` class to use file streams for exporting edges instead of direct file paths. This change improves resource management by ensuring streams are properly disposed of. The export methods for peak shape edges, ion correlation edges, in-source edges, and adduct edges now accept a `Stream` parameter, enhancing flexibility in file handling.
Updated the AlignmentGnpsExporter class to utilize a new GnpsEdges class for managing edges. Refactored edge export methods to be instance methods of GnpsEdges, improving encapsulation and data management. Modified BuildGnpsEdges to return GnpsEdges instead of a list of GnpsEdge objects, enhancing code structure and readability.
- Introduced `IsSelected` property with backing field.
- Updated `CountExportFiles` to return 0 if not selected.
- Modified `Export` method to return early if not selected.
Introduces the `AlignmentGnpsExportViewModel` class to manage GNPS export functionality, implementing the `IAlignmentResultExportViewModel` interface. This class includes properties for export state management and utilizes reactive programming features.

Also updates the `AlignmentResultExportViewModel` to handle `AlignmentGnpsExportModel`, integrating the new view model into the existing export workflow.
Introduced a new DataTemplate for AlignmentGnpsExportViewModel, featuring an Expander that contains a CheckBox for GNPS selection. The CheckBox is bound to the IsSelected.Value property with two-way binding for user interaction.
- Introduced a new `quantTypes` array for export types, improving code readability.
- Updated `peakGroup` initialization to use the `quantTypes` array.
- Added `AlignmentGnpsExportModel` to `exportGroups` for GNPS export support.
- Simplified `spectraGroup` initialization syntax for `ExportspectraType.deconvoluted`.
- Enhanced modularity and maintainability of the code.
Removed GnpsEdgeFilePath and associated edge export functionality from AlignmentGnpsExporter. Edge export logic has been moved to AlignmentGnpsExportModel, ensuring better organization. Standardized date formatting for output file names using a DateTime variable.
# Conflicts:
#	src/MSDIAL5/MsdialGuiApp/Model/Lcms/LcmsMethodModel.cs
#	src/MSDIAL5/MsdialGuiApp/View/Export/AlignmentResultExportWin.xaml
#	src/MSDIAL5/MsdialGuiApp/ViewModel/Export/AlignmentResultExportViewModel.cs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds GNPS (Global Natural Products Social) molecular networking export functionality to MSDIAL5 and updates the target framework from .NET 6.0 to .NET 8.0 across multiple projects.

  • Implements GNPS export functionality with table and MGF spectrum export capabilities
  • Updates target framework from .NET 6.0 to .NET 8.0 across test projects and core libraries
  • Integrates GNPS exporter into all method models (LC-MS, LC-IM-MS, IMMS, GC-MS, DIMS)

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AlignmentGnpsExporter.cs New GNPS exporter implementation with table/MGF export and edge building functionality
AlignmentGnpsExportModel.cs New model class for GNPS export configuration and execution
AlignmentGnpsExportViewModel.cs New view model for GNPS export UI binding
AlignmentResultExportWin.xaml Added GNPS export UI template
Method model files Integrated GNPS exporter into all analytical method configurations
SpectraExport.cs Enhanced MGF export with GNPS-specific metadata fields
Project files Updated target framework from net6.0 to net8.0
GitHub workflow Added .NET 8.0 setup for CI/CD pipeline

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +265 to +269
public string Type { get; set; }
public string Score { get; set; }
public string Annotation { get; set; }
public string EdgeID { get; set; }
public string EdgeIdShort { get; set; }
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Properties should have null-safety annotations. Consider adding nullable reference type annotations or initializing with default values to prevent potential null reference issues.

Suggested change
public string Type { get; set; }
public string Score { get; set; }
public string Annotation { get; set; }
public string EdgeID { get; set; }
public string EdgeIdShort { get; set; }
public string EdgeIdShort { get; set; } = string.Empty;

Copilot uses AI. Check for mistakes.

public sealed class GnpsEdges
{
public List<GnpsEdge> Edges { get; set; }
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Property should have null-safety annotation. Consider using List<GnpsEdge>? or initializing with an empty list to prevent potential null reference issues.

Suggested change
public List<GnpsEdge> Edges { get; set; }
public List<GnpsEdge> Edges { get; set; } = new List<GnpsEdge>();

Copilot uses AI. Check for mistakes.
Comment on lines +156 to +158
//if (edges.Count > 0) {
// edges = edges.GroupBy(n => n.EdgeID).Select(g => g.First()).ToList();
//}
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented-out code or add a comment explaining why this code is preserved for future reference.

Suggested change
//if (edges.Count > 0) {
// edges = edges.GroupBy(n => n.EdgeID).Select(g => g.First()).ToList();
//}

Copilot uses AI. Check for mistakes.
@YukiMatsuzawa YukiMatsuzawa merged commit 0068d22 into master Sep 5, 2025
5 checks passed
@YukiMatsuzawa YukiMatsuzawa deleted the gnps_export branch September 5, 2025 01:35
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.

3 participants