public void TestLogFileName( string logDirectory, string logFileNameBase, string expectedBaseName) { var fileStatsLogger = new SimpleFileStatsLogger { LogFileBaseName = logFileNameBase, LogDirectoryPath = logDirectory, LogMessagesToFile = true }; var fileToFind = ProcessFilesOrDirectoriesBase.GetAppPath(); fileStatsLogger.ProcessFile(fileToFind); Console.WriteLine(); Console.WriteLine("Log file path: " + fileStatsLogger.LogFilePath); var logFileSuffix = expectedBaseName + "_" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; if (!fileStatsLogger.LogFilePath.EndsWith(logFileSuffix)) { Assert.Fail("Unexpected log file name; does not end with " + logFileSuffix); } }
private static void ShowProgramHelp() { try { Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "This program can be used to split apart a protein FASTA file into a number of sections. " + "Although the splitting is random, each section will have a nearly identical number of residues.")); Console.WriteLine(); Console.WriteLine("Program syntax:"); Console.WriteLine(Path.GetFileName(ProcessFilesOrDirectoriesBase.GetAppPath()) + " /I:SourceFastaFile [/O:OutputDirectoryPath]"); Console.WriteLine(" [/N:SplitCount] [/MB:TargetSizeMB] [/P:ParameterFilePath] "); Console.WriteLine(" [/S:[MaxLevel]] [/A:AlternateOutputDirectoryPath] [/R] [/L]"); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The input file path can contain the wildcard character * and should point to a FASTA file. " + "The output directory switch is optional. " + "If omitted, the output file will be created in the same directory as the input file.")); Console.WriteLine(); Console.WriteLine("Use /N to define the number of parts to split the input file into."); Console.WriteLine("For example, /N:10 will split the input FASTA file into 10 parts"); Console.WriteLine(); Console.WriteLine("Alternatively, use /MB to specify the size of the split FASTA files, in MB (minimum {0} MB)", SplitterOptions.MINIMUM_TARGET_FILE_SIZE_MB); Console.WriteLine("For example, /MB:100 will create separate FASTA files that are each ~100 MB in size"); Console.WriteLine(); Console.WriteLine("If both /N and /MB are specified, /N will be ignored"); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The parameter file path is optional. " + "If included, it should point to a valid XML parameter file.")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /S to process all valid files in the input directory and subdirectories. " + "Include a number after /S (like /S:2) to limit the level of subdirectories to examine. " + "When using /S, you can redirect the output of the results using /A. " + "When using /S, you can use /R to re-create the input directory hierarchy in the alternate output directory (if defined).")); Console.WriteLine("Use /L to log messages to a file."); Console.WriteLine(); Console.WriteLine("Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) in 2010"); Console.WriteLine("Version: " + GetAppVersion()); Console.WriteLine(); Console.WriteLine("E-mail: [email protected] or [email protected]"); Console.WriteLine("Website: https://omics.pnl.gov/ or https://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) Thread.Sleep(750); } catch (Exception ex) { Console.WriteLine("Error displaying the program syntax: " + ex.Message); } }
private static void ShowSyntax(string errorMessage = "") { Console.WriteLine(); if (!string.IsNullOrWhiteSpace(errorMessage)) { ConsoleMsgUtils.ShowErrorCustom("Error: " + errorMessage, false); Console.WriteLine(); } var exeName = Path.GetFileName(ProcessFilesOrDirectoriesBase.GetAppPath()); ConsoleWriteWrapped("This program implements a protein parsimony algorithm for grouping proteins with similar peptides."); Console.WriteLine(); Console.WriteLine("Program syntax #1:"); Console.WriteLine(exeName + " InputFilePath.txt [OutputFilePath]"); Console.WriteLine(); ConsoleWriteWrapped("The input file is a tab delimited text file with columns Protein and Peptide " + "(column order does not matter; extra columns are ignored)"); Console.WriteLine(); ConsoleWriteWrapped("If the output file path is not defined, it will be created in the same location " + "as the input file, but with '_parsimony' added to the filename"); Console.WriteLine(); Console.WriteLine("Program syntax #2:"); Console.WriteLine(exeName + " SQLiteDatabase.db3 [TableName]"); Console.WriteLine(); ConsoleWriteWrapped("If the input is a SQLite database file (extension .db, .db3, .sqlite, or\a.sqlite3), " + "proteins and peptides will be read from the specified table, or\afrom " + "T_Row_Metadata if TableName is not provided. The table must have columns " + "Protein and Peptide. Results will be written to tables " + Runner.PARSIMONY_GROUPING_TABLE + " and " + Runner.PARSIMONY_GROUP_MEMBERS_TABLE); Console.WriteLine(); Console.WriteLine("Program written by Josh Aldrich for the Department of Energy (PNNL, Richland, WA)"); Console.WriteLine("Version: " + ProcessFilesOrDirectoriesBase.GetAppVersion(PROGRAM_DATE)); Console.WriteLine(); Console.WriteLine("E-mail: [email protected]"); Console.WriteLine("Website: https://github.com/PNNL-Comp-Mass-Spec/ or https://panomics.pnnl.gov/ or https://www.pnnl.gov/integrative-omics or "); Console.WriteLine(" https://github.com/PNNL-Comp-Mass-Spec"); }
private static void ShowProgramHelp() { try { Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "This program merges the contents of a tab-delimited peptide hit results file " + "(e.g. from X!Tandem or MS-GF+) with the corresponding MASIC results files, " + "appending the relevant MASIC stats for each peptide hit result, " + "writing the merged data to a new tab-delimited text file.")); Console.WriteLine(); Console.WriteLine("It also supports TSV files, e.g. as created by the MzidToTsvConverter"); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "If the input directory includes a MASIC _ReporterIons.txt file, " + "the reporter ion intensities will also be included in the new text file.")); Console.WriteLine(); Console.WriteLine("Program syntax:" + Environment.NewLine + Path.GetFileName(ProcessFilesOrDirectoriesBase.GetAppPath())); Console.WriteLine(" InputFilePathSpec [/M:MASICResultsDirectoryPath] [/O:OutputDirectoryPath]"); Console.WriteLine(" [/N:ScanNumberColumn] [/C] [/Mage] [/Append]"); Console.WriteLine(" [/DartID]"); Console.WriteLine(" [/S:[MaxLevel]] [/A:AlternateOutputDirectoryPath] [/R]"); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The input file should be a tab-delimited file where one column has scan numbers. " + "By default, this program assumes the second column has scan number, but the " + "/N switch can be used to change this (see below).")); Console.WriteLine(); Console.WriteLine("Common input files are:"); Console.WriteLine("- Peptide Hit Results Processor (https://github.com/PNNL-Comp-Mass-Spec/PHRP) tab-delimited files"); Console.WriteLine(" - MS-GF+ syn/fht file (_msgfplus_syn.txt or _msgfplus_fht.txt)"); Console.WriteLine(" - SEQUEST Synopsis or First-Hits file (_syn.txt or _fht.txt)"); Console.WriteLine(" - XTandem _xt.txt file"); Console.WriteLine("- MzidToTSVConverter (https://github.com/PNNL-Comp-Mass-Spec/Mzid-To-Tsv-Converter) .TSV files"); Console.WriteLine(" - This is a tab-delimited text file created from a .mzid file (e.g. from MS-GF+)"); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "If the MASIC result files are not in the same directory as the input file, " + "use /M to define the path to the correct directory.")); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The output directory switch is optional. " + "If omitted, the output file will be created in the same directory as the input file")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /N to change the column number that contains scan number in the input file. " + "The default is 2 (meaning /N:2).")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "When reading data with _ReporterIons.txt files, you can use /C to specify " + "that a separate output file be created for each collision mode type " + "in the input file (typically PQD, CID, and ETD).")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /Mage to specify that the input file is a results file from Mage Extractor. " + "This file will contain results from several analysis jobs; the first column " + "in this file must be Job and the remaining columns must be the standard " + "Synopsis or First-Hits columns supported by PHRPReader. " + "In addition, the input directory must have a file named InputFile_metadata.txt " + "(this file will have been auto-created by Mage Extractor).")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /Append to merge results from multiple datasets together as a single file; " + "this is only applicable when the InputFilePathSpec includes a * wildcard and multiple files are matched. " + "The merged results file will have DatasetID values of 1, 2, 3, etc. " + "along with a second file mapping DatasetID to Dataset Name")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /DartID to only list each peptide once per scan. " + "The Protein column will list the first protein, while the " + "Proteins column will be a comma separated list of all of the proteins. " + "This format is compatible with DART-ID (https://www.ncbi.nlm.nih.gov/pubmed/31260443)")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /S to process all valid files in the input directory and subdirectories. " + "Include a number after /S (like /S:2) to limit the level of subdirectories to examine. " + "When using /S, you can redirect the output of the results using /A to specify an alternate output directory. " + "When using /S, you can use /R to re-create the input directory hierarchy in the alternate output directory (if defined).")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) in 2008; updated in 2019")); Console.WriteLine("Version: " + GetAppVersion()); Console.WriteLine(); Console.WriteLine("E-mail: [email protected] or [email protected]"); Console.WriteLine("Website: https://omics.pnl.gov/ or https://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); } }
private static void Main(string[] args) { try { if (args.Length == 0) { var exePath = ProcessFilesOrDirectoriesBase.GetAppPath(); Console.WriteLine("WriteFaimsXMLFromRawFile version " + GetAppVersion()); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "This program converts a Thermo .raw file with FAIMS scans into a series of .mzXML files, " + "creating one .mzXML file for each FAIMS compensation voltage (CV) value in the .raw file.")); Console.WriteLine(); Console.WriteLine("Syntax:"); Console.WriteLine("{0} InstrumentFile.raw [Output_Directory_Path]", Path.GetFileName(exePath)); Console.WriteLine(); Console.WriteLine("Wild cards are supported, e.g. *.raw"); Console.WriteLine(); // ReSharper disable StringLiteralTypo Console.WriteLine("Program written by Dain Brademan for the Joshua Coon Research Group (University of Wisconsin) in 2018"); Console.WriteLine("Converted to use ThermoFisher.CommonCore DLLs by Matthew Monroe for PNNL (Richland, WA) in 2020"); Console.WriteLine("E-mail: [email protected] or [email protected] or [email protected]"); Console.WriteLine("Website: https://github.com/PNNL-Comp-Mass-Spec/FAIMS-MzXML-Generator/releases or"); Console.WriteLine(" https://github.com/coongroup/FAIMS-MzXML-Generator"); // ReSharper restore StringLiteralTypo return; } var inputFilePathSpec = args[0]; string outputDirectoryPath; if (args.Length > 1) { outputDirectoryPath = args[1]; } else { outputDirectoryPath = string.Empty; } var processor = new FAIMStoMzXMLProcessor(); RegisterEvents(processor); processor.QuickCVLookup = false; var success = processor.ProcessFiles(inputFilePathSpec, outputDirectoryPath); if (success) { Console.WriteLine("Processing completed"); } System.Threading.Thread.Sleep(750); } catch (Exception ex) { ConsoleMsgUtils.ShowError("Error in Program.Main", ex); } }
private static void ShowProgramHelp() { try { Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "This program reads in a .fasta or .txt file containing protein names and sequences (and optionally descriptions). " + "The program also reads in a .txt file containing peptide sequences and protein names (though protein name is optional) " + "then uses this information to compute the sequence coverage percent for each protein.")); Console.WriteLine(); Console.WriteLine("Program syntax:" + Environment.NewLine + Path.GetFileName(ProcessFilesOrDirectoriesBase.GetAppPath())); Console.WriteLine(" /I:PeptideInputFilePath /R:ProteinInputFilePath [/O:OutputDirectoryName]"); Console.WriteLine(" [/P:ParameterFilePath] [/G] [/H] [/M] [/K] [/Debug] [/KeepDB]"); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The input file path can contain the wildcard character *. If a wildcard is present, the same protein input file path " + "will be used for each of the peptide input files matched.")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The output directory name is optional. If omitted, the output files will be created in the same directory as the input file. " + "If included, a subdirectory is created with the name OutputDirectoryName.")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The parameter file path is optional. If included, it should point to a valid XML parameter file.")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /G to ignore I/L differences when finding peptides in proteins or computing coverage.")); Console.WriteLine("Use /H to suppress (hide) the protein sequence in the _coverage.txt file."); Console.WriteLine("Use /M to enable the creation of a protein to peptide mapping file."); Console.WriteLine("Use /K to skip protein coverage computation steps"); Console.WriteLine(); Console.WriteLine("Use /Debug to keep the console open to see additional debug messages"); Console.WriteLine("Use /KeepDB to keep the SQLite database after processing (by default it is deleted)"); Console.WriteLine(); Console.WriteLine("Program written by Matthew Monroe and Nikša Blonder 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: https://omics.pnl.gov or https://panomics.pnl.gov/"); Console.WriteLine(); } catch (Exception ex) { ShowErrorMessage("Error displaying the program syntax: " + ex.Message); } }
private static int Main(string[] args) { var exeName = System.Reflection.Assembly.GetEntryAssembly()?.GetName().Name; var exePath = ProcessFilesOrDirectoriesBase.GetAppPath(); var cmdLineParser = new CommandLineParser <ThermoFAIMStoMzMLOptions>(exeName, GetAppVersion()) { ProgramInfo = "This program converts a Thermo .raw file with FAIMS scans into a series of .mzML files, " + "creating one .mzML file for each FAIMS compensation voltage (CV) value in the .raw file", ContactInfo = "Program written by Matthew Monroe for PNNL (Richland, WA) in 2020" + Environment.NewLine + "E-mail: [email protected] or [email protected]" + Environment.NewLine + "Website: https://omics.pnl.gov/ or https://panomics.pnnl.gov/" }; // Allow /Conf in addition to /ParamFile for specifying a text file with Key=Value options cmdLineParser.AddParamFileKey("Conf"); cmdLineParser.UsageExamples.Add("Program syntax:" + Environment.NewLine + Path.GetFileName(exePath) + " " + "/I:InputFileNameOrDirectoryPath [/O:OutputDirectoryName] " + Environment.NewLine + "[/S] [/R:LevelsToRecurse] [/Preview] " + Environment.NewLine + "[/IE] [/L] [/LogFile:LogFileName]"); 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); } try { var processor = new ThermoFAIMStoMzMLProcessor(options); processor.DebugEvent += Processor_DebugEvent; processor.ErrorEvent += Processor_ErrorEvent; processor.WarningEvent += Processor_WarningEvent; processor.StatusEvent += Processor_MessageEvent; processor.ProgressUpdate += Processor_ProgressUpdate; bool success; if (options.RecurseDirectories) { success = processor.ProcessFilesAndRecurseDirectories( options.InputDataFilePath, options.OutputDirectoryPath, options.MaxLevelsToRecurse); } else { success = processor.ProcessFilesWildcard( options.InputDataFilePath, options.OutputDirectoryPath); } if (success) { return(0); } return(-1); } catch (Exception ex) { ShowErrorMessage("Error occurred in modMain->Main", ex); return(-1); } }
private static void ShowProgramHelp() { try { Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "This program will read a Thermo .RAW file, .mzML file, .mzXML file, or Agilent LC/MSD .CDF/.MGF file combo " + "and create a selected ion chromatogram (SIC) for each parent ion. " + "It also supports extracting reporter ion intensities (e.g. iTRAQ or TMT), " + "and additional metadata from mass spectrometer data files.")); Console.WriteLine(); Console.WriteLine("Program syntax:" + Environment.NewLine + Path.GetFileName(ProcessFilesOrDirectoriesBase.GetAppPath())); Console.WriteLine(" /I:InputFilePath.raw [/O:OutputDirectoryPath]"); Console.WriteLine(" [/P:ParamFilePath] [/D:DatasetID or DatasetLookupFilePath] "); Console.WriteLine(" [/S:[MaxLevel]] [/A:AlternateOutputDirectoryPath] [/R]"); Console.WriteLine(" [/L:[LogFilePath]] [/LogDir:LogDirPath] [/SF:StatusFileName] [/Q]"); Console.WriteLine(); Console.WriteLine("The input file path can contain the wildcard character *"); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The output directory name is optional. " + "If omitted, the output files will be created in the same directory as the input file. " + "If included, then a subdirectory is created with the name OutputDirectoryName.")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The parameter file switch /P is optional. " + "If supplied, it should point to a valid MASIC XML parameter file. If omitted, defaults are used.")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "The /D switch can be used to specify the Dataset ID of the input file; if omitted, 0 will be used")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Alternatively, a lookup file can be specified with the /D switch (useful if processing multiple files using * or /S). " + "The lookup file is a comma, space, or tab delimited file with two columns:" + Environment.NewLine + "Dataset Name and Dataset ID")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /S to process all valid files in the input directory and subdirectories. " + "Include a number after /S (like /S:2) to limit the level of subdirectories to examine.")); Console.WriteLine("When using /S, you can redirect the output of the results using /A."); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "When using /S, you can use /R to re-create the input directory hierarchy in the alternate output directory (if defined).")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /L or /Log to specify that a log file should be created. " + "Use /L:LogFilePath to specify the name (or full path) for the log file.")); Console.WriteLine(); Console.WriteLine(ConsoleMsgUtils.WrapParagraph( "Use /SF to specify the name to use for the Masic Status file (default is " + clsMASICOptions.DEFAULT_MASIC_STATUS_FILE_NAME + ").")); Console.WriteLine(); Console.WriteLine("The optional /Q switch will prevent the progress window from being shown"); Console.WriteLine(); Console.WriteLine("Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) in 2003"); Console.WriteLine("Version: " + GetAppVersion()); Console.WriteLine(); Console.WriteLine("E-mail: [email protected] or [email protected]"); Console.WriteLine("Website: https://omics.pnl.gov/ or https://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) Thread.Sleep(750); } catch (Exception ex) { ShowErrorMessage("Error displaying the program syntax: " + ex.Message); } }