Esempio n. 1
0
        public void getPeakChromatogramTest2()
        {
            var mt = TestUtilities.GetMassTagStandard(1);

            Run run = new XCaliburRun2(FileRefs.RawDataMSFiles.OrbitrapStdFile1);

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

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);

            run.CurrentMassTag = mt;

            var unlabelledTheorGenerator = new TomTheorFeatureGenerator();

            unlabelledTheorGenerator.GenerateTheorFeature(mt);

            var peakChromGen = new PeakChromatogramGenerator(10, Globals.ChromatogramGeneratorMode.TOP_N_PEAKS);

            peakChromGen.TopNPeaksLowerCutOff = 0.4;
            peakChromGen.Execute(run.ResultCollection);

            Assert.AreEqual(133, run.XYData.Xvalues.Length);
            Assert.AreEqual(5543, (int)run.XYData.Xvalues[35]);
            //Assert.AreEqual(7319569, (int)run.XYData.Yvalues[35]);
            run.XYData.Display();
        }
Esempio n. 2
0
        public void getPeakChromatogramTest1()
        {
            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 mt = TestUtilities.GetMassTagStandard(1);

            run.CurrentMassTag = mt;

            var unlabelledTheorGenerator = new JoshTheorFeatureGenerator();

            unlabelledTheorGenerator.GenerateTheorFeature(mt);

            var peakChromGen = new PeakChromatogramGenerator(toleranceInPPM);

            peakChromGen.Execute(run.ResultCollection);

            run.XYData.Display();

            Assert.AreEqual(133, run.XYData.Xvalues.Length);
            Assert.AreEqual(5543, (int)run.XYData.Xvalues[35]);
            Assert.AreEqual(7319569, (int)run.XYData.Yvalues[35]);

            //make sure that the 0's are not trimmed off
            Assert.AreEqual(0, run.XYData.Yvalues[1]);
        }
Esempio n. 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);
        }
Esempio n. 4
0
        public void test2()
        {
            MassTag massTag = new MassTag();

            massTag.ID = 56488;
            massTag.MonoIsotopicMass = 2275.1694779;
            massTag.ChargeState      = 3;
            massTag.MZ = massTag.MonoIsotopicMass / massTag.ChargeState + 1.00727649;


            Run run = new XCaliburRun(xcaliburTestfile);

            PeakImporterFromText peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(xcaliburPeakDataFile);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);


            run.CurrentMassTag = massTag;

            Task peakChromGen = new PeakChromatogramGenerator(10);

            Task smoother = new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(2, 2, 2);
            Task peakDet  = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector();


            peakChromGen.Execute(run.ResultCollection);
            smoother.Execute(run.ResultCollection);
            peakDet.Execute(run.ResultCollection);

            TestUtilities.DisplayPeaks(run.PeakList);
            TestUtilities.DisplayXYValues(run.ResultCollection);
        }
Esempio n. 5
0
        public List <Task> getStandardTaskList(Run run)
        {
            Task peakChromGen = new PeakChromatogramGenerator(chromPPMTolerance);
            Task smoother     = new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(11, 11, 2);
            Task peakDet      = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector(0.5, 0.5);
            Task chromPeakSel = new DeconTools.Backend.ProcessingTasks.ChromPeakSelector(1, 0.01, Globals.PeakSelectorMode.CLOSEST_TO_TARGET);
            MSGeneratorFactory msgenFactory = new MSGeneratorFactory();
            Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType);

            DeconToolsV2.Peaks.clsPeakProcessorParameters peakParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(2, 3, false, DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC);
            Task mspeakDet       = new DeconToolsPeakDetector(peakParams);
            Task theorFeatureGen = new TomTheorFeatureGenerator();
            Task finder          = new N14N15TFFTask(5);
            Task quant           = new N14N15QuantifierTask(1);
            Task fitScoreCalc    = new IsotopicProfileFitScoreCalculator();

            List <Task> taskList = new List <Task>();

            taskList.Add(peakChromGen);
            taskList.Add(smoother);
            taskList.Add(peakDet);
            taskList.Add(chromPeakSel);
            taskList.Add(msgen);
            taskList.Add(mspeakDet);
            taskList.Add(theorFeatureGen);
            taskList.Add(finder);
            taskList.Add(quant);
            taskList.Add(fitScoreCalc);

            return(taskList);
        }
Esempio n. 6
0
        protected virtual void DoMainInitialization()
        {
            ValidateParameters();

            TheorFeatureGen = new JoshTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005);
            ChromGen        = new PeakChromatogramGenerator(WorkflowParameters.ChromGenTolerance, WorkflowParameters.ChromGeneratorMode,
                                                            DeconTools.Backend.Globals.IsotopicProfileType.UNLABELLED,
                                                            WorkflowParameters.ChromGenToleranceUnit)
            {
                TopNPeaksLowerCutOff              = 0.333,
                ChromWindowWidthForAlignedData    = (float)WorkflowParameters.ChromNETTolerance * 2,
                ChromWindowWidthForNonAlignedData = (float)WorkflowParameters.ChromNETTolerance * 2
            };

            //only

            var allowNegativeValues = false;

            ChromSmoother     = new SavitzkyGolaySmoother(WorkflowParameters.ChromSmootherNumPointsInSmooth, 2, allowNegativeValues);
            ChromPeakDetector = new ChromPeakDetector(WorkflowParameters.ChromPeakDetectorPeakBR, WorkflowParameters.ChromPeakDetectorSigNoise);
            ChromPeakSelector = CreateChromPeakSelector(WorkflowParameters);

            ChromPeakAnalyzer = new ChromPeakAnalyzer(WorkflowParameters);

            IterativeTffParameters = new IterativeTFFParameters();
            IterativeTffParameters.ToleranceInPPM = WorkflowParameters.MSToleranceInPPM;

            MsfeatureFinder = new IterativeTFF(IterativeTffParameters);
            FitScoreCalc    = new IsotopicProfileFitScoreCalculator();

            InterferenceScorer = new InterferenceScorer();

            ResultValidator        = new ResultValidatorTask();
            ChromatogramCorrelator = new IqChromCorrelator(WorkflowParameters.ChromSmootherNumPointsInSmooth, 0.05, WorkflowParameters.ChromGenTolerance);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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]);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Finds the XIC based on the m/z and scan parameters.
        /// </summary>
        /// <param name="mz"></param>
        /// <param name="scan"></param>
        /// <returns></returns>
        public List <XYData> FindXic(double mz, int scan, bool shouldSmooth)
        {
            LcmsFeatureTarget target = new LcmsFeatureTarget();

            target.ID              = 0;
            target.MZ              = mz;
            target.ScanLCTarget    = scan;
            target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum;
            m_run.CurrentMassTag   = target;
            var result = m_run.ResultCollection.GetTargetedResult(m_run.CurrentMassTag);

            double chromPeakGeneratorTolInPPM = MzPpmWindow;

            Globals.ChromatogramGeneratorMode chromGeneratorMode = Globals.ChromatogramGeneratorMode.MZ_BASED;

            var chromGen = new PeakChromatogramGenerator(chromPeakGeneratorTolInPPM,
                                                         chromGeneratorMode);

            chromGen.NETWindowWidthForNonAlignedData = Convert.ToSingle(NetWindow);

            int pointsToSmooth = 5;
            var chromSmoother  = new SavitzkyGolaySmoother(pointsToSmooth, 2);

            double chromPeakDetectorPeakBR   = 1;
            double chromPeakDetectorSigNoise = 1;
            var    chromPeakDetector         = new ChromPeakDetector(chromPeakDetectorPeakBR,
                                                                     chromPeakDetectorSigNoise);

            ChromPeakSelectorParameters chromPeakSelectorParameters = new ChromPeakSelectorParameters();
            var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters);

            //this generates an extracted ion chromatogram
            // Since we are not using the built in generator,
            chromGen.Execute(m_run.ResultCollection);

            //this smooths the data - very important step!
            if (shouldSmooth)
            {
                chromSmoother.Execute(m_run.ResultCollection);
            }

            //this detects peaks within an extracted ion chromatogram
            chromPeakDetector.Execute(m_run.ResultCollection);

            //this selects the peak
            chromPeakSelector.Parameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget;
            chromPeakSelector.Execute(m_run.ResultCollection);

            //Here's the chromatogram data...
            List <XYData> data = new List <XYData>();

            for (int i = 0; i < m_run.XYData.Xvalues.Length; i++)
            {
                XYData datum = new XYData(m_run.XYData.Xvalues[i], m_run.XYData.Yvalues[i]);
                data.Add(datum);
            }

            return(data);
        }
Esempio n. 10
0
        public void test3()
        {
            MassTag massTag = new MassTag();

            massTag.ID = 56488;
            massTag.MonoIsotopicMass = 2275.1694779;
            massTag.ChargeState      = 3;
            massTag.MZ     = massTag.MonoIsotopicMass / massTag.ChargeState + 1.00727649;
            massTag.NETVal = 0.3520239f;


            Run run = new XCaliburRun(xcaliburTestfile);
            ChromAlignerUsingVIPERInfo chromAligner = new ChromAlignerUsingVIPERInfo();

            chromAligner.Execute(run);


            PeakImporterFromText peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(xcaliburPeakDataFile);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);


            run.CurrentMassTag = massTag;

            Task peakChromGen = new PeakChromatogramGenerator(20);

            Task smoother     = new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(2, 2, 2);
            Task peakDet      = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector();
            Task chromPeakSel = new DeconTools.Backend.ProcessingTasks.ChromPeakSelector(1, 0.1);

            MSGeneratorFactory msgenFactory = new MSGeneratorFactory();
            Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType);



            peakChromGen.Execute(run.ResultCollection);
            smoother.Execute(run.ResultCollection);
            peakDet.Execute(run.ResultCollection);
            chromPeakSel.Execute(run.ResultCollection);


            Console.WriteLine("Now generating MS....");
            msgen.Execute(run.ResultCollection);
            Console.WriteLine("----------- RESULTS ----------------------\n");
            TestUtilities.DisplayPeaks(run.PeakList);


            MassTagResultBase massTagResult = run.ResultCollection.MassTagResultList[massTag];

            massTagResult.DisplayToConsole();
            Assert.AreEqual(5512, massTagResult.ScanSet.PrimaryScanNumber);
        }
        protected ChromatogramCorrelatorBase(int numPointsInSmoother, double minRelativeIntensityForChromCorr,
                                             double chromTolerance, Globals.ToleranceUnit toleranceUnit = Globals.ToleranceUnit.PPM)
        {
            SavitzkyGolaySmoothingOrder = 2;
            NumPointsInSmoother         = numPointsInSmoother;

            ChromTolerance = chromTolerance;
            MinimumRelativeIntensityForChromCorr = minRelativeIntensityForChromCorr;

            ChromToleranceUnit = toleranceUnit;

            PeakChromGen = new PeakChromatogramGenerator(ChromTolerance, Globals.ChromatogramGeneratorMode.MOST_ABUNDANT_PEAK,
                                                         Globals.IsotopicProfileType.UNLABELLED, toleranceUnit);


            Smoother = new SavitzkyGolaySmoother(NumPointsInSmoother, SavitzkyGolaySmoothingOrder, false);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
            }
        }
        public SimpleMsViewerViewModel(Run run)
        {
            this.Run = run;

            PeakDetector = new DeconToolsPeakDetectorV2();
            _peakChromatogramGenerator = new PeakChromatogramGenerator();
            Peaks = new List<Peak>();

            //the order matters here. See the properties.
            MSGraphMaxX = 1500;
            MSGraphMinX = 400;
            ChromToleranceInPpm = 20;

            ChromSourcePeakDetectorSigNoise = 2;
            ChromSourcePeakDetectorPeakBr = 3;

            NumMSScansToSum = 1;
            ShowMsMsSpectra = false;

            NavigateToNextMS1MassSpectrum();
        }
Esempio n. 15
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);
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        protected virtual void DoMainInitialization()
        {
            ValidateParameters();

            _theorFeatureGen = new JoshTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005);
            _chromGen        = new PeakChromatogramGenerator(_workflowParameters.ChromGenTolerance, _workflowParameters.ChromGeneratorMode,
                                                             DeconTools.Backend.Globals.IsotopicProfileType.UNLABELLED,
                                                             _workflowParameters.ChromGenToleranceUnit)
            {
                TopNPeaksLowerCutOff              = 0.333,
                ChromWindowWidthForAlignedData    = (float)_workflowParameters.ChromNETTolerance * 2,
                ChromWindowWidthForNonAlignedData = (float)_workflowParameters.ChromNETTolerance * 2
            };

            //only

            var allowNegativeValues = false;

            _chromSmoother     = new SavitzkyGolaySmoother(_workflowParameters.ChromSmootherNumPointsInSmooth, 2, allowNegativeValues);
            _chromPeakDetector = new ChromPeakDetectorMedianBased(_workflowParameters.ChromPeakDetectorPeakBR, _workflowParameters.ChromPeakDetectorSigNoise);



            _chromPeakSelector = CreateChromPeakSelector(_workflowParameters);

            _iterativeTFFParameters = new IterativeTFFParameters();
            _iterativeTFFParameters.ToleranceInPPM = _workflowParameters.MSToleranceInPPM;

            _msfeatureFinder        = new IterativeTFF(_iterativeTFFParameters);
            _fitScoreCalc           = new IsotopicProfileFitScoreCalculator();
            _resultValidator        = new ResultValidatorTask();
            _chromatogramCorrelator = new ChromatogramCorrelator(_workflowParameters.ChromSmootherNumPointsInSmooth, 0.01, _workflowParameters.ChromGenTolerance);

            ChromatogramXYData = new XYData();
            MassSpectrumXYData = new XYData();
            ChromPeaksDetected = new List <ChromPeak>();
        }
Esempio n. 18
0
        public void find_targetMassTag_131959Test1()
        {
            var run = new RunFactory().CreateRun(xcaliburTestfile);

            var masstagImporter = new MassTagFromTextFileImporter(massTagTestList1);
            var massTagColl     = masstagImporter.Import();

            Assert.AreEqual(2719, massTagColl.TargetList.Count);

            var chromAligner = new ChromAlignerUsingVIPERInfo();

            chromAligner.Execute(run);

            var peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(xcaliburAllPeaksFile);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);


            //int mtID = 635428;
            var mtID = 131959;

            Task peakChromGen = new PeakChromatogramGenerator(20);
            Task smoother     = new DeconTools.Backend.ProcessingTasks.Smoothers.SavitzkyGolaySmoother(23, 2);
            Task zeroFill     = new DeconTools.Backend.ProcessingTasks.ZeroFillers.DeconToolsZeroFiller(3);
            Task peakDet      = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector(0.5, 1);
            Task msPeakDet    = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true);

            var basicChromPeakSelParam = new ChromPeakSelectorParameters();

            basicChromPeakSelParam.NETTolerance     = 0.1f;
            basicChromPeakSelParam.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget;
            Task chromPeakSel = new BasicChromPeakSelector(basicChromPeakSelParam);


            Task msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType);


            run.CurrentMassTag = massTagColl.TargetList.Find(p => p.ID == mtID);
            var mt = run.CurrentMassTag;

            mt.MZ = mt.MonoIsotopicMass / mt.ChargeState + Globals.PROTON_MASS;

            Task theorFeatureGen       = new TomTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005);
            Task targetedFeatureFinder = new BasicTFF();
            Task fitScoreCalc          = new IsotopicProfileFitScoreCalculator();


            theorFeatureGen.Execute(run.ResultCollection);


            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("------------------- MassTag = " + mt.ID + "---------------------------");
            Console.WriteLine("monoMass = " + mt.MonoIsotopicMass.ToString("0.0000") + "; monoMZ = " + mt.MZ.ToString("0.0000") + "; ChargeState = " + mt.ChargeState + "; NET = " + mt.NormalizedElutionTime.ToString("0.000") + "; Sequence = " + mt.Code + "; EmpiricalFormula= " + mt.EmpiricalFormula + "\n");

            peakChromGen.Execute(run.ResultCollection);
            smoother.Execute(run.ResultCollection);
            //TestUtilities.DisplayXYValues(run.ResultCollection);

            peakDet.Execute(run.ResultCollection);
            TestUtilities.DisplayPeaks(run.PeakList);

            chromPeakSel.Execute(run.ResultCollection);
            msgen.Execute(run.ResultCollection);
            //TestUtilities.DisplayXYValues(run.ResultCollection);
            msPeakDet.Execute(run.ResultCollection);
            targetedFeatureFinder.Execute(run.ResultCollection);
            fitScoreCalc.Execute(run.ResultCollection);

            var massTagResult = run.ResultCollection.MassTagResultList[mt];

            massTagResult.DisplayToConsole();



            //Console.WriteLine("------------------------------ end --------------------------");
        }
Esempio n. 19
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;
            //}
        }
        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());
        }
Esempio n. 21
0
        public void run_fullAnalysisTest1()
        {
            Run run = new BrukerRun(rsph_AOnly_28_run1File);
            MassTagCollection massTagColl = new MassTagCollection();

            run.ResultCollection.MassTagResultType = DeconTools.Backend.Globals.MassTagResultType.N14N15_MASSTAG_RESULT;


            massTagColl.MassTagIDList = fourTestMTs;

            MassTagFromSqlDBImporter importer = new MassTagFromSqlDBImporter("MT_R_sphaeroides241_P513", "Albert");

            importer.chargeStateFilterThreshold = 0.05;
            importer.Import(massTagColl);

            Assert.AreEqual(7, massTagColl.MassTagList.Count);

            ChromAlignerUsingVIPERInfo chromAligner = new ChromAlignerUsingVIPERInfo();

            chromAligner.Execute(run);

            PeakImporterFromText peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(rsph_Aonly_28_run1_scans500_1000_peaks);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);

            Task peakChromGen = new PeakChromatogramGenerator(20);

            Task smoother     = new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(11, 11, 2);
            Task peakDet      = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector(0.5, 0.5);
            Task chromPeakSel = new DeconTools.Backend.ProcessingTasks.ChromPeakSelector(1, 0.01, Globals.PeakSelectorMode.CLOSEST_TO_TARGET);

            MSGeneratorFactory msgenFactory = new MSGeneratorFactory();
            Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType);


            DeconToolsV2.Peaks.clsPeakProcessorParameters peakParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(2, 3, false, DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC);
            Task mspeakDet       = new DeconToolsPeakDetector(peakParams);
            Task theorFeatureGen = new TomTheorFeatureGenerator();


            N14N15TFFTask finder = new N14N15TFFTask(0.01);



            N14N15QuantifierTask quant = new N14N15QuantifierTask(1);


            IsotopicProfileFitScoreCalculator fitScoreCalc = new IsotopicProfileFitScoreCalculator();

            List <long> timingResults = new List <long>();


            foreach (MassTag mt in massTagColl.MassTagList)
            {
                run.CurrentMassTag = mt;
                mt.MZ = mt.MonoIsotopicMass / mt.ChargeState + Globals.PROTON_MASS;

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("------------------- MassTag = " + mt.ID + "---------------------------");
                Console.WriteLine("monoMass = " + mt.MonoIsotopicMass.ToString("0.0000") + "; monoMZ = " + mt.MZ.ToString("0.0000") + "; ChargeState = " + mt.ChargeState + "; NET = " + mt.NETVal.ToString("0.000") + "; Sequence = " + mt.PeptideSequence + "\n");


                Stopwatch sw = new Stopwatch();
                sw.Start();
                try
                {
                    peakChromGen.Execute(run.ResultCollection);
                    smoother.Execute(run.ResultCollection);
                    peakDet.Execute(run.ResultCollection);
                    chromPeakSel.Execute(run.ResultCollection);
                    msgen.Execute(run.ResultCollection);
                    mspeakDet.Execute(run.ResultCollection);
                    theorFeatureGen.Execute(run.ResultCollection);
                    finder.Execute(run.ResultCollection);
                    quant.Execute(run.ResultCollection);
                    fitScoreCalc.Execute(run.ResultCollection);
                    MassTagResultBase massTagResult = run.ResultCollection.MassTagResultList[mt];
                    massTagResult.DisplayToConsole();


                    Console.WriteLine("------------------------------ end --------------------------");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Task failed. Message: " + ex.Message + ex.StackTrace);
                }
                sw.Stop();
                timingResults.Add(sw.ElapsedMilliseconds);
            }

            foreach (long tr in timingResults)
            {
                Console.WriteLine(tr);
            }
            Console.WriteLine("-------- Analysis time for all MTs = " + timingResults.Sum());
            Console.WriteLine("-------- Average time for each MT = " + timingResults.Average());

            Console.WriteLine();
        }
Esempio n. 22
0
        protected override void DoPostInitialization()
        {
            base.DoPostInitialization();
            ValidateParameters();

            theorFeatureGen    = new JoshTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005);
            theorN15FeatureGen = new JoshTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.N15, 0.005);

            chromGenN14 = new PeakChromatogramGenerator(_workflowParameters.ChromGenTolerance, _workflowParameters.ChromGeneratorMode);
            chromGenN14.TopNPeaksLowerCutOff = 0.333;

            chromGenN15 = new PeakChromatogramGenerator(_workflowParameters.ChromGenTolerance, DeconTools.Backend.Globals.ChromatogramGeneratorMode.MOST_ABUNDANT_PEAK, DeconTools.Backend.Globals.IsotopicProfileType.LABELLED);
            chromGenN15.TopNPeaksLowerCutOff = 0.333;

            var pointsToSmooth = (_workflowParameters.ChromSmootherNumPointsInSmooth + 1) / 2;

            chromSmoother     = new SavitzkyGolaySmoother(_workflowParameters.ChromSmootherNumPointsInSmooth, 2);
            chromPeakDetector = new ChromPeakDetector(_workflowParameters.ChromPeakDetectorPeakBR, _workflowParameters.ChromPeakDetectorSigNoise);

            var smartchrompeakSelectorParams = new SmartChromPeakSelectorParameters();

            smartchrompeakSelectorParams.MSFeatureFinderType          = DeconTools.Backend.Globals.TargetedFeatureFinderType.ITERATIVE;
            smartchrompeakSelectorParams.MSPeakDetectorPeakBR         = _workflowParameters.MSPeakDetectorPeakBR;
            smartchrompeakSelectorParams.MSPeakDetectorSigNoiseThresh = _workflowParameters.MSPeakDetectorSigNoise;
            smartchrompeakSelectorParams.MSToleranceInPPM             = _workflowParameters.MSToleranceInPPM;
            smartchrompeakSelectorParams.NETTolerance         = (float)_workflowParameters.ChromNETTolerance;
            smartchrompeakSelectorParams.NumScansToSum        = _workflowParameters.NumMSScansToSum;
            smartchrompeakSelectorParams.NumChromPeaksAllowed = 10;
            smartchrompeakSelectorParams.IterativeTffMinRelIntensityForPeakInclusion = 0.5;


            chromPeakSelectorN14 = new SmartChromPeakSelector(smartchrompeakSelectorParams);


            var chromPeakSelectorParameters = new ChromPeakSelectorParameters();

            chromPeakSelectorParameters.NumScansToSum    = _workflowParameters.NumMSScansToSum;
            chromPeakSelectorParameters.NETTolerance     = (float)_workflowParameters.ChromNETTolerance;
            chromPeakSelectorParameters.PeakSelectorMode = DeconTools.Backend.Globals.PeakSelectorMode.N15IntelligentMode;


            chromPeakSelectorN15 = new BasicChromPeakSelector(chromPeakSelectorParameters);
            chromPeakSelectorN15.IsotopicProfileType = DeconTools.Backend.Globals.IsotopicProfileType.LABELLED;

            msPeakDetector = new DeconToolsPeakDetectorV2(_workflowParameters.MSPeakDetectorPeakBR,
                                                          _workflowParameters.MSPeakDetectorSigNoise, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, false);


            var iterativeTFFParameters = new IterativeTFFParameters();

            iterativeTFFParameters.ToleranceInPPM = _n14N15Workflow2Parameters.TargetedFeatureFinderToleranceInPPM;
            iterativeTFFParameters.MinimumRelIntensityForForPeakInclusion = 0.33;
            iterativeTFFParameters.IsotopicProfileType = DeconTools.Backend.Globals.IsotopicProfileType.UNLABELLED;
            unlabelledProfilefinder = new IterativeTFF(iterativeTFFParameters);

            iterativeTFFParameters = new IterativeTFFParameters();
            iterativeTFFParameters.ToleranceInPPM = _n14N15Workflow2Parameters.TargetedFeatureFinderToleranceInPPM;
            iterativeTFFParameters.MinimumRelIntensityForForPeakInclusion = 0.33;
            iterativeTFFParameters.IsotopicProfileType = DeconTools.Backend.Globals.IsotopicProfileType.LABELLED;
            labelledProfileFinder = new IterativeTFF(iterativeTFFParameters);

            quantifier = new N14N15QuantifierTask(_n14N15Workflow2Parameters.NumPeaksUsedInQuant, _workflowParameters.MSToleranceInPPM);

            fitScoreCalc = new IsotopicProfileFitScoreCalculator();

            var minRelativeIntensityForScore = 0.2;

            resultValidatorN14 = new ResultValidatorTask(minRelativeIntensityForScore, true);

            resultValidatorN15 = new LabelledIsotopicProfileScorer(minRelativeIntensityForScore);

            ChromatogramXYData = new XYData();
            MassSpectrumXYData = new XYData();
            ChromPeaksDetected = new List <ChromPeak>();
        }
Esempio n. 23
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]);
            }
        }
Esempio n. 24
0
        public void test1()
        {
            Run run = new XCaliburRun(xcaliburTestfile);
            MassTagCollection        massTagColl  = new MassTagCollection();
            MassTagIDGenericImporter mtidImporter = new MassTagIDGenericImporter(cysteineMassTagSourceFile1, '\t');

            mtidImporter.Import(massTagColl);

            MassTagFromSqlDBImporter importer = new MassTagFromSqlDBImporter("MT_Shewanella_ProdTest_P352", "porky");

            importer.Import(massTagColl);

            Assert.AreEqual(737, massTagColl.MassTagIDList.Count);

            Assert.AreEqual(826, massTagColl.MassTagList.Count);

            ChromAlignerUsingVIPERInfo chromAligner = new ChromAlignerUsingVIPERInfo();

            chromAligner.Execute(run);

            PeakImporterFromText peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(xcaliburAllPeaksFile);

            peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList);

            Task peakChromGen = new PeakChromatogramGenerator(20);

            Task smoother     = new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(11, 11, 2);
            Task peakDet      = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector(0.5, 0.5);
            Task chromPeakSel = new DeconTools.Backend.ProcessingTasks.ChromPeakSelector(1, 0.01, Globals.PeakSelectorMode.CLOSEST_TO_TARGET);

            MSGeneratorFactory msgenFactory = new MSGeneratorFactory();
            Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType);


            DeconToolsV2.Peaks.clsPeakProcessorParameters peakParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(2, 0.75, true, DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC);
            Task mspeakDet             = new DeconToolsPeakDetector(peakParams);
            Task theorFeatureGen       = new TomTheorFeatureGenerator();
            Task targetedFeatureFinder = new BasicTFF(6);
            Task exporter = new BasicMTResultSQLiteExporter(cysteineAnalysisOutput1);


            IsotopicProfileFitScoreCalculator fitScoreCalc = new IsotopicProfileFitScoreCalculator();

            int         successCounter = 0;
            List <long> timingResults  = new List <long>();

            foreach (MassTag mt in massTagColl.MassTagList)
            {
                run.CurrentMassTag = mt;
                mt.MZ = mt.MonoIsotopicMass / mt.ChargeState + Globals.PROTON_MASS;

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("------------------- MassTag = " + mt.ID + "---------------------------");
                Console.WriteLine("monoMass = " + mt.MonoIsotopicMass.ToString("0.0000") + "; monoMZ = " + mt.MZ.ToString("0.0000") + "; ChargeState = " + mt.ChargeState + "; NET = " + mt.NETVal.ToString("0.000") + "; Sequence = " + mt.PeptideSequence + "\n");


                Stopwatch sw = new Stopwatch();
                sw.Start();
                try
                {
                    peakChromGen.Execute(run.ResultCollection);
                    smoother.Execute(run.ResultCollection);
                    peakDet.Execute(run.ResultCollection);
                    chromPeakSel.Execute(run.ResultCollection);
                    msgen.Execute(run.ResultCollection);
                    mspeakDet.Execute(run.ResultCollection);
                    theorFeatureGen.Execute(run.ResultCollection);
                    targetedFeatureFinder.Execute(run.ResultCollection);
                    fitScoreCalc.Execute(run.ResultCollection);
                    MassTagResultBase massTagResult = run.ResultCollection.MassTagResultList[mt];
                    massTagResult.DisplayToConsole();


                    Console.WriteLine("------------------------------ end --------------------------");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Task failed. Message: " + ex.Message + ex.StackTrace);
                }
                sw.Stop();
                timingResults.Add(sw.ElapsedMilliseconds);

                if (mt == massTagColl.MassTagList.Last())
                {
                    exporter.Execute(run.ResultCollection);
                }
            }

            exporter.Cleanup();

            //List<IMassTagResult> successfulResults = run.ResultCollection.GetSuccessfulMassTagResults();

            foreach (long tr in timingResults)
            {
                Console.WriteLine(tr);
            }
            Console.WriteLine("-------- Analysis time for all MTs = " + timingResults.Sum());
            Console.WriteLine("-------- Average time for each MT = " + timingResults.Average());

            Console.WriteLine();
        }
Esempio n. 25
0
        public void Test1()
        {
            var testFile =
                @"D:\Data\Orbitrap\BrianIQTesting\QC_Shew_11_02_pt5-b_6Jun11_Sphinx_11-03-27.RAW";
            var peaksTestFile =
                @"D:\Data\Orbitrap\BrianIQTesting\QC_Shew_11_02_pt5-b_6Jun11_Sphinx_11-03-27_peaks.txt";


            var run = RunUtilities.CreateAndLoadPeaks(testFile, peaksTestFile);

            var target = new LcmsFeatureTarget();

            target.ID = 0;


            target.MZ              = 715.39214;
            target.ScanLCTarget    = 7343;
            target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum;
            run.CurrentMassTag     = target;

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

            double chromPeakGeneratorTolInPPM = 20;
            var    chromGeneratorMode         = Globals.ChromatogramGeneratorMode.MZ_BASED;

            var chromGen = new PeakChromatogramGenerator(chromPeakGeneratorTolInPPM, chromGeneratorMode);

            // If we want to use the Execute Command
            //BLL .1 and .5 NET windows work.   .02 NET window does not BR and SN was set to 1 however)
            chromGen.ChromWindowWidthForNonAlignedData = .02F;


            var pointsToSmooth = 5;
            var chromSmoother  = new SavitzkyGolaySmoother(pointsToSmooth, 2);

            //BLL We also tried to set the BR and SIG NOISE to 0.  This did not work
            var chromPeakDetectorPeakBR   = 0.5;
            var chromPeakDetectorSigNoise = 0.5;
            var chromPeakDetector         = new ChromPeakDetector(chromPeakDetectorPeakBR, chromPeakDetectorSigNoise);


            var chromPeakSelectorParameters = new ChromPeakSelectorParameters();

            chromPeakSelectorParameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget;
            var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters);

            var smartChromPeakParameters = new SmartChromPeakSelectorParameters();


            var smartChromPeakSelector = new SmartChromPeakSelector(smartChromPeakParameters);


            //this generates an extracted ion chromatogram
            // Since we are not using the built in generator,
            chromGen.Execute(run.ResultCollection);

            //this smooths the data - very important step!

            //BLL. This didnt work for me when we first started, instead of using the NET window above.
            //chromGen.GenerateChromatogram(run,
            //                                target.ScanLCTarget - 300,
            //                                target.ScanLCTarget + 300,
            //                                target.MZ,
            //                                chromPeakGeneratorTolInPPM);
            chromSmoother.Execute(run.ResultCollection);

            //this detects peaks within an extracted ion chromatogram
            chromPeakDetector.Execute(run.ResultCollection);

            //this selects the peak
            chromPeakSelector.Execute(run.ResultCollection);
            //smartChromPeakSelector.Execute(run.ResultCollection);


            //TestUtilities.DisplayXYValues(run.XYData);
            TestUtilities.DisplayPeaks(run.PeakList);



            Console.WriteLine("Number of peaks detected = " + run.PeakList.Count);
            Console.WriteLine("Selected peak= " + result.ChromPeakSelected);
        }
Esempio n. 26
0
 public IqChargeCorrelator(int numPointsInSmoother, double minRelativeIntensityForChromCorr = 0.01, double chromToleranceInPPM = 20, DeconTools.Backend.Globals.ToleranceUnit toleranceUnit = DeconTools.Backend.Globals.ToleranceUnit.PPM)
     : base(numPointsInSmoother, minRelativeIntensityForChromCorr, chromToleranceInPPM, toleranceUnit)
 {
     _chromGen = new PeakChromatogramGenerator();
 }
Esempio n. 27
0
        /// <summary>
        /// Finds the XIC based on the m/z and scan parameters.
        /// </summary>
        /// <param name="mz"></param>
        /// <param name="scan"></param>
        /// <returns></returns>
        public List<PNNLOmics.Data.XYData> FindXic(double mz, int scan, bool shouldSmooth)
        {
            LcmsFeatureTarget target    = new LcmsFeatureTarget();
            target.ID                   = 0;
            target.MZ                   = mz;
            target.ScanLCTarget         = scan;
            target.ElutionTimeUnit      = Globals.ElutionTimeUnit.ScanNum;
            m_run.CurrentMassTag        = target;
            var result                  = m_run.ResultCollection.GetTargetedResult(m_run.CurrentMassTag);

            double chromPeakGeneratorTolInPPM = MzPpmWindow;
            Globals.ChromatogramGeneratorMode chromGeneratorMode = Globals.ChromatogramGeneratorMode.MZ_BASED;

            var chromGen = new PeakChromatogramGenerator(   chromPeakGeneratorTolInPPM,
                                                            chromGeneratorMode);
            chromGen.NETWindowWidthForNonAlignedData = Convert.ToSingle(NetWindow);

            int pointsToSmooth  = 5;
            var chromSmoother   = new SavitzkyGolaySmoother(pointsToSmooth, 2);

            double chromPeakDetectorPeakBR   = 1;
            double chromPeakDetectorSigNoise = 1;
            var chromPeakDetector            = new ChromPeakDetector(   chromPeakDetectorPeakBR,
                                                                        chromPeakDetectorSigNoise);

            ChromPeakSelectorParameters chromPeakSelectorParameters = new ChromPeakSelectorParameters();
            var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters);

            //this generates an extracted ion chromatogram
            // Since we are not using the built in generator,
            chromGen.Execute(m_run.ResultCollection);

            //this smooths the data - very important step!
            if (shouldSmooth)
            {
                chromSmoother.Execute(m_run.ResultCollection);
            }

            //this detects peaks within an extracted ion chromatogram
            chromPeakDetector.Execute(m_run.ResultCollection);

            //this selects the peak
            chromPeakSelector.Parameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget;
            chromPeakSelector.Execute(m_run.ResultCollection);

            //Here's the chromatogram data...
            List<PNNLOmics.Data.XYData> data = new List<PNNLOmics.Data.XYData>();

            for (int i = 0; i < m_run.XYData.Xvalues.Length; i++)
            {
                PNNLOmics.Data.XYData datum = new PNNLOmics.Data.XYData(m_run.XYData.Xvalues[i], m_run.XYData.Yvalues[i]);
                data.Add(datum);
            }

            return data;
        }