forked from compomics/ThermoRawFileParser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainClass.cs
98 lines (92 loc) · 3.36 KB
/
MainClass.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using Mono.Options;
using ThermoFisher.CommonCore.Data;
namespace ThermoRawFileParser
{
public class MainClass
{
public static void Main(string[] args)
{
string rawFilePath = null;
string outputDirectory = null;
Boolean outputMetadata = false;
string collection = null;
string msRun = null;
string subFolder = null;
Boolean help = false;
var optionSet = new OptionSet()
{
{
"h|help", "Prints out the options.",
h => help = h != null
},
{
"i=|input=", "The raw file input.",
v => rawFilePath = v
},
{
"o=|output=", "The metadata and mgf output directory.",
v => outputDirectory = v
},
{
"m|metadata", "Write the metadata output file if this flag is specified (without value).",
v => outputMetadata = v != null
},
{
"c:|collection", "The optional collection identifier (PXD identifier for example).",
v => collection = v
},
{
"r:|run:",
"The optional mass spectrometry run name used in the spectrum title. The RAW file name will be used if not specified.",
v => msRun = v
},
{
"s:|subfolder:",
"Optional, to disambiguate instances where the same collection has 2 or more MS runs with the same name.",
v => subFolder = v
},
};
try
{
List<string> extra;
//parse the command line
extra = optionSet.Parse(args);
if (!extra.IsNullOrEmpty())
{
throw new OptionException("unexpected extra arguments", "N/A");
}
}
catch (OptionException)
{
ShowHelp("Error - usage is (use -option=value for the optional arguments):", optionSet);
}
if (help)
{
const string usageMessage = "ThermoRawFileParser.exe usage (use -option=value for the optional arguments)";
ShowHelp(usageMessage, optionSet);
}
else
{
try
{
CentroidedMgfExtractor centroidedMgfExtractor =
new CentroidedMgfExtractor(rawFilePath, outputDirectory, outputMetadata, collection, msRun, subFolder);
centroidedMgfExtractor.Extract();
}
catch (Exception ex)
{
Console.Error.WriteLine("An unexpected error occured: " + ex.Message);
Environment.Exit(-1);
}
}
}
private static void ShowHelp(string message, OptionSet optionSet)
{
Console.Error.WriteLine(message);
optionSet.WriteOptionDescriptions(Console.Error);
Environment.Exit(-1);
}
}
}