Example #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);
                }
            }
        }
Example #2
0
        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);
             * }
             */
        }
Example #3
0
        public UnevenChromSmoother(double rt_filter_len)
        {
            rt_filter_half_size = rt_filter_len / 2.0;
            rt_per_filter_pt    = rt_filter_len / sample_window_width;
            weights             = new float[sample_window_width];
            //re-use the related class
            ChromSmoother weight_factory = new ChromSmoother(sample_window_width);

            weights = weight_factory.Weights;
        }
Example #4
0
        public override void Execute()
        {
            var uimfRun = (UIMFRun)this.Run;

            //for each frame

            foreach (var frame in uimfRun.ScanSetCollection.ScanSetList)
            {
                uimfRun.CurrentScanSet = frame;


                // detect all peaks in frame
                var masterPeakList = getAllPeaksInFrame(uimfRun, NumMSScansToSumWhenBuildingMasterPeakList);

                // sort peaks
                masterPeakList.Sort(delegate(MSPeakResult peak1, MSPeakResult peak2)
                {
                    return(peak2.MSPeak.Height.CompareTo(peak1.MSPeak.Height));
                });


                // for each peak
                var peakCounter = 0;
                var peaksThatGenerateAChromatogram = 0;
                foreach (var peak in masterPeakList)
                {
                    peakCounter++;

                    //if (peakCounter > 500) break;
                    if (peak.MSPeak.Height < 1000)
                    {
                        break;
                    }


                    var peakFate = "Undefined";

                    var peakResultAlreadyIncludedInChromatogram = (peak.ChromID != -1);
                    if (peakResultAlreadyIncludedInChromatogram)
                    {
                        peakFate = "Chrom_Already";

                        displayPeakInfoAndFate(peak, peakFate);


                        continue;
                    }
                    else
                    {
                        peakFate = "CHROM";

                        //bool peakResultAlreadyFoundInAnMSFeature = findPeakWithinMSFeatureResults(run.ResultCollection.ResultList, peakResult, scanTolerance);
                        //if (peakResultAlreadyFoundInAnMSFeature)
                        //{
                        //    peakFate = "MSFeature_Already";
                        //}
                        //else
                        //{
                        //    peakFate = "CHROM";
                        //}
                    }

                    peaksThatGenerateAChromatogram++;
                    PeakChrom chrom = new BasicPeakChrom();

                    // create drift profile from raw data
                    var driftTimeProfileMZTolerance = this.DriftTimeProfileExtractionPPMTolerance * peak.MSPeak.XValue / 1e6;

                    //TODO: Fix this: update to use UIMF library and not DeconTools
                    //uimfRun.GetDriftTimeProfile  (frame.PrimaryFrame, this.Run.MinScan, this.Run.MaxScan, peak.MSPeak.XValue, driftTimeProfileMZTolerance);

                    var driftTimeProfileIsEmpty = (uimfRun.XYData.Xvalues == null);
                    if (driftTimeProfileIsEmpty)
                    {
                        addPeakToProcessedPeakList(peak);
                        peakFate = peakFate + " DriftProfileEmpty";
                        displayPeakInfoAndFate(peak, peakFate);

                        continue;
                    }

                    chrom.XYData = uimfRun.XYData;


                    // smooth drift profile
                    chrom.XYData = ChromSmoother.Smooth(uimfRun.XYData);

                    // detect peaks in chromatogram
                    chrom.PeakList = this.ChromPeakDetector.FindPeaks(chrom.XYData, 0, 0);

                    if (chrom.PeakDataIsNullOrEmpty)
                    {
                        addPeakToProcessedPeakList(peak);
                        peakFate = peakFate + " NoChromPeaksDetected";
                        displayPeakInfoAndFate(peak, peakFate);


                        continue;
                    }

                    // find which drift profile peak,  if any, the source peak is a member of
                    var chromPeak = chrom.GetChromPeakForGivenSource(peak);
                    if (chromPeak == null)
                    {
                        addPeakToProcessedPeakList(peak);
                        peakFate = peakFate + " TargetChromPeakNotFound";
                        displayPeakInfoAndFate(peak, peakFate);


                        continue;
                    }


                    // find other peaks in the master peaklist that are members of the found drift profile peak
                    // tag these peaks with the source peak's ID
                    var peakWidthSigma = chromPeak.Width / 2.35;      //   width@half-height =  2.35σ   (Gaussian peak theory)

                    var minScanForChrom = (int)Math.Floor(chromPeak.XValue - peakWidthSigma * 4);
                    var maxScanForChrom = (int)Math.Floor(chromPeak.XValue + peakWidthSigma * 4);

                    var peakToleranceInMZ   = driftTimeProfileMZTolerance;
                    var minMZForChromFilter = peak.MSPeak.XValue - peakToleranceInMZ;
                    var maxMZForChromFilter = peak.MSPeak.XValue + peakToleranceInMZ;


                    chrom.ChromSourceData = (from n in masterPeakList
                                             where n.Scan_num >= minScanForChrom && n.Scan_num <= maxScanForChrom &&
                                             n.MSPeak.XValue >= minMZForChromFilter && n.MSPeak.XValue < maxMZForChromFilter
                                             select n).ToList();

                    foreach (var item in chrom.ChromSourceData)
                    {
                        item.ChromID = peak.PeakID;
                    }

                    displayPeakInfoAndFate(peak, peakFate);
                }

                Console.WriteLine("peaksProcessed = " + peakCounter);
                Console.WriteLine("peaks generating a chrom = " + peaksThatGenerateAChromatogram);
            }



            // generate MS by integrating over drift profile peak

            // find MS peaks within range

            // find MS Features.

            // find MS Feature for which the source peak is a member of.


            // if found, add it.
            // And, for each MS peaks of the found MS Feature,  mark all peaks of the masterpeak list that correspond to the found drift time peak and m/z
        }