public void ExecuteWithoutXYData()
        {
            IXYData xyData = new XYData(new List<XYPoint>());
            outputEvent.Subscribe(OnPublishWithoutPeaks);

            IList<ChromatographicPeak> peaks = chromatographicPeakDetection.Execute(xyData);

            Assert.AreEqual(0, peaks.Count);
            Assert.AreEqual(2, messageCount);
            Assert.AreEqual(true, publishCalled);
        }
        public void ExecuteWithoutXYData()
        {
            IXYData xyData = new XYData(new List<XYPoint>());
            SetupOutputEvents();
            IXYData smoothedXYData = smoothing.Execute(xyData);

            Assert.AreEqual(xyData.XValues.Count, smoothedXYData.XValues.Count);
            Assert.AreEqual(0, smoothedXYData.XValues.Count);
            Assert.AreEqual(true, publishCalled);
            Assert.AreEqual(true, clickablePublishCalled);
        }
        public void ExecuteWithoutPeaks()
        {
            IXYData xyData = new XYData(new double[] { 1, 2, 3, 4, 5 }, new double[] { 2, 2, 2, 2, 2 });
            SetupOutputEvents();
            IXYData smoothedXYData = smoothing.Execute(xyData);

            Assert.AreEqual(xyData.XValues.Count, smoothedXYData.XValues.Count);
            Assert.AreEqual(2, xyData.YValues[3]);
            Assert.AreEqual(2.00000, Math.Round(smoothedXYData.YValues[3], 5));
            Assert.AreEqual(true, publishCalled);
            Assert.AreEqual(true, clickablePublishCalled);
        }
        public void TestInitialize()
        {
            IXYData xyData = new XYData(new double[] { 1, 2 }, new double[] { 3, 4 });
            mockServiceLocator = new Mock<IServiceLocator>();
            mockEventAggregator = new Mock<IEventAggregator>();
            mockDataProvider = new Mock<IDataProvider>();
            mockDataProvider.Setup(mock => mock.GetTotalIonChromatogram(TimeUnit.Seconds)).Returns(xyData);
            mockDataProvider.Setup(mock => mock.GetExtractedIonChromatogram(2, 2, 0.5, TimeUnit.Seconds)).Returns(xyData);
            mockDataProvider.Setup(mock => mock.GetSpectrum(2, 3, 3, 6, 0)).Returns(xyData);

            experiment = Test.TestHelper.GetTestExperiment(mockServiceLocator);
            run = new Run(Path.GetFileName(Properties.Settings.Default.mzXMLTestFile1), Properties.Settings.Default.mzXMLTestFile1, new ProteinState(experiment), new Labeling(experiment), experiment, mockDataProvider.Object);
        }
Exemple #5
0
        public IXYData Generate(double mass1, double mass2, double mzTolerance, TimeUnit timeUnits)
        {
            if (mass1 != mass2)
            {
                throw new ArgumentException("This method only supports getting an XIC for one mass.  Mass1 must be equal to Mass2.");
            }

            pwiz.CLI.msdata.SpectrumList spectrumList = run.spectrumList;

            int timePoints = spectrumList.size();

            List<double> msLevelXVals = new List<double>();
            List<double> msLevelYVals = new List<double>();

            for (int i = 0; i < timePoints; i++)
            {
                IList<double> mzValues = new List<double>();
                IList<double> intensityValues = new List<double>();
                double rt;

                if (spectrumCache.IsInCache(i))
                {
                    SpectrumCacheItem cacheItem = spectrumCache.ReadRawCacheItem(i);
                    mzValues = cacheItem.Spectrum.XValues;
                    intensityValues = cacheItem.Spectrum.YValues;
                    rt = cacheItem.Spectrum.StartRT;
                }
                else
                {
                    Domain.ISpectrum spectrum = spectrumExtractor.GetSpectrum(i, timeUnits);
                    mzValues = spectrum.XValues;
                    intensityValues = spectrum.YValues;
                    rt = spectrum.StartRT;
                }

                XicHelper.GetIntensities(mzValues, intensityValues, rt, mass1, mzTolerance, msLevelXVals, msLevelYVals);
            }

            IXYData xyData = new XYData(msLevelXVals.ToArray(), msLevelYVals.ToArray());
            xyData.TimeUnit = TimeUnit.Minutes;

            return xyData;
        }
        public IXYData Execute(IXYData xyData)
        {
            if (Enabled && !executeDisabled)
            {
                _output.Publish("     Savitzky Golay Smoothing Started (LeftParam=" + LeftParam + ", RightParam=" + RightParam + ", Order=" + order + ")");
                float[] xvals = new float[xyData.XValues.Count];
                float[] yvals = new float[xyData.YValues.Count];

                xvals = xyData.XValues.Select(item => (float)item).ToArray();
                yvals = xyData.YValues.Select(item => (float)item).ToArray();

                DeconEngine.Utils.SavitzkyGolaySmooth(this.leftParam, this.rightParam, this.order, ref xvals, ref yvals);

                IXYData smoothedXYData = new XYData(xvals.Select(item => (double)item).ToList(), yvals.Select(item => (double)item).ToList());
                smoothedXYData.Title = "Smoothed " + xyData.Title;

                _clickableOutput.Publish(new ClickableOutputEvent()
                    {
                        Parameter = smoothedXYData,
                        Text = "     Smoothing completed",
                        Click = new DelegateCommand<IXYData>(OnViewXIC)
                    });
                return smoothedXYData;
            }
            return xyData;
        }
Exemple #7
0
 public static IXYData Generate(double[] xValues, double[] yValues)
 {
     IXYData xyData = new XYData(xValues, yValues);
     return xyData;
 }