Ejemplo n.º 1
0
        /// <summary>
        /// Gets the appropriate IMassSpecDataReader for the supplied path.
        /// It is recommended that "NormalizeDatasetPath" be called prior to calling this function, and that the returned string be used instead of the original path
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        /// <remarks>It is recommended that "NormalizeDatasetPath" be called prior to calling this function, and that the returned string be used instead of the original path</remarks>
        public static IMassSpecDataReader GetMassSpecDataReader(string filePath)
        {
            filePath = NormalizeDatasetPath(filePath);
            var type = GetMassSpecDataType(filePath);
            IMassSpecDataReader reader = null;
            switch (type)
            {
                case MassSpecDataType.XCaliburRun:
                    reader = new XCaliburReader(filePath);
                    break;
                case MassSpecDataType.MzMLFile:
                    reader = new MzMLReader(filePath);
                    break;
                case MassSpecDataType.PbfFile:
                    reader = new PbfLcMsRun(filePath);
                    break;
                case MassSpecDataType.Unknown:
                    if (_pwizAvailable)
                    {
                        reader = new ProteoWizardReader(filePath);
                    }
                    break;
            }

            return reader;
        }
Ejemplo n.º 2
0
        [TestCase(@"\\proto-2\UnitTest_Files\InformedProteomics_TestFiles\MZML\VA139IMSMS_compressed.mzML", 3145)] // Centroid, Agilent QTOF, compressed binary data
		public void TestReadMzML(string filePath, int expectedSpectra)
		{
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName, filePath);

			Stopwatch timer = new Stopwatch();
			timer.Start();
			var reader = new MzMLReader(filePath);
            var constTime = timer.Elapsed;
            Console.WriteLine(@"Constructor time: " + constTime);
		    var numSpectra = reader.NumSpectra;
            var metaTime = timer.Elapsed - constTime;
            Console.WriteLine(@"Metadata read time: " + metaTime);
            var spectra = reader.ReadAllSpectra();
            var spectraCount = spectra.Count();
			timer.Stop();
            Console.WriteLine(@"Spectra Read time: " + (timer.Elapsed - metaTime));
            Console.WriteLine(@"Time: " + timer.Elapsed);
            Assert.AreEqual(expectedSpectra, numSpectra, "NumSpectra");
            Assert.AreEqual(expectedSpectra, spectraCount, "SpectraCount");
            Assert.AreEqual(numSpectra, spectraCount, "NumSpectra vs. SpectraCount");
            reader.Close();
		}