Skip to content

Commit

Permalink
Merge pull request #87 from compomics/uvdata
Browse files Browse the repository at this point in the history
Version 1.3.0
  • Loading branch information
caetera committed Aug 26, 2020
2 parents 1755627 + a156701 commit c6dcfc3
Show file tree
Hide file tree
Showing 10 changed files with 944 additions and 166 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
bin/
obj/
*.log
ThermoRawFileParser.sln.DotSettings.user
*.sln.DotSettings.user
.vs/

*.csproj.user
9 changes: 7 additions & 2 deletions MainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class MainClass
private static readonly ILog Log =
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

public const string Version = "1.2.3";
public const string Version = "1.3.0";

public static void Main(string[] args)
{
Expand Down Expand Up @@ -409,6 +409,11 @@ private static void RegularParametersParsing(string[] args)
"Don't use zlib compression for the m/z ratios and intensities. By default zlib compression is enabled.",
v => parseInput.NoZlibCompression = v != null
},
{
"a|allDetectors",
"Extract additonal detector data: UV/PDA etc",
v => parseInput.AllDetectors = v != null
},
{
"l=|logging=", "Optional logging level: 0 for silent, 1 for verbose.",
v => logFormatString = v
Expand Down Expand Up @@ -499,7 +504,7 @@ private static void RegularParametersParsing(string[] args)
{
if (parseInput.RawFilePath != null)
{
parseInput.OutputDirectory = Path.GetDirectoryName(parseInput.RawFilePath);
parseInput.OutputDirectory = Path.GetDirectoryName(Path.GetFullPath(parseInput.RawFilePath));
}
else if (parseInput.RawDirectoryPath != null)
{
Expand Down
3 changes: 3 additions & 0 deletions ParseInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public string RawFilePath

public bool NoZlibCompression { get; set; }

public bool AllDetectors { get; set; }

public LogFormat LogFormat { get; set; }

public bool IgnoreInstrumentErrors { get; set; }
Expand Down Expand Up @@ -98,6 +100,7 @@ public ParseInput()
NoZlibCompression = false;
LogFormat = LogFormat.DEFAULT;
IgnoreInstrumentErrors = false;
AllDetectors = false;
}

public ParseInput(string rawFilePath, string rawDirectoryPath, string outputDirectory, OutputFormat outputFormat
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ optional subcommands are xic|query (use [subcommand] -h for more info]):
-z, --noZlibCompression Don't use zlib compression for the m/z ratios and
intensities. By default zlib compression is
enabled.
-a, --allDetectors Extract additonal detector data: UV/PDA etc
-l, --logging=VALUE Optional logging level: 0 for silent, 1 for
verbose.
-e, --ignoreInstrumentErrors
Expand Down
6 changes: 0 additions & 6 deletions ThermoRawFileParser.csproj.user

This file was deleted.

36 changes: 36 additions & 0 deletions ThermoRawFileParserTest/WriterTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.IO;
using System.Linq;
using System.Net.PeerToPeer.Collaboration;
using System.Xml.Serialization;
using IO.Mgf;
using MzLibUtil;
using NUnit.Framework;
using ThermoRawFileParser;
using ThermoRawFileParser.Writer.MzML;
Expand Down Expand Up @@ -66,6 +69,8 @@ public void TestMzml()

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]
Expand Down Expand Up @@ -98,5 +103,36 @@ public void TestIndexedMzML()
Assert.AreEqual("chromatogram", testMzMl.indexList.index[1].name.ToString());
Assert.AreEqual(1, testMzMl.indexList.index[1].offset.Length);
}

[Test]
public void TestMzML_MS2()
{
// Get temp path for writing the test mzML
var tempFilePath = Path.GetTempPath();

var testRawFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data/small2.RAW");
var parseInput = new ParseInput(testRawFile, null, tempFilePath, OutputFormat.MzML);

RawFileParser.Parse(parseInput);

// Deserialize the mzML file
var xmlSerializer = new XmlSerializer(typeof(mzMLType));
var testMzMl = (mzMLType)xmlSerializer.Deserialize(new FileStream(
Path.Combine(tempFilePath, "small2.mzML"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite));

Assert.AreEqual(95, testMzMl.run.spectrumList.spectrum.Length);

var precursor = testMzMl.run.spectrumList.spectrum[16].precursorList.precursor[0].selectedIonList.selectedIon[0];
var selectedMz = Double.Parse(precursor.cvParam.Where(cv => cv.accession == "MS:1000744").First().value);
Assert.IsTrue(selectedMz - 604.7592 < 0.001);

var selectedZ = int.Parse(precursor.cvParam.Where(cv => cv.accession == "MS:1000041").First().value);
Assert.AreEqual(selectedZ , 2);

//var selectedI = Double.Parse(precursor.cvParam.Where(cv => cv.accession == "MS:1000042").First().value);
//Assert.IsTrue(selectedI - 10073 < 1);

Assert.AreEqual(95, testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength);
}
}
}
2 changes: 1 addition & 1 deletion Writer/MgfSpectrumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
IReaction reaction = GetReaction(scanEvent, scanNumber);

Writer.WriteLine("BEGIN IONS");
Writer.WriteLine($"TITLE={ConstructSpectrumTitle(scanNumber)}");
Writer.WriteLine($"TITLE={ConstructSpectrumTitle((int)Device.MS, 1, scanNumber)}");
Writer.WriteLine($"SCANS={scanNumber}");
Writer.WriteLine(
$"RTINSECONDS={(time * 60).ToString(CultureInfo.InvariantCulture)}");
Expand Down
Loading

0 comments on commit c6dcfc3

Please sign in to comment.