-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
125 lines (103 loc) · 4.69 KB
/
Program.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
using System.IO;
using PRISM;
namespace ThermoFAIMStoMzML
{
internal static class Program
{
// Ignore Spelling: conf, Sto
private const string PROGRAM_DATE = "2024-01-18";
private static int Main(string[] args)
{
var exeName = System.Reflection.Assembly.GetEntryAssembly()?.GetName().Name;
var exePath = AppUtils.GetAppPath();
var parser = new CommandLineParser<ThermoFAIMStoMzMLOptions>(exeName, GetAppVersion())
{
ProgramInfo = "This program converts a Thermo .raw file with FAIMS scans into a series of .mzML files, " +
"creating one .mzML file for each FAIMS compensation voltage (CV) value in the .raw file",
ContactInfo = "Program written by Matthew Monroe for PNNL (Richland, WA)" + Environment.NewLine +
"E-mail: [email protected] or [email protected]" + Environment.NewLine +
"Website: https://github.com/PNNL-Comp-Mass-Spec/ or https://www.pnnl.gov/integrative-omics"
};
// Allow /Conf in addition to /ParamFile for specifying a text file with Key=Value options
parser.AddParamFileKey("Conf");
parser.UsageExamples.Add("Program syntax:" + Environment.NewLine + Path.GetFileName(exePath) + " " +
"/I:InputFileNameOrDirectoryPath [/O:OutputDirectoryName] " + Environment.NewLine +
"[/Renumber] " + Environment.NewLine +
"[/S] [/R:LevelsToRecurse] [/Preview] " + Environment.NewLine +
"[/IE] [/L] [/LogFile:LogFileName]");
var result = parser.ParseArgs(args);
var options = result.ParsedResults;
if (!result.Success || !options.Validate())
{
if (parser.CreateParamFileProvided)
{
return 0;
}
// Delay for 750 msec in case the user double-clicked this file from within Windows Explorer (or started the program via a shortcut)
System.Threading.Thread.Sleep(750);
return -1;
}
try
{
var processor = new ThermoFAIMStoMzMLProcessor(options);
processor.DebugEvent += Processor_DebugEvent;
processor.ErrorEvent += Processor_ErrorEvent;
processor.WarningEvent += Processor_WarningEvent;
processor.StatusEvent += Processor_MessageEvent;
processor.ProgressUpdate += Processor_ProgressUpdate;
bool success;
if (options.RecurseDirectories)
{
success = processor.ProcessFilesAndRecurseDirectories(
options.InputDataFilePath,
options.OutputDirectoryPath,
options.MaxLevelsToRecurse);
}
else
{
success = processor.ProcessFilesWildcard(
options.InputDataFilePath,
options.OutputDirectoryPath);
}
if (success)
return 0;
return -1;
}
catch (Exception ex)
{
ShowErrorMessage("Error occurred in modMain->Main", ex);
return -1;
}
}
private static string GetAppVersion()
{
return AppUtils.GetAppVersion(PROGRAM_DATE);
}
private static void ShowErrorMessage(string message, Exception ex = null)
{
ConsoleMsgUtils.ShowError(message, ex);
}
private static void Processor_DebugEvent(string message)
{
ConsoleMsgUtils.ShowDebug(message);
}
private static void Processor_ErrorEvent(string message, Exception ex)
{
ConsoleMsgUtils.ShowErrorCustom(message, ex, false);
}
private static void Processor_MessageEvent(string message)
{
Console.WriteLine(message);
}
private static void Processor_ProgressUpdate(string progressMessage, float percentComplete)
{
// Console.WriteLine();
// Processor_DebugEvent(percentComplete.ToString("0.0") + "%, " + progressMessage);
}
private static void Processor_WarningEvent(string message)
{
ConsoleMsgUtils.ShowWarning(message);
}
}
}