diff --git a/src/Common/CommonStandard/Enum/CommonEnums.cs b/src/Common/CommonStandard/Enum/CommonEnums.cs index 9ecfec21e..1e4720d51 100644 --- a/src/Common/CommonStandard/Enum/CommonEnums.cs +++ b/src/Common/CommonStandard/Enum/CommonEnums.cs @@ -39,7 +39,7 @@ public enum RiCompoundType { Alkanes, Fames } public enum AlignmentIndexType { RT, RI } public enum TargetOmics { Metabolomics, Lipidomics, Proteomics } public enum Ionization { ESI, EI } - public enum ExportSpectraFileFormat { mgf, msp, txt, mat, ms } + public enum ExportSpectraFileFormat { mgf, msp, txt, mat, ms, sdf } public enum ExportspectraType { profile, centroid, deconvoluted } public enum IonAbundanceUnit { Intensity, Height, Area, pmol, fmol, ng, pg, diff --git a/src/MSDIAL5/MsdialCore/Export/AlignmentSdfExporter.cs b/src/MSDIAL5/MsdialCore/Export/AlignmentSdfExporter.cs new file mode 100644 index 000000000..2d01211fd --- /dev/null +++ b/src/MSDIAL5/MsdialCore/Export/AlignmentSdfExporter.cs @@ -0,0 +1,28 @@ +using CompMs.MsdialCore.DataObj; +using CompMs.MsdialCore.MSDec; +using System.IO; + +namespace CompMs.MsdialCore.Export; + +public sealed class AlignmentSdfExporter : IAlignmentSpectraExporter +{ + private readonly bool _exportNoMs2Molecule; + private readonly bool _set2dCoordinates; + public AlignmentSdfExporter(bool exportNoMs2Molecule, bool set2dCoordinates) + { + _exportNoMs2Molecule = exportNoMs2Molecule; + _set2dCoordinates = set2dCoordinates; + } + public AlignmentSdfExporter() : this(exportNoMs2Molecule: true, set2dCoordinates: true) { } + + void IAlignmentSpectraExporter.Export(Stream stream, AlignmentSpotProperty spot, MSDecResult msdecResult) + { + SpectraExport.SaveSpectraTableAsSdfFormat( + stream, + spot, + msdecResult.Spectrum, + _exportNoMs2Molecule, + _set2dCoordinates + ); + } +} diff --git a/src/MSDIAL5/MsdialCore/Export/AnalysisSdfExporter.cs b/src/MSDIAL5/MsdialCore/Export/AnalysisSdfExporter.cs new file mode 100644 index 000000000..53d8020c9 --- /dev/null +++ b/src/MSDIAL5/MsdialCore/Export/AnalysisSdfExporter.cs @@ -0,0 +1,31 @@ +using CompMs.MsdialCore.DataObj; +using CompMs.MsdialCore.Parser; +using System; +using System.IO; + +namespace CompMs.MsdialCore.Export +{ + public sealed class AnalysisSdfExporter : IAnalysisExporter + { + private readonly Func> _loaderFactory; + + public AnalysisSdfExporter(Func> loaderFuctory) { + _loaderFactory = loaderFuctory ?? throw new ArgumentNullException(nameof(loaderFuctory)); + } + private readonly bool _exportNoMs2Molecule = true; + private readonly bool _set2dCoordinates = true; + + void IAnalysisExporter.Export(Stream stream, AnalysisFileBean analysisFile, ChromatogramPeakFeatureCollection peakFeatureCollection, ExportStyle exportStyle) { + var loader = _loaderFactory(analysisFile); + foreach (var peak in peakFeatureCollection.Items) { + SpectraExport.SaveSpectraTableAsSdfFormat( + stream, + peak, + loader.Load(peak).Spectrum, + _exportNoMs2Molecule, + _set2dCoordinates + ); + } + } + } +} diff --git a/src/MSDIAL5/MsdialCore/Export/SpectraExport.cs b/src/MSDIAL5/MsdialCore/Export/SpectraExport.cs index 5592a2e73..932e4ff49 100644 --- a/src/MSDIAL5/MsdialCore/Export/SpectraExport.cs +++ b/src/MSDIAL5/MsdialCore/Export/SpectraExport.cs @@ -9,8 +9,13 @@ using CompMs.MsdialCore.DataObj; using CompMs.MsdialCore.Parameter; using CompMs.MsdialCore.Utility; +using NCDK; +using NCDK.IO; +using NCDK.Layout; +using NCDK.Smiles; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -34,6 +39,9 @@ public static void SaveSpectraTable( case ExportSpectraFileFormat.mgf: SaveSpectraTableAsMgfFormat(exportStream, chromPeakFeature, scan.Spectrum); break; + case ExportSpectraFileFormat.sdf: + SaveSpectraTableAsSdfFormat(exportStream, chromPeakFeature, scan.Spectrum, true, true); + break; case ExportSpectraFileFormat.mat: SaveSpectraTableAsMatFormat(exportStream, chromPeakFeature, scan.Spectrum, spectrumList, mapper, parameter); break; @@ -53,7 +61,8 @@ public static void SaveSpectraTable( IMSScanProperty scan, DataBaseMapper mapper, ParameterBase parameter, - AlignmentSpotProperty isotopeTrackedLastSpot = null) { + AlignmentSpotProperty isotopeTrackedLastSpot = null) + { switch (spectraFormat) { case ExportSpectraFileFormat.msp: SaveSpectraTableAsNistFormat(exportStream, spotProperty, scan.Spectrum, mapper, parameter); @@ -61,6 +70,9 @@ public static void SaveSpectraTable( case ExportSpectraFileFormat.mgf: SaveSpectraTableAsMgfFormat(exportStream, spotProperty, scan.Spectrum); break; + case ExportSpectraFileFormat.sdf: + SaveSpectraTableAsSdfFormat(exportStream, spotProperty, scan.Spectrum, true, true); + break; case ExportSpectraFileFormat.mat: SaveSpectraTableAsMatFormat(exportStream, spotProperty, scan.Spectrum, mapper, parameter, isotopeTrackedLastSpot); break; @@ -308,6 +320,152 @@ private static void WriteChromXFieldAsMGF( } #endregion + #region sdf + public static void SaveSpectraTableAsSdfFormat( + Stream stream, + AlignmentSpotProperty spotProperty, + IEnumerable spectrum, + bool exportNoMs2Molecule, + bool Set2dCoordinates + ) + { + if (!exportNoMs2Molecule && !spotProperty.IsMsmsAssigned) + { + return; + } + var sb = new StringBuilder(8 * 1024); + if(spotProperty.IsMsmsAssigned) + { + MolBlockFromSmiles(sb, spotProperty.SMILES, Set2dCoordinates); + } + else + { + EmptyMolBlock(sb); + } + WriteChromPeakFeatureInfoAsSdf(sb, spotProperty, spectrum); + sb.AppendLine("$$$$"); + sb.AppendLine(); + var bytes = Encoding.ASCII.GetBytes(sb.ToString()); + stream.Write(bytes, 0, bytes.Length); + } + public static void SaveSpectraTableAsSdfFormat( + Stream stream, + ChromatogramPeakFeature chromPeakFeature, + IEnumerable spectrum, + bool exportNoMs2Molecule, + bool Set2dCoordinates + ) + { + if (!exportNoMs2Molecule && !chromPeakFeature.IsMsmsContained) + { + return; + } + var sb = new StringBuilder(8 * 1024); + if (chromPeakFeature.IsMsmsContained) + { + MolBlockFromSmiles(sb, chromPeakFeature.SMILES, Set2dCoordinates); + } + else + { + EmptyMolBlock(sb); + } + WriteChromPeakFeatureInfoAsSdf(sb, chromPeakFeature, spectrum); + sb.AppendLine("$$$$"); + sb.AppendLine(); + var bytes = Encoding.ASCII.GetBytes(sb.ToString()); + stream.Write(bytes, 0, bytes.Length); + } + private static void WriteSdfDataItem(StringBuilder sb, string fieldName, string value) + { + sb.AppendLine("> <" + fieldName + ">"); + sb.AppendLine(value ?? string.Empty); + } + private static void EmptyMolBlock(StringBuilder sb) + { + sb.AppendLine(""); + sb.AppendLine(" MS-DIAL"); + sb.AppendLine(); + sb.AppendLine(" 0 0 0 0 0 0 999 V2000"); + sb.AppendLine("M END"); + + } + private static void MolBlockFromSmiles(StringBuilder sb, string smiles, bool Set2dCoordinates) + { + var sp = new SmilesParser(); + IAtomContainer mol = sp.ParseSmiles(smiles); + var sdg = new StructureDiagramGenerator + { + Molecule = mol + }; + if(Set2dCoordinates) + { + sdg.GenerateCoordinates(); + } + mol = sdg.Molecule; + using var tw = new StringWriter(sb, CultureInfo.InvariantCulture); + using (var w = new MDLV2000Writer(tw)) + { + w.Write(mol); + }; + } + private static void WriteChromPeakFeatureInfoAsSdf( + StringBuilder sb, + AlignmentSpotProperty spotProperty, + IEnumerable spectrum) + { + WriteSdfDataItem(sb, "NAME", string.IsNullOrWhiteSpace(spotProperty.Name)? "Unknown": spotProperty.Name); + WriteSdfDataItem(sb, "SCANS", spotProperty.MasterAlignmentID.ToString()); + WriteSdfDataItem(sb, "PRECURSOR MZ", Math.Round(spotProperty.MassCenter,5).ToString()); + WriteSdfDataItem(sb, "ION MODE", spotProperty.IonMode.ToString()); + + if (spotProperty.IsMsmsAssigned) + { + if (spotProperty.AdductType != null) WriteSdfDataItem(sb, "PRECURSOR TYPE", spotProperty.AdductType.AdductIonName); + if (!string.IsNullOrWhiteSpace(spotProperty.Formula.FormulaString)) WriteSdfDataItem(sb, "FORMULA", spotProperty.Formula.FormulaString); + if (!string.IsNullOrWhiteSpace(spotProperty.InChIKey)) WriteSdfDataItem(sb, "FORMULA", spotProperty.InChIKey); + if (!string.IsNullOrWhiteSpace(spotProperty.SMILES)) WriteSdfDataItem(sb, "FORMULA", spotProperty.SMILES); + WriteSdfDataItem(sb, "MS LEVEL", "MS2"); + var peaks = spectrum.Where(spec => spec.Intensity > 0).ToList(); + WriteSdfDataItem(sb, "NUM PEAKS", peaks.Count.ToString()); + var peaksText = string.Join( + "\n", + spectrum.Select(p => + $"{Math.Round(p.Mass, 5)} {Math.Round(p.Intensity,0)}" + ) + ); + WriteSdfDataItem(sb, "MASS SPECTRAL PEAKS", peaksText); + } + } + private static void WriteChromPeakFeatureInfoAsSdf( + StringBuilder sb, + ChromatogramPeakFeature spotProperty, + IEnumerable spectrum) + { + WriteSdfDataItem(sb, "NAME", string.IsNullOrWhiteSpace(spotProperty.Name) ? "Unknown" : spotProperty.Name); + WriteSdfDataItem(sb, "SCANS", spotProperty.PeakID.ToString()); + WriteSdfDataItem(sb, "PRECURSOR MZ", Math.Round(spotProperty.PrecursorMz, 5).ToString()); + WriteSdfDataItem(sb, "ION MODE", spotProperty.IonMode.ToString()); + + if (spotProperty.IsMsmsContained) + { + if (spotProperty.AdductType != null) WriteSdfDataItem(sb, "PRECURSOR TYPE", spotProperty.AdductType.AdductIonName); + if (!string.IsNullOrWhiteSpace(spotProperty.Formula.FormulaString)) WriteSdfDataItem(sb, "FORMULA", spotProperty.Formula.FormulaString); + if (!string.IsNullOrWhiteSpace(spotProperty.InChIKey)) WriteSdfDataItem(sb, "FORMULA", spotProperty.InChIKey); + if (!string.IsNullOrWhiteSpace(spotProperty.SMILES)) WriteSdfDataItem(sb, "FORMULA", spotProperty.SMILES); + WriteSdfDataItem(sb, "MS LEVEL", "MS2"); + var peaks = spectrum.Where(spec => spec.Intensity > 0).ToList(); + WriteSdfDataItem(sb, "NUM PEAKS", peaks.Count.ToString()); + var peaksText = string.Join( + "\n", + spectrum.Select(p => + $"{Math.Round(p.Mass, 5)} {Math.Round(p.Intensity, 0)}" + ) + ); + WriteSdfDataItem(sb, "MASS SPECTRAL PEAKS", peaksText); + } + } + #endregion + #region mat private static void SaveSpectraTableAsMatFormat( Stream stream, diff --git a/src/MSDIAL5/MsdialGuiApp/Model/Dims/DimsMethodModel.cs b/src/MSDIAL5/MsdialGuiApp/Model/Dims/DimsMethodModel.cs index fa87a97a6..95b05a1dd 100644 --- a/src/MSDIAL5/MsdialGuiApp/Model/Dims/DimsMethodModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/Model/Dims/DimsMethodModel.cs @@ -99,6 +99,7 @@ public DimsMethodModel( peakSpotSupplyer, new AlignmentSpectraExportFormat("Msp", "msp", new AlignmentMspExporter(storage.DataBaseMapper, storage.Parameter)), new AlignmentSpectraExportFormat("Mgf", "mgf", new AlignmentMgfExporter()), + new AlignmentSpectraExportFormat("Sdf", "sdf", new AlignmentSdfExporter()), new AlignmentSpectraExportFormat("Mat", "mat", new AlignmentMatExporter(storage.DataBaseMapper, storage.Parameter))); var gnps = new AlignmentGnpsExportModel("GNPS", quantTypes, new GnpsMetadataAccessor(storage.DataBaseMapper, storage.Parameter), peakMeta.GetAccessor(), fileMeta.GetAccessor(), analysisFileBeanModelCollection); var spectraAndReference = new AlignmentMatchedSpectraExportModel(peakSpotSupplyer, storage.DataBaseMapper, analysisFileBeanModelCollection.IncludedAnalysisFiles, CompoundSearcherCollection.BuildSearchers(storage.DataBases, storage.DataBaseMapper)); diff --git a/src/MSDIAL5/MsdialGuiApp/Model/Gcms/GcmsMethodModel.cs b/src/MSDIAL5/MsdialGuiApp/Model/Gcms/GcmsMethodModel.cs index be89e2a3c..382df99ff 100644 --- a/src/MSDIAL5/MsdialGuiApp/Model/Gcms/GcmsMethodModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/Model/Gcms/GcmsMethodModel.cs @@ -112,6 +112,7 @@ public GcmsMethodModel(AnalysisFileBeanModelCollection analysisFileBeanModelColl peakSpotSupplyer, new AlignmentSpectraExportFormat("Msp", "msp", new AlignmentMspExporter(storage.DataBaseMapper, storage.Parameter)), new AlignmentSpectraExportFormat("Mgf", "mgf", new AlignmentMgfExporter()), + new AlignmentSpectraExportFormat("Sdf", "sdf", new AlignmentSdfExporter()), new AlignmentSpectraExportFormat("Mat", "mat", new AlignmentMatExporter(storage.DataBaseMapper, storage.Parameter))); var gnps = new AlignmentGnpsExportModel("GNPS", quantTypes, new GnpsMetadataAccessor(storage.DataBaseMapper, storage.Parameter), peakMeta.GetAccessor(), fileMeta.GetAccessor(), analysisFileBeanModelCollection); var exportGroups = new List { peakGroup, spectraGroup, gnps, }; diff --git a/src/MSDIAL5/MsdialGuiApp/Model/ImagingImms/ImagingImmsMethodModel.cs b/src/MSDIAL5/MsdialGuiApp/Model/ImagingImms/ImagingImmsMethodModel.cs index f879ec605..6ddff5703 100644 --- a/src/MSDIAL5/MsdialGuiApp/Model/ImagingImms/ImagingImmsMethodModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/Model/ImagingImms/ImagingImmsMethodModel.cs @@ -15,6 +15,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Threading; @@ -150,6 +151,15 @@ public AnalysisResultExportModel CreateExportAnalysisModel() { FileSuffix = "mgf", Label = "MASCOT format (*.mgf)" }, + new SpectraTypeSelectableMsdialAnalysisExportModel(new Dictionary> { + [ExportspectraType.deconvoluted] = new AnalysisSdfExporter(file => new MSDecLoader(file.DeconvolutionFilePath, file.DeconvolutionFilePathList)), + [ExportspectraType.centroid] = new AnalysisSdfExporter(file => new CentroidMsScanPropertyLoader(_storage.Parameter.ProviderFactoryParameter.Create().Create(file.LoadRawMeasurement(true, true, 5, 5000)), _storage.Parameter.MS2DataType)), + }) + { + FilePrefix = "Sdf", + FileSuffix = "sdf", + Label = "MDL SDfile (*.sdf)" + }, new MsdialAnalysisMassBankRecordExportModel(_storage.Parameter.ProjectParam, StudyContext), }; diff --git a/src/MSDIAL5/MsdialGuiApp/Model/Imms/ImmsMethodModel.cs b/src/MSDIAL5/MsdialGuiApp/Model/Imms/ImmsMethodModel.cs index 9056c73ae..844ae0aad 100644 --- a/src/MSDIAL5/MsdialGuiApp/Model/Imms/ImmsMethodModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/Model/Imms/ImmsMethodModel.cs @@ -104,6 +104,7 @@ public ImmsMethodModel(AnalysisFileBeanModelCollection analysisFileBeanModelColl peakSpotSupplyer, new AlignmentSpectraExportFormat("Msp", "msp", new AlignmentMspExporter(storage.DataBaseMapper, storage.Parameter)), new AlignmentSpectraExportFormat("Mgf", "mgf", new AlignmentMgfExporter()), + new AlignmentSpectraExportFormat("Sdf", "sdf", new AlignmentSdfExporter()), new AlignmentSpectraExportFormat("Mat", "mat", new AlignmentMatExporter(storage.DataBaseMapper, storage.Parameter))); var gnps = new AlignmentGnpsExportModel("GNPS", quantTypes, new GnpsMetadataAccessor(storage.DataBaseMapper, storage.Parameter), peakMeta.GetAccessor(), fileMeta.GetAccessor(), analysisFileBeanModelCollection); var spectraAndReference = new AlignmentMatchedSpectraExportModel(peakSpotSupplyer, storage.DataBaseMapper, analysisFileBeanModelCollection.IncludedAnalysisFiles, CompoundSearcherCollection.BuildSearchers(storage.DataBases, storage.DataBaseMapper)); @@ -317,6 +318,15 @@ public AnalysisResultExportModel CreateExportAnalysisResult() { FileSuffix = "mgf", Label = "MASCOT format (*.mgf)" }, + new SpectraTypeSelectableMsdialAnalysisExportModel(new Dictionary> { + [ExportspectraType.deconvoluted] = new AnalysisSdfExporter(file => new MSDecLoader(file.DeconvolutionFilePath, file.DeconvolutionFilePathList)), + [ExportspectraType.centroid] = new AnalysisSdfExporter(file => new CentroidMsScanPropertyLoader(ProviderFactory.Create(file), _storage.Parameter.MS2DataType)), + }) + { + FilePrefix = "Sdf", + FileSuffix = "sdf", + Label = "MDL SDfile (*.sdf)" + }, new MsdialAnalysisMassBankRecordExportModel(_storage.Parameter.ProjectParam, StudyContext), }; return new AnalysisResultExportModel(AnalysisFileModelCollection, _storage.Parameter.ProjectParam.ProjectFolderPath, _broker, models); diff --git a/src/MSDIAL5/MsdialGuiApp/Model/Lcimms/LcimmsMethodModel.cs b/src/MSDIAL5/MsdialGuiApp/Model/Lcimms/LcimmsMethodModel.cs index e5d3cbfd3..6744f814f 100644 --- a/src/MSDIAL5/MsdialGuiApp/Model/Lcimms/LcimmsMethodModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/Model/Lcimms/LcimmsMethodModel.cs @@ -26,6 +26,7 @@ using Reactive.Bindings.Notifiers; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Reactive.Linq; @@ -100,6 +101,7 @@ public LcimmsMethodModel(AnalysisFileBeanModelCollection analysisFileBeanModelCo peakSpotSupplyer, new AlignmentSpectraExportFormat("Msp", "msp", new AlignmentMspExporter(storage.DataBaseMapper, storage.Parameter)), new AlignmentSpectraExportFormat("Mgf", "mgf", new AlignmentMgfExporter()), + new AlignmentSpectraExportFormat("Sdf", "sdf", new AlignmentSdfExporter()), new AlignmentSpectraExportFormat("Mat", "mat", new AlignmentMatExporter(storage.DataBaseMapper, storage.Parameter))); var gnps = new AlignmentGnpsExportModel("GNPS", quantTypes, new GnpsMetadataAccessor(storage.DataBaseMapper, storage.Parameter), peakMeta.GetAccessor(), fileMeta.GetAccessor(), analysisFileBeanModelCollection); var spectraAndReference = new AlignmentMatchedSpectraExportModel(peakSpotSupplyer, storage.DataBaseMapper, analysisFileBeanModelCollection.IncludedAnalysisFiles, CompoundSearcherCollection.BuildSearchers(storage.DataBases, storage.DataBaseMapper)); @@ -319,6 +321,15 @@ static RawMeasurement map(AnalysisFileBean file) { FileSuffix = "mgf", Label = "MASCOT format (*.mgf)" }, + new SpectraTypeSelectableMsdialAnalysisExportModel(new Dictionary> { + [ExportspectraType.deconvoluted] = new AnalysisSdfExporter(file => new MSDecLoader(file.DeconvolutionFilePath, file.DeconvolutionFilePathList)), + [ExportspectraType.centroid] = new AnalysisSdfExporter(file => new CentroidMsScanPropertyLoader(factory.Create(file), Storage.Parameter.MS2DataType)), + }) + { + FilePrefix = "Sdf", + FileSuffix = "sdf", + Label = "MDL SDfile (*.sdf)" + }, new MsdialAnalysisMassBankRecordExportModel(Storage.Parameter.ProjectParam, _studyContext), }; return new AnalysisResultExportModel(AnalysisFileModelCollection, Storage.Parameter.ProjectParam.ProjectFolderPath, _broker, models); diff --git a/src/MSDIAL5/MsdialGuiApp/Model/Lcms/LcmsMethodModel.cs b/src/MSDIAL5/MsdialGuiApp/Model/Lcms/LcmsMethodModel.cs index 4f4d8d2bd..5393dcadc 100644 --- a/src/MSDIAL5/MsdialGuiApp/Model/Lcms/LcmsMethodModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/Model/Lcms/LcmsMethodModel.cs @@ -22,6 +22,7 @@ using Reactive.Bindings.Notifiers; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Reactive.Linq; @@ -110,6 +111,7 @@ public LcmsMethodModel( peakSpotSupplyer, new AlignmentSpectraExportFormat("Msp", "msp", new AlignmentMspExporter(storage.DataBaseMapper, storage.Parameter)), new AlignmentSpectraExportFormat("Mgf", "mgf", new AlignmentMgfExporter()), + new AlignmentSpectraExportFormat("Sdf", "sdf", new AlignmentSdfExporter()), new AlignmentSpectraExportFormat("Mat", "mat", new AlignmentMatExporter(storage.DataBaseMapper, storage.Parameter))); var gnps = new AlignmentGnpsExportModel("GNPS", quantTypes, new GnpsMetadataAccessor(storage.DataBaseMapper, storage.Parameter), peakMeta.GetAccessor(), fileMeta.GetAccessor(), analysisFileBeanModelCollection); var massBank = new AlignmentResultMassBankRecordExportModel(peakSpotSupplyer, storage.Parameter.ProjectParam, studyContext); @@ -412,6 +414,15 @@ public AnalysisResultExportModel ExportAnalysis() { FileSuffix = "mgf", Label = "MASCOT format (*.mgf)" }, + new SpectraTypeSelectableMsdialAnalysisExportModel(new Dictionary> { + [ExportspectraType.deconvoluted] = new AnalysisSdfExporter(file => new MSDecLoader(file.DeconvolutionFilePath, file.DeconvolutionFilePathList)), + [ExportspectraType.centroid] = new AnalysisSdfExporter(file => new CentroidMsScanPropertyLoader(_providerFactory.Create(file), _storage.Parameter.MS2DataType)), + }) + { + FilePrefix = "Sdf", + FileSuffix = "sdf", + Label = "MDL SDfile (*.sdf)" + }, new MsdialAnalysisMassBankRecordExportModel(_storage.Parameter.ProjectParam, _studyContext), }; return new AnalysisResultExportModel(AnalysisFileModelCollection, _storage.Parameter.ProjectParam.ProjectFolderPath, _broker, models); diff --git a/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsAlignmentViewModel.cs b/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsAlignmentViewModel.cs index 19b0ef76a..d55a1c0c0 100644 --- a/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsAlignmentViewModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsAlignmentViewModel.cs @@ -156,7 +156,7 @@ private void SaveSpectra() var request = new SaveFileNameRequest(_model.SaveSpectra) { Title = "Save spectra", - Filter = "NIST format(*.msp)|*.msp|MassBank format(*.txt)|*.txt;|MASCOT format(*.mgf)|*.mgf|MSFINDER format(*.mat)|*.mat;|SIRIUS format(*.ms)|*.ms", + Filter = "NIST format(*.msp)|*.msp|MassBank format(*.txt)|*.txt;|MASCOT format(*.mgf)|*.mgf|MDF SDfile(*.sdf)|*.sdf|MSFINDER format(*.mat)|*.mat;|SIRIUS format(*.ms)|*.ms", RestoreDirectory = true, AddExtension = true, }; diff --git a/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsAnalysisViewModel.cs b/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsAnalysisViewModel.cs index 5289f2154..832dea07b 100644 --- a/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsAnalysisViewModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsAnalysisViewModel.cs @@ -161,7 +161,7 @@ private void SaveSpectra() var request = new SaveFileNameRequest(_model.SaveSpectra) { Title = "Save spectra", - Filter = "NIST format(*.msp)|*.msp|MassBank format(*.txt)|*.txt;|MASCOT format(*.mgf)|*.mgf|MSFINDER format(*.mat)|*.mat;|SIRIUS format(*.ms)|*.ms", + Filter = "NIST format(*.msp)|*.msp|MassBank format(*.txt)|*.txt;|MASCOT format(*.mgf)|*.mgf|MDF SDfile(*.sdf)|*.sdf|MSFINDER format(*.mat)|*.mat;|SIRIUS format(*.ms)|*.ms", RestoreDirectory = true, AddExtension = true, }; diff --git a/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsMethodViewModel.cs b/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsMethodViewModel.cs index a31460a01..dffaa7a34 100644 --- a/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsMethodViewModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/ViewModel/Dims/DimsMethodViewModel.cs @@ -119,6 +119,15 @@ private void ExportAnalysis() { FileSuffix = "mgf", Label = "MASCOT format (*.mgf)" }, + new SpectraTypeSelectableMsdialAnalysisExportModel(new Dictionary> { + [ExportspectraType.deconvoluted] = new AnalysisMgfExporter(file => new MSDecLoader(file.DeconvolutionFilePath, file.DeconvolutionFilePathList)), + [ExportspectraType.centroid] = new AnalysisSdfExporter(file => new CentroidMsScanPropertyLoader(_model.ProviderFactory.Create(file), container.Parameter.MS2DataType)) + }) + { + FilePrefix = "Sdf", + FileSuffix = "sdf", + Label = "MDL SDfile (*.sdf)" + }, new MsdialAnalysisMassBankRecordExportModel(container.Parameter.ProjectParam, _model.StudyContext), }; var model = new AnalysisResultExportModel(_model.AnalysisFileModelCollection, _model.Storage.Parameter.ProjectParam.ProjectFolderPath, _broker, models); diff --git a/src/MSDIAL5/MsdialGuiApp/ViewModel/Imms/ImmsAlignmentViewModel.cs b/src/MSDIAL5/MsdialGuiApp/ViewModel/Imms/ImmsAlignmentViewModel.cs index 0bcc70dad..d9b0b0e47 100644 --- a/src/MSDIAL5/MsdialGuiApp/ViewModel/Imms/ImmsAlignmentViewModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/ViewModel/Imms/ImmsAlignmentViewModel.cs @@ -187,7 +187,7 @@ private void SaveSpectra() { var request = new SaveFileNameRequest(_model.SaveSpectra) { Title = "Save spectra", - Filter = "NIST format(*.msp)|*.msp|MassBank format(*.txt)|*.txt;|MASCOT format(*.mgf)|*.mgf|MSFINDER format(*.mat)|*.mat;|SIRIUS format(*.ms)|*.ms", + Filter = "NIST format(*.msp)|*.msp|MassBank format(*.txt)|*.txt;|MASCOT format(*.mgf)|*.mgf|MDF SDfile(*.sdf)|*.sdf|MSFINDER format(*.mat)|*.mat;|SIRIUS format(*.ms)|*.ms", RestoreDirectory = true, AddExtension = true, }; diff --git a/src/MSDIAL5/MsdialGuiApp/ViewModel/Lcms/LcmsAlignmentViewModel.cs b/src/MSDIAL5/MsdialGuiApp/ViewModel/Lcms/LcmsAlignmentViewModel.cs index 5365e1c87..02a3415b6 100644 --- a/src/MSDIAL5/MsdialGuiApp/ViewModel/Lcms/LcmsAlignmentViewModel.cs +++ b/src/MSDIAL5/MsdialGuiApp/ViewModel/Lcms/LcmsAlignmentViewModel.cs @@ -219,7 +219,7 @@ private void SaveSpectra() { var request = new SaveFileNameRequest(_model.SaveSpectra) { Title = "Save spectra", - Filter = "NIST format(*.msp)|*.msp|MassBank format(*.txt)|*.txt;|MASCOT format(*.mgf)|*.mgf|MSFINDER format(*.mat)|*.mat;|SIRIUS format(*.ms)|*.ms", + Filter = "NIST format(*.msp)|*.msp|MassBank format(*.txt)|*.txt;|MASCOT format(*.mgf)|*.mgf|MDL SDfile(*.sdf)|*.sdf|MSFINDER format(*.mat)|*.mat;|SIRIUS format(*.ms)|*.ms", RestoreDirectory = true, AddExtension = true, };