/// <summary> /// Parse command line arguments /// </summary> /// <param name="args"></param> /// <returns></returns> static CommandLineOptions ProcessCommandLine(string[] args) { CommandLineOptions myArgs = new CommandLineOptions(); CommandLineArguments parser = new CommandLineArguments(); AddParameters(parser); try { parser.Parse(args, myArgs); } catch (Exception e) { Console.Error.WriteLine("\nException while processing command line arguments [{0}]", e.Message); Environment.Exit(-1); } if (myArgs.Help) { const string helpString = "Usage: SeqcosDiscarderUtil.exe [options] <input file> <output file>\n" + "\nDescription: Discard reads based on length (option -l) or quality (-q).\n" + "\n\n/Help (/h)\n Show this Help information" + "\n\n/Verbose (/v)\n Display more information" + "\n\n/DiscardedFile:<String> (/D)\n Filename to store discarded reads [optional]." + "\n\n*** Discard modes ***" + "\n\n/DiscardByLength:<INT > 0> (/l)\n Discard reads with length less than INT." + "\n\n/DiscardByQuality:<INT > 0> (/q)\n Discard reads with mean Phred-based quality score less than INT." + "\n\n/DiscardByRegex:<Pattern> (/r)\n Discard reads based a .NET Framework regular expression pattern. " + "For more information on .NET supported regular expressions, please visit: http://msdn.microsoft.com/en-us/library/az24scfc.aspx" ; Console.WriteLine(helpString); Environment.Exit(-1); } // Process all the arguments if (!File.Exists(myArgs.FileList[0])) { Console.Error.WriteLine("Error: The file {0} could not be found.", myArgs.FileList[0]); Environment.Exit(-1); } if ((myArgs.FileList == null) || (myArgs.FileList.Length < 2)) { Console.Error.WriteLine("Error: Must specify an input and output file."); Environment.Exit(-1); } if ((myArgs.DiscardByLength == 0 && myArgs.DiscardByQuality == 0) || (myArgs.DiscardByLength > 0 && myArgs.DiscardByQuality > 0)) { Console.Error.WriteLine("Error: You must choose either -l or -q discard modes."); Environment.Exit(-1); } if (myArgs.DiscardByRegex != null && !RegexTools.IsValidRegexPattern(myArgs.DiscardByRegex)) { Console.Error.WriteLine("Error: unable to verify your regular expression pattern."); Environment.Exit(-1); } return(myArgs); }
/// <summary> /// Parse command line arguments /// </summary> /// <param name="args"></param> /// <returns></returns> static CommandLineOptions ProcessCommandLine(string[] args) { CommandLineOptions myArgs = new CommandLineOptions(); CommandLineArguments parser = new CommandLineArguments(); AddParameters(parser); try { parser.Parse(args, myArgs); } catch (Exception e) { Console.Error.WriteLine("\nException while processing command line arguments [{0}]", e.Message); Environment.Exit(-1); } if (myArgs.Help) { const string helpString = "Usage: SeqcosTrimmerUtil.exe [options] <input file> <output file>\n" + "\nDescription: Trim reads based on length (use option -l) or quality (use option -q and optionally -l).\n" + "\n/Help (/h)\n Show this Help information" + "\n/Verbose (/v)\n Display more information" + "\n\n*** Trim modes ***" + "\n\n/TrimByLength:<INT > 0> (/l)\n Minimum length that reads will be trimmed to. Reads whose original length is less than INT will not be discarded." + "\n\n/TrimByQuality:<INT > 0> (/q)\n Minimum Phred-based quality score that reads will be trimmed to. Trimming is done by finding the subsequence whose " + "sum of differences between base quality score and cutoff is maximized. If a subsequence cannot be found due to poor quality, the entire read will be " + "discarded. \n\n Can be combined with /l option to set a minimum trimming length (e.g. if '/q 15 /l 10', any read that gets trimmed to a length less than " + "10 will be discarded." + "\n\n/TrimByRegex:<Pattern> (/r)\n Trim reads based on a .NET Framework regular expression pattern. Any matches found, will be stripped from the sequence. " + "For more information on .NET supported regular expressions, please visit: http://msdn.microsoft.com/en-us/library/az24scfc.aspx" + "\n\n*** Trim options ***\n" + "\n\n/Left (/L)\n When combined with /l, trimming occurs from the beginning of the read. When combined with /q, " + "trimming occurs at both ends of the read. For both modes, this option is OFF (i.e. only trim from right side)." + "\n\n/DiscardedFilename:<String> (/D)\n Filename to store discarded reads [optional]." ; Console.WriteLine(helpString); Environment.Exit(-1); } // Process all the arguments if (!File.Exists(myArgs.InputFile)) { Console.Error.WriteLine("Error: The file {0} could not be found.", myArgs.InputFile); Environment.Exit(-1); } if (myArgs.TrimByLength == 0 && myArgs.TrimByQuality == 0 && myArgs.TrimByRegex != null) { Console.Error.WriteLine("You must choose a trim mode."); Environment.Exit(-1); } if (myArgs.TrimByLength < 0) { Console.Error.WriteLine("Trim length must be greater than zero"); Environment.Exit(-1); } if (myArgs.TrimByQuality < 0) { Console.Error.WriteLine("Quality score threshold must be greater than zero"); Environment.Exit(-1); } if (myArgs.TrimByRegex != null && !RegexTools.IsValidRegexPattern(myArgs.TrimByRegex)) { Console.Error.WriteLine("Error: unable to verify your regular expression pattern."); Environment.Exit(-1); } return(myArgs); }