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");
        }
        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 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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        //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);
            }
        }
        /// <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 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);
        }
        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);
            }
        }
Exemple #11
0
        private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine objParseCommandLine)
        {
            // Returns True if no problems; otherwise, returns false
            var lstValidParameters = new List <string> {
                "I", "O",
                "PK", "NoP", "NoG",
                "Def", "Definition",
                "Com", "Comm", "Comment"
            };

            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)
                {
                    mInputFilePath = objParseCommandLine.RetrieveNonSwitchParameter(0);
                }

                if (objParseCommandLine.NonSwitchParameterCount > 1)
                {
                    mOutputFilePath = objParseCommandLine.RetrieveNonSwitchParameter(1);
                }

                string paramValue;
                if (objParseCommandLine.RetrieveValueForParameter("I", out paramValue))
                {
                    mInputFilePath = string.Copy(paramValue);
                }

                if (objParseCommandLine.RetrieveValueForParameter("O", out paramValue))
                {
                    mOutputFilePath = string.Copy(paramValue);
                }

                if (objParseCommandLine.RetrieveValueForParameter("PK", out paramValue))
                {
                    mPrimaryKeySuffix = string.Copy(paramValue);
                }

                if (objParseCommandLine.IsParameterPresent("NoP"))
                {
                    mOutputOptions.IncludeParentTerms      = false;
                    mOutputOptions.IncludeGrandparentTerms = false;
                }

                if (objParseCommandLine.IsParameterPresent("NoG"))
                {
                    mOutputOptions.IncludeGrandparentTerms = false;
                }

                if (objParseCommandLine.IsParameterPresent("Def") ||
                    objParseCommandLine.IsParameterPresent("Definition"))
                {
                    mOutputOptions.IncludeDefinition = true;
                }

                if (objParseCommandLine.IsParameterPresent("Com") ||
                    objParseCommandLine.IsParameterPresent("Comm") ||
                    objParseCommandLine.IsParameterPresent("Comment"))
                {
                    mOutputOptions.IncludeComment = true;
                }

                return(true);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error parsing the command line parameters", ex);
            }

            return(false);
        }
Exemple #12
0
        /// <summary>
        /// Set options using command line arguments
        /// </summary>
        /// <param name="commandLineParser"></param>
        /// <returns>True if no problems; otherwise, false</returns>
        private static bool SetOptionsUsingCommandLineParameters(clsParseCommandLine commandLineParser)
        {
            var validParameters = new List <string> {
                "I", "O", "P", "D", "S", "A", "R", "L", "Log", "SF", "LogDir", "LogFolder", "Q"
            };

            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);
                }

                if (commandLineParser.RetrieveValueForParameter("O", out var outputDirectoryPath))
                {
                    mOutputDirectoryPath = outputDirectoryPath;
                }

                if (commandLineParser.RetrieveValueForParameter("P", out var parameterFilePath))
                {
                    mParameterFilePath = parameterFilePath;
                }

                if (commandLineParser.RetrieveValueForParameter("D", out var datasetIdOrLookupFile))
                {
                    if (int.TryParse(datasetIdOrLookupFile, out var datasetId))
                    {
                        mDatasetID = datasetId;
                    }
                    else if (!string.IsNullOrWhiteSpace(datasetIdOrLookupFile))
                    {
                        // Assume the user specified a dataset number lookup file comma, space, or tab delimited delimited file specifying the dataset number for each input file)
                        mDatasetLookupFilePath = datasetIdOrLookupFile;
                        mDatasetID             = 0;
                    }
                }

                if (commandLineParser.RetrieveValueForParameter("S", out var recursionDepth))
                {
                    mRecurseDirectories = true;
                    if (int.TryParse(recursionDepth, out var levelsToRecurse))
                    {
                        mMaxLevelsToRecurse = levelsToRecurse;
                    }
                }

                if (commandLineParser.RetrieveValueForParameter("A", out var alternateOutputDirectory))
                {
                    mOutputDirectoryAlternatePath = alternateOutputDirectory;
                }

                if (commandLineParser.IsParameterPresent("R"))
                {
                    mRecreateDirectoryHierarchyInAlternatePath = true;
                }

                var logFileName = string.Empty;
                var logToFile   = false;

                if (commandLineParser.IsParameterPresent("L"))
                {
                    logToFile = commandLineParser.RetrieveValueForParameter("L", out logFileName);
                }
                else if (commandLineParser.IsParameterPresent("Log"))
                {
                    logToFile = commandLineParser.RetrieveValueForParameter("Log", out logFileName);
                }

                if (logToFile)
                {
                    mLogMessagesToFile = true;
                    if (!string.IsNullOrEmpty(logFileName))
                    {
                        mLogFilePath = logFileName.Trim('"');
                    }
                }

                if (commandLineParser.RetrieveValueForParameter("SF", out var masicStatusFile))
                {
                    mMASICStatusFilename = masicStatusFile;
                }

                if (commandLineParser.RetrieveValueForParameter("LogDir", out var logDirectoryPath))
                {
                    mLogMessagesToFile = true;
                    if (!string.IsNullOrEmpty(logDirectoryPath))
                    {
                        mLogDirectoryPath = logDirectoryPath;
                    }
                }

                if (commandLineParser.RetrieveValueForParameter("LogFolder", out var logFolderPath))
                {
                    mLogMessagesToFile = true;
                    if (!string.IsNullOrEmpty(logFolderPath))
                    {
                        mLogDirectoryPath = logFolderPath;
                    }
                }

                if (commandLineParser.IsParameterPresent("Q"))
                {
                    mQuietMode = true;
                }

                return(true);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error parsing the command line parameters: " + Environment.NewLine + ex.Message);
            }

            return(false);
        }