Example #1
0
        /// <summary>
        /// Builds the isotopic profile plot based on the selected isotope ratios.
        /// </summary>
        private void BuildIsotopicProfilePlot()
        {
            if (this.Mass.Equals(0.0))
            {   // Mass has not been set
                return;
            }

            // Set up the concentration tuner if any of the proportions changed.
            var predictor = new IsoProfilePredictor(
                this.IsotopeProportions["C"].GetProportions(),
                this.IsotopeProportions["H"].GetProportions(),
                this.IsotopeProportions["N"].GetProportions(),
                this.IsotopeProportions["O"].GetProportions(),
                this.IsotopeProportions["S"].GetProportions(),
                this.RelativeIntensityThreshold
                );
            var averagine = new Averagine();

            var theoreticalPeaks = averagine.GetTheoreticalIsotopeProfileInst(
                this.Mass,
                this.Charge,
                this.RelativeIntensityThreshold,
                predictor);

            //var actualPeaks = isotopicConcentrationTuner.AlignObservedPeaks(
            //    this.ObservedPeaks.Select(peakDataPoint => new Peak(peakDataPoint.X, peakDataPoint.Y)).ToList(),
            //    theoreticalPeaks);

            this.IsotopicEnvelopePlotViewModel.BuildPlot(
                theoreticalPeaks,
                this.ObservedPeaks.Select(pd => new Peak(pd.Item.X, pd.Item.Y)).ToList(),
                this.IsProfile);
        }
Example #2
0
        public void TestFitMinusOneScore(int precursor, string adduct, string commonName, string id, string rawFilePath)
        {
            var lipid = new Lipid()
            {
                AdductFull = adduct, CommonName = commonName
            };
            var lipidTarget = lipid.CreateLipidTarget();

            var composition = lipidTarget.Composition;
            var compMinus1  = new Composition(composition.C, composition.H - 1, composition.N, composition.O, composition.S, composition.P); //Subtract one hydrogen to make this a minus1 fit score

            var lcmsRun = PbfLcMsRun.GetLcMsRun(rawFilePath);

            var spectrum = lcmsRun.GetSpectrum(precursor);

            var relativeIntensityThreshold = 0.1;

            var tolerance = new Tolerance(30, ToleranceUnit.Ppm);

            //Get the values to use to calculate pearson correlation
            var observedPeaks = LipidUtil.GetAllIsotopePeaks(spectrum, compMinus1, tolerance,
                                                             relativeIntensityThreshold);

            if (observedPeaks == null)
            {
                Console.WriteLine("Observed peaks is null for scan " + id);
            }

            var isotopomerEnvelope = IsoProfilePredictor.GetIsotopomerEnvelop(
                compMinus1.C,
                compMinus1.H,
                compMinus1.N,
                compMinus1.O,
                compMinus1.S);

            var observedIntensities = new double[observedPeaks.Length];

            for (var i = 0; i < observedPeaks.Length; i++)
            {
                var observedPeak = observedPeaks[i];
                observedIntensities[i] = observedPeak != null ? (float)observedPeak.Intensity : 0.0;
            }

            Console.WriteLine("The theoretical y values are: ");
            foreach (var value in isotopomerEnvelope.Envolope)
            {
                Console.WriteLine(value + ", ");
            }

            Console.WriteLine("The observed peak intensity x values are: ");
            foreach (var value in observedIntensities)
            {
                Console.WriteLine(value + ", ");
            }
        }
Example #3
0
        /// <summary>
        /// Get the theoretical isotopic distribution for the given composition.
        /// </summary>
        /// <param name="composition">The composition to calculate the theoretical isotopic profile.</param>
        /// <param name="relativeIntensityThreshold">The least abundant peak to consider as a percentage of the most abundant peak.</param>
        /// <returns>The theoretical isotopic distribution.</returns>
        private double[] GetTheoreticalIntensities(Composition composition, double relativeIntensityThreshold = 0.1)
        {
            var isotopomerEnvelope = IsoProfilePredictor.GetIsotopomerEnvelop(
                composition.C,
                composition.H,
                composition.N,
                composition.O,
                composition.S);

            return(isotopomerEnvelope.Envolope.TakeWhile(isotope => !(isotope < relativeIntensityThreshold)).ToArray());
        }
Example #4
0
        /// <summary>
        /// Gets the theoretical isotope profile calculated using Averagine with the provided
        /// isotope proportions.
        /// </summary>
        /// <param name="proportions">The proportions of each isotope.</param>
        /// <returns>The theoretical isotope profile peaks.</returns>
        public List <Peak> GetTheoreticalIsotopeProfile(double[] proportions)
        {
            // Get IsoProfilePredictor with updated proportions
            var isoProfilePredictor = new IsoProfilePredictor(
                Element.Code == "C" ? proportions : IsoProfilePredictor.DefaultProbC,
                Element.Code == "H" ? proportions : IsoProfilePredictor.DefaultProbH,
                Element.Code == "N" ? proportions : IsoProfilePredictor.DefaultProbN,
                Element.Code == "O" ? proportions : IsoProfilePredictor.DefaultProbO,
                Element.Code == "S" ? proportions : IsoProfilePredictor.DefaultProbS
                );

            var averagine = new Averagine();

            return(averagine.GetTheoreticalIsotopeProfileInst(
                       Mass,
                       Charge,
                       RelativeIntensityThreshold,
                       isoProfilePredictor));
        }