private static void Main(string[] args) { var osVersionInfo = new clsOSVersionInfo(); if (osVersionInfo.GetOSVersion().ToLower().Contains("windows")) { var handle = Process.GetCurrentProcess().MainWindowHandle; SetConsoleMode(handle, EnableExtendedFlags); } if (args.Length % 2 != 0) { PrintUsageInfo("The number of arguments must be even."); return; } // initialize parameters var paramDic = new Dictionary <string, string> { { "-s", null }, { "-d", null }, { "-o", null }, { "-e", "1" }, { "-ntt", "2" }, { "-mod", null }, { "-t", "10" }, { "-f", "10" }, { "-tda", "0" }, { "-minLength", "6" }, { "-maxLength", "40" }, { "-minCharge", "1" }, { "-maxCharge", "4" }, { "-minFragCharge", "1" }, { "-maxFragCharge", "3" } }; for (var i = 0; i < args.Length / 2; i++) { var key = args[2 * i]; var value = args[2 * i + 1]; if (!paramDic.ContainsKey(key)) { PrintUsageInfo("Invalid parameter: " + key); return; } paramDic[key] = value; } var parameters = new BottomUpInputParameters(); var message = parameters.Parse(paramDic); if (message != null) { PrintUsageInfo(message); return; } Console.WriteLine(Name + " " + Version); parameters.Display(); parameters.Write(); foreach (var specFilePath in parameters.SpecFilePaths) { var bottomUpLauncher = new IcBottomUpLauncher( specFilePath, parameters.DatabaseFilePath, parameters.OutputDir, parameters.AminoAcidSet, parameters.Enzyme) { MinSequenceLength = parameters.MinSequenceLength, MaxSequenceLength = parameters.MaxSequenceLength, MinPrecursorIonCharge = parameters.MinPrecursorIonCharge, MaxPrecursorIonCharge = parameters.MaxPrecursorIonCharge, MinProductIonCharge = parameters.MinProductIonCharge, MaxProductIonCharge = parameters.MaxProductIonCharge, PrecursorIonTolerancePpm = parameters.PrecursorIonTolerancePpm, ProductIonTolerancePpm = parameters.ProductIonTolerancePpm, //RunTargetDecoyAnalysisBool = parameters.TdaBool, RunTargetDecoyAnalysis = parameters.Tda, NumTolerableTermini = parameters.NumTolerableTermini, }; bottomUpLauncher.RunSearch(CorrThreshold); } }
public static int Main(string[] args) { PbfGenInputParameters options; try { var osVersionInfo = new clsOSVersionInfo(); if (osVersionInfo.GetOSVersion().ToLower().Contains("windows")) { var handle = Process.GetCurrentProcess().MainWindowHandle; SetConsoleMode(handle, EnableExtendedFlags); } var exeName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name; var parser = new CommandLineParser <PbfGenInputParameters>(exeName, Version); parser.UsageExamples.Add($"Using -start and -end to limit the scan range to include in the .pbf file\n\t{exeName}.exe -s Dataset.raw -start 2000 -end 3000"); var results = parser.ParseArgs(args); if (!results.Success) { // Wait for 1.5 seconds System.Threading.Thread.Sleep(1500); return(-1); } if (!results.ParsedResults.Validate()) { parser.PrintHelp(); // Wait for 1.5 seconds System.Threading.Thread.Sleep(1500); return(-1); } options = results.ParsedResults; } catch (Exception ex) { Console.WriteLine("Exception while parsing the command line parameters: " + ex.Message); return(-5); } #if (!DEBUG) try #endif { var specFilePaths = new[] { options.SourcePath }; if (Directory.Exists(options.SourcePath) && !MassSpecDataReaderFactory.IsADirectoryDataset(options.SourcePath)) { specFilePaths = Directory.GetFiles(options.SourcePath, "*.raw"); // TODO: Support folders with other formats in them too... } foreach (var rawFilePath in specFilePaths) { var pbfFileName = MassSpecDataReaderFactory.ChangeExtension(rawFilePath, PbfLcMsRun.FileExtensionConst); var pbfFilePath = Path.Combine(options.OutputDir, Path.GetFileName(pbfFileName)); if (File.Exists(pbfFilePath) && PbfLcMsRun.CheckFileFormatVersion(pbfFilePath, out var isCurrent) && isCurrent) { Console.WriteLine("{0} already exists.", pbfFilePath); continue; } Console.WriteLine("Creating {0} from {1}", pbfFilePath, rawFilePath); if (options.StartScan > 0 && options.EndScan > 0) { Console.WriteLine("Only including scans {0} to {1}", options.StartScan, options.EndScan); } else if (options.StartScan > 0) { Console.WriteLine("Only including scans {0} to the end", options.StartScan); } else if (options.EndScan > 0) { Console.WriteLine("Only including scans 1 to {0}", options.EndScan); } var reader = MassSpecDataReaderFactory.GetMassSpecDataReader(rawFilePath); var progress = new Progress <ProgressData>(p => { p.UpdateFrequencySeconds = 2; if ((p.Percent % 25).Equals(0) || p.ShouldUpdate()) { Console.Write("\r{0}, {1:00.0}% complete ", p.Status, p.Percent); } }); var run = new PbfLcMsRun(rawFilePath, reader, pbfFilePath, 0, 0, progress, false, options.StartScan, options.EndScan); Console.WriteLine(); } Console.WriteLine("PbfFormatVersion: {0}", PbfLcMsRun.FileFormatId); return(0); } #if (!DEBUG) catch (Exception ex) { // NOTE: The DMS Analysis Manager looks for this text; do not change it Console.WriteLine("Exception while processing: " + ex.Message); Console.WriteLine(ex.StackTrace); var errorCode = -Math.Abs(ex.Message.GetHashCode()); if (errorCode == 0) { return(-1); } else { return(errorCode); } } #endif }
static int Main(string[] args) { LcMsFeatureFinderInputParameters parameters; try { var osVersionInfo = new clsOSVersionInfo(); if (osVersionInfo.GetOSVersion().ToLower().Contains("windows")) { var handle = Process.GetCurrentProcess().MainWindowHandle; SetConsoleMode(handle, EnableExtendedFlags); } //args = new string[] {"-i", @"D:\MassSpecFiles\training\raw\QC_Shew_Intact_26Sep14_Bane_C2Column3.pbf", "-minMass", "3000", "-maxMass", "30000"}; var parser = new CommandLineParser <ProMexInputParameters>(Name, Version); parser.UsageExamples.Add("To create a PNG of the features in an existing ms1ft file " + "(requires both a .pbf file and a .ms1ft file):\n\tProMex.exe -i dataset.pbf -ms1ft dataset.ms1ft -featureMap"); var results = parser.ParseArgs(args); if (!results.Success) { // Wait for 1.5 seconds System.Threading.Thread.Sleep(1500); return(-1); } if (!results.ParsedResults.Validate()) { parser.PrintHelp(); // Wait for 1.5 seconds System.Threading.Thread.Sleep(1500); return(-1); } parameters = results.ParsedResults; } catch (Exception ex) { Console.WriteLine("Exception while parsing the command line parameters: " + ex.Message); return(-5); } #if (!DEBUG) try { #endif // Example text: ProMex version 1.0.6527 (November 14, 2017) // (the build date is computed automatically) Console.WriteLine("************ {0} {1} ************", Name, Version); parameters.Display(); var launcher = new LcMsFeatureFinderLauncher(parameters); int errorCode; if (string.IsNullOrWhiteSpace(parameters.ExistingFeaturesFilePath)) { errorCode = launcher.Run(); } else { errorCode = launcher.CreateFeatureMapImage(parameters.InputPath, parameters.ExistingFeaturesFilePath); } return(errorCode); #if (!DEBUG) } catch (Exception ex) { // NOTE: The DMS Analysis Manager looks for this text; do not change it Console.WriteLine("Exception while processing: " + ex.Message); Console.WriteLine(ex.StackTrace); var errorCode = -Math.Abs(ex.Message.GetHashCode()); if (errorCode == 0) { return(-1); } return(errorCode); } #endif }
public static int Main(string[] args) { var errorCode = 0; #if (!DEBUG) try #endif { var osVersionInfo = new clsOSVersionInfo(); if (osVersionInfo.GetOSVersion().ToLower().Contains("windows")) { var handle = Process.GetCurrentProcess().MainWindowHandle; SetConsoleMode(handle, EnableExtendedFlags); } string entryAsmName; try { entryAsmName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name; } catch { // This method was likely invoked by NUnit entryAsmName = "Unknown_Assembly"; } var parser = new CommandLineParser <TopDownInputParameters>(entryAsmName, Version); parser.UsageExamples.Add(string.Format("Perform a target+decoy search with default parameters and a mods file:\n{0}.exe -s testfile.raw -d sampleProteins.fasta -mod mods.txt -tda 1", entryAsmName)); // TODO: add more examples, maybe a link to GitHub? var results = parser.ParseArgs(args); if (!results.Success) { // Wait for 1.5 seconds System.Threading.Thread.Sleep(1500); return(-3); } if (!results.ParsedResults.Validate()) { parser.PrintHelp(); // Wait for 1.5 seconds System.Threading.Thread.Sleep(1500); return(-3); } var parameters = results.ParsedResults; Console.WriteLine(Name + " " + Version); parameters.Display(); parameters.MaxNumNTermCleavages = 1; // max number of N-term cleavages parameters.MaxNumCTermCleavages = 0; // max number of C-term cleavages foreach (var specFilePath in parameters.SpecFilePaths) { // Update the spec file path in the parameters for each search parameters.SpecFilePath = specFilePath; parameters.Write(); var topDownLauncher = new IcTopDownLauncher(parameters); topDownLauncher.ErrorEvent += TopDownLauncher_ErrorEvent; topDownLauncher.WarningEvent += TopDownLauncher_WarningEvent; topDownLauncher.StatusEvent += TopDownLauncher_StatusEvent; topDownLauncher.ProgressUpdate += TopDownLauncher_ProgressUpdate; var success = topDownLauncher.RunSearch(); if (success) { continue; } // topDownLauncher returned false (not successful) // NOTE: The DMS Analysis Manager looks for this text; do not change it var errorMsg = "Error processing " + Path.GetFileName(specFilePath) + ": "; if (string.IsNullOrWhiteSpace(topDownLauncher.ErrorMessage)) { errorMsg += "unknown error"; } else { errorMsg += topDownLauncher.ErrorMessage; } Console.WriteLine(errorMsg); if (errorCode == 0) { // This is the first error encountered; update the error code // (though we will continue processing the next file if there is one) errorCode = -Math.Abs(errorMsg.GetHashCode()); if (errorCode == 0) { return(-1); } else { return(errorCode); } } } } #if (!DEBUG) catch (Exception ex) { // NOTE: The DMS Analysis Manager looks for this text; do not change it Console.WriteLine("Exception while processing: " + ex.Message); Console.WriteLine(ex.StackTrace); errorCode = -Math.Abs(ex.Message.GetHashCode()); System.Threading.Thread.Sleep(1500); if (errorCode == 0) { return(-1); } else { return(errorCode); } } #endif return(errorCode); }