Skip to content

Commit 29d4e59

Browse files
authored
Merge pull request #181 from compomics/1.4.4
Release of 1.4.4
2 parents 42131e5 + fb5d7bb commit 29d4e59

File tree

9 files changed

+207
-179
lines changed

9 files changed

+207
-179
lines changed

MainClass.cs

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

23-
public const string Version = "1.4.3";
23+
public const string Version = "1.4.4";
2424
public static void Main(string[] args)
2525
{
2626
// Set Invariant culture as default for all further processing
@@ -83,15 +83,15 @@ private static void XicParametersParsing(string[] args)
8383
v => parameters.printJsonExample = v != null
8484
},
8585
{
86-
"o=|output=",
87-
"The output directory. Specify this or an output file. Specifying neither writes to the input directory.",
88-
v => outputDirectory = v
89-
},
90-
{
91-
"b=|output_file",
86+
"b=|output=",
9287
"The output file. Specify this or an output directory. Specifying neither writes to the input directory.",
9388
v => outputFile = v
9489
},
90+
{
91+
"o=|output_directory=",
92+
"The output directory. Specify this or an output file. Specifying neither writes to the input directory.",
93+
v => outputDirectory = v
94+
},
9595
{
9696
"6|base64",
9797
"Encodes the content of the xic vectors as base 64 encoded string.",
@@ -103,7 +103,7 @@ private static void XicParametersParsing(string[] args)
103103
v => parameters.stdout = v != null
104104
},
105105
{
106-
"w|warningsAreErrors", "Return non-zero exit code for warnings; default only for errors",
106+
"w|warningsAreErrors", "Return non-zero exit code for warnings; default only for errors",
107107
v => parameters.Vigilant = v != null
108108
},
109109
{
@@ -338,7 +338,7 @@ private static void SpectrumQueryParametersParsing(string[] args)
338338
v => parameters.scans = v
339339
},
340340
{
341-
"b=|output_file",
341+
"b=|output=",
342342
"The output file. Specifying none writes the output file to the input file parent directory.",
343343
v => parameters.outputFile = v
344344
},
@@ -510,15 +510,15 @@ private static void RegularParametersParsing(string[] args)
510510
v => parseInput.RawDirectoryPath = v
511511
},
512512
{
513-
"o=|output=",
514-
"The output directory. Specify this or an output file -b. Specifying neither writes to the input directory.",
515-
v => parseInput.OutputDirectory = v
516-
},
517-
{
518-
"b=|output_file",
513+
"b=|output=",
519514
"The output file. Specify this or an output directory -o. Specifying neither writes to the input directory.",
520515
v => parseInput.OutputFile = v
521516
},
517+
{
518+
"o=|output_directory=",
519+
"The output directory. Specify this or an output file -b. Specifying neither writes to the input directory.",
520+
v => parseInput.OutputDirectory = v
521+
},
522522
{
523523
"s|stdout",
524524
"Write to standard output. Cannot be combined with file or directory output. Implies silent logging, i.e. logging level 0",
@@ -766,6 +766,8 @@ private static void RegularParametersParsing(string[] args)
766766
if (parseInput.OutputFormat == OutputFormat.IndexMzML) parseInput.OutputFormat = OutputFormat.MzML;
767767
}
768768

769+
parseInput.MaxLevel = parseInput.MsLevel.Max();
770+
769771
if (parseInput.S3Url != null && parseInput.S3AccessKeyId != null &&
770772
parseInput.S3SecretAccessKey != null && parseInput.BucketName != null)
771773
if (Uri.IsWellFormedUriString(parseInput.S3Url, UriKind.Absolute))

ParseInput.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public int Warnings
9696

9797
public HashSet<int> MsLevel { get; set; }
9898

99+
public int MaxLevel { get; set; }
100+
99101
public bool MgfPrecursor { get; set; }
100102

101103
public bool NoiseData { get; set; }
@@ -136,6 +138,7 @@ public ParseInput()
136138
Vigilant = false;
137139
_errors = 0;
138140
_warnings = 0;
141+
MaxLevel = 10;
139142
}
140143

141144
public ParseInput(string rawFilePath, string rawDirectoryPath, string outputDirectory, OutputFormat outputFormat

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ optional subcommands are xic|query (use [subcommand] -h for more info]):
5959
-d, --input_directory=VALUE
6060
The directory containing the raw files (Required).
6161
Specify this or an input raw file -i.
62-
-o, --output=VALUE The output directory. Specify this or an output
63-
file -b. Specifying neither writes to the input
64-
directory.
65-
-b, --output_file=VALUE The output file. Specify this or an output
62+
-b, --output=VALUE The output file. Specify this or an output
6663
directory -o. Specifying neither writes to the
6764
input directory.
65+
-o, --output_directory=VALUE
66+
The output directory. Specify this or an output
67+
file -b. Specifying neither writes to the input
68+
directory.
6869
-s, --stdout Write to standard output. Cannot be combined with
6970
file or directory output. Implies silent logging,
7071
i.e. logging level 0
@@ -137,7 +138,7 @@ usage is:
137138
-h, --help Prints out the options.
138139
-i, --input=VALUE The raw file input (Required).
139140
-n, --scans=VALUE The scan numbers. e.g. "1-5, 20, 25-30"
140-
-b, --output_file=VALUE The output file. Specifying none writes the output
141+
-b, --output=VALUE The output file. Specifying none writes the output
141142
file to the input file parent directory.
142143
-p, --noPeakPicking Don't use the peak picking provided by the native
143144
Thermo library. By default peak picking is
@@ -169,12 +170,13 @@ ThermoRawFileParser.exe xic --help
169170
Specify this or an input file -i.
170171
-j, --json=VALUE The json input file (Required).
171172
-p, --print_example Show a json input file example.
172-
-o, --output=VALUE The output directory. Specify this or an output
173-
file. Specifying neither writes to the input
174-
directory.
175-
-b, --output_file=VALUE The output file. Specify this or an output
173+
-b, --output=VALUE The output file. Specify this or an output
176174
directory. Specifying neither writes to the
177175
input directory.
176+
-o, --output_directory=VALUE
177+
The output directory. Specify this or an output
178+
file. Specifying neither writes to the input
179+
directory.
178180
-6, --base64 Encodes the content of the xic vectors as base 64
179181
encoded string.
180182
-s, --stdout Pipes the output into standard output. Logging is

Util/CVHelpers.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using ThermoRawFileParser.Writer.MzML;
1+
using System.Collections.Generic;
2+
using ThermoRawFileParser.Writer.MzML;
23

34
namespace ThermoRawFileParser.Util
45
{
@@ -18,4 +19,17 @@ public static CVParamType Copy (this CVParamType old)
1819
};
1920
}
2021
}
22+
23+
public class CVComparer : IEqualityComparer<CVParamType>
24+
{
25+
public bool Equals(CVParamType cv1, CVParamType cv2)
26+
{
27+
return cv1.accession == cv2.accession;
28+
}
29+
30+
public int GetHashCode(CVParamType cv)
31+
{
32+
return cv.accession.GetHashCode();
33+
}
34+
}
2135
}

Writer/MetadataWriter.cs

Lines changed: 54 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.IO;
55
using System.Linq;
66
using System.Reflection;
7-
using System.Web.WebSockets;
87
using log4net;
98
using Newtonsoft.Json;
109
using ThermoFisher.CommonCore.Data;
@@ -122,16 +121,14 @@ public void WriteMetadata(IRawDataPlus rawFile, int firstScanNumber, int lastSca
122121
switch (_parseInput.MetadataFormat)
123122
{
124123
case MetadataFormat.JSON:
125-
_metadataFileName = _parseInput.MetadataOutputFile != null
126-
? _parseInput.MetadataOutputFile
127-
: Path.Combine(_parseInput.OutputDirectory, _parseInput.RawFileNameWithoutExtension) +
124+
_metadataFileName = _parseInput.MetadataOutputFile ??
125+
Path.Combine(_parseInput.OutputDirectory, _parseInput.RawFileNameWithoutExtension) +
128126
"-metadata.json";
129127
WriteJsonMetada(rawFile, firstScanNumber, lastScanNumber);
130128
break;
131129
case MetadataFormat.TXT:
132-
_metadataFileName = _parseInput.MetadataOutputFile != null
133-
? _parseInput.MetadataOutputFile
134-
: Path.Combine(_parseInput.OutputDirectory, _parseInput.RawFileNameWithoutExtension) +
130+
_metadataFileName = _parseInput.MetadataOutputFile ??
131+
Path.Combine(_parseInput.OutputDirectory, _parseInput.RawFileNameWithoutExtension) +
135132
"-metadata.txt";
136133
WriteTextMetadata(rawFile, firstScanNumber, lastScanNumber);
137134
break;
@@ -176,43 +173,40 @@ private void WriteJsonMetada(IRawDataPlus rawFile, int firstScanNumber, int last
176173
metadata.addInstrumentProperty(new CVTerm("AFR:0001259", "AFO", "firmware version",
177174
rawFile.GetInstrumentData().HardwareVersion));
178175
}
179-
}
180-
181176

182-
// MS Data
183-
foreach (KeyValuePair<string, int> entry in msTypes)
184-
{
185-
if (entry.Key.Equals(MSOrderType.Ms.ToString()))
186-
metadata.addMSData(new CVTerm("PRIDE:0000481", "PRIDE", "Number of MS1 spectra",
187-
entry.Value.ToString()));
188-
if (entry.Key.Equals(MSOrderType.Ms2.ToString()))
189-
metadata.addMSData(new CVTerm("PRIDE:0000482", "PRIDE", "Number of MS2 spectra",
190-
entry.Value.ToString()));
191-
if (entry.Key.Equals(MSOrderType.Ms3.ToString()))
192-
metadata.addMSData(new CVTerm("PRIDE:0000483", "PRIDE", "Number of MS3 spectra",
193-
entry.Value.ToString()));
194-
}
195-
196-
metadata.addMSData(new CVTerm("PRIDE:0000472", "PRIDE", "MS min charge",
197-
minCharge.ToString(CultureInfo.InvariantCulture)));
198-
metadata.addMSData(new CVTerm("PRIDE:0000473", "PRIDE", "MS max charge",
199-
maxCharge.ToString(CultureInfo.InvariantCulture)));
200-
201-
metadata.addMSData(new CVTerm("PRIDE:0000474", "PRIDE", "MS min RT",
202-
minTime.ToString(CultureInfo.InvariantCulture)));
203-
metadata.addMSData(new CVTerm("PRIDE:0000475", "PRIDE", "MS max RT",
204-
maxTime.ToString(CultureInfo.InvariantCulture)));
205-
206-
metadata.addMSData(new CVTerm("PRIDE:0000476", "PRIDE", "MS min MZ",
207-
minMz.ToString(CultureInfo.InvariantCulture)));
208-
metadata.addMSData(new CVTerm("PRIDE:0000477", "PRIDE", "MS max MZ",
209-
maxMz.ToString(CultureInfo.InvariantCulture)));
210-
211-
// Scan Settings
212-
// Get the start and end time from the RAW file
213-
214-
if (rawFile.SelectMsData())
215-
{
177+
178+
179+
// MS Data
180+
foreach (KeyValuePair<string, int> entry in msTypes)
181+
{
182+
if (entry.Key.Equals(MSOrderType.Ms.ToString()))
183+
metadata.addMSData(new CVTerm("PRIDE:0000481", "PRIDE", "Number of MS1 spectra",
184+
entry.Value.ToString()));
185+
if (entry.Key.Equals(MSOrderType.Ms2.ToString()))
186+
metadata.addMSData(new CVTerm("PRIDE:0000482", "PRIDE", "Number of MS2 spectra",
187+
entry.Value.ToString()));
188+
if (entry.Key.Equals(MSOrderType.Ms3.ToString()))
189+
metadata.addMSData(new CVTerm("PRIDE:0000483", "PRIDE", "Number of MS3 spectra",
190+
entry.Value.ToString()));
191+
}
192+
193+
metadata.addMSData(new CVTerm("PRIDE:0000472", "PRIDE", "MS min charge",
194+
minCharge.ToString(CultureInfo.InvariantCulture)));
195+
metadata.addMSData(new CVTerm("PRIDE:0000473", "PRIDE", "MS max charge",
196+
maxCharge.ToString(CultureInfo.InvariantCulture)));
197+
198+
metadata.addMSData(new CVTerm("PRIDE:0000474", "PRIDE", "MS min RT",
199+
minTime.ToString(CultureInfo.InvariantCulture)));
200+
metadata.addMSData(new CVTerm("PRIDE:0000475", "PRIDE", "MS max RT",
201+
maxTime.ToString(CultureInfo.InvariantCulture)));
202+
203+
metadata.addMSData(new CVTerm("PRIDE:0000476", "PRIDE", "MS min MZ",
204+
minMz.ToString(CultureInfo.InvariantCulture)));
205+
metadata.addMSData(new CVTerm("PRIDE:0000477", "PRIDE", "MS max MZ",
206+
maxMz.ToString(CultureInfo.InvariantCulture)));
207+
208+
// Scan Settings
209+
// Get the start and end time from the RAW file
216210
var runHeaderEx = rawFile.RunHeaderEx;
217211
var startTime = runHeaderEx.StartTime;
218212
var endTime = runHeaderEx.EndTime;
@@ -373,21 +367,20 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
373367
{
374368
output.Add("Firmware version=" + rawFile.GetInstrumentData().HardwareVersion);
375369
}
376-
}
377-
378-
// MS Data
379-
output.Add("#MsData");
380-
foreach (KeyValuePair<string, int> entry in msTypes)
381-
{
382-
if (entry.Key.Equals(MSOrderType.Ms.ToString()))
383-
output.Add("Number of MS1 spectra=" + entry.Value);
384-
if (entry.Key.Equals(MSOrderType.Ms2.ToString()))
385-
output.Add("Number of MS2 spectra=" + entry.Value);
386-
if (entry.Key.Equals(MSOrderType.Ms3.ToString()))
387-
output.Add("Number of MS3 spectra=" + entry.Value);
388-
}
389370

390-
output.AddRange(new List<string>
371+
// MS Data
372+
output.Add("#MsData");
373+
foreach (KeyValuePair<string, int> entry in msTypes)
374+
{
375+
if (entry.Key.Equals(MSOrderType.Ms.ToString()))
376+
output.Add("Number of MS1 spectra=" + entry.Value);
377+
if (entry.Key.Equals(MSOrderType.Ms2.ToString()))
378+
output.Add("Number of MS2 spectra=" + entry.Value);
379+
if (entry.Key.Equals(MSOrderType.Ms3.ToString()))
380+
output.Add("Number of MS3 spectra=" + entry.Value);
381+
}
382+
383+
output.AddRange(new List<string>
391384
{
392385
$"MS min charge={minCharge.ToString(CultureInfo.InvariantCulture)}",
393386
$"MS max charge={maxCharge.ToString(CultureInfo.InvariantCulture)}",
@@ -396,11 +389,9 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
396389
$"MS min MZ={minMz.ToString(CultureInfo.InvariantCulture)}",
397390
$"MS max MZ={maxMz.ToString(CultureInfo.InvariantCulture)}"
398391
}
399-
);
392+
);
400393

401-
// Scan Settings
402-
if (rawFile.SelectMsData())
403-
{
394+
// Scan Settings
404395
// Get the start and end time from the RAW file
405396
var startTime = rawFile.RunHeaderEx.StartTime;
406397
var endTime = rawFile.RunHeaderEx.EndTime;
@@ -410,7 +401,7 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
410401
$"Scan start time={startTime.ToString(CultureInfo.InvariantCulture)}",
411402
$"Expected runtime={rawFile.RunHeaderEx.ExpectedRunTime.ToString(CultureInfo.InvariantCulture)}",
412403
$"Mass resolution=[MS, MS:1000011, mass resolution, {rawFile.RunHeaderEx.MassResolution.ToString(CultureInfo.InvariantCulture)}]",
413-
"Units=" + rawFile.GetInstrumentData().Units,
404+
$"Units={rawFile.GetInstrumentData().Units}",
414405
$"Number of scans={rawFile.RunHeaderEx.SpectraCount}",
415406
$"Scan range={firstScanNumber};{lastScanNumber}",
416407
$"Time range={startTime.ToString(CultureInfo.InvariantCulture)};{endTime.ToString(CultureInfo.InvariantCulture)}",
@@ -419,6 +410,7 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
419410
}
420411
);
421412
}
413+
422414
// Sample Data
423415
output.Add("#SampleData");
424416

Writer/MgfSpectrumWriter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
using System.Reflection;
66
using System.Text.RegularExpressions;
77
using log4net;
8-
using ThermoFisher.CommonCore.Data;
98
using ThermoFisher.CommonCore.Data.Business;
109
using ThermoFisher.CommonCore.Data.FilterEnums;
1110
using ThermoFisher.CommonCore.Data.Interfaces;
12-
using ThermoRawFileParser.Util;
1311

1412
namespace ThermoRawFileParser.Writer
1513
{

0 commit comments

Comments
 (0)