diff --git a/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs b/src/MSDIAL5/MsdialGcMsApi/Algorithm/Alignment/GcmsGapFiller.cs index a11396dc8..9d8e846ac 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 = spot.QuantMass; 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 = spot.QuantMass; GapFillCore(peaklist, chromXCenter, AxTol, target); } 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 @@ - - - -