Skip to content

Commit

Permalink
Fix wrong mzML with -p flag
Browse files Browse the repository at this point in the history
and added some tests
  • Loading branch information
caetera committed Sep 11, 2020
1 parent 9bd769c commit 3a8507e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
52 changes: 52 additions & 0 deletions ThermoRawFileParserTest/WriterTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.PeerToPeer.Collaboration;
Expand Down Expand Up @@ -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<int> { 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()
{
Expand Down
6 changes: 3 additions & 3 deletions Writer/MzMlSpectrumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 3a8507e

Please sign in to comment.