protected XYData GetCorrelatedChromPeakXYData(Run run, int startScan, int stopScan, XYData basePeakChromXYData, double correlatedMZValue)
        {
            var xydata = PeakChromGen.GenerateChromatogram(run, startScan, stopScan, correlatedMZValue, ChromTolerance, ChromToleranceUnit);

            XYData chromPeakXYData;

            if (xydata == null || xydata.Xvalues.Length == 0)
            {
                chromPeakXYData         = new XYData();
                chromPeakXYData.Xvalues = basePeakChromXYData.Xvalues;
                chromPeakXYData.Yvalues = new double[basePeakChromXYData.Xvalues.Length];
            }
            else
            {
                chromPeakXYData = Smoother.Smooth(xydata);
            }


            var chromDataIsOK = chromPeakXYData != null && chromPeakXYData.Xvalues != null &&
                                chromPeakXYData.Xvalues.Length > 3;

            if (chromDataIsOK)
            {
                chromPeakXYData = chromPeakXYData.TrimData(startScan, stopScan);
            }
            return(chromPeakXYData);
        }
예제 #2
0
        public void BadCorrelationTest1()
        {
            var dataset =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\O16O18_standard_testing\Test1_VladAlz\RawData\Alz_P01_A01_097_26Apr12_Roc_12-03-15.RAW";

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

            var peaksDataFile = dataset.ToLower().Replace(".raw", "_peaks.txt");
            var peakImporter  = new PeakImporterFromText(peaksDataFile);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);


            double chromToleranceInPPM = 10;
            var    startScan           = 2340;
            var    stopScan            = 2440;

            var smoother = new SavitzkyGolaySmoother(9, 2);

            var testMZVal1 = 719.80349;

            var peakChromGen = new PeakChromatogramGenerator(chromToleranceInPPM);

            run.XYData = peakChromGen.GenerateChromatogram(run, startScan, stopScan, testMZVal1, chromToleranceInPPM);
            run.XYData = smoother.Smooth(run.XYData);

            var chromdata1 = run.XYData.TrimData(startScan, stopScan);

            var testMZVal2 = 722.325;

            run.XYData = peakChromGen.GenerateChromatogram(run, startScan, stopScan, testMZVal2, chromToleranceInPPM);
            run.XYData = smoother.Smooth(run.XYData);

            var chromdata2 = run.XYData.TrimData(startScan, stopScan);



            //chromdata1.Display();
            //Console.WriteLine();
            //chromdata2.Display();

            ChromatogramCorrelatorBase correlator = new ChromatogramCorrelator(3);
            double slope       = 0;
            double intercept   = 0;
            double rsquaredVal = 0;

            correlator.GetElutionCorrelationData(chromdata1, chromdata2, out slope, out intercept, out rsquaredVal);


            Console.WriteLine("slope = \t" + slope);
            Console.WriteLine("intercept = \t" + intercept);
            Console.WriteLine("rsquared = \t" + rsquaredVal);


            for (var i = 0; i < chromdata1.Xvalues.Length; i++)
            {
                Console.WriteLine(chromdata1.Xvalues[i] + "\t" + chromdata1.Yvalues[i] + "\t" + chromdata2.Yvalues[i]);
            }
        }
예제 #3
0
        public void GetPeakChromatogram_IQStyle_Test3()
        {
            var run = RunUtilities.CreateAndLoadPeaks(FileRefs.RawDataMSFiles.OrbitrapStdFile1, FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500);

            var target = TestUtilities.GetIQTargetStandard(1);

            var chromGen = new PeakChromatogramGenerator();

            chromGen.ChromatogramGeneratorMode = Globals.ChromatogramGeneratorMode.TOP_N_PEAKS;
            chromGen.TopNPeaksLowerCutOff      = 0.4;
            chromGen.Tolerance = 100;

            var lowerScan      = 6087;
            var upperScan      = 6418;
            var massOfInterest = new List <double>();

            massOfInterest.Add(target.TheorIsotopicProfile.Peaklist[0].XValue);
            massOfInterest.Add(target.TheorIsotopicProfile.Peaklist[1].XValue);

            var chromXYData = chromGen.GenerateChromatogram(run, massOfInterest, lowerScan, upperScan, chromGen.Tolerance, chromGen.ToleranceUnit);

            Assert.IsNotNull(chromXYData);
            Assert.AreEqual(96, chromXYData.Xvalues.Length);

            TestUtilities.DisplayXYValues(chromXYData);
        }
예제 #4
0
        public void GetChromatogramsTest1()
        {
            string testDatasetPath =
                @"D:\Data\From_Vlad\Bruker\2013_01_29_ALZ_CTRL_5_0p5_1_01_228.d";

            Run run = RunUtilities.CreateAndLoadPeaks(testDatasetPath);

            PeakChromatogramGenerator chromGen = new PeakChromatogramGenerator(10);

            double targetMZ    = 663.3404;
            int    chargeState = 2;
            int    peakNum     = 4;


            targetMZ = targetMZ + peakNum * Globals.MASS_DIFF_BETWEEN_ISOTOPICPEAKS / chargeState;

            double toleranceInPPM = 10;

            int startScan = 230;
            int stopScan  = 300;

            chromGen.GenerateChromatogram(run, startScan, stopScan, targetMZ, toleranceInPPM);

            run.XYData = run.XYData.TrimData(startScan, stopScan);

            TestUtilities.DisplayXYValues(run.XYData);
        }
예제 #5
0
        /// <summary>
        /// Pulls all XICs needed to perform charge correlation
        /// </summary>
        /// <param name="peaksToCorrelate"></param>
        /// <param name="MZList"></param>
        /// <param name="run"></param>
        /// <param name="startScan"></param>
        /// <param name="stopScan"></param>
        /// <returns></returns>
        private XYData[] GetCorrelationXICs(int peaksToCorrelate, IEnumerable <double> MZList, Run run, int startScan, int stopScan)
        {
            var XICArray = new XYData[peaksToCorrelate];
            var index    = 0;

            foreach (var mz in MZList)
            {
                XICArray[index] = Smoother.Smooth(_chromGen.GenerateChromatogram(run, startScan, stopScan, mz, 20));
                index++;
            }
            return(XICArray);
        }
예제 #6
0
        private double getCorrelation(double mzPeak1, double mzPeak2, double tolerancePPMpeak1, double tolerancePPMpeak2)
        {
            var chromgenPeak1 = new PeakChromatogramGenerator();

            chromgenPeak1.ChromatogramGeneratorMode = Globals.ChromatogramGeneratorMode.TOP_N_PEAKS;
            chromgenPeak1.TopNPeaksLowerCutOff      = 0.4;
            //TODO: correlate narrow range. -100 +100
            //TODO: for gord.
            var scanWindow = 100;
            var lowerScan  = _run.CurrentScanSet.PrimaryScanNumber - scanWindow;
            var upperScan  = _run.CurrentScanSet.PrimaryScanNumber + scanWindow;

            var chromxydataPeak1 = chromgenPeak1.GenerateChromatogram(_run, lowerScan, upperScan, mzPeak1, tolerancePPMpeak1, Globals.ToleranceUnit.PPM);
            var chromxydataPeak2 = chromgenPeak1.GenerateChromatogram(_run, lowerScan, upperScan, mzPeak2, tolerancePPMpeak2, Globals.ToleranceUnit.PPM);

            //var chromxydataPeak1 = chromgenPeak1.GenerateChromatogram(_run, 1, _run.GetNumMSScans(), mzPeak1, tolerancePPMpeak1, Globals.ToleranceUnit.PPM);
            //var chromxydataPeak2 = chromgenPeak1.GenerateChromatogram(_run, 1, _run.GetNumMSScans(), mzPeak2, tolerancePPMpeak2, Globals.ToleranceUnit.PPM);
            if (null == chromxydataPeak1 || null == chromxydataPeak2)
            {
                return(-3.0);
            }

            double[] arrayToCorrelatePeak1;
            double[] arrayToCorrelatePeak2;
            var      overlap = AlignAndFillArraysToCorrelate(chromxydataPeak1, chromxydataPeak2, out arrayToCorrelatePeak1, out arrayToCorrelatePeak2);

            if (overlap)
            {
                var corr = MathNet.Numerics.Statistics.Correlation.Pearson(arrayToCorrelatePeak1, arrayToCorrelatePeak2);
                if (double.IsNaN(corr))
                {
                    return(-2);   //it's present, but they don't overlap any. same as other -2 value.
                }
                //TODO: implement iq standard of getting linear regression.
                return(MathNet.Numerics.Statistics.Correlation.Pearson(arrayToCorrelatePeak1, arrayToCorrelatePeak2));
            }
            return(-2);
        }
예제 #7
0
        public void GetPeakChromatogram_usePPMTolerance_Test1()
        {
            var run = RunUtilities.CreateAndLoadPeaks(FileRefs.RawDataMSFiles.OrbitrapStdFile1,
                                                      FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500);

            var targetMZ  = 759.4032;
            var startScan = 5500;
            var stopScan  = 6500;

            double toleranceInPPM = 20;

            var chromGen = new PeakChromatogramGenerator();
            var xydata   = chromGen.GenerateChromatogram(run, startScan, stopScan, targetMZ, toleranceInPPM, Globals.ToleranceUnit.PPM);

            Assert.IsNotNull(xydata);
            TestUtilities.DisplayXYValues(xydata);
        }
예제 #8
0
        public void CorrelationTest2_UsingExecutorMethod()
        {
            var run = new RunFactory().CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            var peakImporter = new PeakImporterFromText(FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);

            var mt = TestUtilities.GetMassTagStandard(1);

            run.CurrentMassTag = mt;

            var unlabelledTheorGenerator = new JoshTheorFeatureGenerator();

            unlabelledTheorGenerator.GenerateTheorFeature(mt);


            double chromToleranceInPPM = 10;
            var    startScan           = 5460;
            var    stopScan            = 5755;

            var smoother = new SavitzkyGolaySmoother(3, 2);

            var peakChromGen = new PeakChromatogramGenerator(chromToleranceInPPM);

            run.XYData = peakChromGen.GenerateChromatogram(run, startScan, stopScan, mt.IsotopicProfile.Peaklist[0].XValue, chromToleranceInPPM);
            run.XYData = smoother.Smooth(run.XYData);

            var result = run.ResultCollection.GetTargetedResult(mt);

            ChromatogramCorrelatorBase correlator = new ChromatogramCorrelator(3);
            var corrData = correlator.CorrelatePeaksWithinIsotopicProfile(run, mt.IsotopicProfile, startScan, stopScan);

            Debug.Assert(corrData.CorrelationDataItems != null, "corrData.CorrelationDataItems != null");
            Assert.AreEqual(0.98m, (decimal)Math.Round((double)corrData.CorrelationDataItems[1].CorrelationRSquaredVal, 2));

            foreach (var item in corrData.CorrelationDataItems)
            {
                Console.WriteLine(item.CorrelationRSquaredVal);
            }
        }
예제 #9
0
        public void GetPeakChromatogram_IQStyle_Test1()
        {
            var run = RunUtilities.CreateAndLoadPeaks(FileRefs.RawDataMSFiles.OrbitrapStdFile1,
                                                      FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500);

            var target = TestUtilities.GetIQTargetStandard(1);


            //TestUtilities.DisplayIsotopicProfileData(target.TheorIsotopicProfile);

            var chromGen = new PeakChromatogramGenerator();

            chromGen.ChromatogramGeneratorMode = Globals.ChromatogramGeneratorMode.TOP_N_PEAKS;
            chromGen.TopNPeaksLowerCutOff      = 0.4;
            chromGen.Tolerance = 10;

            var chromXYData = chromGen.GenerateChromatogram(run, target.TheorIsotopicProfile, target.ElutionTimeTheor);

            Assert.IsNotNull(chromXYData);

            TestUtilities.DisplayXYValues(chromXYData);
        }
예제 #10
0
        public void GetPeakChromatogram_IQStyle_Test1()
        {
            //Run run = RunUtilities.CreateAndLoadPeaks(FileRefs.RawDataMSFiles.OrbitrapStdFile1,
            //                                          FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500);
            var fileName =
                @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.raw";
            var run = RunUtilities.CreateAndLoadPeaks(fileName);

            var target = TestUtilities.GetIQTargetStandard(1);


            //TestUtilities.DisplayIsotopicProfileData(target.TheorIsotopicProfile);

            var chromGen = new PeakChromatogramGenerator();

            chromGen.ChromatogramGeneratorMode = Globals.ChromatogramGeneratorMode.TOP_N_PEAKS;
            //chromGen.ChromatogramGeneratorMode = Globals.ChromatogramGeneratorMode.;
            chromGen.TopNPeaksLowerCutOff = 0.4;
            chromGen.Tolerance            = 10;


            //var chromXYData = chromGen.GenerateChromatogram(run, target.TheorIsotopicProfile, target.ElutionTimeTheor);
            // var chromXYData = chromGen.GenerateChromatogram(run, new List<double> { 481.27410, 481.77542, 482.27683 }, 4000, 6500, 0.009, Globals.ToleranceUnit.MZ);
            //   var chromXYData = chromGen.GenerateChromatogram(run,500,7000,490.26483,0.005,Globals.ToleranceUnit.MZ);


            //  Assert.IsNotNull(chromXYData);

            Console.WriteLine("481.27410");
            var chromXYData1 = chromGen.GenerateChromatogram(run, 500, 7000, 481.27410, 0.005, Globals.ToleranceUnit.MZ); TestUtilities.DisplayXYValues(chromXYData1);
            //  TestUtilities.DisplayXYValues(chromXYData);
            var minx1 = chromXYData1.Xvalues.Min();
            var maxx1 = chromXYData1.Xvalues.Max();

            Console.WriteLine("481.77542");
            // chromXYData1.
            var chromXYData2 = chromGen.GenerateChromatogram(run, 500, 7000, 481.77542, 0.005, Globals.ToleranceUnit.MZ); TestUtilities.DisplayXYValues(chromXYData2);
            // TestUtilities.DisplayXYValues(chromXYData);
            var minx2 = chromXYData2.Xvalues.Min();
            var maxx2 = chromXYData2.Xvalues.Max();

            Console.WriteLine("482.27683");
            var chromXYData3 = chromGen.GenerateChromatogram(run, 500, 7000, 482.27683, 0.005, Globals.ToleranceUnit.MZ); TestUtilities.DisplayXYValues(chromXYData3);


            TestUtilities.DisplayXYValues(chromXYData3);
            var minx3 = chromXYData3.Xvalues.Min();
            var maxx3 = chromXYData3.Xvalues.Max();

            var minxhelper = Math.Max(minx1, minx2);
            var minx       = Math.Max(minxhelper, minx3);
            var maxxhelper = Math.Min(maxx1, maxx2);
            var maxX       = Math.Min(maxxhelper, maxx3);

            var c1start = chromXYData1.GetClosestXVal(minx);
            var c2start = chromXYData2.GetClosestXVal(minx);
            var c3start = chromXYData3.GetClosestXVal(minx);
            var c1stop  = chromXYData1.GetClosestXVal(maxX);
            var c2stop  = chromXYData2.GetClosestXVal(maxX);
            var c3stop  = chromXYData3.GetClosestXVal(maxX);

            chromXYData1.NormalizeYData();
            chromXYData2.NormalizeYData();
            chromXYData3.NormalizeYData();
            var c1 = new double[c1stop - c1start + 1];
            var c2 = new double[c2stop - c2start + 1];
            var c3 = new double[c3stop - c3start + 1];


            for (int i = c1start, j = 0; i <= c1stop; i++, j++)
            {
                c1[j] = chromXYData1.Yvalues[i];
            }
            for (int i = c2start, j = 0; i <= c2stop; i++, j++)
            {
                c2[j] = chromXYData2.Yvalues[i];
            }
            for (int i = c3start, j = 0; i <= c3stop; i++, j++)
            {
                c3[j] = chromXYData3.Yvalues[i];
            }

            for (var i = 0; i < c1.Length; i++)
            {
                Console.WriteLine("{0}\t{1}\t{2}", c1[i], c2[i], c3[i]);
            }

            // double c1chromEven= chromXYData1.Xvalues
            var corr1 = MathNet.Numerics.Statistics.Correlation.Pearson(c1, c2);
            var corr2 = MathNet.Numerics.Statistics.Correlation.Pearson(c1, c3);

            Console.WriteLine("HERE IS THE CORRELATION: " + corr1);
            Console.WriteLine("HERE IS THE CORRELATION: " + corr2);



            //bool alldone = false, done1 = false, done2 = false, done3 = false;
            //int onestarting=0,twostarting=0,threestarting=0;
            //while (!alldone)
            //{
            //    if (!done1)
            //    {
            //        if (chromXYData1.Xvalues[onestarting]==minx)
            //        {
            //            done1 = true;
            //        }
            //        else
            //        {

            //        }

            //    }
            //    if (!done2)
            //    {

            //    }
            //    if (!done3)
            //    {

            //    }
            //    alldone = done1 && done2 && done3;
            //}
        }
예제 #11
0
        public void CorrelationTest1()
        {
            //TODO: test something

            var run = new RunFactory().CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

            var peakImporter = new PeakImporterFromText(FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);

            var mt = TestUtilities.GetMassTagStandard(1);

            run.CurrentMassTag = mt;

            var unlabelledTheorGenerator = new JoshTheorFeatureGenerator();

            unlabelledTheorGenerator.GenerateTheorFeature(mt);


            double chromToleranceInPPM = 10;
            var    startScan           = 5460;
            var    stopScan            = 5755;

            var smoother = new SavitzkyGolaySmoother(3, 2);

            var peakChromGen = new PeakChromatogramGenerator(chromToleranceInPPM);

            run.XYData = peakChromGen.GenerateChromatogram(run, startScan, stopScan, mt.IsotopicProfile.Peaklist[0].XValue, chromToleranceInPPM);
            run.XYData = smoother.Smooth(run.XYData);

            var chromdata1 = run.XYData.TrimData(startScan, stopScan);


            run.XYData = peakChromGen.GenerateChromatogram(run, startScan, stopScan, mt.IsotopicProfile.Peaklist[3].XValue, chromToleranceInPPM);
            run.XYData = smoother.Smooth(run.XYData);

            var chromdata2 = run.XYData.TrimData(startScan, stopScan);

            //chromdata1.Display();
            //Console.WriteLine();
            //chromdata2.Display();

            ChromatogramCorrelatorBase correlator = new ChromatogramCorrelator(3);
            double slope       = 0;
            double intercept   = 0;
            double rsquaredVal = 0;

            correlator.GetElutionCorrelationData(chromdata1, chromdata2, out slope, out intercept, out rsquaredVal);

            Console.WriteLine(mt);

            Console.WriteLine("slope = \t" + slope);
            Console.WriteLine("intercept = \t" + intercept);
            Console.WriteLine("rsquared = \t" + rsquaredVal);


            for (var i = 0; i < chromdata1.Xvalues.Length; i++)
            {
                Console.WriteLine(chromdata1.Xvalues[i].ToString("0") + "\t" + chromdata1.Yvalues[i].ToString("0") + "\t" + chromdata2.Yvalues[i]);
            }
        }
        public void ChromAnalysisForAllSelectedPrecursors()
        {
            var isDataSmoothed = true;

            var numPointsInSmoothing = 9;
            var smoother             = new DeconTools.Backend.ProcessingTasks.Smoothers.SavitzkyGolaySmoother(numPointsInSmoothing, 2);

            var graphGenerator = new BasicGraphControl();

            var thermoFile1 = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW";
            var run         = new RunFactory().CreateRun(thermoFile1);

            var outputFolderForChromGraphs = @"\\protoapps\DataPkgs\Public\2012\684_DeconMSn_research1\ChromatogramImages";

            if (!Directory.Exists(outputFolderForChromGraphs))
            {
                Directory.CreateDirectory(outputFolderForChromGraphs);
            }

            var scanSetCollection = new ScanSetCollection();
            var scanStart         = run.MinLCScan;
            var scanStop          = run.MaxLCScan;

            scanSetCollection.Create(run, scanStart, scanStop, 1, 1, true);
            var sb = new StringBuilder();

            var expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt");

            if (!File.Exists(expectedPeaksFile))
            {
                var peakCreatorParams = new PeakDetectAndExportWorkflowParameters();
                peakCreatorParams.PeakBR = 1.75;

                var peakCreator = new PeakDetectAndExportWorkflow(run, peakCreatorParams);
                peakCreator.Execute();
            }

            var peakImporter = new PeakImporterFromText(expectedPeaksFile);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);

            double ppmTol = 50;
            var    peakChromatogramGenerator = new PeakChromatogramGenerator(ppmTol, Globals.ChromatogramGeneratorMode.MZ_BASED);
            var    scansetList = scanSetCollection.ScanSetList;

            var scanCounter = 0;
            var currentBin  = 0;

            foreach (var scanSet in scansetList)
            {
                run.CurrentScanSet = scanSet;

                var currentScanLevel = run.GetMSLevel(scanSet.PrimaryScanNumber);


                if (currentScanLevel > 1)
                {
                    scanCounter++;
                    var precursorInfo = run.GetPrecursorInfo(scanSet.PrimaryScanNumber);

                    var scanInfo = run.GetScanInfo(scanSet.PrimaryScanNumber);

                    var scanWindowSize = 400;
                    var startScan      = scanSet.PrimaryScanNumber - scanWindowSize / 2;
                    var stopScan       = scanSet.PrimaryScanNumber + scanWindowSize / 2;

                    run.XYData = peakChromatogramGenerator.GenerateChromatogram(run, startScan, stopScan, precursorInfo.PrecursorMZ, ppmTol);

                    if (run.XYData == null)
                    {
                        run.XYData         = new XYData();
                        run.XYData.Xvalues = new double[] { 0, 1, 2 };
                        run.XYData.Yvalues = new double[] { 0, 1, 2 };

                        Console.WriteLine(scanSet.PrimaryScanNumber + "\t" + precursorInfo.MSLevel + "\t" + precursorInfo.PrecursorMZ +
                                          "\t" + precursorInfo.PrecursorScan + "--------- NO XYData!!! -------------");
                    }
                    else
                    {
                        if (isDataSmoothed)
                        {
                            run.XYData = smoother.Smooth(run.XYData);
                        }
                    }

                    Console.WriteLine(scanSet.PrimaryScanNumber + "\t" + precursorInfo.MSLevel + "\t" + precursorInfo.PrecursorMZ +
                                      "\t" + precursorInfo.PrecursorScan);

                    graphGenerator.GenerateGraph(run.XYData.Xvalues, run.XYData.Yvalues);

                    var line = graphGenerator.GraphPane.CurveList[0] as LineItem;
                    line.Line.IsVisible = true;
                    line.Symbol.Size    = 2;
                    line.Symbol.Type    = SymbolType.Circle;

                    graphGenerator.GraphPane.XAxis.Title.Text          = "scan";
                    graphGenerator.GraphPane.YAxis.Title.Text          = "intensity";
                    graphGenerator.GraphPane.XAxis.Scale.MinAuto       = true;
                    graphGenerator.GraphPane.YAxis.Scale.MinAuto       = false;
                    graphGenerator.GraphPane.YAxis.Scale.Min           = 0;
                    graphGenerator.GraphPane.XAxis.Scale.FontSpec.Size = 12;
                    graphGenerator.AddVerticalLineToGraph(scanSet.PrimaryScanNumber, 3);
                    graphGenerator.AddAnnotationRelativeAxis(scanInfo, 0.3, 0.1);

                    if (scanCounter > 500)
                    {
                        currentBin++;
                        scanCounter = 0;
                    }
                    var currentOutputFolder = Path.Combine(outputFolderForChromGraphs, "bin" + currentBin);
                    if (!Directory.Exists(currentOutputFolder))
                    {
                        Directory.CreateDirectory(currentOutputFolder);
                    }


                    var baseFilename = Path.Combine(currentOutputFolder,
                                                    scanSet.PrimaryScanNumber.ToString().PadLeft(5, '0') + "_mz" + precursorInfo.PrecursorMZ);

                    string outputGraphFilename;

                    string outputXYData;

                    if (isDataSmoothed)
                    {
                        outputGraphFilename = baseFilename + "_smoothed_chrom.png";
                        outputXYData        = baseFilename + "_smoothed_xydata.txt";
                    }
                    else
                    {
                        outputXYData        = baseFilename + "_xydata.txt";
                        outputGraphFilename = baseFilename + "_chrom.png";
                    }


                    graphGenerator.SaveGraph(outputGraphFilename);
                    TestUtilities.WriteToFile(run.XYData, outputXYData);
                }
            }

            Console.WriteLine(sb.ToString());
        }
예제 #13
0
        protected virtual void ExecuteWorkflow(IqResult result)
        {
            result.Target.TheorIsotopicProfile = TheorFeatureGen.GenerateTheorProfile(result.Target.EmpiricalFormula, result.Target.ChargeState);

            result.IqResultDetail.Chromatogram = ChromGen.GenerateChromatogram(Run, result.Target.TheorIsotopicProfile, result.Target.ElutionTimeTheor);

            result.IqResultDetail.Chromatogram = ChromSmoother.Smooth(result.IqResultDetail.Chromatogram);

            result.ChromPeakList = ChromPeakDetector.FindPeaks(result.IqResultDetail.Chromatogram);

            ChromPeakDetector.CalculateElutionTimes(Run, result.ChromPeakList);

            ChromPeakDetector.FilterPeaksOnNET(WorkflowParameters.ChromNETTolerance, result.Target.ElutionTimeTheor, result.ChromPeakList);

            result.IqResultDetail.ChromPeakQualityData = ChromPeakAnalyzer.GetChromPeakQualityData(Run, result.Target, result.ChromPeakList);

            var filterOutFlagged = result.Target.TheorIsotopicProfile.GetIndexOfMostIntensePeak() == 0;

            result.ChromPeakSelected = ChromPeakSelector.SelectBestPeak(result.IqResultDetail.ChromPeakQualityData, filterOutFlagged);


            result.LCScanSetSelected = ChromPeakUtilities.GetLCScanSetForChromPeak(result.ChromPeakSelected, Run,
                                                                                   WorkflowParameters.NumMSScansToSum);

            result.LcScanObs = result.LCScanSetSelected == null ? -1 : result.LCScanSetSelected.PrimaryScanNumber;

            result.IqResultDetail.MassSpectrum = MSGenerator.GenerateMS(Run, result.LCScanSetSelected);

            TrimData(result.IqResultDetail.MassSpectrum, result.Target.MZTheor, MsLeftTrimAmount, MsRightTrimAmount);

            List <Peak> mspeakList;

            result.ObservedIsotopicProfile = MsfeatureFinder.IterativelyFindMSFeature(result.IqResultDetail.MassSpectrum, result.Target.TheorIsotopicProfile, out mspeakList);


            result.FitScore = FitScoreCalc.CalculateFitScore(result.Target.TheorIsotopicProfile, result.ObservedIsotopicProfile,
                                                             result.IqResultDetail.MassSpectrum);

            result.InterferenceScore = InterferenceScorer.GetInterferenceScore(result.ObservedIsotopicProfile, mspeakList);

            //if (_workflowParameters.ChromatogramCorrelationIsPerformed)
            //{
            //    ExecuteTask(_chromatogramCorrelator);
            //}

            result.MonoMassObs = result.ObservedIsotopicProfile == null ? 0 : result.ObservedIsotopicProfile.MonoIsotopicMass;

            result.MZObs = result.ObservedIsotopicProfile == null ? 0 : result.ObservedIsotopicProfile.MonoPeakMZ;

            result.MZObsCalibrated       = result.ObservedIsotopicProfile == null ? 0 : Run.GetAlignedMZ(result.ObservedIsotopicProfile.MonoPeakMZ, result.LcScanObs);
            result.MonoMassObsCalibrated = result.ObservedIsotopicProfile == null
                                               ? 0
                                               : (result.MZObsCalibrated - DeconTools.Backend.Globals.PROTON_MASS) * result.Target.ChargeState;


            var elutionTime = result.ChromPeakSelected == null ? 0d : ((ChromPeak)result.ChromPeakSelected).NETValue;

            result.ElutionTimeObs = elutionTime;

            result.Abundance = GetAbundance(result);
        }