public void peak_interference_UIMF_expectInterference_test1()
        {
            var uimfFrame1200_142 = FileRefs.RawDataBasePath + @"\UIMF\Sarc_MS_90_21Aug10_Cheetah_10-08-02_0000_frame1200_scan142.txt";

            Run run = new DeconTools.Backend.Runs.MSScanFromTextFileRun(uimfFrame1200_142);

            var scanSet = new ScanSet(0);

            run.CurrentScanSet = scanSet;

            var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);

            msgen.MinMZ = 200;
            msgen.MaxMZ = 2000;

            var peakDetector = new DeconToolsPeakDetectorV2(4, 3, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true);

            var decon = new HornDeconvolutor();

            decon.MinIntensityForScore     = 10;
            decon.DeleteIntensityThreshold = 10;
            decon.MaxFitAllowed            = 0.4;
            decon.MinMZ         = 200;
            decon.MaxMZ         = 2000;
            decon.IsMZRangeUsed = false;


            var zeroFiller = new DeconToolsZeroFiller();

            msgen.Execute(run.ResultCollection);
            zeroFiller.Execute(run.ResultCollection);

            peakDetector.Execute(run.ResultCollection);
            decon.Execute(run.ResultCollection);

            //Assert.AreEqual(93, run.ResultCollection.ResultList.Count);

            var testResult = run.ResultCollection.ResultList.Where(p => p.IsotopicProfile.MonoPeakMZ > 428 && p.IsotopicProfile.MonoPeakMZ < 430).First();

            var monoPeak = testResult.IsotopicProfile.getMonoPeak();
            var lastPeak = testResult.IsotopicProfile.Peaklist[testResult.IsotopicProfile.Peaklist.Count - 1];

            var startIndexOfXYData = MathUtils.BinarySearchWithTolerance(run.XYData.Xvalues, monoPeak.XValue - 3, 0, (run.XYData.Xvalues.Length - 1), 2);

            //interference scorer

            var interferenceScorer = new InterferenceScorer();

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var scanPeaks         = run.PeakList.Select <Peak, MSPeak>(i => (MSPeak)i).ToList();
            var interferenceScore = interferenceScorer.GetInterferenceScore(scanPeaks, testResult.IsotopicProfile.Peaklist, monoPeak.XValue - 1.1,
                                                                            lastPeak.XValue + lastPeak.Width);

            stopwatch.Stop();

            Console.WriteLine("interference= " + interferenceScore);
            Console.WriteLine("Time taken = " + stopwatch.ElapsedMilliseconds);
        }
Exemple #2
0
        public void ZeroFillerCompareNewAndOld()
        {
            Run run        = new MSScanFromTextFileRun(FileRefs.RawDataMSFiles.TextFileMS_std1);
            var msgen      = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var zeroFiller = new DeconToolsZeroFiller(3);

            msgen.Execute(run.ResultCollection);
            var numZerosToFill = 3;
            var newZeroFilled  = zeroFiller.ZeroFill(run.XYData.Xvalues, run.XYData.Yvalues, numZerosToFill);
            // var oldZeroFilled = zeroFiller.ZeroFillOld(run.XYData.Xvalues, run.XYData.Yvalues, numZerosToFill);


            var lowerMZ = 625.48;
            var upperMZ = 626.18;

            run.XYData    = run.XYData.TrimData(lowerMZ, upperMZ);
            newZeroFilled = newZeroFilled.TrimData(lowerMZ, upperMZ);
            // oldZeroFilled = oldZeroFilled.TrimData(lowerMZ, upperMZ);

            Console.WriteLine("---------- before zerofilling ---------------");
            TestUtilities.DisplayXYValues(run.XYData);

            Console.WriteLine("---------- after zerofilling ---------------");
            TestUtilities.DisplayXYValues(newZeroFilled);

            // Console.WriteLine("---------- after zerofilling using DeconEngine ---------------");
            // TestUtilities.DisplayXYValues(oldZeroFilled);
        }
        public SaturationIMSScanBasedWorkflow(DeconToolsParameters parameters, Run run, string outputFolderPath = null, BackgroundWorker backgroundWorker = null)
            : base(parameters, run, outputFolderPath, backgroundWorker)
        {
            Check.Require(run is UIMFRun, "Cannot create workflow. Run is required to be a UIMFRun for this type of workflow");

            PeakBRSaturatedPeakDetector = parameters.PeakDetectorParameters.PeakToBackgroundRatio * 0.75;

            _msGenerator  = new UIMF_MSGenerator();
            _peakDetector = new DeconToolsPeakDetectorV2(5, 3, Globals.PeakFitType.QUADRATIC, false);
            _zeroFiller   = new DeconToolsZeroFiller();

//#if Disable_DeconToolsV2
//            throw new NotImplementedException("Cannot use class SaturationIMSScanBasedWorkflow since support for C++ based DeconToolsV2 is disabled");
//#else
            _deconvolutor = new HornDeconvolutor(parameters)
            {
                MaxFitAllowed             = 0.9,
                MinPeptideBackgroundRatio = _peakDetector.PeakToBackgroundRatio
            };
//#endif

            AdjustMonoIsotopicMasses = true;

            Run.PeakList = new List <Peak>();
        }
        public void examineIMFFile_Scan233MZ630()
        {
            Run run = new IMFRun(imfFilepath);

            run.MSParameters       = new DeconTools.Backend.Parameters.MSParameters();
            run.CurrentScanSet     = new ScanSet(233, 229, 237);
            run.MSParameters.MinMZ = 100;
            run.MSParameters.MaxMZ = 631.5;

            int numPeaks = 0;

            for (double n = 629; n < 630; n = n + 0.01)
            {
                ResultCollection rc = new ResultCollection(run);

                Task msGen = new GenericMSGenerator(n, run.MSParameters.MaxMZ);
                msGen.Execute(rc);

                DeconToolsV2.Peaks.clsPeakProcessorParameters detectorParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters();
                detectorParams.PeakBackgroundRatio    = 3;
                detectorParams.PeakFitType            = DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC;
                detectorParams.SignalToNoiseThreshold = 3;
                detectorParams.ThresholdedData        = false;

                Task zeroFiller = new DeconToolsZeroFiller(3);
                //zeroFiller.Execute(rc);

                Task peakDetector = new DeconToolsPeakDetector(detectorParams);
                peakDetector.Execute(rc);

                Task decon = new RapidDeconvolutor();
                decon.Execute(rc);


                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < rc.ResultList.Count; i++)
                {
                    IsosResult result = rc.ResultList[i];
                    if (result.IsotopicProfile.Peaklist[0].XValue > 629 && result.IsotopicProfile.Peaklist[0].XValue < 631)
                    {
                        sb.Append(n.ToString("0.00"));
                        sb.Append("\t");
                        sb.Append(result.IsotopicProfile.Peaklist[0].XValue.ToString("0.00"));
                        sb.Append("\t");
                        sb.Append(result.IsotopicProfile.Score.ToString("0.00"));
                        sb.Append("\t");
                        sb.Append(result.Run.PeakList.Count);
                        sb.Append("\t");
                        sb.Append(result.Run.XYData.Xvalues.Length);

                        sb.Append("\n");
                    }
                }
                Console.Write(sb.ToString());
            }
        }
        public void examineRAWFile_Scan6757()
        {
            Run run = new XCaliburRun(xcaliburTestfile);

            run.MSParameters       = new DeconTools.Backend.Parameters.MSParameters();
            run.CurrentScanSet     = new ScanSet(6757);
            run.MSParameters.MinMZ = 0;
            run.MSParameters.MaxMZ = 10000;

            ResultCollection rc = new ResultCollection(run);

            Task msGen = new GenericMSGenerator(run.MSParameters.MinMZ, run.MSParameters.MaxMZ);

            msGen.Execute(rc);

            DeconToolsV2.Peaks.clsPeakProcessorParameters detectorParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters();
            detectorParams.PeakBackgroundRatio    = 3;
            detectorParams.PeakFitType            = DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC;
            detectorParams.SignalToNoiseThreshold = 3;
            detectorParams.ThresholdedData        = false;

            Task zeroFiller = new DeconToolsZeroFiller(3);
            //zeroFiller.Execute(rc);

            Task peakDetector = new DeconToolsPeakDetector(detectorParams);

            peakDetector.Execute(rc);

            Task decon = new RapidDeconvolutor();

            decon.Execute(rc);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < rc.ResultList.Count; i++)
            {
                IsosResult result = rc.ResultList[i];
                if (result.IsotopicProfile.Peaklist[0].XValue > 0 && result.IsotopicProfile.Peaklist[0].XValue < 10000)
                {
                    sb.Append(result.IsotopicProfile.Peaklist[0].XValue.ToString("0.00"));
                    sb.Append("\t");
                    sb.Append(result.IsotopicProfile.Score.ToString("0.00"));
                    sb.Append("\t");
                    sb.Append(result.IsotopicProfile.Peaklist[0].SN.ToString("0.0"));
                    sb.Append("\t");
                    sb.Append(result.Run.PeakList.Count);
                    sb.Append("\t");
                    sb.Append(result.Run.XYData.Xvalues.Length);

                    sb.Append("\n");
                }
            }
            Console.Write(sb.ToString());
        }
        public void multipleFrames_horn_test1()
        {
            Project.Reset();
            Project project = Project.getInstance();

            project.LoadOldDecon2LSParameters(uimfParameters1);

            UIMFRun run = new UIMFRun(uimfFilepath, 1201, 1203);

            project.RunCollection.Add(run);

            ScanSetCollectionCreator sscc = new ScanSetCollectionCreator(run, 9, 1);

            sscc.Create();

            FrameSetCollectionCreator fscc = new FrameSetCollectionCreator(run, run.MinFrame, run.MaxFrame, 1, 1);

            fscc.Create();

            Task msGen      = new UIMF_MSGenerator(0, 5000);
            Task zeroFiller = new DeconToolsZeroFiller(3);

            Task peakDetector = new DeconToolsPeakDetector(project.Parameters.OldDecon2LSParameters.PeakProcessorParameters);

            Task decon = new HornDeconvolutor(project.Parameters.OldDecon2LSParameters.HornTransformParameters);

            Task scanResultsUpdater = new ScanResultUpdater();

            project.TaskCollection.TaskList.Add(msGen);
            project.TaskCollection.TaskList.Add(zeroFiller);

            project.TaskCollection.TaskList.Add(peakDetector);
            project.TaskCollection.TaskList.Add(decon);
            project.TaskCollection.TaskList.Add(scanResultsUpdater);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            TaskController controller = new UIMF_TaskController(project.TaskCollection);

            controller.Execute(project.RunCollection);
            sw.Stop();

            Console.WriteLine("Time required (ms) = " + sw.ElapsedMilliseconds);
            Console.WriteLine("Scans analyzed = " + project.RunCollection[0].ScanSetCollection.ScanSetList.Count);
            Console.WriteLine("Features found = " + project.RunCollection[0].ResultCollection.ResultList.Count);
            Console.WriteLine("Peaks found = " + project.RunCollection[0].ResultCollection.ScanResultList[0].NumPeaks);



            StringBuilder sb = new StringBuilder();
        }
Exemple #7
0
        protected override void InitializeProcessingTasks()
        {
            MSGenerator  = MSGeneratorFactory.CreateMSGenerator(Run.MSFileType);
            PeakDetector = PeakDetectorFactory.CreatePeakDetector(NewDeconToolsParameters);


            var moreSensitivePeakToBackgroundRatio = NewDeconToolsParameters.PeakDetectorParameters.PeakToBackgroundRatio / 2;
            var moreSensitiveSigNoiseThresh        = NewDeconToolsParameters.PeakDetectorParameters.SignalToNoiseThreshold;

            _moreSensitiveMS1PeakDetector = new DeconToolsPeakDetectorV2(moreSensitivePeakToBackgroundRatio,
                                                                         moreSensitiveSigNoiseThresh, NewDeconToolsParameters.PeakDetectorParameters.PeakFitType,
                                                                         NewDeconToolsParameters.PeakDetectorParameters.IsDataThresholded);

            _superSensitiveMS1PeakDetector = new DeconToolsPeakDetectorV2(0, 0, NewDeconToolsParameters.PeakDetectorParameters.PeakFitType,
                                                                          NewDeconToolsParameters.PeakDetectorParameters.IsDataThresholded);


            Deconvolutor = DeconvolutorFactory.CreateDeconvolutor(NewDeconToolsParameters);


            //Will initialize these but whether or not they are used are determined elsewhere
            ZeroFiller = new DeconToolsZeroFiller(NewDeconToolsParameters.MiscMSProcessingParameters.ZeroFillingNumZerosToFill);
            Smoother   = new SavitzkyGolaySmoother(NewDeconToolsParameters.MiscMSProcessingParameters.SavitzkyGolayNumPointsInSmooth,
                                                   NewDeconToolsParameters.MiscMSProcessingParameters.SavitzkyGolayOrder);

            FitScoreCalculator = new DeconToolsFitScoreCalculator();

            ResultValidator = new ResultValidatorTask();


            PeakToMSFeatureAssociator = new PeakToMSFeatureAssociator();


            _ms2PeakDetectorForCentroidData = new DeconToolsPeakDetectorV2(0, 0, Globals.PeakFitType.QUADRATIC, true)
            {
                RawDataType = Globals.RawDataType.Centroided
            };


            _ms2PeakDetectorForProfileData = new DeconToolsPeakDetectorV2(NewDeconToolsParameters.PeakDetectorParameters.PeakToBackgroundRatio,
                                                                          NewDeconToolsParameters.PeakDetectorParameters.SignalToNoiseThreshold,
                                                                          NewDeconToolsParameters.PeakDetectorParameters.PeakFitType,
                                                                          NewDeconToolsParameters.PeakDetectorParameters.IsDataThresholded);

            Check.Ensure(Deconvolutor is ThrashDeconvolutorV2, "Error. Currently the DeconMSn workflow only works with the ThrashV2 deconvolutor. Selected deconvolutor= " + Deconvolutor);
        }
Exemple #8
0
        public void ZeroFillerTest1()
        {
            Run run        = new MSScanFromTextFileRun(FileRefs.RawDataMSFiles.TextFileMS_std1);
            var msgen      = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var zeroFiller = new DeconToolsZeroFiller(3);

            msgen.Execute(run.ResultCollection);

            // Delete data points such that we only retain 50% of the data
            var fractionToKeep        = 0.50;
            var distanceBetweenPoints = (int)(run.XYData.Xvalues.Length / (run.XYData.Xvalues.Length * fractionToKeep));

            var newXVals = new List <double>();
            var newYVals = new List <double>();

            for (var i = 0; i < run.XYData.Xvalues.Length; i += distanceBetweenPoints)
            {
                if (i < run.XYData.Xvalues.Length)
                {
                    newXVals.Add(run.XYData.Xvalues[i]);
                    newYVals.Add(run.XYData.Yvalues[i]);
                }
            }

            run.XYData.Xvalues = newXVals.ToArray();
            run.XYData.Yvalues = newYVals.ToArray();

            var numZerosToFill = 3;
            var newZeroFilled  = zeroFiller.ZeroFill(run.XYData.Xvalues, run.XYData.Yvalues, numZerosToFill);

            double lowerMZ = 1000;
            double upperMZ = 1300;

            run.XYData    = run.XYData.TrimData(lowerMZ, upperMZ);
            newZeroFilled = newZeroFilled.TrimData(lowerMZ, upperMZ);

            Console.WriteLine("---------- before zerofilling ---------------");
            TestUtilities.DisplayXYValues(run.XYData, lowerMZ, upperMZ);

            Console.WriteLine("---------- after zerofilling ---------------");
            TestUtilities.DisplayXYValues(newZeroFilled, lowerMZ, upperMZ);

            Assert.IsTrue(newZeroFilled.Xvalues.Length > run.XYData.Xvalues.Length);
        }
        public SaturationIMSScanBasedWorkflow(DeconToolsParameters parameters, Run run, string outputDirectoryPath = null, BackgroundWorker backgroundWorker = null)
            : base(parameters, run, outputDirectoryPath, backgroundWorker)
        {
            Check.Require(run is UIMFRun, "Cannot create workflow. Run is required to be a UIMFRun for this type of workflow");

            PeakBRSaturatedPeakDetector = parameters.PeakDetectorParameters.PeakToBackgroundRatio * 0.75;

            _msGenerator  = new UIMF_MSGenerator();
            _peakDetector = new DeconToolsPeakDetectorV2(5, 3);
            _zeroFiller   = new DeconToolsZeroFiller();

            _deconvolutor = new HornDeconvolutor(parameters)
            {
                MaxFitAllowed             = 0.9,
                MinPeptideBackgroundRatio = _peakDetector.PeakToBackgroundRatio
            };

            AdjustMonoIsotopicMasses = true;

            Run.PeakList = new List <Peak>();
        }
Exemple #10
0
        public void Test1()
        {
            var saturationDetector = new SaturationDetector();

            var testFile = FileRefs.RawDataMSFiles.UIMFStdFile3;


            var run = (UIMFRun) new RunFactory().CreateRun(testFile);


            var msgen      = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var zeroFiller = new DeconToolsZeroFiller();


            var peakDetector = new DeconToolsPeakDetectorV2(4, 3, Globals.PeakFitType.QUADRATIC, false);

            var decon = new HornDeconvolutor();

            decon.LeftFitStringencyFactor  = 2.5;
            decon.RightFitStringencyFactor = 0.5;


            var startScan = 100;
            var stopScan  = 200;


            for (var i = startScan; i < stopScan; i++)
            {
                var frame = new ScanSet(500);

                var primaryScan = i;

                var scan = new ScanSet(primaryScan, primaryScan - 3, primaryScan + 3);


                run.CurrentScanSet = frame;
                run.CurrentScanSet = scan;


                msgen.Execute(run.ResultCollection);

                zeroFiller.Execute(run.ResultCollection);

                peakDetector.Execute(run.ResultCollection);

                decon.Execute(run.ResultCollection);

                saturationDetector.GetUnsummedIntensitiesAndDetectSaturation(run, run.ResultCollection.IsosResultBin);
            }


            var msfeatureElution = (from n in run.ResultCollection.ResultList
                                    where
                                    n.IsotopicProfile.MonoIsotopicMass > 1253.71 &&
                                    n.IsotopicProfile.MonoIsotopicMass < 1253.73
                                    select n);


            foreach (var result in msfeatureElution)
            {
                if (result.IsotopicProfile.IsSaturated || true)
                {
                    Console.WriteLine(result.ScanSet.PrimaryScanNumber + "\t" +
                                      result.IsotopicProfile.MonoPeakMZ.ToString("0.0000") + "\t" +
                                      result.IntensityAggregate + "\t" +
                                      result.IsotopicProfile.IntensityAggregateAdjusted);
                }
            }



            //TestUtilities.DisplayIsotopicProfileData(testIso1);
            //TestUtilities.DisplayPeaks(run.PeakList);
        }
        public void multipleFrames_horn_test4()
        {
            Project.Reset();

            //Project.getInstance().LoadOldDecon2LSParameters(uimfParameters1);

            UIMFRun run = new UIMFRun(uimfFilepath, 1202, 1202);

            Project.getInstance().RunCollection.Add(run);


            ScanSetCollectionCreator sscc = new ScanSetCollectionCreator(run, 9, 1);

            sscc.Create();

            FrameSetCollectionCreator fscc = new FrameSetCollectionCreator(run, run.MinFrame, run.MaxFrame, 1, 1);

            fscc.Create();

            Task msGen      = new UIMF_MSGenerator(0, 5000);
            Task zeroFiller = new DeconToolsZeroFiller(3);


            DeconToolsV2.Peaks.clsPeakProcessorParameters detectorParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters();
            detectorParams.PeakBackgroundRatio    = 4;
            detectorParams.SignalToNoiseThreshold = 3;
            detectorParams.PeakFitType            = DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC;


            Task peakDetector = new DeconToolsPeakDetector(detectorParams);


            DeconToolsV2.HornTransform.clsHornTransformParameters hornParams = new DeconToolsV2.HornTransform.clsHornTransformParameters();
            hornParams.CompleteFit               = true;
            hornParams.LeftFitStringencyFactor   = 2.5;
            hornParams.RightFitStringencyFactor  = 0.5;
            hornParams.PeptideMinBackgroundRatio = 4;
            hornParams.MaxFit            = 0.4;
            hornParams.UseMZRange        = false;
            hornParams.UseMercuryCaching = true;

            Task decon = new HornDeconvolutor(hornParams);

            Task scanResultsUpdater = new ScanResultUpdater();

            Project.getInstance().TaskCollection.TaskList.Add(msGen);
            Project.getInstance().TaskCollection.TaskList.Add(zeroFiller);

            Project.getInstance().TaskCollection.TaskList.Add(peakDetector);
            Project.getInstance().TaskCollection.TaskList.Add(decon);
            Project.getInstance().TaskCollection.TaskList.Add(scanResultsUpdater);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            TaskController controller = new UIMF_TaskController(Project.getInstance().TaskCollection);

            controller.Execute(Project.getInstance().RunCollection);
            sw.Stop();

            Console.WriteLine("Time required (ms) = " + sw.ElapsedMilliseconds);
            Console.WriteLine("Scans analyzed = " + Project.getInstance().RunCollection[0].ScanSetCollection.ScanSetList.Count);
            Console.WriteLine("Features found = " + Project.getInstance().RunCollection[0].ResultCollection.ResultList.Count);
            Console.WriteLine("Peaks found = " + Project.getInstance().RunCollection[0].ResultCollection.ScanResultList[0].NumPeaks);



            StringBuilder sb = new StringBuilder();
        }
        public void imf_multipleFrames_horn_test2()
        {
            List <Run> runCollection = new List <Run>();

            Run run = new IMFRun(imfFilePath);

            runCollection.Add(run);

            ScanSetCollectionCreator sscc = new ScanSetCollectionCreator(run, 9, 1);

            sscc.Create();



            Task msGen      = new GenericMSGenerator(0, 5000);
            Task zeroFiller = new DeconToolsZeroFiller(3);


            DeconToolsV2.Peaks.clsPeakProcessorParameters detectorParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters();
            detectorParams.PeakBackgroundRatio    = 4;
            detectorParams.SignalToNoiseThreshold = 3;
            detectorParams.PeakFitType            = DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC;


            Task peakDetector = new DeconToolsPeakDetector(detectorParams);


            DeconToolsV2.HornTransform.clsHornTransformParameters hornParams = new DeconToolsV2.HornTransform.clsHornTransformParameters();
            hornParams.CompleteFit               = true;
            hornParams.LeftFitStringencyFactor   = 2.5;
            hornParams.RightFitStringencyFactor  = 0.5;
            hornParams.PeptideMinBackgroundRatio = 4;
            hornParams.MaxFit = 0.4;


            Task decon = new HornDeconvolutor(hornParams);

            Task scanResultsUpdater = new ScanResultUpdater();

            TaskCollection tc = new TaskCollection();

            tc.TaskList.Add(msGen);
            tc.TaskList.Add(zeroFiller);

            tc.TaskList.Add(peakDetector);
            tc.TaskList.Add(decon);
            tc.TaskList.Add(scanResultsUpdater);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            TaskController controller = new BasicTaskController(tc);

            controller.Execute(runCollection);
            sw.Stop();

            Console.WriteLine("Time required (ms) = " + sw.ElapsedMilliseconds);
            Console.WriteLine("Scans analyzed = " + runCollection[0].ScanSetCollection.ScanSetList.Count);
            Console.WriteLine("Features found = " + runCollection[0].ResultCollection.ResultList.Count);
            Console.WriteLine("Peaks found = " + runCollection[0].ResultCollection.ScanResultList.Sum(p => p.NumPeaks));



            StringBuilder sb = new StringBuilder();
        }
Exemple #13
0
        public void BPISaturationCorrectedTest1()
        {
            var filename = @"D:\Data\UIMF\Sarc_P13_C10_1186_23Sep11_Cheetah_11-09-06.uimf";
            var run      = new RunFactory().CreateRun(filename);

            run.ScanSetCollection = new ScanSetCollection();
            //scanSetCollection.Create(run, 500, 550,1,1);

            var startFrame = 477;
            var stopFrame  = 477;

            //startFrame = run.MinLCScan;
            //stopFrame = run.MaxLCScan;


            run.ScanSetCollection.Create(run, startFrame, stopFrame, 1, 1);



            ((UIMFRun)run).IMSScanSetCollection = new IMSScanSetCollection();
            ((UIMFRun)run).IMSScanSetCollection.Create(run, 122, 122, 1, 1);

            var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);

            var peakDet = new DeconToolsPeakDetectorV2();

            peakDet.PeakToBackgroundRatio  = 2;
            peakDet.SignalToNoiseThreshold = 2;
            peakDet.IsDataThresholded      = true;


            var _zeroFiller = new DeconToolsZeroFiller();

            var _deconvolutor = new ThrashDeconvolutorV2();

            _deconvolutor.UseAutocorrelationChargeDetermination = true;
            _deconvolutor.Parameters.MaxFit = 0.8;


            var saturationWorkflow = new SaturationIMSScanBasedWorkflow(new DeconToolsParameters(), run);



            var outputFile = @"C:\Users\d3x720\Documents\PNNL\My_DataAnalysis\2013\Saturation_Correction\chromOuputSatCorrected.txt";

            using (var writer = new StreamWriter(outputFile))
            {
                var uimfRun = (UIMFRun)run;


                var _unsummedMSFeatures = new List <IsosResult>();

                foreach (var lcScanSet in run.ScanSetCollection.ScanSetList)
                {
                    Console.WriteLine("Scanset= " + lcScanSet);


                    uimfRun.ResultCollection.MSPeakResultList.Clear();
                    _unsummedMSFeatures.Clear();


                    var unsummedFrameSet = new ScanSet(lcScanSet.PrimaryScanNumber);
                    //get saturated MSFeatures for unsummed data
                    uimfRun.CurrentScanSet = unsummedFrameSet;


                    var sb = new StringBuilder();

                    var errorInFrame = false;
                    var numIMSScans  = uimfRun.IMSScanSetCollection.ScanSetList.Count;
                    for (var imsScanNum = 0; imsScanNum < numIMSScans; imsScanNum++)
                    {
                        var imsScanSet = uimfRun.IMSScanSetCollection.ScanSetList[imsScanNum];
                        uimfRun.ResultCollection.IsosResultBin.Clear(); //clear any previous MSFeatures

                        var unsummedIMSScanset = new IMSScanSet(imsScanSet.PrimaryScanNumber);
                        uimfRun.CurrentIMSScanSet = unsummedIMSScanset;

                        try
                        {
                            msgen.Execute(run.ResultCollection);

                            _zeroFiller.Execute(run.ResultCollection);

                            peakDet.Execute(run.ResultCollection);

                            _deconvolutor.Deconvolute(uimfRun.ResultCollection); //adds to IsosResultBin
                        }
                        catch (Exception ex)
                        {
                            errorInFrame = true;
                        }

                        _unsummedMSFeatures.AddRange(run.ResultCollection.IsosResultBin);


                        var basePeakIntensity = 0;
                        //iterate over unsummed MSFeatures and check for saturation
                        foreach (var isosResult in uimfRun.ResultCollection.IsosResultBin)
                        {
                            var isPossiblySaturated = isosResult.IntensityAggregate > 1e7;

                            if (isPossiblySaturated)
                            {
                                var theorIso = new IsotopicProfile();

                                saturationWorkflow.RebuildSaturatedIsotopicProfile(run.XYData, isosResult, uimfRun.PeakList, out theorIso);
                                saturationWorkflow.AdjustSaturatedIsotopicProfile(isosResult.IsotopicProfile, theorIso, true, true);
                            }


                            TestUtilities.DisplayIsotopicProfileData(isosResult.IsotopicProfile);


                            var height = (int)isosResult.IsotopicProfile.getMostIntensePeak().Height;
                            if (height > basePeakIntensity)
                            {
                                basePeakIntensity = height;
                            }
                        }


                        sb.Append(basePeakIntensity);

                        var isNotLastIMSScan = imsScanNum != numIMSScans - 1;
                        if (isNotLastIMSScan)
                        {
                            sb.Append("\t");
                        }
                    }

                    if (errorInFrame)
                    {
                    }
                    else
                    {
                        writer.WriteLine(sb.ToString());
                    }
                }
            }
        }