Esempio n. 1
0
        public static void DifferentAnalyzersTest()
        {
            IMzmlScan[] scans = new IMzmlScan[2];

            double[]       intensities1 = new double[] { 1 };
            double[]       mz1          = new double[] { 50 };
            MzmlMzSpectrum massSpec1    = new MzmlMzSpectrum(mz1, intensities1, false);

            scans[0] = new MzmlScan(1, massSpec1, 1, true, Polarity.Positive, 1, new MzRange(1, 100), "f", MZAnalyzerType.Orbitrap, massSpec1.SumOfAllY, null, "1");

            double[]       intensities2 = new double[] { 1 };
            double[]       mz2          = new double[] { 30 };
            MzmlMzSpectrum massSpec2    = new MzmlMzSpectrum(mz2, intensities2, false);

            scans[1] = new MzmlScanWithPrecursor(2, massSpec2, 2, true, Polarity.Positive, 2, new MzRange(1, 100), "f", MZAnalyzerType.IonTrap3D, massSpec2.SumOfAllY,
                                                 50, null, null, 50, 1, DissociationType.CID, 1, null, null, "2");

            FakeMsDataFile f = new FakeMsDataFile(scans);

            MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(f, Path.Combine(TestContext.CurrentContext.TestDirectory, "asdfefsf.mzML"), false);

            Mzml ok = Mzml.LoadAllStaticData(Path.Combine(TestContext.CurrentContext.TestDirectory, "asdfefsf.mzML"));

            Assert.AreEqual(MZAnalyzerType.Orbitrap, ok.First().MzAnalyzer);
            Assert.AreEqual(MZAnalyzerType.IonTrap3D, ok.Last().MzAnalyzer);
        }
Esempio n. 2
0
        public void LoadMzmlAnotherTest()
        {
            Mzml a = Mzml.LoadAllStaticData(@"small.pwiz.1.1.mzML");

            Assert.AreEqual(19914, a.First().MassSpectrum.Size);

            //a = new Mzml(@"small.pwiz.1.1.mzML", 400);
            //a.Open();

            //Assert.AreEqual(400, a.First().MassSpectrum.Size);

            //var cool = a.GetOneBasedScan(6) as MzmlScanWithPrecursor;

            //Assert.AreEqual(1, cool.IsolationWidth);

            //a.Close();
        }
Esempio n. 3
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().X);
            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));

            var newSpectrum = new ThermoSpectrum(a.GetOneBasedScan(51).MassSpectrum);

            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.First().Polarity, readCovertedMzmlFile.First().Polarity);
        }