Exemplo n.º 1
0
        public void Test1()
        {
            Run run = new RunFactory().CreateRun(
                @"\\pnl\projects\MSSHARE\Webb_Ian\no cid.UIMF");


            DeconToolsParameters parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(
                @"\\pnl\projects\MSSHARE\Webb_Ian\IMS_UIMF_PeakBR2_PeptideBR3_SN3_SumScans3_NoLCSum_Sat50000_2012-02-27.xml");


            string expectedIsosFile  = Path.Combine(run.DataSetPath, run.DatasetName + "_isos.csv");
            string expectedScansFile = Path.Combine(run.DataSetPath, run.DatasetName + "_scans.csv");
            string expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt");

            if (File.Exists(expectedIsosFile))
            {
                File.Delete(expectedIsosFile);
            }
            if (File.Exists(expectedScansFile))
            {
                File.Delete(expectedScansFile);
            }
            if (File.Exists(expectedPeaksFile))
            {
                File.Delete(expectedPeaksFile);
            }

            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.Execute();
        }
        public void saturatedFixingTest2()
        {
            string uimfFile =
                @"D:\Data\UIMF\Sarc_Main_Study_Controls\Sarc_P08_A01_0673_21Nov11_Cheetah_11-09-03.uimf";

            Run run        = new RunFactory().CreateRun(uimfFile);
            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(@"\\gigasax\DMS_Parameter_Files\Decon2LS\IMS_UIMF_PeakBR4_PeptideBR4_SN3_SumScans3_NoLCSum_Sat50000_2012-01-30.xml");

            parameters.MSGeneratorParameters.UseLCScanRange = true;
            parameters.MSGeneratorParameters.MinLCScan      = 397;
            parameters.MSGeneratorParameters.MaxLCScan      = 408;

            parameters.ScanBasedWorkflowParameters.ScanBasedWorkflowName = "uimf_saturation_repair";

            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.ExportData = true;

            var sw = new Stopwatch();

            sw.Start();

            workflow.Execute();
            return;

            sw.Stop();

            var distinctItems = run.ResultCollection.ResultList.GroupBy(x => x.MSFeatureID).Select(y => y.First()).ToList();

            int minFrame = parameters.MSGeneratorParameters.MinLCScan;
            int maxFrame = parameters.MSGeneratorParameters.MaxLCScan;

            int minScan = 102;
            int maxScan = 125;


            double targetMass  = 1642.85958;
            int    chargestate = 4;


            double tolerance   = 0.3;
            var    featureData =
                (from n in distinctItems
                 where (Math.Abs(n.IsotopicProfile.MonoIsotopicMass - targetMass)) < tolerance &&
                 n.IsotopicProfile.ChargeState == chargestate
                 select n).Select <IsosResult, UIMFIsosResult>(r => (UIMFIsosResult)r).ToList();

            OutputFeatureIntensityData(featureData, minFrame, maxFrame, maxScan, minScan);

            MathUtils mathUtils = new MathUtils();

            var monoMasses = (from n in featureData select n.IsotopicProfile.MonoIsotopicMass).ToList();

            var massVariance = MathUtils.GetStDev(monoMasses);

            Console.WriteLine("Mass variance = " + massVariance);
            Console.WriteLine("Time taken = " + sw.ElapsedMilliseconds);
        }
Exemplo n.º 3
0
        public void scanBasedWorkflowTest1()
        {
            string testFile      = @"D:\Data\UIMF\Problem_datasets\DsrC_Black_02_6Feb12_Cougar_11-10-11.raw";
            string parameterFile = @"D:\Data\UIMF\Problem_datasets\LTQ_Orb_USTags_MS2_THRASH_WithPeaks_Relaxed.xml";


            Run run        = new RunFactory().CreateRun(testFile);
            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);


            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.NewDeconToolsParameters.MSGeneratorParameters.UseLCScanRange = true;
            workflow.NewDeconToolsParameters.MSGeneratorParameters.MinLCScan      = 1;
            workflow.NewDeconToolsParameters.MSGeneratorParameters.MaxLCScan      = 5;

            workflow.ExportData = true;
            workflow.Execute();

            // foreach (var isosResult in run.ResultCollection.ResultList)
            // {
            //     isosResult.Display();
            // }
        }
        public void saturatedFixingTest3()
        {
            var uimfFile = @"D:\Data\UIMF\Sarc_Main_Study_Controls\Sarc_P09_B06_0786_20Jul11_Cheetah_11-05-31.uimf";

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

            parameters.LoadFromOldDeconToolsParameterFile(
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\ParameterFiles\IMS_UIMF_PeakBR2_PeptideBR3_SN3_SumScans3_NoLCSum_Sat50000_2012-02-27_frames_180_195.xml");

            parameters.MSGeneratorParameters.UseLCScanRange = true;
            parameters.MSGeneratorParameters.MinLCScan      = 394;
            parameters.MSGeneratorParameters.MaxLCScan      = 404;


            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.ExportData = false;

            var sw = new Stopwatch();

            sw.Start();

            workflow.Execute();
            //return;

            sw.Stop();

            var distinctItems = run.ResultCollection.ResultList.GroupBy(x => x.MSFeatureID).Select(y => y.First()).ToList();

            var minFrame = parameters.MSGeneratorParameters.MinLCScan;
            var maxFrame = parameters.MSGeneratorParameters.MaxLCScan;

            var minScan = 102;
            var maxScan = 127;

            var targetMass  = 1059.55169;
            var chargestate = 2;



            var tolerance   = 0.3;
            var featureData =
                (from n in distinctItems
                 where (Math.Abs(n.IsotopicProfile.MonoIsotopicMass - targetMass)) < tolerance &&
                 n.IsotopicProfile.ChargeState == chargestate
                 select n).Select <IsosResult, UIMFIsosResult>(r => (UIMFIsosResult)r).ToList();

            OutputFeatureIntensityData(featureData, minFrame, maxFrame, maxScan, minScan);

            var mathUtils = new MathUtils();

            var monoMasses = (from n in featureData select n.IsotopicProfile.MonoIsotopicMass).ToList();

            var massVariance = MathUtils.GetStDev(monoMasses);

            Console.WriteLine("Mass variance = " + massVariance);
            Console.WriteLine("Time taken = " + sw.ElapsedMilliseconds);
        }
        public void TraditionalWorkflowTestOrbitrapData_useThrashV1_test2()
        {
            var parameterFile =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\ParameterFiles\LTQ_Orb\LTQ_Orb_SN2_PeakBR1pt3_PeptideBR1_Thrash_scan6000_9000 - oldThrash.xml";

            var run = new RunFactory().CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);
            var expectedIsosFile  = Path.Combine(run.DataSetPath, run.DatasetName + "_isos.csv");
            var expectedScansFile = Path.Combine(run.DataSetPath, run.DatasetName + "_scans.csv");
            var expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt");

            if (File.Exists(expectedIsosFile))
            {
                File.Delete(expectedIsosFile);
            }
            if (File.Exists(expectedScansFile))
            {
                File.Delete(expectedScansFile);
            }
            if (File.Exists(expectedPeaksFile))
            {
                File.Delete(expectedPeaksFile);
            }

            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);

            //parameters.MSGeneratorParameters.MinLCScan = 6005;
            //parameters.MSGeneratorParameters.MaxLCScan = 6005;


            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.Execute();

            Assert.IsTrue(File.Exists(expectedIsosFile), "Isos file was not created.");
            Assert.IsTrue(File.Exists(expectedScansFile), "Scans file was not created.");
            Assert.IsTrue(File.Exists(expectedPeaksFile), "Peaks file was not created.");

            var isosImporter = new IsosImporter(expectedIsosFile, run.MSFileType);
            var isos         = isosImporter.Import();

            Assert.AreEqual(186, isos.Count);

            var peakImporter = new PeakImporterFromText(expectedPeaksFile);

            var peaklist = new List <MSPeakResult>();

            peakImporter.ImportPeaks(peaklist);

            Assert.AreEqual(809, peaklist.Count);

            var sumIntensities = isos.Select(p => p.IntensityAggregate).Sum();
            //Assert.AreEqual(263499300d, Math.Round(sumIntensities));

            var sumPeakIntensities = peaklist.Select(p => p.Height).Sum();
            //Assert.AreEqual(605170496.0f, sumPeakIntensities);
        }
        public void NegativeIonModeDeisotoping_useThrashV1()
        {
            var parameterFile =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\ParameterFiles\LTQ_Orb\LTQ_Orb_SN2_PeakBR2_PeptideBR1_NegIon_Thrash_Sum3.xml";

            var testFile =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\NegativeIonMode\AC2_Neg_highpH_14Apr13_Sauron_13-04-03.raw";


            var run = new RunFactory().CreateRun(testFile);
            var expectedIsosFile  = Path.Combine(run.DataSetPath, run.DatasetName + "_isos.csv");
            var expectedScansFile = Path.Combine(run.DataSetPath, run.DatasetName + "_scans.csv");
            var expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt");

            if (File.Exists(expectedIsosFile))
            {
                File.Delete(expectedIsosFile);
            }
            if (File.Exists(expectedScansFile))
            {
                File.Delete(expectedScansFile);
            }
            if (File.Exists(expectedPeaksFile))
            {
                File.Delete(expectedPeaksFile);
            }

            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);
            parameters.ScanBasedWorkflowParameters.DeconvolutionType = Globals.DeconvolutionType.ThrashV1;

            parameters.MSGeneratorParameters.MinLCScan = 4100;
            parameters.MSGeneratorParameters.MaxLCScan = 4100;


            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.Execute();

            Assert.IsTrue(File.Exists(expectedIsosFile), "Isos file was not created.");
            Assert.IsTrue(File.Exists(expectedScansFile), "Scans file was not created.");
            Assert.IsTrue(File.Exists(expectedPeaksFile), "Peaks file was not created.");

            var isosImporter = new IsosImporter(expectedIsosFile, run.MSFileType);
            var isos         = isosImporter.Import();

            var testIso =
                (from n in isos where n.IsotopicProfile.MonoPeakMZ > 744 && n.IsotopicProfile.MonoPeakMZ < 749 select n).FirstOrDefault();

            Assert.IsNotNull(testIso, "Test iso not found.");

            Console.WriteLine("monomass= " + testIso.IsotopicProfile.MonoIsotopicMass);
            Assert.AreEqual(1491.32852m, (decimal)Math.Round(testIso.IsotopicProfile.MonoIsotopicMass, 5));
        }
        public void TraditionalWorkflowTestOrbitrapData_usingNewThrash()
        {
            var parameterFile = FileRefs.ParameterFiles.Orbitrap_Scans6000_6050ParamFile;

            var run = new RunFactory().CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);
            var expectedIsosFile  = Path.Combine(run.DataSetPath, run.DatasetName + "_isos.csv");
            var expectedScansFile = Path.Combine(run.DataSetPath, run.DatasetName + "_scans.csv");
            var expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt");

            if (File.Exists(expectedIsosFile))
            {
                File.Delete(expectedIsosFile);
            }
            if (File.Exists(expectedScansFile))
            {
                File.Delete(expectedScansFile);
            }
            if (File.Exists(expectedPeaksFile))
            {
                File.Delete(expectedPeaksFile);
            }

            var allPeaksFilepath = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_peaksFULL.txt";

            File.Copy(allPeaksFilepath, allPeaksFilepath.Replace("FULL", ""));

            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);
            parameters.ScanBasedWorkflowParameters.DeconvolutionType = Globals.DeconvolutionType.ThrashV2;

            parameters.MSGeneratorParameters.UseLCScanRange = true;
            parameters.MSGeneratorParameters.MinLCScan      = 6000; // run.GetMinPossibleLCScanNum();
            parameters.MSGeneratorParameters.MaxLCScan      = 6050; // run.GetMaxPossibleLCScanNum();


            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.Execute();

            Assert.IsTrue(File.Exists(expectedIsosFile), "Isos file was not created.");
            Assert.IsTrue(File.Exists(expectedScansFile), "Scans file was not created.");
            Assert.IsTrue(File.Exists(expectedPeaksFile), "Peaks file was not created.");

            var isosImporter = new IsosImporter(expectedIsosFile, run.MSFileType);
            var isos         = isosImporter.Import();

            //Assert.AreEqual(186, isos.Count);
            //TODO: still report

            Console.WriteLine("Num MSfeatures = " + isos.Count);

            var sumIntensities = isos.Select(p => p.IntensityAggregate).Sum();
            // Assert.AreEqual(266185816d, Math.Round(sumIntensities));
        }
        public void TraditionalWorkflowTestOrbitrapData_DetectPeaksOnly()
        {
            var parameterFile = FileRefs.ParameterFiles.Orbitrap_Scans6000_6050ParamFile;

            var run = new RunFactory().CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);
            var expectedIsosFile  = Path.Combine(run.DataSetPath, run.DatasetName + "_isos.csv");
            var expectedScansFile = Path.Combine(run.DataSetPath, run.DatasetName + "_scans.csv");
            var expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt");

            if (File.Exists(expectedIsosFile))
            {
                File.Delete(expectedIsosFile);
            }
            if (File.Exists(expectedScansFile))
            {
                File.Delete(expectedScansFile);
            }
            if (File.Exists(expectedPeaksFile))
            {
                File.Delete(expectedPeaksFile);
            }

            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);
            parameters.ScanBasedWorkflowParameters.DeconvolutionType = Globals.DeconvolutionType.None;

            parameters.MSGeneratorParameters.MinLCScan = 6005;
            parameters.MSGeneratorParameters.MaxLCScan = 6005;


            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.Execute();

            Assert.IsTrue(File.Exists(expectedIsosFile), "Isos file was not created.");
            Assert.IsTrue(File.Exists(expectedScansFile), "Scans file was not created.");
            Assert.IsTrue(File.Exists(expectedPeaksFile), "Peaks file was not created.");


            var peakImporter = new PeakImporterFromText(expectedPeaksFile);

            var peaklist = new List <MSPeakResult>();

            peakImporter.ImportPeaks(peaklist);

            Assert.AreEqual(809, peaklist.Count);


            var isosImporter = new IsosImporter(expectedIsosFile, run.MSFileType);
            var isos         = isosImporter.Import();

            Assert.AreEqual(0, isos.Count);
        }
        public void TraditionalWorkflowTestOrbitrapData_InformedThrash()
        {
            var parameterFile = FileRefs.ParameterFiles.Orbitrap_Scans6000_6050ParamFile;

            var run = new RunFactory().CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);
            var expectedIsosFile  = Path.Combine(run.DataSetPath, run.DatasetName + "_isos.csv");
            var expectedScansFile = Path.Combine(run.DataSetPath, run.DatasetName + "_scans.csv");
            var expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt");

            if (File.Exists(expectedIsosFile))
            {
                File.Delete(expectedIsosFile);
            }
            if (File.Exists(expectedScansFile))
            {
                File.Delete(expectedScansFile);
            }
            //if (File.Exists(expectedPeaksFile)) File.Delete(expectedPeaksFile);

            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);
            parameters.ScanBasedWorkflowParameters.DeconvolutionType = Globals.DeconvolutionType.ThrashV2;

            parameters.MSGeneratorParameters.MinLCScan = 6005;
            parameters.MSGeneratorParameters.MaxLCScan = 6050;


            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.Execute();

            Assert.IsTrue(File.Exists(expectedIsosFile), "Isos file was not created.");
            Assert.IsTrue(File.Exists(expectedScansFile), "Scans file was not created.");
            Assert.IsTrue(File.Exists(expectedPeaksFile), "Peaks file was not created.");

            var isosImporter = new IsosImporter(expectedIsosFile, run.MSFileType);
            var isos         = isosImporter.Import();

            Assert.AreEqual(1287, isos.Count);

            var sumIntensities = isos.Select(p => p.IntensityAggregate).Sum();

            Assert.AreEqual(1974438598m, (decimal)Math.Round(sumIntensities));

            //  Expected: 1973657234m
            // But was:  1974438598m
        }
Exemplo n.º 10
0
        public void LoadParametersForIMSDataprocessingTest2()
        {
            var parameterFile =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\ParameterFiles\IMS\IMS_UIMF_PeakBR4_PeptideBR4_SN3_SumScans3_NoLCSum_Sat90000_newFormat.xml";

            Assert.IsTrue(File.Exists(parameterFile));
            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);

            Assert.IsNotNullOrEmpty(parameters.ThrashParameters.AveragineFormula);
            Assert.AreEqual("C4.9384 H7.7583 N1.3577 O1.4773 S0.0417", parameters.ThrashParameters.AveragineFormula);
            Assert.AreEqual("AREA", parameters.ThrashParameters.IsotopicProfileFitType.ToString());
            Assert.AreEqual(1.00727649, parameters.ThrashParameters.ChargeCarrierMass);
            Assert.AreEqual(10, (decimal)parameters.ThrashParameters.MinIntensityForDeletion);
            Assert.AreEqual(0.4, parameters.ThrashParameters.MaxFit);
            Assert.AreEqual(10, parameters.ThrashParameters.MaxCharge);
            Assert.AreEqual(4, parameters.ThrashParameters.MinMSFeatureToBackgroundRatio);
            Assert.AreEqual(10000, parameters.ThrashParameters.MaxMass);
            Assert.AreEqual(false, parameters.ThrashParameters.IsO16O18Data);
            Assert.AreEqual(false, parameters.ThrashParameters.CheckAllPatternsAgainstChargeState1);
            Assert.AreEqual(true, parameters.ThrashParameters.IsThrashUsed);

            Assert.AreEqual("Text", parameters.ScanBasedWorkflowParameters.ExportFileType.ToString());
            Assert.AreEqual("uimf_saturation_repair", parameters.ScanBasedWorkflowParameters.ScanBasedWorkflowName.ToLower());
            Assert.AreEqual(false, parameters.ScanBasedWorkflowParameters.ExportPeakData);

            Assert.AreEqual(500, parameters.MSGeneratorParameters.MinLCScan);
            Assert.AreEqual(510, parameters.MSGeneratorParameters.MaxLCScan);
            Assert.AreEqual(false, parameters.MSGeneratorParameters.UseMZRange);
            Assert.AreEqual(100, parameters.MSGeneratorParameters.MinMZ);
            Assert.AreEqual(3000, parameters.MSGeneratorParameters.MaxMZ);

            Assert.AreEqual("quadratic", parameters.PeakDetectorParameters.PeakFitType.ToString().ToLower());
            Assert.AreEqual(true, parameters.PeakDetectorParameters.IsDataThresholded);


            Assert.AreEqual(1, parameters.MSGeneratorParameters.NumLCScansToSum);
            Assert.AreEqual(7, parameters.MSGeneratorParameters.NumImsScansToSum);
            Assert.AreEqual(true, parameters.MSGeneratorParameters.SumSpectraAcrossIms);
            Assert.AreEqual(true, parameters.MSGeneratorParameters.SumSpectraAcrossLC);
        }
Exemplo n.º 11
0
        public void ParameterFileTest1()
        {
            //see https://jira.pnnl.gov/jira/browse/OMCS-460

            var fiParameterFile = new FileInfo(@"..\..\..\TestFiles\SampleParameterFile.xml");

            Assert.IsTrue(fiParameterFile.Exists);
            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(fiParameterFile.FullName);

            Assert.IsNotNullOrEmpty(parameters.ThrashParameters.AveragineFormula);
            Assert.AreEqual("C4.9384 H7.7583 N1.3577 O1.4773 S0.0417", parameters.ThrashParameters.AveragineFormula);
            Assert.AreEqual("AREA", parameters.ThrashParameters.IsotopicProfileFitType.ToString());
            Assert.AreEqual(1.00727649, parameters.ThrashParameters.ChargeCarrierMass);
            Assert.AreEqual(1, parameters.ThrashParameters.MinIntensityForDeletion);
            Assert.AreEqual(0.3m, (decimal)Math.Round(parameters.ThrashParameters.MaxFit, 1));
            Assert.AreEqual(10, parameters.ThrashParameters.MaxCharge);
            Assert.AreEqual(1, parameters.ThrashParameters.MinMSFeatureToBackgroundRatio);
            Assert.AreEqual(10000, parameters.ThrashParameters.MaxMass);
            Assert.AreEqual(false, parameters.ThrashParameters.IsO16O18Data);
            Assert.AreEqual(false, parameters.ThrashParameters.CheckAllPatternsAgainstChargeState1);
            Assert.AreEqual(true, parameters.ThrashParameters.IsThrashUsed);

            Assert.AreEqual("Text", parameters.ScanBasedWorkflowParameters.ExportFileType.ToString());
            Assert.AreEqual("standard", parameters.ScanBasedWorkflowParameters.ScanBasedWorkflowName.ToLower());
            Assert.AreEqual(false, parameters.ScanBasedWorkflowParameters.ExportPeakData);
            Assert.AreEqual("ThrashV1", parameters.ScanBasedWorkflowParameters.DeconvolutionType.ToString());

            Assert.AreEqual(-2147483648, parameters.MSGeneratorParameters.MinLCScan);
            Assert.AreEqual(2147483647, parameters.MSGeneratorParameters.MaxLCScan);
            Assert.AreEqual(true, parameters.MSGeneratorParameters.UseMZRange);
            Assert.AreEqual(100, parameters.MSGeneratorParameters.MinMZ);
            Assert.AreEqual(3000, parameters.MSGeneratorParameters.MaxMZ);
            Assert.AreEqual(3, parameters.MSGeneratorParameters.NumLCScansToSum);
            Assert.AreEqual(true, parameters.MSGeneratorParameters.SumSpectraAcrossLC);

            Assert.AreEqual("quadratic", parameters.PeakDetectorParameters.PeakFitType.ToString().ToLower());
            Assert.AreEqual(true, parameters.PeakDetectorParameters.IsDataThresholded);
            Assert.AreEqual(false, parameters.PeakDetectorParameters.PeaksAreStored);
        }
Exemplo n.º 12
0
        public static ScanBasedWorkflow CreateWorkflow(string datasetFileName, string parameterFile, string outputFolderPath = null, BackgroundWorker backgroundWorker = null, bool useNewDeconToolsParameterObjects = true)
        {
            var datasetFile = new FileInfo(datasetFileName);

            if (!datasetFile.Exists)
            {
                var datasetFolder = new DirectoryInfo(datasetFileName);
                if (!datasetFolder.Exists)
                {
                    throw new FileNotFoundException("Dataset file (or folder) not found: " + datasetFile);
                }
            }

            var paramFile = new FileInfo(parameterFile);

            if (!paramFile.Exists)
            {
                throw new FileNotFoundException("Parameter file not found: " + parameterFile);
            }

            // Initialize a new Run
            Run run;

            try
            {
                run = new RunFactory().CreateRun(datasetFileName);
            }
            catch (Exception ex)
            {
                Logger.Instance.OutputFilename = datasetFileName + "_BAD_ERROR_log.txt";
                Logger.Instance.AddEntry("DeconTools.Backend.dll version = " + AssemblyInfoRetriever.GetVersion(typeof(ScanBasedWorkflow)));
                Logger.Instance.AddEntry("UIMFLibrary version = " + AssemblyInfoRetriever.GetVersion(typeof(UIMFLibrary.DataReader)), Logger.Instance.OutputFilename);   //forces it to write out immediately and clear buffer
                Logger.Instance.AddEntry("ERROR message= " + ex.Message, Logger.Instance.OutputFilename);
                Logger.Instance.AddEntry("ERROR type= " + ex, Logger.Instance.OutputFilename);
                Logger.Instance.AddEntry("STACKTRACE = " + PRISM.clsStackTraceFormatter.GetExceptionStackTraceMultiLine(ex), Logger.Instance.OutputFilename);

                throw new ApplicationException(
                          "A fatal error occured when connecting to the instrument data file. Could not create the Run object. Internal error message: " +
                          ex.Message + Environment.NewLine + Environment.NewLine + PRISM.clsStackTraceFormatter.GetExceptionStackTraceMultiLine(ex));
            }

            DeconToolsParameters newParameters;

            try
            {
                newParameters = new DeconToolsParameters();
                newParameters.LoadFromOldDeconToolsParameterFile(parameterFile);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                          "Error loading the parameter file: " +
                          ex.Message + Environment.NewLine + Environment.NewLine + PRISM.clsStackTraceFormatter.GetExceptionStackTraceMultiLine(ex));
            }

            try
            {
                return(CreateWorkflow(run, newParameters, outputFolderPath, backgroundWorker));
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                          "Error creating the workflow: " +
                          ex.Message + Environment.NewLine + Environment.NewLine + PRISM.clsStackTraceFormatter.GetExceptionStackTraceMultiLine(ex));
            }
        }
        public void saturatedFixing_RedmineIssue966()
        {
            var uimfFile = @"D:\Data\UIMF\Sarc_Main_Study_Controls\Sarc_P09_B06_0786_20Jul11_Cheetah_11-05-31.uimf";

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

            var parameterFile =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\ParameterFiles\IMS_UIMF_PeakBR4_PeptideBR4_SN3_SumScans3_NoLCSum_saturationRepair_Frame_1-500.xml";

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);

            parameters = new DeconToolsParameters();
            parameters.PeakDetectorParameters.PeakToBackgroundRatio  = 4;
            parameters.PeakDetectorParameters.SignalToNoiseThreshold = 3;
            parameters.ThrashParameters.MaxFit = 0.6;
            parameters.MSGeneratorParameters.UseLCScanRange      = true;
            parameters.MSGeneratorParameters.MinLCScan           = 320;
            parameters.MSGeneratorParameters.MaxLCScan           = 328;
            parameters.MSGeneratorParameters.SumSpectraAcrossLC  = true;
            parameters.MSGeneratorParameters.SumSpectraAcrossIms = true;
            parameters.MSGeneratorParameters.NumLCScansToSum     = 1;
            parameters.MSGeneratorParameters.NumImsScansToSum    = 3;
            parameters.MSGeneratorParameters.UseMZRange          = false;
            parameters.MiscMSProcessingParameters.UseZeroFilling = true;
            parameters.ThrashParameters.MinIntensityForDeletion  = 10;

            parameters.ScanBasedWorkflowParameters.ScanBasedWorkflowName = "uimf_saturation_repair";
            parameters.Save(@"\\protoapps\UserData\Slysz\DeconTools_TestFiles\ParameterFiles\IMS_UIMF_PeakBR4_PeptideBR4_SN3_SumScans3_NoLCSum_saturationRepair_Frame_1-500_copy.xml");

            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.ExportData = true;

            var sw = new Stopwatch();

            sw.Start();

            workflow.Execute();
            //return;

            sw.Stop();

            var distinctItems = run.ResultCollection.ResultList.GroupBy(x => x.MSFeatureID).Select(y => y.First()).ToList();

            var minFrame = parameters.MSGeneratorParameters.MinLCScan;
            var maxFrame = parameters.MSGeneratorParameters.MaxLCScan;

            var minScan = 117;
            var maxScan = 131;

            var chargestate = 2;
            var targetMass  = (605.82 - 1.00727649) * chargestate;

            var tolerance   = 0.3;
            var featureData =
                (from n in distinctItems
                 where (Math.Abs(n.IsotopicProfile.MonoIsotopicMass - targetMass)) < tolerance &&
                 n.IsotopicProfile.ChargeState == chargestate
                 select n).Select <IsosResult, UIMFIsosResult>(r => (UIMFIsosResult)r).ToList();

            OutputFeatureIntensityData(featureData, minFrame, maxFrame, maxScan, minScan);

            var mathUtils = new MathUtils();

            var monoMasses = (from n in featureData select n.IsotopicProfile.MonoIsotopicMass).ToList();

            var massVariance = MathUtils.GetStDev(monoMasses);

            Console.WriteLine("Mass variance = " + massVariance);
            Console.WriteLine("Time taken = " + sw.ElapsedMilliseconds);
        }
Exemplo n.º 14
0
        public void TraditionalWorkflowTestOrbitrapData1()
        {
            var parameterFile = FileRefs.ParameterFiles.Orbitrap_Scans6000_6050ParamFile;

            var run = new RunFactory().CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);
            var expectedIsosFile  = Path.Combine(run.DataSetPath, run.DatasetName + "_isos.csv");
            var expectedScansFile = Path.Combine(run.DataSetPath, run.DatasetName + "_scans.csv");
            var expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt");

            if (File.Exists(expectedIsosFile))
            {
                File.Delete(expectedIsosFile);
            }
            if (File.Exists(expectedScansFile))
            {
                File.Delete(expectedScansFile);
            }
            if (File.Exists(expectedPeaksFile))
            {
                File.Delete(expectedPeaksFile);
            }

            var parameters = new DeconToolsParameters();

            parameters.LoadFromOldDeconToolsParameterFile(parameterFile);
            parameters.ScanBasedWorkflowParameters.DeconvolutionType = Globals.DeconvolutionType.ThrashV1;


            parameters.MSGeneratorParameters.MinLCScan = 6005;
            parameters.MSGeneratorParameters.MaxLCScan = 6005;


            var workflow = ScanBasedWorkflow.CreateWorkflow(run, parameters);

            workflow.Execute();

            Assert.IsTrue(File.Exists(expectedIsosFile), "Isos file was not created.");
            Assert.IsTrue(File.Exists(expectedScansFile), "Scans file was not created.");
            Assert.IsTrue(File.Exists(expectedPeaksFile), "Peaks file was not created.");

            var isosImporter = new IsosImporter(expectedIsosFile, run.MSFileType);
            var isos         = isosImporter.Import();

            Assert.AreEqual(186, isos.Count);

            var peakImporter = new PeakImporterFromText(expectedPeaksFile);

            var peaklist = new List <MSPeakResult>();

            peakImporter.ImportPeaks(peaklist);

            Assert.AreEqual(809, peaklist.Count);

            var sumIntensities = isos.Select(p => p.IntensityAggregate).Sum();

            Assert.AreEqual(266185816d, Math.Round(sumIntensities));

            var sumPeakIntensities = peaklist.Select(p => p.Height).Sum();

            Assert.AreEqual(605170496.0f, sumPeakIntensities);
        }
Exemplo n.º 15
0
        private void btnAutoProcess_Click(object sender, EventArgs e)
        {
            if (!File.Exists(_parameterFileName))
            {
                MessageBox.Show("File not found error - Parameter file does not exist.");
                return;
            }


            if (_bw != null && _bw.IsBusy)
            {
                MessageBox.Show("Already processing...  please wait or click 'Abort'");
                return;
            }

            if (this._inputFileList == null || this._parameterFileName == null)
            {
                MessageBox.Show("Please run the Setup Wizard first");
                return;
            }

            try
            {
                TrySetOutputFolder();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                _parameters = new DeconToolsParameters();
                _parameters.LoadFromOldDeconToolsParameterFile(_parameterFileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Tried to load parameters. Serious error occurred. Error message: " + ex.Message +
                                "\n\n" + ex.StackTrace);
                return;
            }



            this.txtProcessingStatus.Text = "Working...";

            _bw = new BackgroundWorker();

            _bw.WorkerReportsProgress      = true;
            _bw.WorkerSupportsCancellation = true;

            _bw.DoWork             += bw_DoWork;
            _bw.ProgressChanged    += bw_ProgressChanged;
            _bw.RunWorkerCompleted += bw_RunWorkerCompleted;
            _bw.RunWorkerAsync();


            //for (int i = 0; i < inputFileList.Length; i++)
            //{
            //    CALL_DeconConsole(inputFileList[i]);
            //}

            //MessageBox.Show("Processing complete!");
        }