Пример #1
0
        private void PlotSpeciesIsotopeXics(AnnotatedSpecies species, MsDataScan scan, int?charge = null)
        {
            double rtWindowHalfWidth = 2.5;

            MsDataScan startScan = null;

            for (int i = scan.OneBasedScanNumber; i >= 1; i--)
            {
                var theScan = CurrentlySelectedSpectraFile.Value.GetOneBasedScanFromDynamicConnection(i);

                if (theScan.RetentionTime < scan.RetentionTime - rtWindowHalfWidth)
                {
                    break;
                }

                startScan = theScan;
            }

            List <MsDataScan> scans = new List <MsDataScan>();

            for (int i = startScan.OneBasedScanNumber; i < 1000000; i++)
            {
                var theScan = CurrentlySelectedSpectraFile.Value.GetOneBasedScanFromDynamicConnection(i);

                if (theScan.RetentionTime > scan.RetentionTime + rtWindowHalfWidth)
                {
                    break;
                }

                if (theScan.MsnOrder == 1)
                {
                    scans.Add(theScan);
                }
            }

            int z = species.DeconvolutionFeature.Charges[species.DeconvolutionFeature.Charges.Count / 2];

            for (int i = 0; i < 10; i++)
            {
                List <Datum> xicData = new List <Datum>();

                double    isotopeMass = species.DeconvolutionFeature.MonoisotopicMass + i * Constants.C13MinusC12;
                Tolerance t           = new PpmTolerance(5);

                foreach (var item in scans)
                {
                    int index = item.MassSpectrum.GetClosestPeakIndex(isotopeMass.ToMz(z));

                    if (t.Within(item.MassSpectrum.XArray[index], isotopeMass.ToMz(z)))
                    {
                        xicData.Add(new Datum(item.RetentionTime, item.MassSpectrum.YArray[index]));
                    }
                    else
                    {
                        xicData.Add(new Datum(item.RetentionTime, 0));
                    }
                }

                if (i == 0)
                {
                    XicPlot = new LinePlot(topPlotView, xicData);
                }
                else
                {
                    XicPlot.AddLinePlot(xicData);
                }
            }
        }
Пример #2
0
        private void PlotSpeciesInSpectrum(AnnotatedSpecies species, MsDataScan scan, int?charge = null)
        {
            // add non-annotated peaks
            List <Datum> spectrumData = new List <Datum>();

            for (int i = 0; i < scan.MassSpectrum.XArray.Length; i++)
            {
                spectrumData.Add(new Datum(scan.MassSpectrum.XArray[i], scan.MassSpectrum.YArray[i]));
            }

            SpectrumPlot = new SpectrumPlot(bottomPlotView, spectrumData);

            // add annotated peaks
            List <Datum> annotatedData = new List <Datum>();
            List <int>   chargesToPlot = new List <int>();

            if (species.DeconvolutionFeature != null)
            {
                double mass = species.DeconvolutionFeature.MonoisotopicMass;

                if (charge == null)
                {
                    chargesToPlot.AddRange(species.DeconvolutionFeature.Charges);
                }
                else
                {
                    chargesToPlot.Add(charge.Value);
                }

                foreach (var z in chargesToPlot)
                {
                    Tolerance t = new PpmTolerance(5);

                    bool peakHasBeenObserved = false;

                    for (int i = 0; i < 20; i++)
                    {
                        double isotopeMass = (mass + i * Constants.C13MinusC12).ToMz(z);
                        int    index       = scan.MassSpectrum.GetClosestPeakIndex(isotopeMass);
                        double expMz       = scan.MassSpectrum.XArray[index];

                        if (t.Within(expMz.ToMass(z), isotopeMass.ToMass(z)))
                        {
                            annotatedData.Add(new Datum(scan.MassSpectrum.XArray[index], scan.MassSpectrum.YArray[index]));
                            peakHasBeenObserved = true;
                        }
                        //else if (peakHasBeenObserved)
                        //{
                        //    break;
                        //}
                    }
                }
            }
            else if (species.Identification != null)
            {
                //TODO
            }

            SpectrumPlot.AddSpectrumPlot(annotatedData, OxyPlot.OxyColors.Blue, 2.0);
            ZoomAxes(annotatedData, SpectrumPlot);
        }