private IsotopicProfile GetTheorIsotopicProfile(IsosResult saturatedFeature, double lowerIntensityCutoff = 0.0001)
        {
            var theorTarget = new PeptideTarget
            {
                ChargeState      = (short)saturatedFeature.IsotopicProfile.ChargeState,
                MonoIsotopicMass = saturatedFeature.IsotopicProfile.MonoIsotopicMass
            };

            theorTarget.MZ = (theorTarget.MonoIsotopicMass / theorTarget.ChargeState) + Globals.PROTON_MASS;

            var averagineFormula =
                _tomIsotopicPatternGenerator.GetClosestAvnFormula(saturatedFeature.IsotopicProfile.MonoIsotopicMass, false);

            theorTarget.IsotopicProfile = _tomIsotopicPatternGenerator.GetIsotopePattern(averagineFormula,
                                                                                         _tomIsotopicPatternGenerator.aafIsos);
            theorTarget.EmpiricalFormula = averagineFormula;
            theorTarget.CalculateMassesForIsotopicProfile(saturatedFeature.IsotopicProfile.ChargeState);

            //NOTE: This is critical to choosing the optimum peak of the observed isotopic profile
            //A value of 0.001 will leave more peaks in the theor profile. This
            //can be bad with co-eluting peptides, so that a peak of the interfering peptide
            //is used to correct the intensity of our target peptide.
            //A value of 0.01 helps prevent this (by trimming the peaks of the theor profile,
            //and reducing the peaks to be considered for peak intensity extrapolation of the target peptide.
            PeakUtilities.TrimIsotopicProfile(theorTarget.IsotopicProfile, lowerIntensityCutoff);

            return(theorTarget.IsotopicProfile);
        }
        private IsotopicProfile GetUnlabelledIsotopicProfile(TargetBase mt)
        {
            var iso = new IsotopicProfile();

            try
            {
                //empirical formula may contain non-integer values for



                iso = _isotopicDistCalculator.GetIsotopePattern(mt.EmpiricalFormula);
            }
            catch (Exception ex)
            {
                throw new Exception("Theoretical feature generator failed. Details: " + ex.Message);
            }

            PeakUtilities.TrimIsotopicProfile(iso, LowPeakCutOff);
            iso.ChargeState = mt.ChargeState;


            if (iso.ChargeState != 0)
            {
                calculateMassesForIsotopicProfile(iso, mt.MonoIsotopicMass, mt.ChargeState);
            }

            return(iso);
        }
        public override void GenerateTheorFeature(TargetBase mt)
        {
            Check.Require(mt != null, "FeatureGenerator failed. Target must not be null.");
            var iso = IsotopicDistCalculator.GetAveraginePattern(mt.MZ);

            PeakUtilities.TrimIsotopicProfile(iso, LowPeakCutOff);
            iso.ChargeState    = mt.ChargeState;
            mt.IsotopicProfile = iso;
        }
Exemple #4
0
        public void getN15IsotopicProfileTest1()
        {
            var isIt = isotopicDistributionCalculator.IsSetToLabeled;


            var utils = new PeptideUtils();
            //string formula = utils.GetEmpiricalFormulaForPeptideSequence("SAMPLERPAMPLERSAMPLERPAMPLERSAMPLERPAMPLERSAMPLERPAMPLER");
            var formula = utils.GetEmpiricalFormulaForPeptideSequence("SAMPLERPAMPLERSAMPLERPAMPLER");



            var numNitrogens = utils.GetNumAtomsForElement("N", formula);


            var iso1 = isotopicDistributionCalculator.GetIsotopePattern(formula);

            PeakUtilities.TrimIsotopicProfile(iso1, 0.001);

            TestUtilities.DisplayIsotopicProfileData(iso1);

            isotopicDistributionCalculator.SetLabeling("N", 14, 0.02, 15, 0.98);

            var iso2 = isotopicDistributionCalculator.GetIsotopePattern(formula);

            //PeakUtilities.TrimIsotopicProfile(iso2, 0.001);

            isotopicDistributionCalculator.ResetToUnlabeled();
            var iso3 = isotopicDistributionCalculator.GetIsotopePattern(formula);

            PeakUtilities.TrimIsotopicProfile(iso3, 0.001);


            Console.WriteLine();
            TestUtilities.DisplayIsotopicProfileData(iso2);


            for (var i = 0; i < iso1.Peaklist.Count; i++)
            {
                Assert.AreEqual((decimal)Math.Round(iso1.Peaklist[i].Height, 4), (decimal)Math.Round(iso3.Peaklist[i].Height, 4));
            }

            Console.WriteLine();
            TestUtilities.DisplayIsotopicProfileData(iso3);

            Console.WriteLine("Num nitrogens= " + numNitrogens);
        }
Exemple #5
0
        public IsotopicProfile GetN15IsotopicProfile(TargetBase mt, double lowpeakCutoff)
        {
            Check.Require(mt != null, "Mass tag not defined");
            Check.Require(mt.IsotopicProfile != null, "Mass tag's theor isotopic profile not defined");
            Check.Require(mt.ChargeState != 0, "Can't have a charge state of '0'");

            var numNitrogens = mt.GetAtomCountForElement("N");

            var labeledTheorProfile = _TomIsotopicPatternGenerator.GetIsotopePattern(mt.EmpiricalFormula, _TomIsotopicPatternGenerator.aafN15Isos);

            addMZInfoToTheorProfile(mt.IsotopicProfile, labeledTheorProfile, numNitrogens, mt.ChargeState);

            PeakUtilities.TrimIsotopicProfile(labeledTheorProfile, lowpeakCutoff);

            labeledTheorProfile.ChargeState = mt.ChargeState;

            return(labeledTheorProfile);
        }
Exemple #6
0
        public IsotopicProfile GetN15IsotopicProfile2(TargetBase mt, double lowPeakCutoff)
        {
            Check.Require(mt != null, "Mass tag not defined");
            Check.Require(mt.IsotopicProfile != null, "Mass tag's theor isotopic profile not defined");
            Check.Require(mt.ChargeState != 0, "Can't have a charge state of '0'");

            var nitrogenCount = mt.GetAtomCountForElement("N");

            _isotopicDistributionCalculator.SetLabeling("N", N14ISOTOPE_NUMBER, this.N14LabelingAmount, N15ISOTOPE_NUMBER, this.N15LabelingAmount);
            var labeledTheorProfile = _isotopicDistributionCalculator.GetIsotopePattern(mt.EmpiricalFormula);

            addMZInfoToTheorProfile(mt.IsotopicProfile, labeledTheorProfile, nitrogenCount, mt.ChargeState);

            _isotopicDistributionCalculator.ResetToUnlabeled();

            PeakUtilities.TrimIsotopicProfile(labeledTheorProfile, lowPeakCutoff);

            labeledTheorProfile.ChargeState = mt.ChargeState;

            return(labeledTheorProfile);
        }
Exemple #7
0
        private IsotopicProfile GetUnlabeledIsotopicProfile(TargetBase mt)
        {
            IsotopicProfile iso;

            try
            {
                iso = _tomIsotopicPatternGenerator.GetIsotopePattern(mt.EmpiricalFormula, _tomIsotopicPatternGenerator.aafIsos);
            }
            catch (Exception ex)
            {
                throw new Exception("Theoretical feature generator failed. Details: " + ex.Message);
            }

            PeakUtilities.TrimIsotopicProfile(iso, LowPeakCutOff);
            iso.ChargeState = mt.ChargeState;
            if (iso.ChargeState != 0)
            {
                calculateMassesForIsotopicProfile(iso, mt);
            }

            return(iso);
        }
Exemple #8
0
        public void getIsotopicProfileTest1()
        {
            var utils   = new PeptideUtils();
            var formula = utils.GetEmpiricalFormulaForPeptideSequence("SAMPLERPAMPLERSAMPLERPAMPLERSAMPLERPAMPLERSAMPLERPAMPLER");

            var iso1 = isotopicDistributionCalculator.GetIsotopePattern(formula);

            PeakUtilities.TrimIsotopicProfile(iso1, 0.001);

            var tomGen = new TomIsotopicPattern();
            var iso2   = tomGen.GetIsotopePattern(formula);

            PeakUtilities.TrimIsotopicProfile(iso2, 0.001);

            for (var i = 0; i < iso1.Peaklist.Count; i++)
            {
                var roundedI1 = (decimal)Math.Round(iso1.Peaklist[i].Height, 2);
                var roundedI2 = (decimal)Math.Round(iso2.Peaklist[i].Height, 2);

                Assert.AreEqual(roundedI1, roundedI2);
            }

            TestUtilities.DisplayIsotopicProfileData(iso1);
        }
Exemple #9
0
        public IsotopicProfile GetDHIsotopicProfile2(TargetBase mt, double lowpeakCutoff, double fractionLabeling, double molarMixingofH)
        {
            Check.Require(mt != null, "Mass tag not defined");
            Check.Require(mt.IsotopicProfile != null, "Mass tag's theor isotopic profile not defined");
            Check.Require(mt.ChargeState != 0, "Can't have a charge state of '0'");

            //int numNitrogens = mt.GetAtomCountForElement("N");
            var numDeuterium = 0;

            //_isotopicDistributionCalculator.SetLabeling("H", H_ISOTOPE_NUMBER, this.HLabelingAmount, D_ISOTOPE_NUMBER, this.DLabelingAmount);
            var hydrogenTheoreticalProfile = _isotopicDistributionCalculator.GetIsotopePattern(mt.EmpiricalFormula);

            var deuteriumTheoreticalProfile = _isotopicDistributionCalculator.GetIsotopePattern(mt.EmpiricalFormula);

            HLabelingAmount = molarMixingofH;
            DLabelingAmount = 1 - molarMixingofH;

            //convert to floats
            var labelingAmountFraction = Convert.ToSingle(fractionLabeling);
            var HLabelingAmountMix     = Convert.ToSingle(HLabelingAmount);
            var DLabelingAmountMix     = Convert.ToSingle(DLabelingAmount);

            //initialization
            float maxHeightForNormalization = 0;

            if (hydrogenTheoreticalProfile.Peaklist.Count > 0)
            {
                maxHeightForNormalization = hydrogenTheoreticalProfile.Peaklist[0].Height * HLabelingAmountMix;
            }

            //add deuterated peaks as an offset index
            for (var i = 0; i < hydrogenTheoreticalProfile.Peaklist.Count; i++)
            {
                var    peakH = hydrogenTheoreticalProfile.Peaklist[i];
                MSPeak peakD;
                if (i == 0) //initial peak where there is no D contribution
                {
                    peakD = new MSPeak(0);
                }
                else
                {
                    peakD = deuteriumTheoreticalProfile.Peaklist[i - 1];
                }

                var contributionH = peakH.Height * HLabelingAmountMix;
                var contributionD = (1 - labelingAmountFraction) * peakD.Height * DLabelingAmountMix + labelingAmountFraction * peakD.Height * DLabelingAmountMix;

                peakH.Height = contributionH + contributionD;

                //peakH.Height = peakH.Height + (1-Convert.ToSingle(fractionLabeling)) * peakD.Height +Convert.ToSingle(fractionLabeling) * peakD.Height;

                //find true hightes peak in combined distribusion
                if (peakH.Height > maxHeightForNormalization)
                {
                    maxHeightForNormalization = peakH.Height;
                }
            }

            //rename for clarity
            var labeledTheoreticalProfile = hydrogenTheoreticalProfile;

            //normalize to 1
            foreach (var peak in labeledTheoreticalProfile.Peaklist)
            {
                peak.Height /= maxHeightForNormalization;
            }

            //should be good up to here

            addMZInfoToTheorProfile(mt.IsotopicProfile, labeledTheoreticalProfile, numDeuterium, mt.ChargeState);//Keep this as the H mass?

            //_isotopicDistributionCalculator.ResetToUnlabeled();

            PeakUtilities.TrimIsotopicProfile(labeledTheoreticalProfile, lowpeakCutoff);

            labeledTheoreticalProfile.ChargeState = mt.ChargeState;

            return(labeledTheoreticalProfile);
        }