Пример #1
0
        static int Main(string[] args)
        {
            var appName = System.Reflection.Assembly.GetEntryAssembly()?.GetName().Name;
            var exeName = Path.GetFileName(PRISM.FileProcessor.ProcessFilesOrDirectoriesBase.GetAppPath());

            var parser = new CommandLineParser <CommandLineOptions>(appName, PRISM.FileProcessor.ProcessFilesOrDirectoriesBase.GetAppVersion(PROGRAM_DATE))
            {
                ProgramInfo = ConsoleMsgUtils.WrapParagraph(
                    "This program contacts DMS to retrieve a list of Bionet computers (hosts). " +
                    "It pings each computer to see which respond, then optionally contacts DMS with the list of active hosts.") + Environment.NewLine + Environment.NewLine +
                              ConsoleMsgUtils.WrapParagraph(
                    "By default, it contacts DMS to retrieve the list of bionet hosts, then pings each one (appending suffix .bionet)." +
                    "Alternatively, use /Manual to define a list of hosts to contact (.bionet is not auto-appended). " +
                    "Or use /File to specify a text file listing one host per line (.bionet is not auto-appended)." +
                    "The /File switch is useful when used in conjunction with script Export_DNS_Entries.ps1, " +
                    "which can be run daily via a scheduled task to export all hosts and IP addresses " +
                    "tracked by the bionet DNS server (Gigasax).") + Environment.NewLine + Environment.NewLine +
                              ConsoleMsgUtils.WrapParagraph(
                    "When using /File, this program will still contact DMS to determine which hosts are inactive, " +
                    "and it will skip those hosts.  Use /HideInactive to not see the names of the skipped hosts"),
                ContactInfo = "Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA)" + Environment.NewLine +
                              "E-mail: [email protected] or [email protected]" + Environment.NewLine +
                              "Website: https://github.com/PNNL-Comp-Mass-Spec/ or https://panomics.pnnl.gov/ or https://www.pnnl.gov/integrative-omics"
            };

            parser.UsageExamples.Add(
                "Program syntax:" + Environment.NewLine +
                exeName + Environment.NewLine +
                " [/Manual:Host1,Host2,Host3] [/File:HostListFile] [/HideInactive]" + Environment.NewLine +
                " [/Simulate] [/DB] [/DBAdd] [/NoDB]");

            var result = parser.ParseArgs(args);

            mOptions = result.ParsedResults;

            // Running with no command-line arguments specified is valid.
            if (args.Length > 0 && !result.Success)
            {
                if (parser.CreateParamFileProvided)
                {
                    return(0);
                }

                // 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
            {
                PingBionetComputers(mOptions.HostNameFile, mOptions.HostOverrideList);
                return(0);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error occurred in Program->Main", ex);
                return(-1);
            }
        }
        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);
            }
        }
Пример #3
0
        private static void ShowProgramHelp()
        {
            var exePath = PRISM.FileProcessor.ProcessFilesOrDirectoriesBase.GetAppPath();

            Console.WriteLine("Program syntax:" + Environment.NewLine + Path.GetFileName(exePath));
            Console.WriteLine("  InputFilePath.raw [/GetFilters] [/Centroid] [/Sum] [/Start:Scan] [/End:Scan]");
            Console.WriteLine("  [/ScanInfo:IntervalScans] [/NoScanData] [/NoScanEvents] [/NoCE]");
            Console.WriteLine("  [/NoMethods] [/MSLevelOnly] [/Trace]");

            Console.WriteLine();
            Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                  "Running this program without any parameters it will process file " + DEFAULT_FILE_PATH));
            Console.WriteLine();
            Console.WriteLine("The first parameter specifies the file to read");
            Console.WriteLine();
            Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                  "Use /GetFilters to compile and display a list of scan filters in any MASIC _ScanStatsEx.txt files in the working directory"));
            Console.WriteLine();
            Console.WriteLine("Without /GetFilters, data is read from the file, either from all scans, or a scan range");
            Console.WriteLine("Use /Start and /End to limit the scan range to process");
            Console.WriteLine("If /Start and /End are not provided, will read every 21 scans");
            Console.WriteLine();
            Console.WriteLine("Use /Centroid to centroid the data when reading");
            Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                  "Use /Sum to test summing the data across 15 scans " +
                                  "(each spectrum will be shown twice; once with summing and once without)"));
            Console.WriteLine();
            Console.WriteLine("While reading data, the scan number and elution time is displayed for each scan.");
            Console.WriteLine("To show this info every 5 scans, use /ScanInfo:5");
            Console.WriteLine();
            Console.WriteLine("Use /NoScanData to skip loading any scan data");
            Console.WriteLine("Use /NoScanEvents to skip loading any scan events");
            Console.WriteLine("Use /NoCE to skip trying to determine collision energies");
            Console.WriteLine("Use /NoMethods to skip loading instrument methods");
            Console.WriteLine();
            Console.WriteLine("Use /MSLevelOnly to only load MS levels using GetMSLevel");
            Console.WriteLine("Use /TestFilters to test the parsing of a set of standard scan filters");
            Console.WriteLine();
            Console.WriteLine("Use /Trace to display additional debug messages");
            Console.WriteLine();
            Console.WriteLine("Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) in 2012");
            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 1.5 seconds in case the user double clicked this file from within Windows Explorer (or started the program via a shortcut)
            System.Threading.Thread.Sleep(1500);
        }
Пример #4
0
        public void TestWrapParagraph(string textToWrap, int wrapWidth, int spaceIndentCount, int expectedLineCount, int expectedCharacterCount)
        {
            if (spaceIndentCount > 0)
            {
                // Indent all of the wrapped lines by the given amount
                textToWrap = new string(' ', spaceIndentCount) + textToWrap;
            }

            var wrappedText = ConsoleMsgUtils.WrapParagraph(textToWrap, wrapWidth);

            Console.WriteLine(wrappedText);

            var wrappedLines = wrappedText.Split('\n');

            var charCount = 0;
            var lineCount = 0;

            foreach (var textLine in wrappedLines)
            {
                charCount += textLine.Length;
                lineCount++;
            }

            Console.WriteLine();
            Console.WriteLine("Wrapping to {0} characters per line gives {1} lines of wrapped text and {2} total characters", wrapWidth, lineCount, charCount);
            if (spaceIndentCount > 0)
            {
                Console.WriteLine("Indented text by {0} characters", spaceIndentCount);
            }

            if (expectedLineCount > 0)
            {
                Assert.AreEqual(expectedLineCount, lineCount,
                                "Text wrapped to {0} lines instead of {1} lines", lineCount, expectedLineCount);
            }
            else
            {
                Console.WriteLine("Skipped line count validation");
            }

            if (expectedCharacterCount > 0)
            {
                Assert.AreEqual(expectedCharacterCount, charCount,
                                "Wrapped text has {0} characters instead of {1} characters", charCount, expectedCharacterCount);
            }
            else
            {
                Console.WriteLine("Skipped character count validation");
            }
        }
        private static void ShowProgramHelp()
        {
            var exeName = Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            try
            {
                Console.WriteLine();
                Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                      "This program searches for Visual Studio project files (.csproj and.vsproj) " +
                                      "that reference a specific NuGet package and updates the referenced version " +
                                      "to a newer version if necessary.  It also updates packages.config files."));
                Console.WriteLine();
                Console.WriteLine("Program syntax:" + Environment.NewLine + exeName);
                Console.WriteLine(" DirectoryPath /Package:PackageName /Version:PackageVersion");
                Console.WriteLine(" [/S] [/Preview] [/Apply] [/Rollback] [/Verbose]");
                Console.WriteLine();
                Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                      "DirectoryPath is the path to the directory to search for Visual Studio project files. " +
                                      "If DirectoryPath is not specified, the current directory is used"));
                Console.WriteLine();
                Console.WriteLine("Use /S to recurse subdirectories");
                Console.WriteLine();
                Console.WriteLine("Specify the NuGet package name using /Package or using /P");
                Console.WriteLine("Specify the NuGet package version using /Version or using /V");
                Console.WriteLine("");
                Console.WriteLine("By default will not update files (/Preview is implied)");
                Console.WriteLine("Use /Apply to save changes");
                Console.WriteLine();
                Console.WriteLine("Use /Rollback to downgrade versions if a newer version is found");
                Console.WriteLine();
                Console.WriteLine("Use /Verbose to see every Visual Studio project file processed");
                Console.WriteLine("Otherwise, only projects containing package PackageName will be shown");
                Console.WriteLine();
                Console.WriteLine("Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) in 2017");
                Console.WriteLine("Version: " + GetAppVersion());
                Console.WriteLine();

                Console.WriteLine("E-mail: [email protected] or [email protected]");
                Console.WriteLine("Website: https://github.com/PNNL-Comp-Mass-Spec/ or https://panomics.pnnl.gov/ or https://www.pnnl.gov/integrative-omics");
                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);
            }
        }
Пример #6
0
        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 void ShowProgramHelp()
        {
            var exeName = Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            try
            {
                Console.WriteLine();
                Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                      "This program estimates the value of Pi, using either a single thread or multiple threads. " +
                                      "This can be used to simulate varying levels of load on a computer"));
                Console.WriteLine();
                Console.WriteLine("Program syntax:" + Environment.NewLine + exeName);
                Console.WriteLine(" [/Mode:{1,2,3,4}] [/RunTime:Seconds] [/Threads:ThreadCount] [/UseTiered] [/Preview]");
                Console.WriteLine();
                Console.WriteLine("/Mode:1 is serial calculation (single thread)");
                Console.WriteLine("/Mode:2 uses a Parallel.For loop");
                Console.WriteLine("/Mode:3 uses the Task Parallel Library (TPL) framework, initializing with factories");
                Console.WriteLine("/Mode:4 uses the Task Parallel Library (TPL) framework, but without factories");

                Console.WriteLine();
                Console.WriteLine("Specify the runtime, in seconds, using /RunTime");
                Console.WriteLine();
                Console.WriteLine("Specify the number of threads to use with /Threads");
                Console.WriteLine("If not specified, all cores will be used; " + GetCoreCount() + " on this computer");
                Console.WriteLine();
                Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                      "Use /UseTiered with modes 2 through 4 to indicate that different threads should run for tiered runtimes " +
                                      "(each thread will run for a shorter time than the previous thread)"));
                Console.WriteLine();
                Console.WriteLine("Use /Preview to preview the threads that would be started");
                Console.WriteLine();
                Console.WriteLine("Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) in 2015");
                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 1 second in case the user double clicked this file from within Windows Explorer (or started the program via a shortcut)
                ConsoleMsgUtils.SleepSeconds(1);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error displaying the program syntax", ex);
            }
        }
        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);
            }
        }
Пример #9
0
        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 text file containing peptide sequences. " +
                                      "It then searches the specified .fasta or text file containing protein names and sequences " +
                                      "(and optionally descriptions) to find the proteins that contain each peptide. " +
                                      "It will also compute the sequence coverage percent for each protein (disable using /K)."));
                Console.WriteLine();
                Console.WriteLine("Program syntax:" + Environment.NewLine + Path.GetFileName(Assembly.GetExecutingAssembly().Location));
                Console.WriteLine(" /I:PeptideInputFilePath /R:ProteinInputFilePath");
                Console.WriteLine(" [/O:OutputDirectoryName] [/P:ParameterFilePath] [/F:FileFormatCode] ");
                Console.WriteLine(" [/N:InspectParameterFilePath] [/G] [/H] [/K] [/A]");
                Console.WriteLine(" [/L[:LogFilePath]] [/LogDir:LogDirectoryPath] [/VerboseLog] [/Q]");
                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, then 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("Use /F to specify the peptide input file format code.  Options are:");
                Console.WriteLine("   " + clsPeptideToProteinMapEngine.ePeptideInputFileFormatConstants.AutoDetermine + "=Auto Determine: Treated as /F:1 unless name ends in _inspect.txt, then /F:3");
                Console.WriteLine("   " + clsPeptideToProteinMapEngine.ePeptideInputFileFormatConstants.PeptideListFile + "=Peptide sequence in the 1st column (subsequent columns are ignored)");
                Console.WriteLine("   " + clsPeptideToProteinMapEngine.ePeptideInputFileFormatConstants.ProteinAndPeptideFile + "=Protein name in 1st column and peptide sequence 2nd column");
                Console.WriteLine("   " + clsPeptideToProteinMapEngine.ePeptideInputFileFormatConstants.InspectResultsFile + "=Inspect search results file (peptide sequence in the 3rd column)");
                Console.WriteLine("   " + clsPeptideToProteinMapEngine.ePeptideInputFileFormatConstants.MSGFPlusResultsFile + "=MS-GF+ search results file (peptide sequence in the column titled 'Peptide'; optionally scan number in the column titled 'Scan')");
                Console.WriteLine("   " + clsPeptideToProteinMapEngine.ePeptideInputFileFormatConstants.PHRPFile + "=SEQUEST, X!Tandem, Inspect, or MS-GF+ PHRP data file");
                Console.WriteLine();

                Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                      "When processing an Inspect search results file, use /N to specify the Inspect parameter file used " +
                                      "(required for determining the mod names embedded in the identified peptides)."));
                Console.WriteLine();

                Console.WriteLine("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 /K to skip the protein coverage computation steps (enabling faster processing)");
                Console.WriteLine(ConsoleMsgUtils.WrapParagraph(
                                      "Use /A to create a copy of the source file, but with a new column listing the mapped protein for each peptide. " +
                                      "If a peptide maps to multiple proteins, then multiple lines will be listed"));

                Console.WriteLine("Use /L to create a log file, optionally specifying the file name");
                Console.WriteLine("Use /LogDir to define the directory in which the log file should be created");
                Console.WriteLine("Use /VerboseLog to create a detailed log file");
                Console.WriteLine();
                Console.WriteLine("Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) in 2008");
                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();

                // 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);
            }
        }
Пример #11
0
 private static void ConsoleWriteWrapped(string textToWrap)
 {
     Console.WriteLine(ConsoleMsgUtils.WrapParagraph(textToWrap));
 }
Пример #12
0
        /// <summary>
        /// Program entry point
        /// </summary>
        /// <param name="args"></param>
        /// <returns>0 if no error, error code if an error</returns>
        private static int Main(string[] args)
        {
            var programName = System.Reflection.Assembly.GetEntryAssembly()?.GetName().Name;
            var exeName     = Path.GetFileName(PRISM.FileProcessor.ProcessFilesOrDirectoriesBase.GetAppPath());

            var parser = new CommandLineParser <CommandLineOptions>(programName, GetAppVersion())
            {
                ProgramInfo = "This program compares two or more files (typically in separate directories) to check whether the " +
                              "start of the files match, the end of the files match, and selected sections inside the files also match. " +
                              "Useful for comparing large files without reading the entire file. " +
                              "Alternatively, you can provide two directory paths and the program will compare all of the files " +
                              "in the first directory to the identically named files in the second directory.",

                ContactInfo = "Program written by Matthew Monroe for the Department of Energy (PNNL, Richland, WA)" +
                              Environment.NewLine + Environment.NewLine +
                              "E-mail: [email protected] or [email protected]" + Environment.NewLine +
                              "Website: https://github.com/PNNL-Comp-Mass-Spec/ or https://panomics.pnnl.gov/ or https://www.pnnl.gov/integrative-omics"
            };

            parser.UsageExamples.Add(
                "Program syntax 1: compare two files; in this case the filenames cannot have wildcards" +
                Environment.NewLine +
                " " + exeName + " FilePath1 FilePath2" + Environment.NewLine +
                " [/N:NumberOfSamples] [/Bytes:SampleSizeBytes]" + Environment.NewLine +
                " [/KB:SizeKB] [/MB:SizeMB] [/GB:SizeGB]" + Environment.NewLine +
                " [/L[:LogFilePath]] [/LogDirectory:LogDirectoryPath]");

            parser.UsageExamples.Add("Program syntax 2: compare two directories (including all subdirectories)" + Environment.NewLine +
                                     " " + exeName + " DirectoryPath1 DirectoryPath2" + Environment.NewLine +
                                     " [/N:NumberOfSamples] [/Bytes:SampleSizeBytes]" + Environment.NewLine +
                                     " [/L] [/LogDirectory]");

            parser.UsageExamples.Add(ConsoleMsgUtils.WrapParagraph(
                                         "Program syntax 3: compare a set of files in one directory to identically named files in a separate directory. " +
                                         "Use wildcards in FileMatchSpec to specify the files to examine") + Environment.NewLine +
                                     " " + exeName + " FileMatchSpec DirectoryPathToExamine" + Environment.NewLine +
                                     " [/N:NumberOfSamples] [/Bytes:SampleSizeBytes]" + Environment.NewLine +
                                     " [/L] [/LogDirectory]");

            parser.UsageExamples.Add(ConsoleMsgUtils.WrapParagraph(
                                         "Program syntax 4: compare a DMS dataset's files between the storage server and the archive. " +
                                         "The first argument must be DMS; the second argument is the Dataset Name.") + Environment.NewLine +
                                     " " + exeName + " DMS DatasetNameToCheck" + Environment.NewLine +
                                     " [/N:NumberOfSamples] [/Bytes:SampleSizeBytes]" + Environment.NewLine +
                                     " [/L] [/LogDirectory]");

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

            if (!result.Success || !options.Validate())
            {
                if (parser.CreateParamFileProvided)
                {
                    return(0);
                }

                // Delay for 1000 msec in case the user double clicked this file from within Windows Explorer (or started the program via a shortcut)
                ProgRunner.SleepMilliseconds(1000);
                return(-1);
            }

            try
            {
                int returnCode;

                mProcessingClass = new SampledFileComparer
                {
                    NumberOfSamples = options.NumberOfSamples,
                    SampleSizeBytes = options.SampleSizeBytes,
                    IgnoreErrorsWhenUsingWildcardMatching = true,
                    LogMessagesToFile = options.LogMessagesToFile,
                    LogFilePath       = options.LogFilePath,
                    LogDirectoryPath  = options.LogDirectoryPath
                };

                mProcessingClass.ProgressUpdate += ProcessingClass_ProgressChanged;
                mProcessingClass.ProgressReset  += ProcessingClass_ProgressReset;

                if (string.IsNullOrWhiteSpace(options.InputFileOrDirectoryPath))
                {
                    ShowErrorMessage("Base file or directory to compare is empty");
                    return(-1);
                }

                bool success;

                if (string.Equals(options.InputFileOrDirectoryPath, "DMS", StringComparison.OrdinalIgnoreCase) &&
                    options.ComparisonFileOrDirectoryPath.IndexOf("\\", StringComparison.Ordinal) < 0)
                {
                    // InputFile is "DMS"

                    // Treat ComparisonFile as a dataset name and compare files on the storage server to files in the archive
                    // This feature does not yet support files in MyEMSL
                    success = mProcessingClass.ProcessDMSDataset(options.ComparisonFileOrDirectoryPath);
                }
                else
                {
                    // Comparing two files or two directories
                    success = mProcessingClass.ProcessFilesWildcard(options.InputFileOrDirectoryPath, options.ComparisonFileOrDirectoryPath);
                }

                if (success)
                {
                    returnCode = 0;
                }
                else
                {
                    returnCode = (int)mProcessingClass.ErrorCode;
                    if (returnCode != 0)
                    {
                        ShowErrorMessage("Error while processing: " + mProcessingClass.GetErrorMessage());
                    }
                }

                return(returnCode);
            }
            catch (Exception ex)
            {
                ShowErrorMessage("Error occurred in modMain->Main: " + ex.Message);
                return(-1);
            }
        }
Пример #13
0
        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);
            }
        }