コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }