diff --git a/ThermoRawFileParserTest/WriterTests.cs b/ThermoRawFileParserTest/WriterTests.cs index 1e63789..de48bd9 100644 --- a/ThermoRawFileParserTest/WriterTests.cs +++ b/ThermoRawFileParserTest/WriterTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.PeerToPeer.Collaboration; @@ -73,6 +74,57 @@ public void TestMzml() Assert.AreEqual(48, testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength); } + [Test] + public void TestProfileMzml() + { + // Get temp path for writing the test mzML + var tempFilePath = Path.GetTempPath(); + + var testRawFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data/small.RAW"); + var parseInput = new ParseInput(testRawFile, null, tempFilePath, OutputFormat.MzML); + + parseInput.NoPeakPicking = true; + + RawFileParser.Parse(parseInput); + + // Deserialize the mzML file + var xmlSerializer = new XmlSerializer(typeof(mzMLType)); + var testMzMl = (mzMLType)xmlSerializer.Deserialize(new FileStream( + Path.Combine(tempFilePath, "small.mzML"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); + + Assert.AreEqual("48", testMzMl.run.spectrumList.count); + Assert.AreEqual(48, testMzMl.run.spectrumList.spectrum.Length); + + Assert.AreEqual("1", testMzMl.run.chromatogramList.count); + Assert.AreEqual(1, testMzMl.run.chromatogramList.chromatogram.Length); + + Assert.AreEqual(48, testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength); + } + + [Test] + public void TestMSLevels() + { + // Get temp path for writing the test mzML + var tempFilePath = Path.GetTempPath(); + + var testRawFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data/small.RAW"); + var parseInput = new ParseInput(testRawFile, null, tempFilePath, OutputFormat.MzML); + + parseInput.MsLevel = new HashSet { 1 }; + + RawFileParser.Parse(parseInput); + + // Deserialize the mzML file + var xmlSerializer = new XmlSerializer(typeof(mzMLType)); + var testMzMl = (mzMLType)xmlSerializer.Deserialize(new FileStream( + Path.Combine(tempFilePath, "small.mzML"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); + + Assert.AreEqual("14", testMzMl.run.spectrumList.count); + Assert.AreEqual(14, testMzMl.run.spectrumList.spectrum.Length); + + Assert.AreEqual(48, testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength); + } + [Test] public void TestIndexedMzML() { diff --git a/Writer/MzMlSpectrumWriter.cs b/Writer/MzMlSpectrumWriter.cs index c0f4883..3360a60 100644 --- a/Writer/MzMlSpectrumWriter.cs +++ b/Writer/MzMlSpectrumWriter.cs @@ -293,10 +293,10 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc name = "peak picking", value = "" }); + _writer.WriteEndElement(); // processingMethod } - _writer.WriteEndElement(); // processingMethod - _writer.WriteEndElement(); // dataProcessing - _writer.WriteEndElement(); // dataProcessingList + _writer.WriteEndElement(); // dataProcessing + _writer.WriteEndElement(); // dataProcessingList // run _writer.WriteStartElement("run");