From d69fdecb41881007adb2bb20a18fc85ef06d4814 Mon Sep 17 00:00:00 2001 From: Yuki Matsuzawa Date: Thu, 19 Mar 2026 11:35:17 +0900 Subject: [PATCH 1/3] Set AlignmentChromPeakFeature quant mass in gap filling --- src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs b/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs index a11396dc8..719203f0e 100644 --- a/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs +++ b/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs @@ -46,6 +46,7 @@ public void GapFill(Ms1Spectra ms1Spectra, RawSpectra rawSpectra, IReadOnlyList< var chromXCenter = GetCenter(spot, detected); var peakWidth = GetPeakWidth(detected); var peaklist = GetPeaks(rawSpectra, chromXCenter, peakWidth, fileID, _smoothingMethod, _smoothingLevel); + target.Mass = chromXCenter.Mz.Value; GapFillCore(peaklist, chromXCenter, AxTol, target); } @@ -58,6 +59,7 @@ public void UpdateQuantMass(RawSpectra rawSpectra, AlignmentSpotProperty spot, i var chromXCenter = GetCenter(spot, detected); var peakWidth = GetPeakWidth(detected); var peaklist = GetPeaks(rawSpectra, chromXCenter, peakWidth, fileID, _smoothingMethod, _smoothingLevel); + target.Mass = chromXCenter.Mz.Value; GapFillCore(peaklist, chromXCenter, AxTol, target); } From 32314c905cd338c693f910675daa207b6c9833c3 Mon Sep 17 00:00:00 2001 From: Yuki Matsuzawa Date: Thu, 19 Mar 2026 12:15:51 +0900 Subject: [PATCH 2/3] Add unit test for GcmsGapFiller UpdateQuantMass logic Introduced GcmsGapFillerTests with a test verifying that UpdateQuantMass sets the target peak's Mass to the spot's QuantMass. Includes a stubbed GcmsGapFiller implementation and necessary setup. --- .../Algorithm/Alignment/GcmsGapFillerTests.cs | 61 +++++++++++++++++++ .../MsdialGcMsApiTests.csproj | 4 -- 2 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 tests/MSDIAL5/MsdialGcMsApiTests/Algorithm/Alignment/GcmsGapFillerTests.cs diff --git a/tests/MSDIAL5/MsdialGcMsApiTests/Algorithm/Alignment/GcmsGapFillerTests.cs b/tests/MSDIAL5/MsdialGcMsApiTests/Algorithm/Alignment/GcmsGapFillerTests.cs new file mode 100644 index 000000000..2d0592dbb --- /dev/null +++ b/tests/MSDIAL5/MsdialGcMsApiTests/Algorithm/Alignment/GcmsGapFillerTests.cs @@ -0,0 +1,61 @@ +using CompMs.Common.Components; +using CompMs.Common.Enum; +using CompMs.MsdialCore.DataObj; +using CompMs.MsdialGcMsApi.Parameter; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; + +namespace CompMs.MsdialGcMsApi.Algorithm.Alignment.Tests { + [TestClass()] + public class GcmsGapFillerTests { + [TestMethod()] + public void UpdateQuantMassSetsTargetMassToSpotQuantMass() { + var filler = new StubGcmsGapFiller(new MsdialGcmsParameter()); + + var target = new AlignmentChromPeakFeature { + FileID = 0, + MasterPeakID = -1, + PeakID = -1, + Mass = 999d, + }; + var detected = new AlignmentChromPeakFeature { + FileID = 1, + MasterPeakID = 1, + PeakID = 1, + ChromXsLeft = new ChromXs(0.9d, ChromXType.RT, ChromXUnit.Min), + ChromXsTop = new ChromXs(1.0d, ChromXType.RT, ChromXUnit.Min), + ChromXsRight = new ChromXs(1.1d, ChromXType.RT, ChromXUnit.Min), + }; + var spot = new AlignmentSpotProperty { + QuantMass = 123.456d, + AlignedPeakProperties = new List { target, detected }, + }; + + filler.UpdateQuantMass(rawSpectra: null, spot, fileID: target.FileID); + + Assert.AreEqual(spot.QuantMass, target.Mass); + } + + private sealed class StubGcmsGapFiller : GcmsGapFiller { + public StubGcmsGapFiller(MsdialGcmsParameter parameter) : base(parameter) { + } + + protected override double AxTol => 0.05d; + + protected override ChromXs GetCenter(AlignmentSpotProperty spot, IEnumerable peaks) { + return new ChromXs(1.0d, ChromXType.RT, ChromXUnit.Min) { + Mz = new MzValue(spot.QuantMass), + RI = new RetentionIndex(1000d), + }; + } + + protected override double GetPeakWidth(IEnumerable peaks) { + return 0.1d; + } + + protected override List GetPeaks(RawSpectra rawSpectra, ChromXs center, double peakWidth, int fileID, SmoothingMethod smoothingMethod, int smoothingLevel) { + return new List(); + } + } + } +} diff --git a/tests/MSDIAL5/MsdialGcMsApiTests/MsdialGcMsApiTests.csproj b/tests/MSDIAL5/MsdialGcMsApiTests/MsdialGcMsApiTests.csproj index 1f7a17e8c..ace545286 100644 --- a/tests/MSDIAL5/MsdialGcMsApiTests/MsdialGcMsApiTests.csproj +++ b/tests/MSDIAL5/MsdialGcMsApiTests/MsdialGcMsApiTests.csproj @@ -22,8 +22,4 @@ - - - - From e322f0da3d57e9f3666561b236bafd7070da35c8 Mon Sep 17 00:00:00 2001 From: YukiMatsuzawa <122433968+YukiMatsuzawa@users.noreply.github.com> Date: Thu, 19 Mar 2026 12:19:08 +0900 Subject: [PATCH 3/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs b/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs index 719203f0e..9d8e846ac 100644 --- a/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs +++ b/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs @@ -46,7 +46,7 @@ public void GapFill(Ms1Spectra ms1Spectra, RawSpectra rawSpectra, IReadOnlyList< var chromXCenter = GetCenter(spot, detected); var peakWidth = GetPeakWidth(detected); var peaklist = GetPeaks(rawSpectra, chromXCenter, peakWidth, fileID, _smoothingMethod, _smoothingLevel); - target.Mass = chromXCenter.Mz.Value; + target.Mass = spot.QuantMass; GapFillCore(peaklist, chromXCenter, AxTol, target); } @@ -59,7 +59,7 @@ public void UpdateQuantMass(RawSpectra rawSpectra, AlignmentSpotProperty spot, i var chromXCenter = GetCenter(spot, detected); var peakWidth = GetPeakWidth(detected); var peaklist = GetPeaks(rawSpectra, chromXCenter, peakWidth, fileID, _smoothingMethod, _smoothingLevel); - target.Mass = chromXCenter.Mz.Value; + target.Mass = spot.QuantMass; GapFillCore(peaklist, chromXCenter, AxTol, target); }