示例#1
0
        public override double GetFragmentScore(Composition prefixFragmentComposition, Composition suffixFragmentComposition)
        {
            var score = 0.0;

            foreach (var baseIonType in BaseIonTypes)
            {
                var fragmentComposition = baseIonType.IsPrefix
                              ? prefixFragmentComposition + baseIonType.OffsetComposition
                              : suffixFragmentComposition + baseIonType.OffsetComposition;

                if (fragmentComposition.Mass < Ms2Spectrum.Peaks[0].Mz)
                {
                    continue;
                }
                var chargeRange = GetMinMaxChargeRange(fragmentComposition);

                var containsIon = false;
                for (var charge = chargeRange.Min; charge <= chargeRange.Max; charge++)
                {
                    var ion = new Ion(fragmentComposition, charge);
                    if (Ms2Spectrum.GetCorrScore(ion, Tolerance) > _corrScoreThreshold)
                    {
                        containsIon = true;
                        break;
                    }
                }

                if (containsIon)
                {
                    score += 1.0;
                }
            }
            return(score);
        }
示例#2
0
        /// <summary>
        /// Find the praks that match the provided composition
        /// </summary>
        /// <param name="fragmentComposition"></param>
        /// <param name="corrThreshold"></param>
        /// <param name="distThreshold"></param>
        /// <returns></returns>
        protected IEnumerable <DeconvolutedPeak> FindMatchedPeaks(Composition fragmentComposition,
                                                                  double corrThreshold, double distThreshold)
        {
            var mostAbundantIsotopeIndex = fragmentComposition.GetMostAbundantIsotopeZeroBasedIndex();
            var fragmentIonMass          = fragmentComposition.Mass;

            //var matchedPeak = new MatchedFragmentPeak();
            //var deconvPeak = new DeconvolutedPeak()
            if (fragmentIonMass < Ms2Spectrum.Peaks.First().Mz)
            {
                yield break;
            }

            var prevObservedCharge     = 0;
            var fragmentIonMostAbuMass = fragmentIonMass + Constants.C13MinusC12 * mostAbundantIsotopeIndex;
            var chargeRange            = GetMinMaxChargeRange(fragmentIonMostAbuMass);

            for (var charge = chargeRange.Min; charge <= chargeRange.Max; charge++)
            {
                var ion = new Ion(fragmentComposition, charge);

                var observedPeaks = Ms2Spectrum.GetAllIsotopePeaks(ion, Tolerance, RelativeIsotopeIntensityThreshold);
                if (observedPeaks == null)
                {
                    if (prevObservedCharge > 0 && charge - prevObservedCharge > 1)
                    {
                        yield break;
                    }
                    continue;
                }

                var distCorr = GetDistCorr(ion, observedPeaks);
                if (distCorr.Item2 < corrThreshold && distCorr.Item1 > distThreshold)
                {
                    if (prevObservedCharge > 0 && charge - prevObservedCharge > 1)
                    {
                        yield break;
                    }
                    continue;
                }
                var matchedPeak = new DeconvolutedPeak(fragmentIonMass, observedPeaks[mostAbundantIsotopeIndex].Intensity, charge, distCorr.Item2, distCorr.Item1, observedPeaks);
                prevObservedCharge = charge;

                yield return(matchedPeak);
            }
        }
示例#3
0
        /*
         * protected Peak[] FindMostAbundantPeak(Composition.Composition fragmentComposition,
         *         double corrThreshold, double distThreshold,
         *         out int observedCharge, out double envelopeCorr, out double envelopeDist)
         * {
         *  //Peak[] intenseObservedPeaks = null;
         *  var mostAbundantIsotopeIndex = fragmentComposition.GetMostAbundantIsotopeZeroBasedIndex();
         *  var fragmentIonMass = fragmentComposition.Mass;
         *  observedCharge = 0;
         *  envelopeCorr = 0d;
         *  envelopeDist = 1.0d;
         *
         *  if (fragmentIonMass < Ms2Spectrum.Peaks.First().Mz) return null;
         *
         *  var fragmentIonMostAbuMass = fragmentIonMass + Constants.C13MinusC12 * mostAbundantIsotopeIndex;
         *  var chargeRange = GetMinMaxChargeRange(fragmentIonMostAbuMass);
         *
         *  for (var charge = chargeRange.Min; charge <= chargeRange.Max; charge++)
         *  {
         *      var ion = new Ion(fragmentComposition, charge);
         *
         *      var observedPeaks = Ms2Spectrum.GetAllIsotopePeaks(ion, Tolerance, RelativeIsotopeIntensityThreshold);
         *      if (observedPeaks == null) continue;
         *
         *      var distCorr = GetDistCorr(ion, observedPeaks);
         *      if (distCorr.Item2 < corrThreshold && distCorr.Item1 > distThreshold) continue;
         *      //var mostAbuPeak = observedPeaks[mostAbundantIsotopeIndex];
         *      //if (intenseObservedPeaks == null || mostAbuPeak.Intensity > intenseObservedPeaks[mostAbundantIsotopeIndex].Intensity)
         *      //{
         *          //intenseObservedPeaks = observedPeaks;
         *      observedCharge = charge;
         *      envelopeDist = distCorr.Item1;
         *      envelopeCorr = distCorr.Item2;
         *      return observedPeaks;
         *      //}
         *  }
         *  return null;
         * }
         */

        /// <summary>
        /// Find the highest-intensity peak that matches the provided fragment composition
        /// </summary>
        /// <param name="fragmentComposition"></param>
        /// <param name="corrThreshold"></param>
        /// <param name="distThreshold"></param>
        /// <param name="observedCharge"></param>
        /// <param name="envelopeCorr"></param>
        /// <param name="envelopeDist"></param>
        /// <returns></returns>
        protected Peak[] FindMostIntensePeak(Composition fragmentComposition, double corrThreshold, double distThreshold, out int observedCharge, out double envelopeCorr, out double envelopeDist)
        {
            Peak[] intenseObservedPeaks     = null;
            var    mostAbundantIsotopeIndex = fragmentComposition.GetMostAbundantIsotopeZeroBasedIndex();
            var    fragmentIonMass          = fragmentComposition.Mass;

            observedCharge = 0;
            envelopeCorr   = 0d;
            envelopeDist   = 1.0d;

            if (fragmentIonMass < Ms2Spectrum.Peaks.First().Mz)
            {
                return(null);
            }

            var fragmentIonMostAbuMass = fragmentIonMass + Constants.C13MinusC12 * mostAbundantIsotopeIndex;
            var chargeRange            = GetMinMaxChargeRange(fragmentIonMostAbuMass);

            for (var charge = chargeRange.Min; charge <= chargeRange.Max; charge++)
            {
                var ion = new Ion(fragmentComposition, charge);

                var observedPeaks = Ms2Spectrum.GetAllIsotopePeaks(ion, Tolerance, RelativeIsotopeIntensityThreshold);
                if (observedPeaks == null)
                {
                    continue;
                }

                var distCorr = GetDistCorr(ion, observedPeaks);
                if (distCorr.Item2 < corrThreshold && distCorr.Item1 > distThreshold)
                {
                    continue;
                }
                var mostAbuPeak = observedPeaks[mostAbundantIsotopeIndex];

                if (intenseObservedPeaks == null || mostAbuPeak.Intensity > intenseObservedPeaks[mostAbundantIsotopeIndex].Intensity)
                {
                    intenseObservedPeaks = observedPeaks;
                    observedCharge       = charge;
                    envelopeDist         = distCorr.Item1;
                    envelopeCorr         = distCorr.Item2;
                }
            }
            return(intenseObservedPeaks);
        }
示例#4
0
        public override double GetFragmentScore(Composition prefixFragmentComposition, Composition suffixFragmentComposition,
                                                AminoAcid nTerminalResidue = null,
                                                AminoAcid cTerminalResidue = null)
        {
            var score = 0.0;

            foreach (var baseIonType in BaseIonTypes)
            {
                var fragmentComposition = baseIonType.IsPrefix
                              ? prefixFragmentComposition + baseIonType.OffsetComposition
                              : suffixFragmentComposition + baseIonType.OffsetComposition;

                if (fragmentComposition.Mass < Ms2Spectrum.Peaks[0].Mz)
                {
                    continue;
                }
                var chargeRange = GetMinMaxChargeRange(fragmentComposition);

                var containsIon = false;
                for (var charge = chargeRange.Min; charge <= chargeRange.Max; charge++)
                {
                    var ion = new Ion(fragmentComposition, charge);
                    if (Ms2Spectrum.ContainsIon(ion, Tolerance, RelativeIsotopeIntensityThreshold))
                    {
                        containsIon = true;
                        break;
                    }
                }

                if (containsIon)
                {
                    score += 1.0;
                }
            }
            return(score);
        }