コード例 #1
0
        public static int Main(string[] args)
        {
            var exeName       = System.Reflection.Assembly.GetEntryAssembly()?.GetName().Name;
            var exePath       = PRISM.FileProcessor.ProcessFilesOrDirectoriesBase.GetAppPath();
            var cmdLineParser = new CommandLineParser <CommandLineOptions>(exeName, GetAppVersion());

            var scannerInfo = new clsMSFileInfoScanner();

            cmdLineParser.ProgramInfo = "This program will scan a series of MS data files (or data directories) and " +
                                        "extract the acquisition start and end times, number of spectra, and the " +
                                        "total size of the data, saving the values in the file " +
                                        clsMSFileInfoScanner.DefaultAcquisitionTimeFilename + ". " +
                                        "Supported file types are Thermo .RAW files, Agilent Ion Trap (.D directories), " +
                                        "Agilent or QStar/QTrap .WIFF files, MassLynx .Raw directories, Bruker 1 directories, " +
                                        "Bruker XMass analysis.baf files, .UIMF files (IMS), " +
                                        "zipped Bruker imaging datasets (with 0_R*.zip files), and " +
                                        "DeconTools _isos.csv files" + Environment.NewLine + Environment.NewLine +
                                        "Known file extensions: " + CollapseList(scannerInfo.GetKnownFileExtensionsList()) + Environment.NewLine +
                                        "Known directory extensions: " + CollapseList(scannerInfo.GetKnownDirectoryExtensionsList());
            cmdLineParser.ContactInfo = "Program written by Matthew Monroe for PNNL (Richland, WA) in 2005" + Environment.NewLine +
                                        "E-mail: [email protected] or [email protected]" + Environment.NewLine + "Website: https://omics.pnl.gov/ or https://panomics.pnnl.gov/";

            cmdLineParser.UsageExamples.Add("Program syntax:" + Environment.NewLine + Path.GetFileName(exePath) +
                                            " /I:InputFileNameOrDirectoryPath [/O:OutputDirectoryName]" +
                                            " [/P:ParamFilePath] [/S[:MaxLevel]] [/IE] [/L:LogFilePath]" +
                                            " [/LC[:MaxPointsToPlot]] [/NoTIC] [/LCGrad]" +
                                            " [/DI] [/SS] [/QS] [/CC]" +
                                            " [/MS2MzMin:MzValue] [/NoHash]" +
                                            " [/DST:DatasetStatsFileName]" +
                                            " [/ScanStart:0] [/ScanEnd:0] [/Debug]" +
                                            " [/C] [/M:nnn] [/H] [/QZ]" +
                                            " [/CF] [/R] [/Z]" +
                                            " [/PostToDMS] [/PythonPlot]");

            var result  = cmdLineParser.ParseArgs(args);
            var options = result.ParsedResults;

            if (!result.Success || !options.Validate())
            {
                // Delay for 750 msec in case the user double clicked this file from within Windows Explorer (or started the program via a shortcut)
                System.Threading.Thread.Sleep(750);
                return(-1);
            }

            mLastProgressTime = DateTime.UtcNow;

            try
            {
                var scanner = new clsMSFileInfoScanner();

                scanner.DebugEvent     += MSFileScanner_DebugEvent;
                scanner.ErrorEvent     += MSFileScanner_ErrorEvent;
                scanner.WarningEvent   += MSFileScanner_WarningEvent;
                scanner.StatusEvent    += MSFileScanner_MessageEvent;
                scanner.ProgressUpdate += MSFileScanner_ProgressUpdate;

                options.CopyToScanner(scanner);
                scanner.ShowCurrentProcessingOptions();

                bool processingError;

                int returnCode;
                if (options.RecurseDirectories)
                {
                    if (scanner.ProcessMSFilesAndRecurseDirectories(options.InputDataFilePath, options.OutputDirectoryName, options.MaxLevelsToRecurse))
                    {
                        returnCode      = 0;
                        processingError = false;
                    }
                    else
                    {
                        returnCode      = (int)scanner.ErrorCode;
                        processingError = true;
                    }
                }
                else
                {
                    if (scanner.ProcessMSFileOrDirectoryWildcard(options.InputDataFilePath, options.OutputDirectoryName, true))
                    {
                        returnCode      = 0;
                        processingError = false;
                    }
                    else
                    {
                        returnCode      = (int)scanner.ErrorCode;
                        processingError = true;
                    }
                }

                if (processingError)
                {
                    if (returnCode != 0)
                    {
                        ShowErrorMessage("Error while processing: " + scanner.GetErrorMessage());
                    }
                    else
                    {
                        ShowErrorMessage("Unknown error while processing (ProcessMSFileOrDirectoryWildcard returned false but the ErrorCode is 0)");
                    }

                    System.Threading.Thread.Sleep(1500);
                }
                else if (scanner.ErrorCode == iMSFileInfoScanner.eMSFileScannerErrorCodes.MS2MzMinValidationWarning)
                {
                    ConsoleMsgUtils.ShowWarning("MS2MzMin validation warning: " + scanner.MS2MzMinValidationMessage);
                }

                scanner.SaveCachedResults();

                return(returnCode);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error occurred in modMain->Main", ex);
                return(-1);
            }
        }
コード例 #2
0
        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);
        }