public void CopyToScanner(clsMSFileInfoScanner scanner) { // Note: These values will be overridden if /P was used and they are defined in the parameter file scanner.UseCacheFiles = UseCacheFiles; scanner.ReprocessExistingFiles = ReprocessingExistingFiles; scanner.ReprocessIfCachedSizeIsZero = ReprocessIfCachedSizeIsZero; scanner.PlotWithPython = PlotWithPython; scanner.SaveTICAndBPIPlots = SaveTICAndBPIPlots; scanner.SaveLCMS2DPlots = SaveLCMS2DPlots; scanner.LCMS2DPlotMaxPointsToPlot = LCMS2DMaxPointsToPlot; scanner.LCMS2DOverviewPlotDivisor = LCMS2DOverviewPlotDivisor; scanner.TestLCMSGradientColorSchemes = TestLCMSGradientColorSchemes; scanner.CheckCentroidingStatus = CheckCentroidingStatus; scanner.MS2MzMin = MS2MzMin; scanner.DisableInstrumentHash = DisableInstrumentHash; scanner.ScanStart = ScanStart; scanner.ScanEnd = ScanEnd; scanner.ShowDebugInfo = ShowDebugInfo; scanner.ComputeOverallQualityScores = ComputeOverallQualityScores; scanner.CreateDatasetInfoFile = CreateDatasetInfoFile; scanner.CreateScanStatsFile = CreateScanStatsFile; scanner.UpdateDatasetStatsTextFile = UpdateDatasetStatsTextFile; scanner.DatasetStatsTextFileName = DatasetStatsTextFileName; scanner.CheckFileIntegrity = CheckFileIntegrity; scanner.RecheckFileIntegrityForExistingDirectories = ReprocessingExistingFiles; scanner.MaximumTextFileLinesToCheck = MaximumTextFileLinesToCheck; scanner.ComputeFileHashes = ComputeFileHashes; scanner.ZipFileCheckAllData = ZipFileCheckAllData; scanner.IgnoreErrorsWhenRecursing = IgnoreErrorsWhenRecursing; if (LogFilePath.Length > 0) { scanner.LogMessagesToFile = true; scanner.LogFilePath = LogFilePath; } scanner.DatasetIDOverride = DatasetID; scanner.DSInfoDBPostingEnabled = PostResultsToDMS; if (!string.IsNullOrEmpty(ParameterFilePath)) { scanner.LoadParameterFileSettings(ParameterFilePath); } }
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); } }
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 void ShowProgramHelp() { try { var scanner = new clsMSFileInfoScanner(); Console.WriteLine("This program will scan a series of MS data files (or data folders) 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 Finnigan .RAW files, Agilent Ion Trap (.D folders), " + "Agilent or QStar/QTrap .WIFF files, Masslynx .Raw folders, Bruker 1 folders, " + "Bruker XMass analysis.baf files, .UIMF files (IMS), " + "zipped Bruker imaging datasets (with 0_R*.zip files), and " + "DeconTools _isos.csv files"); Console.WriteLine(); Console.WriteLine("Program syntax:" + Environment.NewLine + Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location)); Console.WriteLine(" /I:InputFileNameOrFolderPath [/O:OutputFolderName]"); Console.WriteLine(" [/P:ParamFilePath] [/S[:MaxLevel]] [/IE] [/L:LogFilePath]"); Console.WriteLine(" [/LC[:MaxPointsToPlot]] [/NoTIC] [/LCGrad]"); Console.WriteLine(" [/DI] [/SS] [/QS] [/CC]"); Console.WriteLine(" [/DST:DatasetStatsFileName]"); Console.WriteLine(" [/ScanStart:0] [/ScanEnd:0] [/Debug]"); Console.WriteLine(" [/C] [/M:nnn] [/H] [/QZ]"); Console.WriteLine(" [/CF] [/R] [/Z]"); Console.WriteLine(" [/PostToDMS] [/PythonPlot]"); Console.WriteLine(); Console.WriteLine("Use /I to specify the name of a file or folder to scan; the path can contain the wildcard character *"); Console.WriteLine("The output folder name is optional. If omitted, the output files will be created in the program directory."); Console.WriteLine(); Console.WriteLine("The param file switch is optional. If supplied, it should point to a valid XML parameter file. If omitted, defaults are used."); Console.WriteLine("Use /S to process all valid files in the input folder and subfolders. Include a number after /S (like /S:2) to limit the level of subfolders to examine. Use /IE to ignore errors when recursing."); Console.WriteLine("Use /L to specify the file path for logging messages."); Console.WriteLine(); Console.WriteLine("Use /LC to create 2D LCMS plots (this process could take several minutes for each dataset). By default, plots the top " + clsLCMSDataPlotterOptions.DEFAULT_MAX_POINTS_TO_PLOT + " points. To plot the top 20000 points, use /LC:20000."); Console.WriteLine("Use /LCDiv to specify the divisor to use when creating the overview 2D LCMS plots. By default, uses /LCDiv:" + clsLCMSDataPlotterOptions.DEFAULT_LCMS2D_OVERVIEW_PLOT_DIVISOR + "; use /LCDiv:0 to disable creation of the overview plots."); Console.WriteLine("Use /NoTIC to not save TIC and BPI plots."); Console.WriteLine("Use /LCGrad to save a series of 2D LC plots, each using a different color scheme. The default color scheme is OxyPalettes.Jet"); Console.WriteLine(); Console.WriteLine("Use /DatasetID:# to define the dataset's DatasetID value (where # is an integer); only appropriate if processing a single dataset"); Console.WriteLine("Use /DI to create a dataset info XML file for each dataset."); Console.WriteLine(); Console.WriteLine("Use /SS to create a _ScanStats.txt file for each dataset."); Console.WriteLine("Use /QS to compute an overall quality score for the data in each datasets."); Console.WriteLine("Use /CC to check spectral data for whether it is centroided or profile"); Console.WriteLine(); Console.WriteLine("Use /DST to update (or create) a tab-delimited text file with overview stats for the dataset. " + "If /DI is used, will include detailed scan counts; otherwise, will just have the dataset name, " + "acquisition date, and (if available) sample name and comment. " + "By default, the file is named " + clsDatasetStatsSummarizer.DEFAULT_DATASET_STATS_FILENAME + "; " + "to override, add the file name after the /DST switch, for example /DST:DatasetStatsFileName.txt"); Console.WriteLine(); Console.WriteLine("Use /ScanStart and /ScanEnd to limit the scan range to process; useful for files where the first few scans are corrupt. " + "For example, to start processing at scan 10, use /ScanStart:10"); Console.WriteLine("Use /Debug to display debug information at the console, including showing the scan number prior to reading each scan's data"); Console.WriteLine(); Console.WriteLine("Use /C to perform an integrity check on all known file types; this process will open known file types and " + "verify that they contain the expected This option is only used if you specify an Input Folder and use a wildcard; you will typically also want to use /S when using /C."); Console.WriteLine(("Use /M to define the maximum number of lines to process when checking text or csv files;" + " default is /M:" + clsFileIntegrityChecker.DEFAULT_MAXIMUM_TEXT_FILE_LINES_TO_CHECK)); Console.WriteLine(); Console.WriteLine("Use /H to compute Sha-1 file hashes when verifying file integrity."); Console.WriteLine("Use /QZ to run a quick zip-file validation test when verifying file integrity (the test does not check all data in the .Zip file)."); Console.WriteLine(); Console.WriteLine("Use /CF to save/load information from the acquisition time file (cache file). This option is auto-enabled if you use /C."); Console.WriteLine("Use /R to reprocess files that are already defined in the acquisition time file."); Console.WriteLine("Use /Z to reprocess files that are already defined in the acquisition time file only if their cached size is 0 bytes."); Console.WriteLine(); Console.WriteLine("Use /PostToDMS to store the dataset info in the DMS database. To customize the server name and/or stored procedure to use for posting, use an XML parameter file with settings DSInfoConnectionString, DSInfoDBPostingEnabled, and DSInfoStoredProcedure"); Console.WriteLine(); Console.WriteLine("Use /PythonPlot to create plots with Python instead of OxyPlot"); Console.WriteLine(); Console.WriteLine("Known file extensions: " + CollapseList(scanner.GetKnownFileExtensionsList())); Console.WriteLine("Known folder extensions: " + CollapseList(scanner.GetKnownFolderExtensionsList())); Console.WriteLine(); Console.WriteLine("Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) in 2005"); Console.WriteLine("Version: " + GetAppVersion()); Console.WriteLine(); Console.WriteLine("E-mail: [email protected] or [email protected]"); Console.WriteLine("Website: http://omics.pnl.gov/ or http://panomics.pnnl.gov/"); Console.WriteLine(); // 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); } catch (Exception ex) { ShowErrorMessage("Error displaying the program syntax: " + ex.Message); } }