Exemple #1
0
        /// <summary>
        /// ChargeStateChildTopDownIqWorkflow
        /// Generates theoretical isotopic profile, XIC, and creates ChromPeakIqTargets based on peaks found
        /// </summary>
        /// <param name="result"></param>
        protected override void ExecuteWorkflow(IqResult result)
        {
            //Generate theoretical isotopic profile
            result.Target.TheorIsotopicProfile = TheorFeatureGen.GenerateTheorProfile(result.Target.EmpiricalFormula, result.Target.ChargeState);

            if (!Parser.CheckSequenceIntegrity(result.Target.Code))
            {
                ShiftIsotopicProfile(result.Target.TheorIsotopicProfile, result.Target.MonoMassTheor, result.Target.ChargeState);
            }

            //Generate XIC and smooth
            result.IqResultDetail.Chromatogram = ChromGen.GenerateChromatogram(Run, result.Target.TheorIsotopicProfile, result.Target.ElutionTimeTheor);
            result.IqResultDetail.Chromatogram = ChromSmoother.Smooth(result.IqResultDetail.Chromatogram);

            //Look for peaks in XIC
            result.ChromPeakList = ChromPeakDetector.FindPeaks(result.IqResultDetail.Chromatogram);
            ChromPeakDetector.CalculateElutionTimes(Run, result.ChromPeakList);
            ChromPeakDetector.FilterPeaksOnNET(WorkflowParameters.ChromNETTolerance, result.Target.ElutionTimeTheor, result.ChromPeakList);

            var tempMinScanWithinTol = (int)Run.NetAlignmentInfo.GetScanForNet(result.Target.ElutionTimeTheor - WorkflowParameters.ChromNETTolerance);
            var tempMaxScanWithinTol = (int)Run.NetAlignmentInfo.GetScanForNet(result.Target.ElutionTimeTheor + WorkflowParameters.ChromNETTolerance);
            var tempCenterTol        = (int)Run.NetAlignmentInfo.GetScanForNet(result.Target.ElutionTimeTheor);

            result.NumChromPeaksWithinTolerance = result.ChromPeakList.Count;

            //General peak information output written to console.
            Console.WriteLine("SmartPeakSelector --> NETTolerance= " + WorkflowParameters.ChromNETTolerance + ";  chromMinCenterMax= " +
                              tempMinScanWithinTol + "\t" + tempCenterTol + "" +
                              "\t" + tempMaxScanWithinTol);
            Console.WriteLine("MT= " + result.Target.ID + ";z= " + result.Target.ChargeState + "; mz= " + result.Target.MZTheor.ToString("0.000") +
                              ";  ------------------------- PeaksWithinTol = " + result.ChromPeakList.Count);

            //Creates a ChromPeakIqTarget for each peak found
            foreach (ChromPeak peak in result.ChromPeakList)
            {
                var target = new ChromPeakIqTarget(new ChromPeakAnalyzerIqWorkflow(Run, WorkflowParameters));
                TargetUtilities.CopyTargetProperties(result.Target, target, false);
                target.ChromPeak = peak;
                result.Target.AddTarget(target);
            }

            //Executes each grandchild ChromPeakAnalyzerIqWorkflow
            var children = result.Target.ChildTargets();

            foreach (var child in children)
            {
                child.DoWorkflow();
            }

            if (Utilities.SipperDataDump.OutputResults)
            {
                //Data Dump for use with Sipper
                children = result.Target.ChildTargets();
                foreach (var child in children)
                {
                    Utilities.SipperDataDump.DataDump(child, Run);
                }
            }
        }
        protected override void ExecuteWorkflow(IqResult result)
        {
            if (ChromPeakAnalyzerIqWorkflow == null)
            {
                InitializeChromPeakAnalyzerWorkflow();
            }

            result.Target.TheorIsotopicProfile = TheorFeatureGen.GenerateTheorProfile(result.Target.EmpiricalFormula, result.Target.ChargeState);

            result.IqResultDetail.Chromatogram = ChromGen.GenerateChromatogram(Run, result.Target.TheorIsotopicProfile, result.Target.ElutionTimeTheor);

            result.IqResultDetail.Chromatogram = ChromSmoother.Smooth(result.IqResultDetail.Chromatogram);

            result.ChromPeakList = ChromPeakDetector.FindPeaks(result.IqResultDetail.Chromatogram);

            ChromPeakDetector.CalculateElutionTimes(Run, result.ChromPeakList);

            ChromPeakDetector.FilterPeaksOnNET(WorkflowParameters.ChromNETTolerance, result.Target.ElutionTimeTheor, result.ChromPeakList);

            result.NumChromPeaksWithinTolerance = result.ChromPeakList.Count;


            //Creates a ChromPeakIqTarget for each peak found
            foreach (ChromPeak peak in result.ChromPeakList)
            {
                var target = new ChromPeakIqTarget(ChromPeakAnalyzerIqWorkflow);
                TargetUtilities.CopyTargetProperties(result.Target, target, false);
                target.ChromPeak = peak;
                result.Target.AddTarget(target);
            }

            //Executes each grandchild ChromPeakAnalyzerIqWorkflow
            var children          = result.Target.ChildTargets();
            var targetRemovalList = new List <IqTarget>();

            foreach (var child in children)
            {
                child.DoWorkflow();

                /*
                 * //Selects grandchildren with extremely poor metric scores for removal
                 * IqResult childResult = child.GetResult();
                 * if ((childResult.FitScore >= .8) || (childResult.CorrelationData.RSquaredValsMedian <= .15))
                 * {
                 *  targetRemovalList.Add(child);
                 * }
                 */
            }

            /*
             * //Removes the poorly scoring grandchild ChromPeakIqTargets
             * foreach (IqTarget iqTarget in targetRemovalList)
             * {
             *  result.RemoveResult(iqTarget.GetResult());
             *  result.Target.RemoveTarget(iqTarget);
             * }
             */
        }
Exemple #3
0
        /// <summary>
        /// Updates parent charge state result based on the selected chrom peak target
        /// </summary>
        /// <param name="chromPeakTarget"></param>
        private void UpdateSelection(ChromPeakIqTarget chromPeakTarget)
        {
            var childResult = chromPeakTarget.ParentTarget.GetResult();

            var chromPeakResult = chromPeakTarget.GetResult();

            childResult.ChromPeakSelected = chromPeakTarget.ChromPeak;

            childResult.LcScanObs = chromPeakResult.LcScanObs;

            childResult.LCScanSetSelected = chromPeakResult.LCScanSetSelected;

            childResult.IqResultDetail.MassSpectrum = chromPeakResult.IqResultDetail.MassSpectrum;

            TrimData(childResult.IqResultDetail.MassSpectrum, childResult.Target.MZTheor, MsLeftTrimAmount, MsRightTrimAmount);

            childResult.ObservedIsotopicProfile = chromPeakResult.ObservedIsotopicProfile;

            childResult.FitScore = chromPeakResult.FitScore;

            childResult.NETError = chromPeakResult.NETError;

            childResult.InterferenceScore = chromPeakResult.InterferenceScore;

            childResult.CorrelationData = chromPeakResult.CorrelationData;

            childResult.MonoMassObs = chromPeakResult.ObservedIsotopicProfile == null
                                          ? 0
                                          : chromPeakResult.ObservedIsotopicProfile.MonoIsotopicMass;

            childResult.MZObs = chromPeakResult.ObservedIsotopicProfile == null
                                    ? 0
                                    : chromPeakResult.ObservedIsotopicProfile.MonoPeakMZ;


            childResult.MZObsCalibrated = chromPeakResult.ObservedIsotopicProfile == null
                                              ? 0
                                              : Run.GetAlignedMZ(childResult.MZObs, chromPeakResult.LcScanObs);


            childResult.MonoMassObsCalibrated = (childResult.MZObsCalibrated - DeconTools.Backend.Globals.PROTON_MASS) *
                                                childResult.MZObsCalibrated / childResult.Target.ChargeState;

            childResult.MassErrorBefore = chromPeakResult.ObservedIsotopicProfile == null
                                              ? 0
                                              : chromPeakResult.MassErrorBefore;


            childResult.MassErrorAfter = (childResult.MZObsCalibrated - childResult.Target.MZTheor) / childResult.Target.MZTheor *
                                         1e6;


            var elutionTime = childResult.ChromPeakSelected == null ? 0d : ((ChromPeak)childResult.ChromPeakSelected).NETValue;

            childResult.ElutionTimeObs = elutionTime;

            childResult.Abundance = GetAbundance(childResult);
        }
Exemple #4
0
        /// <summary>
        /// Expands charge range to cover all instances of a given sequence
        /// </summary>
        /// <param name="parentTarget"></param>
        /// <param name="referenceTarget"></param>
        private void ExpandChargeRange(TopDownIqTarget parentTarget, ChromPeakIqTarget referenceTarget)
        {
            var childWorkflow = new ChargeStateChildTopDownIqWorkflow(Run, WorkflowParameters);

            var childTargets = parentTarget.ChildTargets().ToArray();

            var fitTolerance         = 0.5;
            var correlationTolerance = 0.95;

            var minCharge = (IqChargeStateTarget)childTargets.First();
            var maxCharge = (IqChargeStateTarget)childTargets.Last();

            if (minCharge.GetResult().IqResultDetail.Chromatogram != null)
            {
                var charge     = minCharge.ChargeState;
                var extendDown = true;
                while (extendDown)
                {
                    var extend = new IqChargeStateTarget(childWorkflow);
                    charge             = charge - 1;
                    extend.ChargeState = charge;
                    parentTarget.AddTarget(extend);
                    extend.RefineTarget();
                    extend.DoWorkflow();
                    extendDown = ChargeExpansionPeakSelection(parentTarget, referenceTarget, extend, correlationTolerance, fitTolerance);
                }
            }

            if (maxCharge.GetResult().IqResultDetail.Chromatogram != null)
            {
                var charge   = maxCharge.ChargeState;
                var extendUp = true;
                while (extendUp)
                {
                    var extend = new IqChargeStateTarget(childWorkflow);
                    charge             = charge + 1;
                    extend.ChargeState = charge;
                    parentTarget.AddTarget(extend);
                    extend.RefineTarget();
                    extend.DoWorkflow();
                    extendUp = ChargeExpansionPeakSelection(parentTarget, referenceTarget, extend, correlationTolerance, fitTolerance);
                }
            }

            parentTarget.SortChildTargetsByCharge();
        }
Exemple #5
0
        /// <summary>
        /// Selects a peak that correlates with the reference target and returns a bool to continue extending the charge range
        /// </summary>
        /// <param name="parentTarget"></param>
        /// <param name="referenceTarget"></param>
        /// <param name="chargeTarget"></param>
        /// <param name="correlationCutoff"></param>
        /// <param name="fitCutoff"></param>
        /// <returns></returns>
        private bool ChargeExpansionPeakSelection(TopDownIqTarget parentTarget, ChromPeakIqTarget referenceTarget, IqChargeStateTarget chargeTarget, double correlationCutoff, double fitCutoff)
        {
            var iqChargeCorrelator = ChromatogramCorrelator as IqChargeCorrelator;

            var peakTargets       = chargeTarget.ChildTargets();
            var sortedPeakTargets = peakTargets.OrderBy(x => x.GetResult().FitScore);

            foreach (ChromPeakIqTarget target in sortedPeakTargets)
            {
                if (referenceTarget.ChromPeak != null)
                {
                    var minScan = referenceTarget.ChromPeak.XValue - (0.5 * referenceTarget.ChromPeak.Width);
                    var maxScan = referenceTarget.ChromPeak.XValue + (0.5 * +referenceTarget.ChromPeak.Width);
                    if ((target.ChromPeak.XValue > minScan) && (target.ChromPeak.XValue < maxScan))
                    {
                        var correlation = iqChargeCorrelator.PairWiseChargeCorrelation(referenceTarget, target, Run, 3);
                        if (correlation > correlationCutoff && target.GetResult().FitScore < fitCutoff)
                        {
                            UpdateSelection(target);
                            var parentResult = parentTarget.GetResult() as TopDownIqResult;
                            foreach (var item in parentResult.ChargeCorrelationData.CorrelationData)
                            {
                                if (referenceTarget == item.ReferenceTarget)
                                {
                                    var corrItem = new ChromCorrelationDataItem(0, 0, correlation);
                                    var corr     = new ChromCorrelationData();
                                    corr.AddCorrelationData(corrItem);
                                    item.PeakCorrelationData.Add(target, corr);
                                }
                            }

                            return(true);
                        }
                    }
                }
            }
            return(false);
        }