Skip to content

Commit 273ff2c

Browse files
committed
PeakPicking with levels
1 parent 1d3e79a commit 273ff2c

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

MainClass.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static class MainClass
1919
private static readonly ILog Log =
2020
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
2121

22-
public const string Version = "1.3.3";
22+
public const string Version = "1.4.0";
2323

2424
public static void Main(string[] args)
2525
{
@@ -407,9 +407,9 @@ private static void RegularParametersParsing(string[] args)
407407
v => parseInput.Gzip = v != null
408408
},
409409
{
410-
"p|noPeakPicking",
411-
"Don't use the peak picking provided by the native Thermo library. By default peak picking is enabled.",
412-
v => parseInput.NoPeakPicking = v != null
410+
"p:|noPeakPicking:",
411+
"Don't use the peak picking provided by the native Thermo library. By default peak picking is enabled. Optional argument allows disabling peak peaking only for selected MS levels and should be a comma-separated list of integers (1,2,3) and/or intervals (1-3), open-end intervals (1-) are allowed",
412+
v => parseInput.NoPeakPicking = v is null? ParseInput.AllLevels: ParseMsLevel(v)
413413
},
414414
{
415415
"z|noZlibCompression",

ParseInput.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.IO;
43
using ThermoRawFileParser.Writer;
54

@@ -8,7 +7,7 @@ namespace ThermoRawFileParser
87
public class ParseInput
98
{
109
// All MS levels
11-
private readonly HashSet<int> _allLevels = new HashSet<int>(new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
10+
public static HashSet<int> AllLevels { get => new HashSet<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; }
1211

1312
/// <summary>
1413
/// The RAW file path.
@@ -63,7 +62,7 @@ public string RawFilePath
6362
/// </summary>
6463
public bool Gzip { get; set; }
6564

66-
public bool NoPeakPicking { get; set; }
65+
public HashSet<int> NoPeakPicking { get; set; }
6766

6867
public bool NoZlibCompression { get; set; }
6968

@@ -101,12 +100,12 @@ public ParseInput()
101100
MetadataFormat = MetadataFormat.NONE;
102101
OutputFormat = OutputFormat.NONE;
103102
Gzip = false;
104-
NoPeakPicking = false;
103+
NoPeakPicking = new HashSet<int>();
105104
NoZlibCompression = false;
106105
LogFormat = LogFormat.DEFAULT;
107106
IgnoreInstrumentErrors = false;
108107
AllDetectors = false;
109-
MsLevel = _allLevels;
108+
MsLevel = AllLevels;
110109
MgfPrecursor = false;
111110
StdOut = false;
112111
}

ThermoRawFileParserTest/WriterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void TestProfileMzml()
9090
var testRawFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data/small.RAW");
9191
var parseInput = new ParseInput(testRawFile, null, tempFilePath, OutputFormat.MzML);
9292

93-
parseInput.NoPeakPicking = true;
93+
parseInput.NoPeakPicking = new HashSet<int> { 1, 2 };
9494

9595
RawFileParser.Parse(parseInput);
9696

Writer/MgfSpectrumWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
139139
// Write the filter string
140140
//Writer.WriteLine($"SCANEVENT={scanEvent.ToString()}");
141141

142-
if (!ParseInput.NoPeakPicking)
142+
if (!ParseInput.NoPeakPicking.Contains((int)scanFilter.MSOrder))
143143
{
144144
// Check if the scan has a centroid stream
145145
if (scan.HasCentroidStream)

Writer/MzMlSpectrumWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
285285
value = ""
286286
});
287287
_writer.WriteEndElement(); // processingMethod
288-
if (!ParseInput.NoPeakPicking)
288+
if (ParseInput.NoPeakPicking.Count < ParseInput.AllLevels.Count)
289289
{
290290
_writer.WriteStartElement("processingMethod");
291291
_writer.WriteAttributeString("order", "1");
@@ -1386,7 +1386,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
13861386
double[] masses;
13871387
double[] intensities;
13881388

1389-
if (!ParseInput.NoPeakPicking)
1389+
if (!ParseInput.NoPeakPicking.Contains((int)scanFilter.MSOrder))
13901390
{
13911391
//Spectrum will be centroided
13921392
spectrumCvParams.Add(new CVParamType

0 commit comments

Comments
 (0)