Пример #1
0
        public void SpeedTest1()
        {
            var fileName = FileRefs.RawDataMSFiles.OrbitrapStdFile1;
            var run      = new RunFactory().CreateRun(fileName);

            run.ScanSetCollection.Create(run, 5500, 5550, 1, 1, false);
            var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);

            var peakBr       = 1.3;//0.25;
            var peakDetector = new DeconToolsPeakDetectorV2(peakBr, 2, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true);

            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = peakBr;
            thrashParameters.MaxFit = 0.4;

            var newDeconvolutor = new InformedThrashDeconvolutor(thrashParameters);

            var watch = new Stopwatch();

            watch.Start();
            foreach (var scanSet in run.ScanSetCollection.ScanSetList)
            {
                run.CurrentScanSet = scanSet;
                msgen.Execute(run.ResultCollection);
                peakDetector.Execute(run.ResultCollection);
                run.CurrentScanSet.BackgroundIntensity = peakDetector.BackgroundIntensity;
                newDeconvolutor.Execute(run.ResultCollection);
            }
            watch.Stop();

            Console.WriteLine("Time per scan (INFORMED) = " + watch.ElapsedMilliseconds / run.ScanSetCollection.ScanSetList.Count);
        }
Пример #2
0
        public void MSGeneratorOnUIMFTest1()
        {
            var uimfFile = FileRefs.RawDataMSFiles.UIMFStdFile3;

            var run          = new RunFactory().CreateRun(uimfFile);
            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true);
            var zeroFiller   = new DeconTools.Backend.ProcessingTasks.ZeroFillers.DeconToolsZeroFiller(3);

            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = 1;
            thrashParameters.MaxFit = 0.4;

            var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters);

            var testLCScan       = 500;
            var testIMSScan      = 120;
            var numIMSScanSummed = 7;
            var lowerIMSScan     = testIMSScan - (numIMSScanSummed - 1) / 2;
            var upperIMSScan     = testIMSScan + (numIMSScanSummed - 1) / 2;

            var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1);

            run.CurrentScanSet = scanSet;
            ((UIMFRun)run).CurrentIMSScanSet = new IMSScanSet(testIMSScan, lowerIMSScan, upperIMSScan);

            msgen.Execute(run.ResultCollection);

            Assert.IsTrue(run.XYData.Xvalues.Length > 100);
        }
Пример #3
0
        public void ThrashPreferPlusOneChargeStateTest1()
        {
            Run run = new XCaliburRun2(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            run.ScanSetCollection.Create(run, 6005, 6005, 1, 1, false);

            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(0.5, 2, Globals.PeakFitType.QUADRATIC, true);

            peakDetector.IsDataThresholded = true;

            var parameters = new ThrashParameters();

            parameters.MinMSFeatureToBackgroundRatio = 1;
            parameters.MaxFit = 0.3;
            parameters.CheckAllPatternsAgainstChargeState1 = true;

            var deconvolutor = new ThrashDeconvolutorV2(parameters);

            var scan = new ScanSet(6005);

            run.CurrentScanSet = scan;
            msgen.Execute(run.ResultCollection);
            peakDetector.Execute(run.ResultCollection);

            run.PeakList = run.PeakList.Where(p => p.XValue > 750 && p.XValue < 753).ToList();


            deconvolutor.Execute(run.ResultCollection);

            Assert.IsTrue(run.ResultCollection.ResultList.Count > 0);
            var result1 = run.ResultCollection.ResultList.First();

            Assert.AreEqual(1, result1.IsotopicProfile.ChargeState);

            Console.WriteLine("--------- Prefer +1 charge state ----------------");
            TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            run.ResultCollection.ResultList.Clear();
            run.ResultCollection.IsosResultBin.Clear();

            deconvolutor.Parameters.CheckAllPatternsAgainstChargeState1 = false;
            deconvolutor.Execute(run.ResultCollection);


            Console.WriteLine("\n--------- No charge state bias ----------------");
            TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            Assert.IsTrue(run.ResultCollection.ResultList.Count > 0);
            result1 = run.ResultCollection.ResultList.First();

            Assert.AreEqual(3, result1.IsotopicProfile.ChargeState);
        }
Пример #4
0
        public void CompareToScottsData1()
        {
            var fileName = FileRefs.RawDataMSFiles.OrbitrapStdFile1;
            var run      = new RunFactory().CreateRun(fileName);

            run.ScanSetCollection.Create(run, 5509, 5509, 1, 1, false);
            var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);

            var peakBr       = 1.9;//1.3;
            var peakDetector = new DeconToolsPeakDetectorV2(peakBr, 2, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true);

            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = peakBr;
            thrashParameters.MaxFit = 0.4;

            var newDeconvolutor = new InformedThrashDeconvolutor(thrashParameters);

            var scanset = new ScanSet(5509);

            run.CurrentScanSet = scanset;

            msgen.Execute(run.ResultCollection);
            peakDetector.Execute(run.ResultCollection);
            run.CurrentScanSet.BackgroundIntensity = peakDetector.BackgroundIntensity;
            newDeconvolutor.Execute(run.ResultCollection);


            var scottMzVals = ReadScottsAnnotationsScan5509().ToArray();

            var myMzVals = run.ResultCollection.ResultList.Select(p => p.IsotopicProfile.MonoPeakMZ).OrderBy(p => p).ToArray();

            var comparisions = new Dictionary <decimal, double>();

            foreach (var scottVal in scottMzVals)
            {
                var tolerance     = 0.01;
                var indexInThrash = MathUtils.BinarySearchWithTolerance(myMzVals, scottVal, 0, myMzVals.Length - 1, tolerance);

                var myMzVal = indexInThrash == -1 ? 0.0d : myMzVals[indexInThrash];
                comparisions.Add((decimal)scottVal, myMzVal);
            }

            var numCorrect = comparisions.Values.Count(p => p > 0);

            var numMissing = scottMzVals.Count() - numCorrect;

            Console.WriteLine("Total annotated= \t" + scottMzVals.Count());
            Console.WriteLine("Number correct = \t" + numCorrect);
            Console.WriteLine("Number missing = \t" + numMissing);
        }
Пример #5
0
        public void ThrashV2OnIMSDataTest1()
        {
            var uimfFile =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\UIMF\Sarc_MS2_90_6Apr11_Cheetah_11-02-19.uimf";

            var run          = new RunFactory().CreateRun(uimfFile);
            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true);
            var zeroFiller   = new DeconTools.Backend.ProcessingTasks.ZeroFillers.DeconToolsZeroFiller(3);

            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = 1;
            thrashParameters.MaxFit = 0.4;

            var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters);

            var testLCScan       = 500;
            var testIMSScan      = 120;
            var numIMSScanSummed = 7;
            var lowerIMSScan     = testIMSScan - (numIMSScanSummed - 1) / 2;
            var upperIMSScan     = testIMSScan + (numIMSScanSummed - 1) / 2;

            var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1);

            run.CurrentScanSet = scanSet;
            ((UIMFRun)run).CurrentIMSScanSet = new IMSScanSet(testIMSScan, lowerIMSScan, upperIMSScan);

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

            TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            Assert.IsTrue(run.ResultCollection.ResultList.Count > 0);
            Assert.AreEqual(33, run.ResultCollection.ResultList.Count);

            var result1 = run.ResultCollection.ResultList[0];

            Assert.AreEqual(13084442, (decimal)Math.Round(result1.IntensityAggregate));
            Assert.AreEqual(960.53365m, (decimal)Math.Round(result1.IsotopicProfile.MonoIsotopicMass, 5));
            Assert.AreEqual(2, result1.IsotopicProfile.ChargeState);
        }
Пример #6
0
        public void Stolen_ThrashV2OnOrbitrapTest1()
        {
            //Run run = new XCaliburRun2(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            var fileName =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.raw";
            //Run run = RunUtilities.CreateAndLoadPeaks(fileName);
            var run = new RunFactory().CreateRun(fileName);

            run.ScanSetCollection.Create(run, 6005, 6005, 1, 1, false);

            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true);

            peakDetector.IsDataThresholded = true;

            var parameters = new ThrashParameters();

            parameters.MinMSFeatureToBackgroundRatio = 1;
            parameters.MaxFit = 0.3;

            var deconvolutor = new InformedThrashDeconvolutor(parameters);
            //var deconvolutor2 = new

            var scan = new ScanSet(6005);

            run.CurrentScanSet = scan;
            msgen.Execute(run.ResultCollection);
            peakDetector.Execute(run.ResultCollection);
            deconvolutor.Execute(run.ResultCollection);
            Console.WriteLine(run.ResultCollection.MSPeakResultList);
            // TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            Assert.IsTrue(run.ResultCollection.ResultList.Count > 0);
            //Assert.AreEqual(187, run.ResultCollection.ResultList.Count);

            var result1 = run.ResultCollection.ResultList[0];

            Assert.AreEqual(13084442, (decimal)Math.Round(result1.IntensityAggregate));
            Assert.AreEqual(960.53365m, (decimal)Math.Round(result1.IsotopicProfile.MonoIsotopicMass, 5));
            Assert.AreEqual(2, result1.IsotopicProfile.ChargeState);
        }
Пример #7
0
        public void UIMFTesting1()
        {
            var uimfFile =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\UIMF\Sarc_MS2_90_6Apr11_Cheetah_11-02-19.uimf";

            var run = new RunFactory().CreateRun(uimfFile);

            var testLCScan  = 500;
            var testIMSScan = 120;

            var numIMSScanSummed = 7;
            var lowerIMSScan     = testIMSScan - (numIMSScanSummed - 1) / 2;
            var upperIMSScan     = testIMSScan + (numIMSScanSummed - 1) / 2;

            var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1);


            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(2, 2, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true);

            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = 2;
            thrashParameters.MaxFit = 0.4;

            var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters);


            run.CurrentScanSet = scanSet;
            ((UIMFRun)run).CurrentIMSScanSet = new IMSScanSet(testIMSScan, lowerIMSScan, upperIMSScan);

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

            //6	500	728.6907	729.69800	1	34678	0.252	0.000

            run.PeakList = (from n in run.PeakList where n.XValue > 729 && n.XValue < 731 select n).ToList();

            newDeconvolutor.Execute(run.ResultCollection);

            TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);
        }
Пример #8
0
        public void ThrashV2OnOrbitrapTest1()
        {
            Run run = new XCaliburRun2(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            run.ScanSetCollection.Create(run, 6005, 6005, 1, 1, false);

            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true);

            peakDetector.IsDataThresholded = true;

            var parameters = new ThrashParameters();

            parameters.MinMSFeatureToBackgroundRatio = 1;
            parameters.MaxFit = 0.3;

            var deconvolutor = new ThrashDeconvolutorV2(parameters);

            var scan = new ScanSet(6005);

            run.CurrentScanSet = scan;
            msgen.Execute(run.ResultCollection);
            peakDetector.Execute(run.ResultCollection);
            deconvolutor.Execute(run.ResultCollection);
            Console.WriteLine(run.ResultCollection.MSPeakResultList);
            // TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            Assert.IsTrue(run.ResultCollection.ResultList.Count > 0);
            //Assert.AreEqual(187, run.ResultCollection.ResultList.Count);

            var result1 = run.ResultCollection.ResultList[0];

            Assert.AreEqual(13084442, (decimal)Math.Round(result1.IntensityAggregate));
            Assert.AreEqual(960.53365m, (decimal)Math.Round(result1.IsotopicProfile.MonoIsotopicMass, 5));
            Assert.AreEqual(2, result1.IsotopicProfile.ChargeState);
        }
 public InformedThrashDeconvolutor(ThrashParameters parameters)
 {
     Parameters = parameters;
 }
Пример #10
0
 public ThrashDeconvolutorV2(ThrashParameters parameters)
 {
     Parameters = parameters;
 }
Пример #11
0
        public void Stolen_CompareOldAndNewDeconvolutorsOrbitrap()
        {
            Run run = new XCaliburRun2(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            //string fileName = @"C:\Users\Klin638\Documents\Visual Studio 2010\Backup Files\New folder\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW";
            //@"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.raw";
            //@"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\Vorbi\Yellow_C12_099_18Mar10_Griffin_10-01-13.raw";

            //@"C:\Users\Klin638\Documents\Visual Studio 2010\Backup Files\New folder\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW";
            //
            //Run run = RunUtilities.CreateAndLoadPeaks(fileName);
            //Run run = new RunFactory().CreateRun(fileName);

            run.ScanSetCollection.Create(run, 6005, 6005, 1, 1, false);

            //to sum
            //run.ScanSetCollection.Create(run, 6005, 6005, 5, 1, false);


            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true);



            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = 3;
            thrashParameters.MaxFit = 0.4;

            var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters);
            //var newDeconvolutor = new InformedThrashDeconvolutor(thrashParameters);

            var scanset = new ScanSet(6005);

            //For summing mass spectra:
            //scanset = new ScanSetFactory().CreateScanSet(run, 6005, 5);

            run.CurrentScanSet = scanset;

            var oldDeconvolutor = new HornDeconvolutor();

            oldDeconvolutor.MinPeptideBackgroundRatio = 3;
            oldDeconvolutor.MaxFitAllowed             = 0.4;

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


            //run.PeakList = run.PeakList.Where(p => p.XValue > 634 && p.XValue < 642).ToList();
            //run.DeconToolsPeakList = run.DeconToolsPeakList.Where(p => p.mdbl_mz > 634 && p.mdbl_mz < 642).ToArray();

            run.CurrentScanSet.BackgroundIntensity = peakDetector.BackgroundIntensity;

            newDeconvolutor.Execute(run.ResultCollection);

            //Console.WriteLine("\n--------------New decon ------------------");
            //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            var newResults = new List <IsosResult>(run.ResultCollection.ResultList);

            //TestUtilities.DisplayMSFeatures(newResults);
            //return;

            // DisplayPPMErrorsForeachPeakOfMSFeature(newResults);

            run.ResultCollection.ResultList.Clear();
            run.ResultCollection.IsosResultBin.Clear();
            oldDeconvolutor.Execute(run.ResultCollection);

            var oldResults = new List <IsosResult>(run.ResultCollection.ResultList);


            //Console.WriteLine("\n--------------Old decon ------------------");
            //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);


            var sharedIsos  = new List <IsosResult>();
            var uniqueToNew = new List <IsosResult>();
            var uniqueToOld = new List <IsosResult>();


            GetComparisons(newResults, oldResults, sharedIsos, uniqueToNew, uniqueToOld);


            Console.WriteLine("\n--------------Common to new and Old ------------------");
            TestUtilities.DisplayMSFeatures(sharedIsos);


            Console.WriteLine("\n--------------Unique to new ------------------");
            TestUtilities.DisplayMSFeatures(uniqueToNew);

            var outputFilename = @"C:\Temp\ThrashTesting\exportedIsos.csv";
            var exporter       = IsosExporterFactory.CreateIsosExporter(run.ResultCollection.ResultType, Globals.ExporterType.Text, outputFilename);

            exporter.ExportIsosResults(uniqueToNew);


            Console.WriteLine("\n--------------Unique to old ------------------");
            TestUtilities.DisplayMSFeatures(uniqueToOld);
        }
Пример #12
0
        public void TestAndComparingScottsData()
        {
            var fileName = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.raw";
            var run      = new RunFactory().CreateRun(fileName);

            run.ScanSetCollection.Create(run, 5509, 5509, 1, 1, false);
            var msgen  = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakBr = 0.5;

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

            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = peakBr;//3;
            thrashParameters.MaxFit = 0.4;

            //var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters);
            var newDeconvolutor = new InformedThrashDeconvolutor(thrashParameters);

            var scanset = new ScanSet(5509);

            //For summing mass spectra:
            //scanset = new ScanSetFactory().CreateScanSet(run, 6005, 5);

            run.CurrentScanSet = scanset;

            var oldDeconvolutor = new HornDeconvolutor();

            oldDeconvolutor.MinPeptideBackgroundRatio = peakBr;
            oldDeconvolutor.MaxFitAllowed             = 0.4;

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

            //run.PeakList = run.PeakList.Where(p => p.XValue > 634 && p.XValue < 642).ToList();
            //run.DeconToolsPeakList = run.DeconToolsPeakList.Where(p => p.mdbl_mz > 634 && p.mdbl_mz < 642).ToArray();

            run.CurrentScanSet.BackgroundIntensity = peakDetector.BackgroundIntensity;

            newDeconvolutor.Execute(run.ResultCollection);

            //Console.WriteLine("\n--------------New decon ------------------");
            //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            var newResults = new List <IsosResult>(run.ResultCollection.ResultList);

            //TestUtilities.DisplayMSFeatures(newResults);
            //return;

            // DisplayPPMErrorsForeachPeakOfMSFeature(newResults);

            run.ResultCollection.ResultList.Clear();
            run.ResultCollection.IsosResultBin.Clear();
            oldDeconvolutor.Execute(run.ResultCollection);

            var oldResults = new List <IsosResult>(run.ResultCollection.ResultList);

            //Console.WriteLine("\n--------------Old decon ------------------");
            //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            var sharedIsos  = new List <IsosResult>();
            var uniqueToNew = new List <IsosResult>();
            var uniqueToOld = new List <IsosResult>();

            GetComparisons(newResults, oldResults, sharedIsos, uniqueToNew, uniqueToOld);
            var scottsData      = GetScottsData();
            var scottsDataArray = scottsData.ToArray();

            GetScottComparisons(sharedIsos, uniqueToNew, uniqueToOld, scottsDataArray);

            Console.WriteLine("\n--------------Common to new and Old ------------------");
            TestUtilities.DisplayMSFeatures(sharedIsos);

            Console.WriteLine("\n--------------Unique to new ------------------");
            TestUtilities.DisplayMSFeatures(uniqueToNew);

            var outputFilename = @"C:\Temp\ThrashTesting\exportedIsos.csv";
            var exporter       = IsosExporterFactory.CreateIsosExporter(run.ResultCollection.ResultType, Globals.ExporterType.Text, outputFilename);

            exporter.ExportIsosResults(uniqueToNew);

            Console.WriteLine("\n--------------Unique to old ------------------");
            TestUtilities.DisplayMSFeatures(uniqueToOld);
        }
Пример #13
0
        public void CompareOldAndNewDeconvolutorsUIMF()
        {
            var uimfFile =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\UIMF\Sarc_MS2_90_6Apr11_Cheetah_11-02-19.uimf";



            var run = new RunFactory().CreateRun(uimfFile);

            var testLCScan  = 500;
            var testIMSScan = 120;

            var numIMSScanSummed = 7;
            var lowerIMSScan     = testIMSScan - (numIMSScanSummed - 1) / 2;
            var upperIMSScan     = testIMSScan + (numIMSScanSummed - 1) / 2;

            var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1);


            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true);
            var zeroFiller   = new DeconTools.Backend.ProcessingTasks.ZeroFillers.DeconToolsZeroFiller(3);

            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = 1;
            thrashParameters.MaxFit = 0.4;

            var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters);


            var oldDeconvolutor = new HornDeconvolutor();

            oldDeconvolutor.MinPeptideBackgroundRatio = 1;
            oldDeconvolutor.MaxFitAllowed             = 0.4;

            run.CurrentScanSet = scanSet;
            ((UIMFRun)run).CurrentIMSScanSet = new IMSScanSet(testIMSScan, lowerIMSScan, upperIMSScan);


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

            peakDetector.Execute(run.ResultCollection);

            newDeconvolutor.Execute(run.ResultCollection);

            //Console.WriteLine("\n--------------New decon ------------------");
            //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            var newResults = new List <IsosResult>(run.ResultCollection.ResultList);

            // TestUtilities.DisplayMSFeatures(newResults);

            //DisplayPPMErrorsForeachPeakOfMSFeature(newResults);

            //return;

            run.ResultCollection.ResultList.Clear();
            run.ResultCollection.IsosResultBin.Clear();
            oldDeconvolutor.Execute(run.ResultCollection);

            var oldResults = new List <IsosResult>(run.ResultCollection.ResultList);


            //Console.WriteLine("\n--------------Old decon ------------------");
            //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);


            var sharedIsos  = new List <IsosResult>();
            var uniqueToNew = new List <IsosResult>();
            var uniqueToOld = new List <IsosResult>();


            var toleranceForComparison = 0.05;


            foreach (var newresult in newResults)
            {
                var foundMatch = false;
                for (var i = 0; i < oldResults.Count; i++)
                {
                    var oldResult = oldResults[i];

                    if (Math.Abs(newresult.IsotopicProfile.MonoIsotopicMass - oldResult.IsotopicProfile.MonoIsotopicMass) < toleranceForComparison &&
                        newresult.IsotopicProfile.ChargeState == oldResult.IsotopicProfile.ChargeState)
                    {
                        foundMatch = true;
                    }
                }

                if (foundMatch)
                {
                    sharedIsos.Add(newresult);
                }
                else
                {
                    uniqueToNew.Add(newresult);
                }
            }

            foreach (var oldResult in oldResults)
            {
                var foundMatch = false;
                for (var i = 0; i < newResults.Count; i++)
                {
                    var newresult = newResults[i];

                    if (Math.Abs(newresult.IsotopicProfile.MonoIsotopicMass - oldResult.IsotopicProfile.MonoIsotopicMass) < toleranceForComparison &&
                        newresult.IsotopicProfile.ChargeState == oldResult.IsotopicProfile.ChargeState)
                    {
                        foundMatch = true;
                    }
                }

                if (!foundMatch)
                {
                    uniqueToOld.Add(oldResult);
                }
            }


            Console.WriteLine("\n--------------Common to new and Old ------------------");
            TestUtilities.DisplayMSFeatures(sharedIsos);


            Console.WriteLine("\n--------------Unique to new ------------------");
            TestUtilities.DisplayMSFeatures(uniqueToNew);

            Console.WriteLine("\n--------------Unique to old ------------------");
            TestUtilities.DisplayMSFeatures(uniqueToOld);
        }
Пример #14
0
        public void CompareOldAndNewDeconvolutorsOrbitrap()
        {
            Run run = new XCaliburRun2(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            //run.ScanSetCollection.Create(run, 6005, 6005, 1, 1, false);

            //to sum
            run.ScanSetCollection.Create(run, 6005, 6005, 5, 1, false);


            var msgen        = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);
            var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true);



            var thrashParameters = new ThrashParameters();

            thrashParameters.MinMSFeatureToBackgroundRatio = 3;
            thrashParameters.MaxFit = 0.4;

            var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters);

            var scanset = new ScanSet(6005);

            //For summing mass spectra:
            //scanset = new ScanSetFactory().CreateScanSet(run, 6005, 5);

            run.CurrentScanSet = scanset;

            var oldDeconvolutor = new HornDeconvolutor();

            oldDeconvolutor.MinPeptideBackgroundRatio = 3;
            oldDeconvolutor.MaxFitAllowed             = 0.4;

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


            //run.PeakList = run.PeakList.Where(p => p.XValue > 634 && p.XValue < 642).ToList();
            //run.DeconToolsPeakList = run.DeconToolsPeakList.Where(p => p.mdbl_mz > 634 && p.mdbl_mz < 642).ToArray();

            run.CurrentScanSet.BackgroundIntensity = peakDetector.BackgroundIntensity;

            newDeconvolutor.Execute(run.ResultCollection);

            //Console.WriteLine("\n--------------New decon ------------------");
            //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);

            var newResults = new List <IsosResult>(run.ResultCollection.ResultList);

            //TestUtilities.DisplayMSFeatures(newResults);
            //return;

            // DisplayPPMErrorsForeachPeakOfMSFeature(newResults);

            run.ResultCollection.ResultList.Clear();
            run.ResultCollection.IsosResultBin.Clear();
            oldDeconvolutor.Execute(run.ResultCollection);

            var oldResults = new List <IsosResult>(run.ResultCollection.ResultList);


            //Console.WriteLine("\n--------------Old decon ------------------");
            //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList);


            var sharedIsos  = new List <IsosResult>();
            var uniqueToNew = new List <IsosResult>();
            var uniqueToOld = new List <IsosResult>();


            GetComparisons(newResults, oldResults, sharedIsos, uniqueToNew, uniqueToOld);


            Console.WriteLine("\n--------------Common to new and Old ------------------");
            TestUtilities.DisplayMSFeatures(sharedIsos);


            Console.WriteLine("\n--------------Unique to new ------------------");
            TestUtilities.DisplayMSFeatures(uniqueToNew);

            var diOutputFolder = new DirectoryInfo(@"C:\Temp\ThrashTesting");

            if (!diOutputFolder.Exists)
            {
                diOutputFolder.Create();
            }

            var outputFilename = Path.Combine(diOutputFolder.FullName, "exportedIsos.csv");
            var exporter       = IsosExporterFactory.CreateIsosExporter(run.ResultCollection.ResultType, Globals.ExporterType.Text, outputFilename);

            exporter.ExportIsosResults(uniqueToNew);


            Console.WriteLine("\n--------------Unique to old ------------------");
            TestUtilities.DisplayMSFeatures(uniqueToOld);
        }