public override IsotopicProfile IterativelyFindMSFeature(XYData xydata, IsotopicProfile theorIso)
        {
            var o16TheorFeature = theorIso;
            var o16Profile      = _iterativeTffStandard.IterativelyFindMSFeature(xydata, o16TheorFeature);

            var o18TheorProfileSingleLabel = convertO16ProfileToO18(o16TheorFeature, 2);
            var o18SingleLabelProfile      = _iterativeTffStandard.IterativelyFindMSFeature(xydata, o18TheorProfileSingleLabel);

            var o18TheorProfileDoubleLabel = convertO16ProfileToO18(o16TheorFeature, 4);
            var o18DoubleLabelProfile      = _iterativeTffStandard.IterativelyFindMSFeature(xydata, o18TheorProfileDoubleLabel);

            IsotopicProfile foundO16O18Profile;

            if (o16Profile == null)
            {
                if (o18DoubleLabelProfile == null)
                {
                    return(null);
                }

                foundO16O18Profile = o18DoubleLabelProfile.CloneIsotopicProfile();
                foundO16O18Profile.MonoIsotopicMass = o18DoubleLabelProfile.MonoIsotopicMass - 4 * Globals.MASS_DIFF_BETWEEN_ISOTOPICPEAKS;
                foundO16O18Profile.MonoPeakMZ       = foundO16O18Profile.MonoIsotopicMass / foundO16O18Profile.ChargeState +
                                                      Globals.PROTON_MASS;
            }
            else
            {
                foundO16O18Profile = o16Profile.CloneIsotopicProfile();
            }

            //rebuild isotopic peak list
            AddIsotopePeaks(foundO16O18Profile, o16Profile, 2);
            AddIsotopePeaks(foundO16O18Profile, o18SingleLabelProfile, 4);      // add the O18(1) and the O18(2) if present
            AddIsotopePeaks(foundO16O18Profile, o18DoubleLabelProfile, 100);    // add as many peaks as possible

            lookForMissingPeaksAndInsertZeroIntensityPeaksWhenMissing(foundO16O18Profile, o16TheorFeature);

            return(foundO16O18Profile);
        }
Example #2
0
        public override void Execute(ResultCollection resultList)
        {
            Check.Require(resultList?.Run != null, string.Format("{0} failed. Run is empty.", Name));
            if (resultList?.Run == null)
            {
                return;
            }

            Check.Require(resultList.Run.CurrentMassTag != null, string.Format("{0} failed. CurrentMassTag hasn't been defined.", Name));

            if (resultList.Run.CurrentMassTag == null)
            {
                return;
            }

            var result = resultList.CurrentTargetedResult;

            if (resultList.Run.XYData?.Xvalues == null || resultList.Run.XYData.Xvalues.Length < 4)
            {
                result.IsotopicProfile = null;
                return;
            }

            //TODO: decide whether not to trim or not. Trimming XYData may help with speed.
            double mzWindowForPeakDetection = 20;

            resultList.Run.XYData = resultList.Run.XYData.TrimData(resultList.Run.CurrentMassTag.MZ - mzWindowForPeakDetection / 2, resultList.Run.CurrentMassTag.MZ + mzWindowForPeakDetection / 2);

            resultList.IsosResultBin.Clear();

            var o16TheorFeature = resultList.Run.CurrentMassTag.IsotopicProfile;
            var o16profile      = _iterativeTFFStandard.IterativelyFindMSFeature(resultList.Run.XYData, o16TheorFeature, out var peakList);

            var peakListToUseLater = new List <Peak>(peakList);

            var o18TheorProfileSingleLabel = convertO16ProfileToO18(o16TheorFeature, 2);
            var o18SingleLabelProfile      = _iterativeTFFStandard.IterativelyFindMSFeature(resultList.Run.XYData, o18TheorProfileSingleLabel, out peakList);

            if (peakList != null && peakList.Count > peakListToUseLater.Count)
            {
                peakListToUseLater = new List <Peak>(peakList);
            }

            var o18TheorProfileDoubleLabel = convertO16ProfileToO18(o16TheorFeature, 4);
            var o18DoubleLabelProfile      = _iterativeTFFStandard.IterativelyFindMSFeature(resultList.Run.XYData, o18TheorProfileDoubleLabel, out peakList);

            if (peakList != null && peakList.Count > peakListToUseLater.Count)
            {
                peakListToUseLater = new List <Peak>(peakList);
            }

            //store best peakList for use in later tasks
            resultList.Run.PeakList = peakListToUseLater;

            IsotopicProfile foundO16O18Profile;

            if (o16profile == null)
            {
                if (o18DoubleLabelProfile == null)
                {
                    result.IsotopicProfile = null;
                    result.FailedResult    = true;
                    result.FailureType     = Globals.TargetedResultFailureType.MsfeatureNotFound;
                    return;
                }

                foundO16O18Profile = o18DoubleLabelProfile.CloneIsotopicProfile();
                //lookForMissingPeaksAndInsertZeroIntensityPeaksWhenMissing(foundO16O18Profile, o16TheorFeature);
                foundO16O18Profile.MonoIsotopicMass = o18DoubleLabelProfile.MonoIsotopicMass -
                                                      4 * Globals.MASS_DIFF_BETWEEN_ISOTOPICPEAKS;

                foundO16O18Profile.MonoPeakMZ = foundO16O18Profile.MonoIsotopicMass / foundO16O18Profile.ChargeState +
                                                Globals.PROTON_MASS;
            }
            else
            {
                foundO16O18Profile = o16profile.CloneIsotopicProfile();
            }

            //rebuild isotopic peak list
            addIsotopePeaks(foundO16O18Profile, o16profile, 2);
            addIsotopePeaks(foundO16O18Profile, o18SingleLabelProfile, 4);      // add the O18(1) and the O18(2) if present
            addIsotopePeaks(foundO16O18Profile, o18DoubleLabelProfile, 100);    // add as many peaks as possible

            lookForMissingPeaksAndInsertZeroIntensityPeaksWhenMissing(foundO16O18Profile, o16TheorFeature);

            result.IsotopicProfile = foundO16O18Profile;

            resultList.IsosResultBin.Add(result);
        }