Пример #1
0
        public void TestFitScoreCalculationEtd()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            if (!File.Exists(FilePaths.TestTopDownRawFilePathEtd))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + FilePaths.TestTopDownRawFilePathCid);
            }

            var run  = InMemoryLcMsRun.GetLcMsRunScanRange(FilePaths.TestTopDownRawFilePathEtd, 810, 810);
            var spec = run.GetSpectrum(810) as ProductSpectrum;

            Assert.True(spec != null);

            const string suf54     = "ENIKTLPAKRNEQDQKQLIVPLADSLKPGTYTVDWHVVSVDGHKTKGHYTFSVK";
            var          suf54Comp = new AminoAcidSet().GetComposition(suf54);

            Assert.True(suf54Comp != null);

            var ionType = new IonTypeFactory(10).GetIonType("z6");
            var ion     = ionType.GetIon(suf54Comp);

            //ion.Composition.ComputeApproximateIsotopomerEnvelop();
            Console.WriteLine("MonoMz: {0}, MonoMass: {1}", ion.GetMonoIsotopicMz(), ion.Composition.Mass);

            var fitScore = spec.GetFitScore(ion, new Tolerance(15), 0.1);

            Console.WriteLine("FitScore: {0}", fitScore);
            Assert.True(fitScore < 0.15);
        }
Пример #2
0
        public void TestReadingDiaRawFile()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            const string rawFilePath = TestRawFilePath;

            if (!File.Exists(rawFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, rawFilePath);
            }

            const int SCAN       = 100;
            const int MAX_POINTS = 50;

            var run  = InMemoryLcMsRun.GetLcMsRunScanRange(rawFilePath, SCAN);
            var spec = run.GetSpectrum(SCAN);

            spec.Display(MAX_POINTS);

            // Console.WriteLine("{0}, {1}", spec.Peaks[50].Mz, spec.Peaks[50].Intensity);
            // Console.WriteLine("{0}, {1}", spec.Peaks[500].Mz, spec.Peaks[500].Intensity);
            // Console.WriteLine("{0}, {1}", spec.Peaks[1000].Mz, spec.Peaks[1000].Intensity);

            Assert.IsTrue(Math.Abs(spec.Peaks[50].Mz - 414.75503540039062) < 0.0001, "Invalid m/z for peak at index 50");
            Assert.IsTrue(Math.Abs(spec.Peaks[50].Intensity - 1071.5673828125) < 0.01, "Invalid intensity for peak at index 50");

            Assert.IsTrue(Math.Abs(spec.Peaks[500].Mz - 578.1298828125) < 0.0001, "Invalid m/z for peak at index 500");
            Assert.IsTrue(Math.Abs(spec.Peaks[500].Intensity - 573.02374267578125) < 0.01, "Invalid intensity for peak at index 500");

            Assert.IsTrue(Math.Abs(spec.Peaks[1000].Mz - 974.17694091796875) < 0.0001, "Invalid m/z for peak at index 1000");
            Assert.IsTrue(Math.Abs(spec.Peaks[1000].Intensity - 678.13824462890625) < 0.01, "Invalid intensity for peak at index 1000");
        }
Пример #3
0
        public void TestReadingScanNums()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            if (!File.Exists(FilePaths.TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + FilePaths.TestRawFilePath);
            }

            var run = InMemoryLcMsRun.GetLcMsRunScanRange(FilePaths.TestRawFilePath, 20000, 20100);

            var msLevel = new Dictionary <int, int>();

            //for (var scanNum = run.MinLcScan; scanNum <= run.MaxLcScan; scanNum++)
            foreach (var scanNum in run.AllScanNumbers)
            {
                msLevel[scanNum] = run.GetMsLevel(scanNum);
            }

            //for (var scanNum = run.MinLcScan; scanNum <= run.MaxLcScan; scanNum++)
            foreach (var scanNum in run.AllScanNumbers)
            {
                var spec = run.GetSpectrum(scanNum);
                Assert.True(spec.MsLevel == msLevel[scanNum]);

                if (spec.MsLevel == 2)
                {
                    var precursorScanNum = 0;
                    for (var prevScan = scanNum - 1; prevScan >= run.MinLcScan; prevScan--)
                    {
                        if (run.GetMsLevel(prevScan) == 1)
                        {
                            precursorScanNum = prevScan;
                            break;
                        }
                    }
                    Assert.True(run.GetPrecursorScanNum(scanNum) == precursorScanNum);

                    var nextScanNum = run.MaxLcScan + 1;
                    //for (var nextScan = scanNum + 1; nextScan <= run.MaxLcScan; nextScan++)
                    foreach (var nextScan in run.AllScanNumbers.Where(x => x > scanNum))
                    {
                        if (run.GetMsLevel(nextScan) == 1)
                        {
                            nextScanNum = nextScan;
                            break;
                        }
                    }
                    if (run.GetNextScanNum(scanNum) != nextScanNum)
                    {
                        Console.WriteLine("{0}\t{1}\t{2}", scanNum, run.GetNextScanNum(scanNum), nextScanNum);
                    }
                    Assert.True(run.GetNextScanNum(scanNum) == nextScanNum);
                }
            }
            Assert.True(run.GetNextScanNum(20025) == 20032);
            Console.WriteLine(run.GetNextScanNum(20025));
        }
Пример #4
0
        public void TestFitScoreCalculationCid()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            if (!File.Exists(FilePaths.TestTopDownRawFilePathCid))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + FilePaths.TestTopDownRawFilePathCid);
            }

            var run  = InMemoryLcMsRun.GetLcMsRunScanRange(FilePaths.TestTopDownRawFilePathCid, 5743, 5743);
            var spec = run.GetSpectrum(5743);

            Assert.True(spec != null);

            const string protein  = "MRIILLGAPGAGKGTQAQFIMEKYGIPQISTGDMLRAAVKSGSELGKQAKDIMDAGKLVTDELVIALVKERIAQEDCRNGFLLDGFPRTIPQADAMKEAGIVVDYVLEFDVPDELIVDRIVGRRVHAASGRVYHVKFNPPKVEGKDDVTGEDLTTRKDDQEETVRKRLVEYHQMTAPLIGYYQKEAEAGNTKYAKVDGTQAVADVRAALEKILG";
            var          protComp = new AminoAcidSet().GetComposition(protein) + Composition.H2O;

            Assert.True(protComp != null);
            Assert.True(protComp.C == 1035);
            Assert.True(protComp.H == 1683);
            Assert.True(protComp.N == 289);
            Assert.True(protComp.O == 318);
            Assert.True(protComp.P == 0);
            Assert.True(protComp.S == 7);
            Assert.True(Math.Abs(protComp.Mass - 23473.245267145) < 0.0000001);
            Assert.True(protComp.NominalMass == 23461);

            var ion = new Ion(protComp, 20);
//            ion.Composition.ComputeApproximateIsotopomerEnvelop();
            var isotopomerEnvelope = ion.Composition.GetIsotopomerEnvelopeRelativeIntensities();

            Console.WriteLine(@"MonoMz: {0}, MonoMass: {1}", ion.GetMonoIsotopicMz(), ion.Composition.Mass);

            var matchedPeaks = spec.GetAllIsotopePeaks(ion, new Tolerance(15), 0.1);

            for (var i = 0; i < matchedPeaks.Length; i++)
            {
                var intensity = matchedPeaks[i] == null ? 0 : matchedPeaks[i].Intensity;
                Console.WriteLine(@"{0,3}  {1,10:F4}  {2,10:F3}  {3,10:F3}", i, ion.GetIsotopeMz(i), isotopomerEnvelope[i], intensity);
            }
            var fitScore = spec.GetFitScore(ion, new Tolerance(15), 0.1);
            var cosine   = spec.GetConsineScore(ion, new Tolerance(15), 0.1);
            var corr     = spec.GetCorrScore(ion, new Tolerance(15), 0.1);

            Console.WriteLine(@"FitScore: {0}", fitScore);
            Console.WriteLine(@"Cosine: {0}", cosine);
            Console.WriteLine(@"Corr: {0}", corr);

            Assert.True(Math.Abs(fitScore - 0.181194589537041) < 0.0001);
            Assert.True(Math.Abs(cosine - 0.917609346566222) < 0.0001);
            Assert.True(Math.Abs(corr - 0.808326778009839) < 0.0001);
        }
Пример #5
0
        public void TestReadingIsolationWindows()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            if (!File.Exists(TestLcMsRun.TestRawFilePath))
            {
                Assert.Ignore(@"Skipping test " + methodName + @" since file not found: " + TestLcMsRun.TestRawFilePath);
            }

            var run = InMemoryLcMsRun.GetLcMsRunScanRange(TestRawFilePath, 10000, 10100);

            for (var scanNum = run.MinLcScan; scanNum <= run.MaxLcScan; scanNum++)
            {
                var isolationWindow = run.GetIsolationWindow(scanNum);
                if (isolationWindow != null)
                {
                    Console.WriteLine("{0}\t{1}\t{2}", scanNum, isolationWindow.MonoisotopicMz ?? 0.0, isolationWindow.Charge ?? 0.0);
                }
            }
        }
Пример #6
0
        public void TestParsingSpectrumFile()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();

            if (!File.Exists(TestTopDownRawFilePathCid))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, TestTopDownRawFilePathCid);
            }

            const int SCAN       = 425;
            const int MAX_POINTS = 50;

            var run = InMemoryLcMsRun.GetLcMsRunScanRange(TestTopDownRawFilePathCid, SCAN, SCAN);

            const int scanNum = SCAN;
            var       spec    = run.GetSpectrum(scanNum) as ProductSpectrum;

            if (spec != null)
            {
                spec.Display(MAX_POINTS);
                var precursorInfo = spec.IsolationWindow;
                Console.WriteLine("ActivationMethod: {0}", spec.ActivationMethod);
                Console.WriteLine("Rt: {0}", spec.ElutionTime);
                Console.WriteLine("PrecursorScan: {0}", run.GetPrecursorScanNum(spec.ScanNum));
                Console.WriteLine("IsolationWindowTargetMz: {0}", precursorInfo.IsolationWindowTargetMz);
                Console.WriteLine("IsolationWindowLowerOffset: {0}", precursorInfo.IsolationWindowLowerOffset);
                Console.WriteLine("IsolationWindowUpperOffset: {0}", precursorInfo.IsolationWindowUpperOffset);
                Console.WriteLine("MsLevel: {0}", run.GetMsLevel(scanNum));
            }

            Console.WriteLine(@"Done. {0:f4} sec", sw.Elapsed.TotalSeconds);
        }