示例#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 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);
        }
        public static Deconvolutor CreateDeconvolutor(DeconToolsParameters parameters)
        {
            Check.Require(parameters != null, "Factory cannot create Deconvolutor class. DeconToolsParameters are null.");
            if (parameters == null)
            {
                return(new NullDeconvolutor());
            }

            Deconvolutor decon;

            switch (parameters.ScanBasedWorkflowParameters.DeconvolutionType)
            {
            case Globals.DeconvolutionType.None:
                return(new NullDeconvolutor());

            case Globals.DeconvolutionType.ThrashV1:
                // 2016 Port of ThrashV1 in DeconEngineV2 to C#, .NET 4
                // This is the preferred deconvoluter as of Fall 2017
                decon = new HornDeconvolutor(parameters);
                return(decon);

            case Globals.DeconvolutionType.ThrashV2:
                // 2012 port of DeconEngine to C#
                // As of 2016, not used because results do not agree with ThrashV1, C++
#pragma warning disable 618
                decon = new InformedThrashDeconvolutor(parameters.ThrashParameters);
#pragma warning restore 618
                return(decon);

            case Globals.DeconvolutionType.Rapid:
                // To include support for Rapid, you must add a reference to DeconEngine.dll, which was compiled with Visual Studio 2003 and uses MSVCP71.dll
                // Note that DeconEngine.dll also depends on xerces-c_2_7.dll while DeconEngineV2.dll depends on xerces-c_2_8.dll
#if INCLUDE_RAPID
                return(new RapidDeconvolutor(parameters.ThrashParameters.MinMSFeatureToBackgroundRatio,
                                             Deconvolutor.DeconResultComboMode.simplyAddIt));
#else
                throw new NotSupportedException("Support for Rapid is not included in this version of the DLL");
#endif
            default:
                throw new ArgumentOutOfRangeException(nameof(parameters),
                                                      "Trying to create the deconvolutor, but an incorrect Deconvolutor type was given. Good example: 'ThrashV1'");
            }
        }
示例#4
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);
        }
示例#5
0
        public static Deconvolutor CreateDeconvolutor(DeconToolsParameters parameters)
        {
            Check.Require(parameters != null, "Factory cannot create Deconvolutor class. DeconToolsParameters are null.");

            Deconvolutor decon;

            switch (parameters.ScanBasedWorkflowParameters.DeconvolutionType)
            {
            case Globals.DeconvolutionType.None:
                return(new NullDeconvolutor());

            case Globals.DeconvolutionType.ThrashV1:
//#if Disable_DeconToolsV2
//                    throw new NotSupportedException(
//                        "Deconvolution method ThrashV1 is not supported since support for C++ based DeconToolsV2 is disabled; update the parameter file to use <DeconvolutionType>ThrashV2</DeconvolutionType>");
//#else
                decon = new HornDeconvolutor(parameters);
                return(decon);

//#endif
            case Globals.DeconvolutionType.ThrashV2:
                decon = new InformedThrashDeconvolutor(parameters.ThrashParameters);
                return(decon);

            case Globals.DeconvolutionType.Rapid:
                // To include support for Rapid, you must add a reference to DeconEngine.dll, which was compiled with Visual Studio 2003 and uses MSVCP71.dll
                // Note that DeconEngine.dll also depends on xerces-c_2_7.dll while DeconEngineV2.dll depends on xerces-c_2_8.dll
#if INCLUDE_RAPID
                return(new RapidDeconvolutor(parameters.ThrashParameters.MinMSFeatureToBackgroundRatio,
                                             Deconvolutor.DeconResultComboMode.simplyAddIt));
#else
                throw new NotSupportedException("Support for Rapid is not included in this version of the DLL");
#endif
            default:
                throw new ArgumentOutOfRangeException("parameters",
                                                      "Trying to create the deconvolutor, but an incorrect Deconvolutor type was given. Good example: 'ThrashV1'");
            }
        }
示例#6
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);
        }