예제 #1
0
        public static void ThermoDynamicTest()
        {
            ThermoDynamicData dynamicThermo = ThermoDynamicData.InitiateDynamicConnection(@"testFileWMS2.raw");
            var        ms1scan = dynamicThermo.GetOneBasedScan(1);
            MsDataScan ms2scan = dynamicThermo.GetOneBasedScan(651);

            Assert.That(ms1scan.OneBasedScanNumber == 1);
            Assert.That(ms2scan.OneBasedScanNumber == 651);
            Assert.That(Math.Round(ms2scan.RetentionTime, 2) == 12.16);
            Assert.That(ms2scan.OneBasedPrecursorScanNumber == 650);
            Assert.That(ms2scan.SelectedIonMZ == 442.67);
            var t = dynamicThermo.ThermoGlobalParams.MsOrderByScan;

            Assert.That(t[0] == 1);
            Assert.That(t[5] == 1);
            Assert.That(t[649] == 1);
            Assert.That(t[650] == 2);
            Assert.That(!t.Where(v => v == 0).Any());
        }
예제 #2
0
        public static void LoadThermoTest2()
        {
            ThermoStaticData a = ThermoStaticData.LoadAllStaticData(@"05-13-16_cali_MS_60K-res_MS.raw");

            Assert.AreEqual(360, a.NumSpectra);
            Assert.GreaterOrEqual(1000, a.GetOneBasedScan(1).MassSpectrum.Extract(0, 500).Last().Mz);
            Assert.AreEqual(2, a.GetOneBasedScan(1).MassSpectrum.FilterByY(5e6, double.MaxValue).Count());
            var ye = a.GetOneBasedScan(1).MassSpectrum.CopyTo2DArray();

            Assert.AreEqual(77561752, a.GetOneBasedScan(1).TotalIonCurrent);
            Assert.AreEqual(144, a.GetClosestOneBasedSpectrumNumber(2));

            MzSpectrum newSpectrum = new MzSpectrum(a.GetOneBasedScan(51).MassSpectrum.XArray, a.GetOneBasedScan(51).MassSpectrum.YArray, true);

            Assert.AreEqual(1120, a.GetOneBasedScan(1).MassSpectrum.Size);

            var newDeconvolution = a.GetOneBasedScan(1).MassSpectrum.Deconvolute(new MzRange(double.MinValue, double.MaxValue), 1, 10, 1, 4).ToList();

            Assert.IsTrue(newDeconvolution.Any(b => Math.Abs(b.peaks.First().mz.ToMass(b.charge) - 523.257) < 0.001));

            MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(a, Path.Combine(TestContext.CurrentContext.TestDirectory, "convertedThermo.mzML"), false);

            var sdafaf = a.Deconvolute(null, null, 1, 30, 10, 3, 10, b => true).OrderByDescending(b => b.NumPeaks).First();

            Assert.IsTrue(Math.Abs(262.64 - sdafaf.Mass.ToMz(2)) <= 0.01);

            using (ThermoDynamicData dynamicThermo = ThermoDynamicData.InitiateDynamicConnection(@"05-13-16_cali_MS_60K-res_MS.raw"))
            {
                Assert.AreEqual(136, dynamicThermo.GetClosestOneBasedSpectrumNumber(1.89));
                dynamicThermo.ClearCachedScans();
            }

            Mzml readCovertedMzmlFile = Mzml.LoadAllStaticData(Path.Combine(TestContext.CurrentContext.TestDirectory, "convertedThermo.mzML"));

            Assert.AreEqual(a.GetAllScansList().First().Polarity, readCovertedMzmlFile.GetAllScansList().First().Polarity);
        }
예제 #3
0
        public static void TestFlashLFQWithPassedFile()
        {
            // read periodic table - needed to open the raw files
            PeriodicTableLoader.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"elements.dat"));

            // get the raw files
            string rawPath  = Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-raw.raw");
            string mzmlPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"sliced-mzml.mzml");

            var rawFile  = ThermoDynamicData.InitiateDynamicConnection(rawPath);
            var mzmlFile = Mzml.LoadAllStaticData(mzmlPath);

            RawFileInfo raw  = new RawFileInfo(rawPath, rawFile);
            RawFileInfo mzml = new RawFileInfo(mzmlPath, mzmlFile);

            // create some PSMs
            Identification id1 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <string> {
                "MyProtein"
            });
            Identification id2 = new Identification(raw, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <string> {
                "MyProtein"
            });
            Identification id3 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.12193, 2, new List <string> {
                "MyProtein"
            });
            Identification id4 = new Identification(mzml, "EGFQVADGPLYR", "EGFQVADGPLYR", 1350.65681, 94.05811, 2, new List <string> {
                "MyProtein"
            });

            // create the FlashLFQ engine
            FlashLFQEngine engine = new FlashLFQEngine(new List <Identification> {
                id1, id2, id3, id4
            });

            // run the engine
            var results = engine.Run();

            // check raw results
            Assert.That(results.peaks[raw].Count == 1);
            Assert.That(results.peaks[raw].First().intensity > 0);
            Assert.That(!results.peaks[raw].First().isMbrFeature);
            Assert.That(results.peptideBaseSequences["EGFQVADGPLYR"].intensities[raw] > 0);
            Assert.That(results.peptideModifiedSequences["EGFQVADGPLYR"].intensities[raw] > 0);
            Assert.That(results.proteinGroups["MyProtein"].intensities[raw] > 0);

            // check mzml results
            Assert.That(results.peaks[mzml].Count == 1);
            Assert.That(results.peaks[mzml].First().intensity > 0);
            Assert.That(!results.peaks[mzml].First().isMbrFeature);
            Assert.That(results.peptideBaseSequences["EGFQVADGPLYR"].intensities[mzml] > 0);
            Assert.That(results.peptideModifiedSequences["EGFQVADGPLYR"].intensities[mzml] > 0);
            Assert.That(results.proteinGroups["MyProtein"].intensities[mzml] > 0);

            // test peak output
            List <string> output = new List <string>()
            {
                FlashLFQ.ChromatographicPeak.TabSeparatedHeader
            };

            foreach (var peak in results.peaks.SelectMany(p => p.Value))
            {
                output.Add(peak.ToString());
            }
            Assert.That(output.Count == 3);

            // test peptide base sequence output
            output = new List <string>()
            {
                Peptide.TabSeparatedHeader
            };
            foreach (var pep in results.peptideBaseSequences)
            {
                output.Add(pep.Value.ToString());
            }
            Assert.That(output.Count == 2);

            // test peptide mod sequence output
            output = new List <string>()
            {
                Peptide.TabSeparatedHeader
            };
            foreach (var pep in results.peptideModifiedSequences)
            {
                output.Add(pep.Value.ToString());
            }
            Assert.That(output.Count == 2);

            // test protein output
            output = new List <string>()
            {
                ProteinGroup.TabSeparatedHeader
            };
            foreach (var protein in results.proteinGroups)
            {
                output.Add(protein.Value.ToString());
            }
            Assert.That(output.Count == 2);
        }