Esempio n. 1
0
        public void ExportPeakDataToTextFileTest1()
        {
            var outputFile = FileRefs.OutputFolderPath + "ExportPeakDataToTextFileTest1.txt";

            if (File.Exists(outputFile))
            {
                File.Delete(outputFile);
            }

            var run = TestDataCreationUtilities.CreatePeakDataFromStandardOrbitrapData();

            NUnit.Framework.Assume.That(5608 == run.ResultCollection.MSPeakResultList.Count);

            var peakExporter = new PeakListTextExporter(run.MSFileType, outputFile);

            peakExporter.WriteOutPeaks(run.ResultCollection.MSPeakResultList);

            var fi = new FileInfo(outputFile);

            Assert.AreEqual(true, fi.Exists);
            Assert.AreNotEqual(0, fi.Length);
        }
Esempio n. 2
0
        public void Execute()
        {
            InitializeWorkflow();

            if (Run.MSFileType == Globals.MSFileType.PNNL_UIMF)
            {
                IMSScanSetCollection = CreateIMSScanSetCollection();
            }

            LcScanSetCollection = CreateLcScanSetCollection();

            PrepareOutputDirectory(WorkflowParameters.OutputDirectory);

            var outputPeaksFilePath = getOutputPeaksFilename();

            peakExporter = new PeakListTextExporter(Run.MSFileType, outputPeaksFilePath);

            var numTotalScans = LcScanSetCollection.ScanSetList.Count;
            var lastProgress  = DateTime.UtcNow;

            using (var sw = new StreamWriter(new FileStream(outputPeaksFilePath, FileMode.Append, FileAccess.Write, FileShare.Read)))
            {
                if (Run.MSFileType == Globals.MSFileType.PNNL_UIMF && Run is UIMFRun uimfRun)
                {
                    var numTotalFrames = LcScanSetCollection.ScanSetList.Count;
                    var frameCounter   = 0;

                    foreach (var frameSet in LcScanSetCollection.ScanSetList)
                    {
                        frameCounter++;
                        uimfRun.CurrentScanSet = frameSet;
                        uimfRun.ResultCollection.MSPeakResultList.Clear();

                        foreach (var scanSet in IMSScanSetCollection.ScanSetList)
                        {
                            uimfRun.CurrentIMSScanSet = (IMSScanSet)scanSet;
                            MSGenerator.Execute(uimfRun.ResultCollection);
                            _ms1PeakDetector.Execute(uimfRun.ResultCollection);
                        }
                        peakExporter.WriteOutPeaks(sw, uimfRun.ResultCollection.MSPeakResultList);

                        if (DateTime.UtcNow.Subtract(lastProgress).TotalSeconds >= 1 || frameCounter == numTotalFrames)
                        {
                            lastProgress = DateTime.UtcNow;
                            var percentProgress = frameCounter * 100 / (double)numTotalFrames;
                            reportProgress(percentProgress);
                        }
                    }
                }
                else
                {
                    var scanCounter = 0;
                    foreach (var scan in LcScanSetCollection.ScanSetList)
                    {
                        scanCounter++;

                        Run.CurrentScanSet = scan;

                        Run.ResultCollection.MSPeakResultList.Clear();

                        MSGenerator.Execute(Run.ResultCollection);
                        if (Run.GetMSLevel(scan.PrimaryScanNumber) == 1)
                        {
                            _ms1PeakDetector.Execute(Run.ResultCollection);
                        }
                        else
                        {
                            var dataIsCentroided = Run.IsDataCentroided(scan.PrimaryScanNumber);
                            if (dataIsCentroided)
                            {
                                _ms2PeakDetectorForCentroidedData.Execute(Run.ResultCollection);
                            }
                            else
                            {
                                _ms2PeakDetectorForProfileData.Execute(Run.ResultCollection);
                            }
                        }

                        peakExporter.WriteOutPeaks(sw, Run.ResultCollection.MSPeakResultList);

                        if (DateTime.UtcNow.Subtract(lastProgress).TotalSeconds >= 1 || scanCounter == numTotalScans)
                        {
                            lastProgress = DateTime.UtcNow;
                            var percentProgress = scanCounter * 100 / (double)numTotalScans;
                            reportProgress(percentProgress);
                        }
                    }
                }
            }

            Run.ResultCollection.MSPeakResultList.Clear();
        }
        public override void Execute()
        {
            InitializeWorkflow();

            PrepareOutputFolder(_workflowParameters.OutputFolder);

            string outputPeaksFileName = getOutputPeaksFilename();

            peakExporter = new PeakListTextExporter(Run.MSFileType, outputPeaksFileName);

            int numTotalScans = Run.ScanSetCollection.ScanSetList.Count;
            int scanCounter   = 0;

            if (Run.MSFileType == DeconTools.Backend.Globals.MSFileType.PNNL_UIMF)
            {
                var uimfrun = Run as UIMFRun;

                int numTotalFrames = uimfrun.ScanSetCollection.ScanSetList.Count;
                int frameCounter   = 0;

                foreach (var frameSet in uimfrun.ScanSetCollection.ScanSetList)
                {
                    frameCounter++;
                    uimfrun.CurrentScanSet = frameSet;
                    uimfrun.ResultCollection.MSPeakResultList.Clear();

                    foreach (var scanSet in uimfrun.IMSScanSetCollection.ScanSetList)
                    {
                        uimfrun.CurrentIMSScanSet = (IMSScanSet)scanSet;
                        MSGenerator.Execute(uimfrun.ResultCollection);
                        this._ms1PeakDetector.Execute(uimfrun.ResultCollection);
                    }
                    peakExporter.WriteOutPeaks(uimfrun.ResultCollection.MSPeakResultList);

                    if (frameCounter % 5 == 0 || scanCounter == numTotalFrames)
                    {
                        double percentProgress = frameCounter * 100 / numTotalFrames;
                        reportProgress(percentProgress);
                    }
                }
            }
            else
            {
                foreach (var scan in Run.ScanSetCollection.ScanSetList)
                {
                    scanCounter++;

                    Run.CurrentScanSet = scan;

                    Run.ResultCollection.MSPeakResultList.Clear();

                    MSGenerator.Execute(Run.ResultCollection);
                    if (Run.GetMSLevel(scan.PrimaryScanNumber) == 1)
                    {
                        this._ms1PeakDetector.Execute(Run.ResultCollection);
                    }
                    else
                    {
                        var dataIsCentroided = Run.IsDataCentroided(scan.PrimaryScanNumber);
                        if (dataIsCentroided)
                        {
                            _ms2PeakDetectorForCentroidedData.Execute(Run.ResultCollection);
                        }
                        else
                        {
                            _ms2PeakDetectorForProfileData.Execute(Run.ResultCollection);
                        }
                    }

                    peakExporter.WriteOutPeaks(Run.ResultCollection.MSPeakResultList);

                    if (scanCounter % 50 == 0 || scanCounter == numTotalScans)
                    {
                        double percentProgress = scanCounter * 100 / numTotalScans;
                        reportProgress(percentProgress);
                    }
                }
            }



            Run.ResultCollection.MSPeakResultList.Clear();
        }
Esempio n. 4
0
        private void ExportPeaks_copied(string peaksfile)
        {
            DeconToolsPeakDetectorV2 _ms1PeakDetector;
            DeconToolsPeakDetectorV2 _ms2PeakDetectorForCentroidedData;
            DeconToolsPeakDetectorV2 _ms2PeakDetectorForProfileData;
            var msGen = MSGeneratorFactory.CreateMSGenerator(_run.MSFileType);

            _ms1PeakDetector = new DeconToolsPeakDetectorV2(2.0, 2.0,
                                                            DeconTools.Backend.Globals.PeakFitType.QUADRATIC, false);

            _ms2PeakDetectorForProfileData = new DeconToolsPeakDetectorV2(2.0,
                                                                          2.0,
                                                                          DeconTools.Backend.Globals.PeakFitType.QUADRATIC,
                                                                          false);
            _ms2PeakDetectorForCentroidedData             = new DeconToolsPeakDetectorV2(0, 0, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true);
            _ms2PeakDetectorForCentroidedData.RawDataType = DeconTools.Backend.Globals.RawDataType.Centroided;

            _ms2PeakDetectorForProfileData.PeaksAreStored    = true;
            _ms2PeakDetectorForCentroidedData.PeaksAreStored = true;
            _ms1PeakDetector.PeaksAreStored = true;


            var peakExporter = new PeakListTextExporter(_run.MSFileType, peaksfile);

            var numTotalScans = _run.ScanSetCollection.ScanSetList.Count;
            var scanCounter   = 0;

            if (_run.MSFileType == DeconTools.Backend.Globals.MSFileType.PNNL_UIMF)
            {
                var uimfrun = _run as UIMFRun;

                var numTotalFrames = uimfrun.ScanSetCollection.ScanSetList.Count;
                var frameCounter   = 0;

                foreach (var frameSet in uimfrun.ScanSetCollection.ScanSetList)
                {
                    frameCounter++;
                    uimfrun.CurrentScanSet = frameSet;
                    uimfrun.ResultCollection.MSPeakResultList.Clear();

                    foreach (var scanSet in uimfrun.IMSScanSetCollection.ScanSetList)
                    {
                        uimfrun.CurrentIMSScanSet = (IMSScanSet)scanSet;
                        msGen.Execute(uimfrun.ResultCollection);
                        _ms1PeakDetector.Execute(uimfrun.ResultCollection);
                    }
                    peakExporter.WriteOutPeaks(uimfrun.ResultCollection.MSPeakResultList);

                    if (frameCounter % 5 == 0 || scanCounter == numTotalFrames)
                    {
                        double percentProgress = frameCounter * 100 / numTotalFrames;
                        // reportProgress(percentProgress);
                    }
                }
            }
            else
            {
                foreach (var scan in _run.ScanSetCollection.ScanSetList)
                {
                    scanCounter++;

                    _run.CurrentScanSet = scan;

                    _run.ResultCollection.MSPeakResultList.Clear();

                    msGen.Execute(_run.ResultCollection);
                    if (_run.GetMSLevel(scan.PrimaryScanNumber) == 1)
                    {
                        _ms1PeakDetector.Execute(_run.ResultCollection);
                    }
                    else
                    {
                        var dataIsCentroided = _run.IsDataCentroided(scan.PrimaryScanNumber);
                        if (dataIsCentroided)
                        {
                            _ms2PeakDetectorForCentroidedData.Execute(_run.ResultCollection);
                        }
                        else
                        {
                            _ms2PeakDetectorForProfileData.Execute(_run.ResultCollection);
                        }
                    }

                    peakExporter.WriteOutPeaks(_run.ResultCollection.MSPeakResultList);
                }
            }
        }