private static bool ParseParameterInt( clsParseCommandLine objParseCommandLine, string parameterName, string description, ref int targetVariable) { var strValue = string.Empty; if (!ParseParameter(objParseCommandLine, parameterName, description, ref strValue)) { return(false); } if (string.IsNullOrWhiteSpace(strValue)) { return(true); } if (int.TryParse(strValue, out targetVariable)) { return(true); } ShowErrorMessage("Invalid valid for /" + parameterName + "; '" + strValue + "' is not an integer"); return(false); }
private static void ParseCommandLineParameters(clsParseCommandLine commandLineParser) { mExtractScanFilters = commandLineParser.IsParameterPresent("GetFilters"); if (commandLineParser.NonSwitchParameterCount > 0) { mSourceFilePath = commandLineParser.RetrieveNonSwitchParameter(0); } mCentroid = commandLineParser.IsParameterPresent("centroid"); mTestSumming = commandLineParser.IsParameterPresent("sum"); mStartScan = 0; mEndScan = 0; if (commandLineParser.RetrieveValueForParameter("Start", out var startScan)) { if (int.TryParse(startScan, out var value)) { mStartScan = value; } } if (commandLineParser.RetrieveValueForParameter("End", out var endScan)) { if (int.TryParse(endScan, out var value)) { mEndScan = value; } } if (commandLineParser.RetrieveValueForParameter("ScanInfo", out var scanInfoInterval)) { if (int.TryParse(scanInfoInterval, out var value)) { mScanInfoInterval = value; } } if (commandLineParser.IsParameterPresent("NoScanData")) { mLoadScanData = false; } if (commandLineParser.IsParameterPresent("NoScanEvents")) { mGetScanEvents = false; } if (commandLineParser.IsParameterPresent("NoCE")) { mLoadCollisionEnergies = false; } mOnlyLoadMSLevelInfo = commandLineParser.IsParameterPresent("MSLevelOnly"); mTestScanFilters = commandLineParser.IsParameterPresent("TestFilters"); mTraceMode = commandLineParser.IsParameterPresent("Trace"); }
static int Main(string[] args) { var objParseCommandLine = new clsParseCommandLine(); mInputFilePath = string.Empty; mOutputFilePath = string.Empty; mOutputOptions = clsOwlConverter.DefaultOutputOptions(); mPrimaryKeySuffix = clsOwlConverter.DEFAULT_PRIMARY_KEY_SUFFIX; try { var success = false; if (objParseCommandLine.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(objParseCommandLine)) { success = true; } } if (!success || objParseCommandLine.NeedToShowHelp || string.IsNullOrWhiteSpace(mInputFilePath)) { ShowProgramHelp(); return(-1); } var converter = new clsOwlConverter(mPrimaryKeySuffix) { OutputOptions = mOutputOptions }; converter.ErrorEvent += Converter_ErrorEvent; converter.StatusEvent += Converter_StatusEvent; converter.WarningEvent += Converter_WarningEvent; success = converter.ConvertOwlFile(mInputFilePath, mOutputFilePath); if (!success) { ShowErrorMessage("ConvertOwlFile returned false"); } } catch (Exception ex) { Console.WriteLine("Error occurred in Program->Main: " + Environment.NewLine + ex.Message); Console.WriteLine(ex.StackTrace); return(-1); } return(0); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if (AppUpdatesAvailableInternal()) //{ // MessageBox.Show("New version of Inferno available.", // "New version!", MessageBoxButtons.OK, MessageBoxIcon.Information); //} //Splasher.Show(typeof(frmSplash)); mDanteFilePath = string.Empty; mLogFilePath = string.Empty; try { var objParseCommandLine = new clsParseCommandLine(); var success = false; if (objParseCommandLine.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(objParseCommandLine)) { success = true; } } if (!success || objParseCommandLine.NeedToShowHelp || objParseCommandLine.ParameterCount + objParseCommandLine.NonSwitchParameterCount == 0) { var syntaxMessage = "Supported command line switches are /F and /L \n" + "Use '/F FilePath.dnt' to load a data file \n" + "Use '/L LogFilePath' to specify a custom log file path"; MessageBox.Show(syntaxMessage, "InfernoRDN Syntax", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } catch (Exception ex) { MessageBox.Show("Exception parsing the command line arguments: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } var mfrmDAnTEmdi = new frmDAnTEmdi(mDanteFilePath, mLogFilePath); if (!mfrmDAnTEmdi.IsDisposed) { Application.Run(mfrmDAnTEmdi); } }
private static bool ParseParameter(clsParseCommandLine commandLineParser, string parameterName, string description, ref string targetVariable) { if (commandLineParser.RetrieveValueForParameter(parameterName, out var value)) { if (string.IsNullOrWhiteSpace(value)) { ShowErrorMessage("/" + parameterName + " does not have " + description); return(false); } targetVariable = string.Copy(value); } return(true); }
static int Main() { var commandLineParser = new clsParseCommandLine(); try { mProcessingMode = eProcessingMode.TaskParallelLibrary4_5; // Set this to 1 for now // If argument /Threads is present, it will be set to that // Otherwise, it will be set to value returned by GetCoreCount() mThreadCount = 1; mRuntimeSeconds = 15; mUseTieredRuntimes = false; var success = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { success = true; } } else { if (commandLineParser.NonSwitchParameterCount + commandLineParser.ParameterCount == 0 && !commandLineParser.NeedToShowHelp) { // No arguments were provided; that's OK success = true; } } if (!success || commandLineParser.NeedToShowHelp) { ShowProgramHelp(); return(-1); } StartProcessing(); } catch (Exception ex) { ShowErrorMessage("Error occurred in Program->Main", ex); return(-1); } return(0); }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine objParseCommandLine) { // Returns True if no problems; otherwise, returns false var lstValidParameters = new List <string> { "F", "L" }; try { // Make sure no invalid parameters are present if (objParseCommandLine.InvalidParametersPresent(lstValidParameters)) { var badArguments = new List <string>(); foreach (var item in objParseCommandLine.InvalidParameters(lstValidParameters)) { badArguments.Add("/" + item); } ShowErrorMessage("Invalid commmand line parameters", badArguments); return(false); } // Query objParseCommandLine to see if various parameters are present if (objParseCommandLine.NonSwitchParameterCount > 0) { mDanteFilePath = objParseCommandLine.RetrieveNonSwitchParameter(0); } if (!ParseParameter(objParseCommandLine, "F", "a session file path", ref mDanteFilePath)) { return(false); } if (!ParseParameter(objParseCommandLine, "L", "a log file path", ref mLogFilePath)) { return(false); } return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message); } return(false); }
public static int Main() { var commandLineParser = new clsParseCommandLine(); mFileMask = string.Empty; mRecurse = false; mOutputFilePath = string.Empty; mFullPathsInResults = false; mPreviewMode = false; try { var success = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { success = true; } } if (!success || commandLineParser.NeedToShowHelp || commandLineParser.ParameterCount + commandLineParser.NonSwitchParameterCount == 0) { ShowProgramHelp(); return(-1); } success = ComputeChecksums(mFileMask, mRecurse, mOutputFilePath, mFullPathsInResults, mPreviewMode); if (!success) { Thread.Sleep(1000); return(-2); } } catch (Exception ex) { Console.WriteLine("Error occurred in Program->Main: " + Environment.NewLine + ex.Message); Console.WriteLine(ex.StackTrace); return(-1); } return(0); }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParser) { // Returns True if no problems; otherwise, returns false var validParameters = new List <string>() { "I" }; try { // Make sure no invalid parameters are present if (commandLineParser.InvalidParametersPresent(validParameters)) { ShowErrorMessage("Invalid command line parameters", (from item in commandLineParser.InvalidParameters(validParameters) select("/" + item)).ToList()); return(false); } // Query commandLineParser to see if various parameters are present if (commandLineParser.RetrieveValueForParameter("I", out var inputFilePath)) { mInputFilePath = inputFilePath; } else if (commandLineParser.NonSwitchParameterCount > 0) { // Treat the first non-switch parameter as the input file mInputFilePath = commandLineParser.RetrieveNonSwitchParameter(0); } return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message); } return(false); }
public static int Main() { // Returns 0 if no error, error code if an error var commandLineParser = new clsParseCommandLine(); mInputFilePath = string.Empty; try { var proceed = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { proceed = true; } } else if (!commandLineParser.NeedToShowHelp) { proceed = true; } if (commandLineParser.NeedToShowHelp || !proceed) { ShowProgramHelp(); return(-1); } ShowGUI(); return(0); } catch (Exception ex) { ShowErrorMessage("Error occurred in Program->Main: " + Environment.NewLine + ex.Message); return(-1); } }
private static bool GetParamInt(clsParseCommandLine commandLineParser, string paramName, ref int paramValue) { if (!commandLineParser.RetrieveValueForParameter(paramName, out var paramValueText)) { // Leave paramValue unchanged return(true); } if (string.IsNullOrWhiteSpace(paramValueText)) { ShowErrorMessage("/" + paramName + " does not have a value"); return(false); } // Update paramValue if (int.TryParse(paramValueText, out paramValue)) { return(true); } ShowErrorMessage("Error converting " + paramValueText + " to an integer for parameter /" + paramName); return(false); }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParser, SplitterOptions options) { // Returns True if no problems; otherwise, returns false var validParameters = new List <string> { "I", "N", "MB", "O", "P", "S", "A", "R", "L" }; try { // Make sure no invalid parameters are present if (commandLineParser.InvalidParametersPresent(validParameters)) { ConsoleMsgUtils.ShowErrors("Invalid command line parameters", (from item in commandLineParser.InvalidParameters(validParameters) select("/" + item)).ToList()); return(false); } // Query commandLineParser to see if various parameters are present if (commandLineParser.RetrieveValueForParameter("I", out var inputFilePath)) { mInputFilePath = inputFilePath; } else if (commandLineParser.NonSwitchParameterCount > 0) { mInputFilePath = commandLineParser.RetrieveNonSwitchParameter(0); } if (commandLineParser.RetrieveValueForParameter("N", out var splitCount)) { if (int.TryParse(splitCount, out var value)) { options.SplitCount = value; } else { ConsoleMsgUtils.ShowError( "Error parsing number from the /N parameter; " + "for example, use /N:{0} to specify the file be split into {0} parts", SplitterOptions.DEFAULT_SPLIT_COUNT); options.SplitCount = SplitterOptions.DEFAULT_SPLIT_COUNT; } } if (commandLineParser.RetrieveValueForParameter("MB", out var targetSizeMB)) { options.UseTargetFileSize = true; if (int.TryParse(targetSizeMB, out var value)) { options.TargetFastaFileSizeMB = value; } else { ConsoleMsgUtils.ShowError( "Error parsing number from the /MB parameter; " + "for example, use /MB:{0} to specify the file be split into files that are each {0} MB in size", SplitterOptions.DEFAULT_TARGET_FILE_SIZE_MB); options.TargetFastaFileSizeMB = SplitterOptions.DEFAULT_TARGET_FILE_SIZE_MB; } } if (commandLineParser.RetrieveValueForParameter("O", out var outputDirectory)) { mOutputDirectoryName = outputDirectory; } if (commandLineParser.RetrieveValueForParameter("P", out var parameterFile)) { mParameterFilePath = parameterFile; } if (commandLineParser.RetrieveValueForParameter("S", out var recurseSubdirectories)) { mRecurseDirectories = true; if (!int.TryParse(recurseSubdirectories, out mMaxLevelsToRecurse)) { mMaxLevelsToRecurse = 0; } } if (commandLineParser.RetrieveValueForParameter("A", out var alternateOutputDirectory)) { mOutputDirectoryAlternatePath = alternateOutputDirectory; } if (commandLineParser.IsParameterPresent("R")) { mRecreateDirectoryHierarchyInAlternatePath = true; } if (commandLineParser.IsParameterPresent("L")) { mLogMessagesToFile = true; } return(true); } catch (Exception ex) { ConsoleMsgUtils.ShowError("Error parsing the command line parameters", ex); return(false); } }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParser) { // Returns True if no problems; otherwise, returns false var lstValidParameters = new List <string> { "I", "O", "F", "S", "Preview" }; try { // Make sure no invalid parameters are present if (commandLineParser.InvalidParametersPresent(lstValidParameters)) { var badArguments = new List <string>(); foreach (var item in commandLineParser.InvalidParameters(lstValidParameters)) { badArguments.Add("/" + item); } ShowErrorMessage("Invalid command line parameters", badArguments); return(false); } // Query commandLineParser to see if various parameters are present if (commandLineParser.NonSwitchParameterCount > 0) { mFileMask = commandLineParser.RetrieveNonSwitchParameter(0); } if (!ParseParameter(commandLineParser, "I", "a file mask specification", ref mFileMask)) { return(false); } if (!ParseParameter(commandLineParser, "O", "an output file path", ref mOutputFilePath)) { return(false); } if (commandLineParser.IsParameterPresent("F")) { mFullPathsInResults = true; } if (commandLineParser.IsParameterPresent("Preview")) { mPreviewMode = true; } if (commandLineParser.IsParameterPresent("S")) { mRecurse = true; } return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + ex.Message, ex); } return(false); }
/// <summary> /// Main processing method /// </summary> /// <returns>0 if no error, error code if an error</returns> public static int Main() { var commandLineParser = new clsParseCommandLine(); // Initialize the options mInputFilePath = string.Empty; mOutputDirectoryName = string.Empty; mParameterFilePath = string.Empty; mRecurseDirectories = false; mMaxLevelsToRecurse = 0; mLogMessagesToFile = false; var options = new SplitterOptions(); try { var proceed = commandLineParser.ParseCommandLine() && SetOptionsUsingCommandLineParameters(commandLineParser, options); if (!proceed || commandLineParser.NeedToShowHelp || commandLineParser.ParameterCount + commandLineParser.NonSwitchParameterCount == 0 || mInputFilePath.Length == 0) { ShowProgramHelp(); return(-1); } // Note: mSplitCount and mSplitCount will be overridden if mParameterFilePath points to a valid parameter file that has these settings defined var fastaFileSplitter = new clsFastaFileSplitter(options) { LogMessagesToFile = mLogMessagesToFile }; RegisterEvents(fastaFileSplitter); fastaFileSplitter.ProgressReset += ProgressReset; int returnCode; if (mRecurseDirectories) { if (fastaFileSplitter.ProcessFilesAndRecurseDirectories(mInputFilePath, mOutputDirectoryName, mOutputDirectoryAlternatePath, mRecreateDirectoryHierarchyInAlternatePath, mParameterFilePath, mMaxLevelsToRecurse)) { returnCode = 0; } else { if (fastaFileSplitter.ErrorCode == ProcessFilesBase.ProcessFilesErrorCodes.NoError) { returnCode = -1; } else { returnCode = (int)fastaFileSplitter.ErrorCode; } } } else if (fastaFileSplitter.ProcessFilesWildcard(mInputFilePath, mOutputDirectoryName, mParameterFilePath)) { returnCode = 0; } else { if (fastaFileSplitter.ErrorCode != ProcessFilesBase.ProcessFilesErrorCodes.NoError) { Console.WriteLine("Error while processing: " + fastaFileSplitter.GetErrorMessage()); } returnCode = (int)fastaFileSplitter.ErrorCode; } DisplayProgressPercent(mLastProgressReportValue, true); return(returnCode); } catch (Exception ex) { ConsoleMsgUtils.ShowError("Error occurred in modMain->Main", ex); return(-1); } }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParser) { // Returns True if no problems; otherwise, returns false var lstValidParameters = new List <string> { "Mode", "Runtime", "Threads", "UseTiered", "Preview" }; try { // Make sure no invalid parameters are present if (commandLineParser.InvalidParametersPresent(lstValidParameters)) { var badArguments = new List <string>(); foreach (var item in commandLineParser.InvalidParameters(lstValidParameters)) { badArguments.Add("/" + item); } ShowErrorMessage("Invalid command line parameters", badArguments); return(false); } // Could query commandLineParser to see if various parameters are present //if (commandLineParser.NonSwitchParameterCount > 0) //{ // mFileName = commandLineParser.RetrieveNonSwitchParameter(0); //} var modeValue = 0; if (!GetParamInt(commandLineParser, "Mode", ref modeValue)) { return(false); } try { if (modeValue > 0) { mProcessingMode = (eProcessingMode)(modeValue - 1); } } catch (Exception ex) { ShowErrorMessage("Invalid value for /Mode; should be /Mode:1 or /Mode:2 or /Mode:3 or /Mode:4", ex); } if (!GetParamInt(commandLineParser, "Runtime", ref mRuntimeSeconds)) { return(false); } if (commandLineParser.IsParameterPresent("Threads")) { if (!GetParamInt(commandLineParser, "Threads", ref mThreadCount)) { return(false); } } else { mThreadCount = GetCoreCount(); } mUseTieredRuntimes = commandLineParser.IsParameterPresent("UseTiered"); mPreviewMode = commandLineParser.IsParameterPresent("Preview"); return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message); } return(false); }
public static int Main() { // Returns 0 if no error, error code if an error var commandLineParser = new clsParseCommandLine(); var returnCode = 0; mPeptideInputFilePath = string.Empty; mProteinInputFilePath = string.Empty; mParameterFilePath = string.Empty; mIgnoreILDifferences = false; mOutputProteinSequence = true; mSaveProteinToPeptideMappingFile = false; mSkipCoverageComputationSteps = false; mDebugMode = false; mKeepDB = false; try { var proceed = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { proceed = true; } } if (!commandLineParser.NeedToShowHelp & string.IsNullOrEmpty(mProteinInputFilePath)) { ShowGUI(); } else if (!proceed || commandLineParser.NeedToShowHelp || commandLineParser.ParameterCount == 0 || mPeptideInputFilePath.Length == 0) { ShowProgramHelp(); returnCode = -1; } else { if (string.IsNullOrWhiteSpace(mParameterFilePath) && !mSaveProteinToPeptideMappingFile && mSkipCoverageComputationSteps) { ConsoleMsgUtils.ShowWarning("You used /K but didn't specify /M; no results will be saved"); ConsoleMsgUtils.ShowWarning("It is advised that you use only /M (and don't use /K)"); } try { mProteinCoverageSummarizer = new clsProteinCoverageSummarizerRunner() { ProteinInputFilePath = mProteinInputFilePath, CallingAppHandlesEvents = false, IgnoreILDifferences = mIgnoreILDifferences, OutputProteinSequence = mOutputProteinSequence, SaveProteinToPeptideMappingFile = mSaveProteinToPeptideMappingFile, SearchAllProteinsSkipCoverageComputationSteps = mSkipCoverageComputationSteps, KeepDB = mKeepDB }; mProteinCoverageSummarizer.StatusEvent += ProteinCoverageSummarizer_StatusEvent; mProteinCoverageSummarizer.ErrorEvent += ProteinCoverageSummarizer_ErrorEvent; mProteinCoverageSummarizer.WarningEvent += ProteinCoverageSummarizer_WarningEvent; mProteinCoverageSummarizer.ProgressUpdate += ProteinCoverageSummarizer_ProgressChanged; mProteinCoverageSummarizer.ProgressReset += ProteinCoverageSummarizer_ProgressReset; mProteinCoverageSummarizer.ProcessFilesWildcard(mPeptideInputFilePath, mOutputDirectoryPath, mParameterFilePath); } catch (Exception ex) { ShowErrorMessage("Error initializing Protein File Parser General Options " + ex.Message); } } } catch (Exception ex) { ShowErrorMessage("Error occurred in modMain->Main: " + Environment.NewLine + ex.Message); returnCode = -1; } return(returnCode); }
//private static void SaveTestPlots() //{ // // var plotter = new clsTICandBPIPlotter("modMain", true); // var testChart = new LiveCharts.WinForms.CartesianChart(); // testChart.Series = new SeriesCollection // { // new LineSeries // { // Title = "Series 1", // Values = new ChartValues<double> {4, 6, 5, 2, 7} // }, // new LineSeries // { // Title = "Series 2", // Values = new ChartValues<double> {6, 7, 3, 4, 6}, // PointGeometry = null // }, // //new LineSeries // //{ // // Title = "Series 2", // // Values = new ChartValues<double> {5, 2, 8, 3}, // // PointGeometry = DefaultGeometries.Square, // // PointGeometrySize = 15 // //} // }; // Console.WriteLine("Update XAxis"); // testChart.AxisX.Add(new Axis // { // Title = "Month", // Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May" } // }); // testChart.AxisY.Add(new Axis // { // Title = "Sales", // LabelFormatter = value => value.ToString("C") // }); // Console.WriteLine("Add legend"); // testChart.LegendLocation = LegendLocation.Right; // ////modifying the series collection will animate and update the chart // //testChart.Series.Add(new LineSeries // //{ // // Values = new ChartValues<double> { 5, 3, 2, 4, 5 }, // // LineSmoothness = 0, //straight lines, 1 really smooth lines // // PointGeometry = Geometry.Parse("m 25 70.36218 20 -28 -20 22 -8 -6 z"), // // PointGeometrySize = 50, // // PointForeground = System.Windows.Media.Brushes.Gray // //}); // //modifying any series values will also animate and update the chart // // testChart.Series[2].Values.Add(5d); // //Viewbox viewBox = WrapChart(testChart, 1400, 700); // // testChart.Model.Updater.Run(false, true); // Console.WriteLine("Call AddTitleToChart"); // var panel = AddTitleToChart(testChart, "My title"); // Console.WriteLine("Update chart"); // testChart.Update(false, true); // Console.WriteLine("Render as bitmap"); // using (Bitmap printImage = new Bitmap(panel.Width, panel.Height)) // { // panel.DrawToBitmap(printImage, new Rectangle(0, 0, printImage.Width, printImage.Height)); // var fileName = "TestExport" + DateTime.Now.ToString("yyyy-MM-dd_hh_mm_ss") + ".png"; // printImage.Save(fileName, ImageFormat.Png); // } // //var plotTest = new frmPlot(); // //plotTest.Show(); // Console.WriteLine("Saved"); //} //public static TableLayoutPanel AddTitleToChart(Control chart, string title) //{ // Console.WriteLine("Add label"); // Label label = new Label(); // label.AutoSize = true; // label.Dock = System.Windows.Forms.DockStyle.Fill; // label.Font = new Font("Arial", 12); // label.Location = new System.Drawing.Point(3, 0); // label.Name = "label1"; // label.Size = new System.Drawing.Size(1063, 55); // label.TabIndex = 0; // label.Text = title; // label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // label.BackColor = chart.BackColor; // chart.Dock = System.Windows.Forms.DockStyle.Fill; // Console.WriteLine("Create TableLayoutPanel"); // TableLayoutPanel tableLayoutPanel = new TableLayoutPanel(); // tableLayoutPanel.AutoSize = true; // tableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; // tableLayoutPanel.BackColor = System.Drawing.Color.White; // tableLayoutPanel.ColumnCount = 1; // tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 1069F)); // Console.WriteLine("Add label to TableLayoutPanel"); // tableLayoutPanel.Controls.Add(label, 0, 0); // Console.WriteLine("Add chart to TableLayoutPanel"); // tableLayoutPanel.Controls.Add(chart, 0, 1); // Console.WriteLine("Update TableLayoutPanel DockStyle"); // tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; // tableLayoutPanel.Location = new System.Drawing.Point(0, 0); // tableLayoutPanel.Name = "tableLayoutPanel1"; // Console.WriteLine("Set Rowcount= 2"); // tableLayoutPanel.RowCount = 2; // tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); // tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); // Console.WriteLine("Define size"); // tableLayoutPanel.Size = new System.Drawing.Size(1069, 662); // Console.WriteLine("Set tab index"); // tableLayoutPanel.TabIndex = 2; // return (tableLayoutPanel); //} //public Viewbox viewBox WrapChart(CartesianChart testChart, Grid grid, int width, int height) //{ // testChart.grid.Width = width; // testChart.grid.Height = height; // viewbox.Child = chart.grid; // viewbox.Width = width; // viewbox.Height = height; // viewbox.Measure(new System.Windows.Size(width, height)); // viewbox.Arrange(new Rect(0, 0, width, height)); // viewbox.UpdateLayout(); //} private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine parser) { // Returns True if no problems; otherwise, returns false var lstValidParameters = new List <string> { "I", "O", "P", "S", "IE", "L", "C", "M", "H", "QZ", "NoTIC", "LC", "LCDiv", "LCGrad", "CC", "QS", "ScanStart", "ScanEnd", "DatasetID", "DI", "DST", "SS", "CF", "R", "Z", "PostToDMS", "Debug", "Python", "PythonPlot" }; try { // Make sure no invalid parameters are present if (parser.InvalidParametersPresent(lstValidParameters)) { ShowErrorMessage("Invalid commmand line parameters", (from item in parser.InvalidParameters(lstValidParameters) select "/" + item).ToList()); return(false); } int value; // Query parser to see if various parameters are present if (parser.RetrieveValueForParameter("I", out var strValue)) { mInputDataFilePath = strValue; } else if (parser.NonSwitchParameterCount > 0) { // Treat the first non-switch parameter as the input file mInputDataFilePath = parser.RetrieveNonSwitchParameter(0); } if (parser.RetrieveValueForParameter("O", out strValue)) { mOutputFolderName = strValue; } if (parser.RetrieveValueForParameter("P", out strValue)) { mParameterFilePath = strValue; } if (parser.RetrieveValueForParameter("S", out strValue)) { mRecurseFolders = true; if (int.TryParse(strValue, out value)) { mRecurseFoldersMaxLevels = value; } } if (parser.RetrieveValueForParameter("IE", out strValue)) { mIgnoreErrorsWhenRecursing = true; } if (parser.RetrieveValueForParameter("L", out strValue)) { mLogFilePath = strValue; } if (parser.IsParameterPresent("C")) { mCheckFileIntegrity = true; } if (parser.RetrieveValueForParameter("M", out strValue)) { if (int.TryParse(strValue, out value)) { mMaximumTextFileLinesToCheck = value; } } if (parser.IsParameterPresent("H")) { mComputeFileHashes = true; } if (parser.IsParameterPresent("QZ")) { mZipFileCheckAllData = false; } if (parser.IsParameterPresent("NoTIC")) { mSaveTICandBPIPlots = false; } if (parser.RetrieveValueForParameter("LC", out strValue)) { mSaveLCMS2DPlots = true; if (int.TryParse(strValue, out value)) { mLCMS2DMaxPointsToPlot = value; } } if (parser.RetrieveValueForParameter("LCDiv", out strValue)) { if (int.TryParse(strValue, out value)) { mLCMS2DOverviewPlotDivisor = value; } } if (parser.IsParameterPresent("LCGrad")) { mTestLCMSGradientColorSchemes = true; } if (parser.IsParameterPresent("CC")) { mCheckCentroidingStatus = true; } if (parser.RetrieveValueForParameter("ScanStart", out strValue)) { if (int.TryParse(strValue, out value)) { mScanStart = value; } } if (parser.RetrieveValueForParameter("ScanEnd", out strValue)) { if (int.TryParse(strValue, out value)) { mScanEnd = value; } } if (parser.IsParameterPresent("Debug")) { mShowDebugInfo = true; } if (parser.IsParameterPresent("QS")) { mComputeOverallQualityScores = true; } if (parser.RetrieveValueForParameter("DatasetID", out strValue)) { if (!int.TryParse(strValue, out mDatasetID)) { ShowErrorMessage("DatasetID is not an integer"); return(false); } } if (parser.IsParameterPresent("DI")) { mCreateDatasetInfoFile = true; } if (parser.IsParameterPresent("SS")) { mCreateScanStatsFile = true; } if (parser.RetrieveValueForParameter("DST", out strValue)) { mUpdateDatasetStatsTextFile = true; if (!string.IsNullOrEmpty(strValue)) { mDatasetStatsTextFileName = strValue; } } if (parser.IsParameterPresent("CF")) { mUseCacheFiles = true; } if (parser.IsParameterPresent("R")) { mReprocessingExistingFiles = true; } if (parser.IsParameterPresent("Z")) { mReprocessIfCachedSizeIsZero = true; } if (parser.IsParameterPresent("PostToDMS")) { mPostResultsToDMS = true; } if (parser.IsParameterPresent("PythonPlot") || parser.IsParameterPresent("Python")) { mPlotWithPython = true; } return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message); return(false); } }
public static int Main(string[] args) { var objParseCommandLine = new clsParseCommandLine(); mInputFileOrFolderPath = string.Empty; mOutputFileOrFolderPath = string.Empty; mOutputFolderAlternatePath = string.Empty; mAssumeNoWildcards = false; mKnownExtensions = new List <string>(); mProcessFolders = false; mRecurse = false; mRecurseDepth = 0; try { var success = false; if (objParseCommandLine.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(objParseCommandLine)) { success = true; } } if (!success || objParseCommandLine.NeedToShowHelp || string.IsNullOrWhiteSpace(mInputFileOrFolderPath)) { ShowProgramHelp(); return(-1); } const string PARAM_FILE_PATH = ""; if (mProcessFolders) { var folderProcessor = new FolderProcessor(); RegisterEvents(folderProcessor); folderProcessor.SkipConsoleWriteIfNoProgressListener = true; if (mRecurse) { ConsoleMsgUtils.ShowDebug("Calling folderProcessor.ProcessAndRecurseFolders"); success = folderProcessor.ProcessAndRecurseFolders(mInputFileOrFolderPath, mOutputFileOrFolderPath, PARAM_FILE_PATH, mRecurseDepth); } else if (mAssumeNoWildcards) { ConsoleMsgUtils.ShowDebug("Calling folderProcessor.ProcessFolder"); success = folderProcessor.ProcessFolder(mInputFileOrFolderPath, mOutputFileOrFolderPath, PARAM_FILE_PATH); } else { ConsoleMsgUtils.ShowDebug("Calling folderProcessor.ProcessFoldersWildcard"); success = folderProcessor.ProcessFoldersWildcard(mInputFileOrFolderPath, mOutputFileOrFolderPath); } } else { var fileProcessor = new FileProcessor(); RegisterEvents(fileProcessor); fileProcessor.SkipConsoleWriteIfNoProgressListener = true; if (mRecurse) { const bool RECREATE_FOLDER_HIERARCHY = true; if (mKnownExtensions.Count > 0) { ConsoleMsgUtils.ShowDebug( "Calling fileProcessor.ProcessFilesAndRecurseFolders with user-defined extensions: " + string.Join(", ", mKnownExtensions)); success = fileProcessor.ProcessFilesAndRecurseFolders( mInputFileOrFolderPath, mOutputFileOrFolderPath, mOutputFolderAlternatePath, RECREATE_FOLDER_HIERARCHY, PARAM_FILE_PATH, mRecurseDepth, mKnownExtensions); } else { ConsoleMsgUtils.ShowDebug("Calling fileProcessor.ProcessFilesAndRecurseFolders with " + "input file [" + mInputFileOrFolderPath + "], output folder [" + mOutputFileOrFolderPath + "]" + " and extensions: " + string.Join(", ", fileProcessor.GetDefaultExtensionsToParse())); success = fileProcessor.ProcessFilesAndRecurseFolders( mInputFileOrFolderPath, mOutputFileOrFolderPath, mOutputFolderAlternatePath, RECREATE_FOLDER_HIERARCHY, PARAM_FILE_PATH, mRecurseDepth); } } else if (mAssumeNoWildcards) { ConsoleMsgUtils.ShowDebug("Calling fileProcessor.ProcessFile with " + "input file [" + mInputFileOrFolderPath + "] and output folder [" + mOutputFileOrFolderPath + "]"); success = fileProcessor.ProcessFile(mInputFileOrFolderPath, mOutputFileOrFolderPath); } else { ConsoleMsgUtils.ShowDebug("Calling fileProcessor.ProcessFilesWildcard with " + "input file [" + mInputFileOrFolderPath + "] and output folder [" + mOutputFileOrFolderPath + "]"); success = fileProcessor.ProcessFilesWildcard(mInputFileOrFolderPath, mOutputFileOrFolderPath); } } if (!success) { System.Threading.Thread.Sleep(1500); return(-3); } } catch (Exception ex) { Console.WriteLine("Error occurred in Program->Main: " + Environment.NewLine + ex.Message); Console.WriteLine(ex.StackTrace); System.Threading.Thread.Sleep(1500); return(-1); } return(0); }
/// <summary> /// Set options using command line parameters /// </summary> /// <param name="commandLineParser"></param> /// <returns>True if no problems; otherwise, returns false</returns> private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParser) { var validParameters = new List <string> { "Local", "Preview", "Trace", "LogDB", "FS" }; try { // Make sure no invalid parameters are present if (commandLineParser.InvalidParametersPresent(validParameters)) { var badArguments = new List <string>(); foreach (var item in commandLineParser.InvalidParameters(validParameters)) { badArguments.Add("/" + item); } ShowErrorMessage("Invalid command line parameters", badArguments); return(false); } // Query commandLineParser to see if various parameters are present if (commandLineParser.NonSwitchParameterCount > 0) { mMTSServer = commandLineParser.RetrieveNonSwitchParameter(0); } if (commandLineParser.IsParameterPresent("Local")) { mLocalServerMode = true; } if (commandLineParser.IsParameterPresent("Preview")) { mPreviewMode = true; } if (commandLineParser.IsParameterPresent("Trace")) { mTraceMode = true; } if (commandLineParser.RetrieveValueForParameter("LogDB", out var strValue)) { if (string.IsNullOrWhiteSpace(strValue)) { ShowErrorMessage("/LogDB does not have a value; not overriding the logging connection string"); } else { mLogDBConnectionString = strValue; } } if (commandLineParser.RetrieveValueForParameter("FS", out strValue)) { if (string.IsNullOrWhiteSpace(strValue)) { ShowErrorMessage("/FS does not have a value; not overriding the minimum free space"); } else { if (!int.TryParse(strValue, out mMinimumCacheFreeSpaceGB)) { ShowErrorMessage("Error converting " + strValue + " to an integer for parameter /FS"); } } } return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message); } return(false); }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParser) { // Returns True if no problems; otherwise, returns false var validParameters = new List <string> { "I", "M", "O", "N", "C", "Mage", "Append", "DartID", "S", "A", "R" }; try { // Make sure no invalid parameters are present if (commandLineParser.InvalidParametersPresent(validParameters)) { ShowErrorMessage("Invalid command line parameters", (from item in commandLineParser.InvalidParameters(validParameters) select "/" + item).ToList()); return(false); } // Query commandLineParser to see if various parameters are present if (commandLineParser.RetrieveValueForParameter("I", out var inputFile)) { mInputFilePath = inputFile; } else if (commandLineParser.NonSwitchParameterCount > 0) { mInputFilePath = commandLineParser.RetrieveNonSwitchParameter(0); } if (commandLineParser.RetrieveValueForParameter("M", out var masicResultsDir)) { mMASICResultsDirectoryPath = masicResultsDir; } if (commandLineParser.RetrieveValueForParameter("O", out var outputDirectory)) { mOutputDirectoryPath = outputDirectory; } if (commandLineParser.RetrieveValueForParameter("N", out var scanNumColumnIndex)) { if (int.TryParse(scanNumColumnIndex, out var value)) { mScanNumberColumn = value; } } if (commandLineParser.IsParameterPresent("C")) { mSeparateByCollisionMode = true; } if (commandLineParser.IsParameterPresent("Mage")) { mMageResults = true; } if (commandLineParser.IsParameterPresent("Append")) { mMergeWildcardResults = true; } if (commandLineParser.IsParameterPresent("DartID")) { mCreateDartIdInputFile = true; } if (commandLineParser.RetrieveValueForParameter("S", out var maxLevelsToRecurse)) { mRecurseDirectories = true; if (int.TryParse(maxLevelsToRecurse, out var levels)) { mRecurseDirectoriesMaxLevels = levels; } } if (commandLineParser.RetrieveValueForParameter("A", out var alternatePath)) { mOutputDirectoryAlternatePath = alternatePath; } if (commandLineParser.IsParameterPresent("R")) { mRecreateDirectoryHierarchyInAlternatePath = true; } return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters", ex); } return(false); }
private static int Main() { var commandLineParse = new clsParseCommandLine(); mSearchDirectoryPath = "."; mRecurse = false; mUpdateOptions = new PackageUpdateOptions { NuGetPackageName = "", NuGetPackageVersion = "", Rollback = false, Preview = true }; mVerboseLogging = false; try { var success = false; if (commandLineParse.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParse)) { success = true; } } if (!success || commandLineParse.NeedToShowHelp) { ShowProgramHelp(); return(-1); } if (string.IsNullOrWhiteSpace(mSearchDirectoryPath)) { mSearchDirectoryPath = "."; } if (string.IsNullOrWhiteSpace(mUpdateOptions.NuGetPackageName)) { ShowErrorMessage("NuGet package must be defined using /P or /Package"); return(-3); } if (string.IsNullOrWhiteSpace(mUpdateOptions.NuGetPackageVersion)) { ShowErrorMessage("NuGet package version must be defined using /V or /Version"); return(-4); } success = SearchForProjectFiles(mSearchDirectoryPath, mRecurse, mUpdateOptions); if (!success) { Thread.Sleep(1500); return(-1); } Console.WriteLine(); Console.WriteLine("Search complete"); Thread.Sleep(250); } catch (Exception ex) { ShowErrorMessage("Error occurred in Program->Main", ex); Thread.Sleep(1500); return(-1); } return(0); }
public static void Main() { mScanInfoInterval = 1; mLoadMethods = true; mLoadScanData = true; mGetScanEvents = true; mLoadCollisionEnergies = true; mOnlyLoadMSLevelInfo = false; var commandLineParser = new clsParseCommandLine(); commandLineParser.ParseCommandLine(); if (commandLineParser.NeedToShowHelp) { ShowProgramHelp(); return; } if (Path.DirectorySeparatorChar == '/') { mSourceFilePath = DEFAULT_FILE_PATH.Replace('\\', '/'); } else { mSourceFilePath = DEFAULT_FILE_PATH; } ParseCommandLineParameters(commandLineParser); if (mExtractScanFilters) { var workingDirectory = "."; if (commandLineParser.NonSwitchParameterCount > 0) { workingDirectory = commandLineParser.RetrieveNonSwitchParameter(0); } ExtractScanFilters(workingDirectory); System.Threading.Thread.Sleep(1500); return; } var sourceFile = new FileInfo(mSourceFilePath); if (!sourceFile.Exists) { Console.WriteLine("File not found: " + sourceFile.FullName); System.Threading.Thread.Sleep(1500); return; } if (mTestScanFilters) { TestScanFilterParsing(); } TestReader(sourceFile.FullName, mCentroid, mTestSumming, mStartScan, mEndScan); if (mCentroid) { // Also process the file with centroiding off TestReader(sourceFile.FullName, false, mTestSumming, mStartScan, mEndScan); } if (mGetScanEvents) { TestGetAllScanEvents(sourceFile.FullName); } Console.WriteLine("Done"); System.Threading.Thread.Sleep(150); }
public static int Main() { int intReturnCode; var objParseCommandLine = new clsParseCommandLine(); mInputDataFilePath = string.Empty; mOutputFolderName = string.Empty; mParameterFilePath = string.Empty; mLogFilePath = string.Empty; mRecurseFolders = false; mRecurseFoldersMaxLevels = 2; mIgnoreErrorsWhenRecursing = false; mReprocessingExistingFiles = false; mReprocessIfCachedSizeIsZero = false; mUseCacheFiles = false; mSaveTICandBPIPlots = true; mSaveLCMS2DPlots = false; mLCMS2DMaxPointsToPlot = clsLCMSDataPlotterOptions.DEFAULT_MAX_POINTS_TO_PLOT; mLCMS2DOverviewPlotDivisor = clsLCMSDataPlotterOptions.DEFAULT_LCMS2D_OVERVIEW_PLOT_DIVISOR; mTestLCMSGradientColorSchemes = false; mCheckCentroidingStatus = false; mScanStart = 0; mScanEnd = 0; mShowDebugInfo = false; mComputeOverallQualityScores = false; mCreateDatasetInfoFile = false; mCreateScanStatsFile = false; mUpdateDatasetStatsTextFile = false; mDatasetStatsTextFileName = string.Empty; mCheckFileIntegrity = false; mComputeFileHashes = false; mZipFileCheckAllData = true; mMaximumTextFileLinesToCheck = clsFileIntegrityChecker.DEFAULT_MAXIMUM_TEXT_FILE_LINES_TO_CHECK; mPostResultsToDMS = false; mPlotWithPython = false; mLastProgressTime = DateTime.UtcNow; try { var blnProceed = false; if (objParseCommandLine.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(objParseCommandLine)) { blnProceed = true; } } if (mInputDataFilePath == null) { mInputDataFilePath = string.Empty; } if (!blnProceed || objParseCommandLine.NeedToShowHelp || objParseCommandLine.ParameterCount + objParseCommandLine.NonSwitchParameterCount == 0 || mInputDataFilePath.Length == 0) { ShowProgramHelp(); return(-1); } var scanner = new clsMSFileInfoScanner(); scanner.DebugEvent += mMSFileScanner_DebugEvent; scanner.ErrorEvent += mMSFileScanner_ErrorEvent; scanner.WarningEvent += mMSFileScanner_WarningEvent; scanner.StatusEvent += mMSFileScanner_MessageEvent; scanner.ProgressUpdate += mMSFileScanner_ProgressUpdate; if (mCheckFileIntegrity) { mUseCacheFiles = true; } // Note: These values will be overridden if /P was used and they are defined in the parameter file scanner.UseCacheFiles = mUseCacheFiles; scanner.ReprocessExistingFiles = mReprocessingExistingFiles; scanner.ReprocessIfCachedSizeIsZero = mReprocessIfCachedSizeIsZero; scanner.PlotWithPython = mPlotWithPython; scanner.SaveTICAndBPIPlots = mSaveTICandBPIPlots; scanner.SaveLCMS2DPlots = mSaveLCMS2DPlots; scanner.LCMS2DPlotMaxPointsToPlot = mLCMS2DMaxPointsToPlot; scanner.LCMS2DOverviewPlotDivisor = mLCMS2DOverviewPlotDivisor; scanner.TestLCMSGradientColorSchemes = mTestLCMSGradientColorSchemes; scanner.CheckCentroidingStatus = mCheckCentroidingStatus; scanner.ScanStart = mScanStart; scanner.ScanEnd = mScanEnd; scanner.ShowDebugInfo = mShowDebugInfo; scanner.ComputeOverallQualityScores = mComputeOverallQualityScores; scanner.CreateDatasetInfoFile = mCreateDatasetInfoFile; scanner.CreateScanStatsFile = mCreateScanStatsFile; scanner.UpdateDatasetStatsTextFile = mUpdateDatasetStatsTextFile; scanner.DatasetStatsTextFileName = mDatasetStatsTextFileName; scanner.CheckFileIntegrity = mCheckFileIntegrity; scanner.MaximumTextFileLinesToCheck = mMaximumTextFileLinesToCheck; scanner.ComputeFileHashes = mComputeFileHashes; scanner.ZipFileCheckAllData = mZipFileCheckAllData; scanner.IgnoreErrorsWhenRecursing = mIgnoreErrorsWhenRecursing; if (mLogFilePath.Length > 0) { scanner.LogMessagesToFile = true; scanner.LogFilePath = mLogFilePath; } scanner.DatasetIDOverride = mDatasetID; scanner.DSInfoDBPostingEnabled = mPostResultsToDMS; if (!string.IsNullOrEmpty(mParameterFilePath)) { scanner.LoadParameterFileSettings(mParameterFilePath); } if (mRecurseFolders) { if (scanner.ProcessMSFilesAndRecurseFolders(mInputDataFilePath, mOutputFolderName, mRecurseFoldersMaxLevels)) { intReturnCode = 0; } else { intReturnCode = (int)scanner.ErrorCode; } } else { if (scanner.ProcessMSFileOrFolderWildcard(mInputDataFilePath, mOutputFolderName, true)) { intReturnCode = 0; } else { intReturnCode = (int)scanner.ErrorCode; if (intReturnCode != 0) { ShowErrorMessage("Error while processing: " + scanner.GetErrorMessage()); } } } scanner.SaveCachedResults(); } catch (Exception ex) { ShowErrorMessage("Error occurred in modMain->Main: " + Environment.NewLine + ex.Message); intReturnCode = -1; } return(intReturnCode); }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParser) { // Returns True if no problems; otherwise, returns false // /I:PeptideInputFilePath /R: ProteinInputFilePath /O:OutputDirectoryPath /P:ParameterFilePath var validParameters = new List <string>() { "I", "O", "R", "P", "G", "H", "M", "K", "Debug", "KeepDB" }; try { // Make sure no invalid parameters are present if (commandLineParser.InvalidParametersPresent(validParameters)) { ShowErrorMessage("Invalid command line parameters", (from item in commandLineParser.InvalidParameters(validParameters) select("/" + item)).ToList()); return(false); } // Query commandLineParser to see if various parameters are present if (commandLineParser.RetrieveValueForParameter("I", out var inputFilePath)) { mPeptideInputFilePath = inputFilePath; } else if (commandLineParser.NonSwitchParameterCount > 0) { mPeptideInputFilePath = commandLineParser.RetrieveNonSwitchParameter(0); } if (commandLineParser.RetrieveValueForParameter("O", out var outputDirectoryPath)) { mOutputDirectoryPath = outputDirectoryPath; } if (commandLineParser.RetrieveValueForParameter("R", out var proteinFile)) { mProteinInputFilePath = proteinFile; } if (commandLineParser.RetrieveValueForParameter("P", out var parameterFile)) { mParameterFilePath = parameterFile; } if (commandLineParser.RetrieveValueForParameter("H", out _)) { mOutputProteinSequence = false; } mIgnoreILDifferences = commandLineParser.IsParameterPresent("G"); mSaveProteinToPeptideMappingFile = commandLineParser.IsParameterPresent("M"); mSkipCoverageComputationSteps = commandLineParser.IsParameterPresent("K"); mDebugMode = commandLineParser.IsParameterPresent("Debug"); mKeepDB = commandLineParser.IsParameterPresent("KeepDB"); return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message); } return(false); }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine CommandLineParser) { // Returns True if no problems; otherwise, returns false // /I:PeptideInputFilePath /R: ProteinInputFilePath /O:OutputDirectoryPath /P:ParameterFilePath string value = string.Empty; var validParameters = new List <string>() { "I", "O", "R", "P", "F", "N", "G", "H", "K", "A", "L", "LogDir", "LogFolder", "VerboseLog" }; int intValue; try { // Make sure no invalid parameters are present if (CommandLineParser.InvalidParametersPresent(validParameters)) { ShowErrorMessage("Invalid command line parameters", (from item in CommandLineParser.InvalidParameters(validParameters) select("/" + item)).ToList()); return(false); } else { // Query commandLineParser to see if various parameters are present if (CommandLineParser.RetrieveValueForParameter("I", out value)) { mPeptideInputFilePath = value; } else if (CommandLineParser.NonSwitchParameterCount > 0) { mPeptideInputFilePath = CommandLineParser.RetrieveNonSwitchParameter(0); } if (CommandLineParser.RetrieveValueForParameter("O", out value)) { mOutputDirectoryPath = value; } if (CommandLineParser.RetrieveValueForParameter("R", out value)) { mProteinInputFilePath = value; } if (CommandLineParser.RetrieveValueForParameter("P", out value)) { mParameterFilePath = value; } if (CommandLineParser.RetrieveValueForParameter("F", out value)) { if (int.TryParse(value, out intValue)) { try { mInputFileFormatCode = (clsPeptideToProteinMapEngine.ePeptideInputFileFormatConstants)intValue; } catch (Exception ex) { // Conversion failed; leave mInputFileFormatCode unchanged } } } if (CommandLineParser.RetrieveValueForParameter("N", out value)) { mInspectParameterFilePath = value; } if (CommandLineParser.RetrieveValueForParameter("G", out value)) { mIgnoreILDifferences = true; } if (CommandLineParser.RetrieveValueForParameter("H", out value)) { mOutputProteinSequence = false; } if (CommandLineParser.RetrieveValueForParameter("K", out value)) { mSkipCoverageComputationSteps = true; } if (CommandLineParser.RetrieveValueForParameter("A", out value)) { mSaveSourceDataPlusProteinsFile = true; } if (CommandLineParser.RetrieveValueForParameter("L", out value)) { mLogMessagesToFile = true; if (!string.IsNullOrEmpty(value)) { mLogFilePath = value; } } if (CommandLineParser.RetrieveValueForParameter("LogDir", out value)) { mLogMessagesToFile = true; if (!string.IsNullOrEmpty(value)) { mLogDirectoryPath = value; } } if (CommandLineParser.RetrieveValueForParameter("LogFolder", out value)) { mLogMessagesToFile = true; if (!string.IsNullOrEmpty(value)) { mLogDirectoryPath = value; } } if (CommandLineParser.RetrieveValueForParameter("VerboseLog", out value)) { mVerboseLogging = true; } return(true); } } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message); } return(false); }
/// <summary> /// Main entry method /// </summary> public static int Main() { var commandLineParser = new clsParseCommandLine(); mLogLevel = BaseLogger.LogLevels.INFO; mMTSServer = string.Empty; mLogDBConnectionString = clsMyEMSLMTSFileCacher.LOG_DB_CONNECTION_STRING; mMinimumCacheFreeSpaceGB = clsMyEMSLMTSFileCacher.DEFAULT_MINIMUM_CACHE_FREE_SPACE_GB; mLocalServerMode = false; mPreviewMode = false; mTraceMode = false; try { var success = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { success = true; } } if (!success || commandLineParser.NeedToShowHelp || commandLineParser.ParameterCount + commandLineParser.NonSwitchParameterCount == 0 || mMTSServer.Length == 0 && !mLocalServerMode) { ShowProgramHelp(); return(-1); } if (mLocalServerMode) { mMTSServer = string.Empty; } else { var updatesArePending = WindowsUpdateStatus.UpdatesArePending(out var pendingWindowsUpdateMessage); if (updatesArePending) { Console.WriteLine(pendingWindowsUpdateMessage); Console.WriteLine("Will not contact the MTS server to process cache requests"); return(0); } } var downloader = new clsMyEMSLMTSFileCacher(mMTSServer, mLogLevel, mLogDBConnectionString) { MinimumCacheFreeSpaceGB = mMinimumCacheFreeSpaceGB, TraceMode = mTraceMode }; // Attach the events downloader.DebugEvent += Downloader_DebugEvent; downloader.ErrorEvent += Downloader_ErrorEvent; downloader.StatusEvent += Downloader_StatusEvent; downloader.WarningEvent += Downloader_WarningEvent; downloader.ProgressUpdate += Downloader_ProgressUpdate; mPercentComplete = 0; mLastProgressUpdateTime = DateTime.UtcNow; // Initiate processing, which will contact the MTS Server to see if any files need to be cached success = downloader.Start(mPreviewMode); LogTools.FlushPendingMessages(); if (!success) { ShowErrorMessage("Error processing cache requests for MTS server " + mMTSServer + ": " + downloader.ErrorMessage); return(-3); } } catch (Exception ex) { LogTools.FlushPendingMessages(); Console.WriteLine("Error occurred in Program->Main: " + Environment.NewLine + ex.Message); Console.WriteLine(ex.StackTrace); Thread.Sleep(1500); return(-1); } return(0); }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParse) { // Returns True if no problems; otherwise, returns false var lstValidParameters = new List <string> { "I", "P", "Package", "V", "Version", "Preview", "Apply", "Rollback", "S", "Verbose" }; try { // Make sure no invalid parameters are present if (commandLineParse.InvalidParametersPresent(lstValidParameters)) { var badArguments = new List <string>(); foreach (var item in commandLineParse.InvalidParameters(lstValidParameters)) { badArguments.Add("/" + item); } ShowErrorMessage("Invalid command line parameters", badArguments); return(false); } // Query commandLineParse to see if various parameters are present if (commandLineParse.NonSwitchParameterCount > 0) { mSearchDirectoryPath = commandLineParse.RetrieveNonSwitchParameter(0); } if (commandLineParse.RetrieveValueForParameter("I", out var paramValue)) { mSearchDirectoryPath = string.Copy(paramValue); } if (commandLineParse.RetrieveValueForParameter("Package", out paramValue)) { mUpdateOptions.NuGetPackageName = paramValue; } else if (commandLineParse.RetrieveValueForParameter("P", out paramValue)) { mUpdateOptions.NuGetPackageName = paramValue; } if (commandLineParse.RetrieveValueForParameter("Version", out paramValue)) { mUpdateOptions.NuGetPackageVersion = paramValue; } else if (commandLineParse.RetrieveValueForParameter("V", out paramValue)) { mUpdateOptions.NuGetPackageVersion = paramValue; } if (commandLineParse.IsParameterPresent("Apply")) { mUpdateOptions.Preview = false; } if (commandLineParse.IsParameterPresent("Preview")) { mUpdateOptions.Preview = true; } if (commandLineParse.IsParameterPresent("Rollback")) { mUpdateOptions.Rollback = true; } if (commandLineParse.IsParameterPresent("S")) { mRecurse = true; } if (commandLineParse.IsParameterPresent("Verbose")) { mVerboseLogging = true; } return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters", ex); } return(false); }
public static int Main() { // Returns 0 if no error, error code if an error int returnCode; var commandLineParser = new clsParseCommandLine(); bool proceed; returnCode = 0; mPeptideInputFilePath = string.Empty; mProteinInputFilePath = string.Empty; mParameterFilePath = string.Empty; mInspectParameterFilePath = string.Empty; mIgnoreILDifferences = false; mOutputProteinSequence = true; mSaveProteinToPeptideMappingFile = true; mSaveSourceDataPlusProteinsFile = false; mSkipCoverageComputationSteps = false; mInputFileFormatCode = clsPeptideToProteinMapEngine.ePeptideInputFileFormatConstants.AutoDetermine; mLogMessagesToFile = false; mLogFilePath = string.Empty; mLogDirectoryPath = string.Empty; try { proceed = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { proceed = true; } } if (!proceed || commandLineParser.NeedToShowHelp || commandLineParser.ParameterCount + commandLineParser.NonSwitchParameterCount == 0) { ShowProgramHelp(); returnCode = -1; } else { try { if (mVerboseLogging) { CreateVerboseLogFile(); } if (string.IsNullOrWhiteSpace(mPeptideInputFilePath)) { ShowErrorMessage("Peptide input file must be defined via /I (or by listing the filename just after the .exe)"); returnCode = -1; return(returnCode); } else if (string.IsNullOrWhiteSpace(mProteinInputFilePath)) { ShowErrorMessage("Protein input file must be defined via /R"); returnCode = -1; return(returnCode); } mPeptideToProteinMapEngine = new clsPeptideToProteinMapEngine() { ProteinInputFilePath = mProteinInputFilePath, LogMessagesToFile = mLogMessagesToFile, LogFilePath = mLogFilePath, LogDirectoryPath = mLogDirectoryPath, PeptideInputFileFormat = mInputFileFormatCode, InspectParameterFilePath = mInspectParameterFilePath, IgnoreILDifferences = mIgnoreILDifferences, OutputProteinSequence = mOutputProteinSequence, SaveProteinToPeptideMappingFile = mSaveProteinToPeptideMappingFile, SaveSourceDataPlusProteinsFile = mSaveSourceDataPlusProteinsFile, SearchAllProteinsSkipCoverageComputationSteps = mSkipCoverageComputationSteps }; mPeptideToProteinMapEngine.StatusEvent += PeptideToProteinMapEngine_StatusEvent; mPeptideToProteinMapEngine.ErrorEvent += PeptideToProteinMapEngine_ErrorEvent; mPeptideToProteinMapEngine.WarningEvent += PeptideToProteinMapEngine_WarningEvent; mPeptideToProteinMapEngine.ProgressUpdate += PeptideToProteinMapEngine_ProgressChanged; mPeptideToProteinMapEngine.ProgressReset += PeptideToProteinMapEngine_ProgressReset; mPeptideToProteinMapEngine.ProcessFilesWildcard(mPeptideInputFilePath, mOutputDirectoryPath, mParameterFilePath); if (mVerboseLogFile != null) { mVerboseLogFile.Close(); } } catch (Exception ex) { ShowErrorMessage("Error initializing the Peptide to Protein Mapper Options " + ex.Message); } } } catch (Exception ex) { ShowErrorMessage("Error occurred in modMain->Main: " + Environment.NewLine + ex.Message); returnCode = -1; } return(returnCode); }
private static int Main() { // Returns 0 if no error, error code if an error var commandLineParser = new clsParseCommandLine(); mInputFilePath = string.Empty; mCreateDartIdInputFile = false; mMageResults = false; mMergeWildcardResults = false; mMASICResultsDirectoryPath = string.Empty; mOutputDirectoryPath = string.Empty; mRecurseDirectories = false; mRecurseDirectoriesMaxLevels = 0; mLogMessagesToFile = false; mScanNumberColumn = MASICResultsMerger.DEFAULT_SCAN_NUMBER_COLUMN; mSeparateByCollisionMode = false; try { var proceed = false; if (commandLineParser.ParseCommandLine()) { if (SetOptionsUsingCommandLineParameters(commandLineParser)) { proceed = true; } } if (!proceed || commandLineParser.NeedToShowHelp || commandLineParser.ParameterCount + commandLineParser.NonSwitchParameterCount == 0 || mInputFilePath.Length == 0) { ShowProgramHelp(); return(-1); } // Note: If a parameter file is defined, settings in that file will override the options defined here mMASICResultsMerger = new MASICResultsMerger { LogMessagesToFile = mLogMessagesToFile, MASICResultsDirectoryPath = mMASICResultsDirectoryPath, ScanNumberColumn = mScanNumberColumn, SeparateByCollisionMode = mSeparateByCollisionMode, CreateDartIdInputFile = mCreateDartIdInputFile, MageResults = mMageResults }; mMASICResultsMerger.ErrorEvent += MASICResultsMerger_ErrorEvent; mMASICResultsMerger.WarningEvent += MASICResultsMerger_WarningEvent; mMASICResultsMerger.StatusEvent += MASICResultsMerger_StatusEvent; mMASICResultsMerger.DebugEvent += MASICResultsMerger_DebugEvent; mMASICResultsMerger.ProgressUpdate += MASICResultsMerger_ProgressUpdate; mMASICResultsMerger.ProgressReset += MASICResultsMerger_ProgressReset; int returnCode; if (mRecurseDirectories) { if (mMASICResultsMerger.ProcessFilesAndRecurseDirectories(mInputFilePath, mOutputDirectoryPath, mOutputDirectoryAlternatePath, mRecreateDirectoryHierarchyInAlternatePath, string.Empty, mRecurseDirectoriesMaxLevels)) { returnCode = 0; } else { returnCode = (int)mMASICResultsMerger.ErrorCode; } } else if (mMASICResultsMerger.ProcessFilesWildcard(mInputFilePath, mOutputDirectoryPath)) { returnCode = 0; } else { returnCode = (int)mMASICResultsMerger.ErrorCode; if (returnCode != 0) { ShowErrorMessage("Error while processing: " + mMASICResultsMerger.GetErrorMessage()); } } if (mMergeWildcardResults && mMASICResultsMerger.ProcessedDatasets.Count > 0) { mMASICResultsMerger.MergeProcessedDatasets(); } if (mLastProgressReportValue > 0) { DisplayProgressPercent(mLastProgressReportValue, true); } return(returnCode); } catch (Exception ex) { ShowErrorMessage("Error occurred in modMain->Main: ", ex); return(-1); } }
private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine objParseCommandLine) { // Returns True if no problems; otherwise, returns false var lstValidParameters = new List <string> { "I", "O", "AltOutput", "Folders", "S", "NoWild", "Ext" }; try { // Make sure no invalid parameters are present if (objParseCommandLine.InvalidParametersPresent(lstValidParameters)) { var badArguments = new List <string>(); foreach (var item in objParseCommandLine.InvalidParameters(lstValidParameters)) { badArguments.Add("/" + item); } ShowErrorMessage("Invalid command line parameters", badArguments); return(false); } // Query objParseCommandLine to see if various parameters are present if (objParseCommandLine.NonSwitchParameterCount > 0) { mInputFileOrFolderPath = objParseCommandLine.RetrieveNonSwitchParameter(0); } if (objParseCommandLine.NonSwitchParameterCount > 1) { mOutputFileOrFolderPath = objParseCommandLine.RetrieveNonSwitchParameter(1); } if (objParseCommandLine.RetrieveValueForParameter("I", out var paramValue)) { mInputFileOrFolderPath = string.Copy(paramValue); } if (objParseCommandLine.RetrieveValueForParameter("O", out paramValue)) { mOutputFileOrFolderPath = string.Copy(paramValue); } if (objParseCommandLine.RetrieveValueForParameter("AltOutput", out paramValue)) { mOutputFolderAlternatePath = string.Copy(paramValue); } if (objParseCommandLine.IsParameterPresent("Folders")) { mProcessFolders = true; } mRecurse = objParseCommandLine.IsParameterPresent("S"); if (mRecurse && objParseCommandLine.RetrieveValueForParameter("S", out paramValue)) { if (int.TryParse(paramValue, out var recurseDepth)) { mRecurseDepth = recurseDepth; } } mAssumeNoWildcards = objParseCommandLine.IsParameterPresent("NoWild"); if (mRecurse && objParseCommandLine.RetrieveValueForParameter("Ext", out paramValue)) { var extensions = paramValue.Split(','); if (extensions.Length > 0) { mKnownExtensions.Clear(); mKnownExtensions.AddRange(extensions); } } return(true); } catch (Exception ex) { ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message, ex); } return(false); }