public void InvalidateParse()
        {
            AggregateNumbers aggregateNos = new AggregateNumbers();
            CommandLineArguments parser = new CommandLineArguments();

            //add parameters
            parser.Parameter(ArgumentType.Required, "InputFile", ArgumentValueType.String, "i", "File containing numbers to add");
            parser.Parameter(ArgumentType.Required, "ResultFile", ArgumentValueType.String, "r", "File to store output");
            string outputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            //pass parameter without value
            try
            {
                string[] args = { "/InputFile:", "/ResultFile:" + outputfileName };
                parser.Parse(args, aggregateNos);
                Assert.Fail();
            }
            catch (ArgumentParserException ex)
            {
                ApplicationLog.WriteLine("CommandLineArguments P2: Successfully caught InvalidArgumentValueException : " + ex.Message);
            }

            //pass invalid starting character
            try
            {
                string[] args = { "*/ResultFile:" + outputfileName };
                parser.Parse(args, aggregateNos);
                Assert.Fail();
            }
            catch (ArgumentParserException ex)
            {
                ApplicationLog.WriteLine("CommandLineArguments P2: Successfully caught ArgumentNullException : " + ex.Message);
            }
        }
        public void ValidateGetEnumerator()
        {
            AggregateNumbers aggregateNos = new AggregateNumbers();
            CommandLineArguments parser = new CommandLineArguments();

            //add parameters
            parser.Parameter(ArgumentType.Required, "InputFile", ArgumentValueType.String, "i", "File containing numbers to add");
            parser.Parameter(ArgumentType.Required, "ResultFile", ArgumentValueType.String, "r", "File to store output");
            string inputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string outputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string[] args = { "-InputFile:" + inputfileName, "-ResultFile:" + outputfileName };
            parser.Parse(args, aggregateNos);
            IEnumerator parsedVals =  parser.GetEnumerator();
            Assert.IsNotNull(parsedVals);
            string current = string.Empty;
            int count = 0;
            parser.Reset();
            while (parser.MoveNext())
            {
                current = parser.Current.ToString();
                ApplicationLog.WriteLine(current);
                count++;
            }
            Assert.AreEqual(2, count);
        }
Ejemplo n.º 3
0
        public static VennToolArguments ProcessCommandLineArguments(string[] args)
        {
            VennToolArguments parsedArgs = new VennToolArguments();
            CommandLineArguments parser = new CommandLineArguments();
            
            // Add parameters
            parser.Parameter(ArgumentType.DefaultArgument, "regionArray", ArgumentValueType.MultipleInts, "", 
                "Values 3 or 7 values for regions in chart, [A B AB] or [A B C AB AC BC ABC]");
            parser.Parameter(ArgumentType.Optional, "xl", ArgumentValueType.String, "", "XL OutputFile");
            parser.Parameter(ArgumentType.Optional, "polar", ArgumentValueType.Bool, "", "Write result using polar coordinates");
            parser.Parameter(ArgumentType.Optional, "presort", ArgumentValueType.Bool, "", "PreSort .BED files prior to processing");
            parser.Parameter(ArgumentType.Optional, "Verbose", ArgumentValueType.Bool, "v", "Display Verbose output during processing");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "h", "Print the help information.");

            try
            {
                parser.Parse(args, parsedArgs);
            }
            catch(ArgumentParserException ex)
            {
                Console.Error.WriteLine(ex.Message);
                DisplayHelpScreen();
                Environment.Exit(-1);
            }

            if (parsedArgs.Help)
            {
                DisplayHelpScreen();
                Environment.Exit(-1);
            }

            /*
             * Do any and all follow-up command line argument validation required
             */

            if ((parsedArgs.regionArray == null)
                || ((parsedArgs.regionArray.Length != 3) && (parsedArgs.regionArray.Length != 7)))
            {
                Console.Error.WriteLine("\nProcessCommandLineArguments failed to find the expected number of arguments. [3 or 7]");
                Environment.Exit(-1);
            }

            if (parsedArgs.Verbose)
            {
                Console.WriteLine(parsedArgs.Verbose);
                Console.Write("RegionArray Size: {0}\n   [", parsedArgs.regionArray.Length);
                for (int i = 0; i < parsedArgs.regionArray.Length; ++i)
                {
                    if (i == 0)
                        Console.Write(parsedArgs.regionArray[i]);
                    else
                        Console.Write(", {0}", parsedArgs.regionArray[i]);
                }
                Console.WriteLine("]");
            }

            return parsedArgs;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parses NUCmer command line parameters.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void Alignment(string[] args)
        {
            NucmerArguments arguments = new NucmerArguments();
            CommandLineArguments parser = new CommandLineArguments();

            // Add Nucmer parameters
            parser.Parameter(ArgumentType.DefaultArgument, "FilePath", ArgumentValueType.MultipleUniqueStrings, "", "File path");
            parser.Parameter(ArgumentType.Optional, "Mum", ArgumentValueType.Bool, "m", "Use anchor matches that are unique in both the reference and query.");
            parser.Parameter(ArgumentType.Optional, "MumReference", ArgumentValueType.Bool, "r", "Use anchor matches that are unique in the reference but not necessarily unique in the query (default behavior).");
            parser.Parameter(ArgumentType.Optional, "MaxMatch", ArgumentValueType.Bool, "x", "Use all anchor matches regardless of their uniqueness.");
            parser.Parameter(ArgumentType.Optional, "BreakLength", ArgumentValueType.Int, "b", "Distance an alignment extension will attempt to extend poor scoring regions before giving up (default 200).");
            parser.Parameter(ArgumentType.Optional, "MinCluster", ArgumentValueType.Int, "c", "Minimum cluster length (default 65).");
            parser.Parameter(ArgumentType.Optional, "DiagFactor", ArgumentValueType.Int, "d", "Maximum diagonal difference factor for clustering, i.e. diagonal difference / match separation (default 0.12).");
            parser.Parameter(ArgumentType.Optional, "Forward", ArgumentValueType.Bool, "f", "Use only the forward strand of the query sequence.");
            parser.Parameter(ArgumentType.Optional, "MaxGap", ArgumentValueType.Int, "g", "Maximum gap between two adjacent matches in a cluster (default 90).");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "h", "Print the help information.");
            parser.Parameter(ArgumentType.Optional, "MinMatch", ArgumentValueType.Int, "l", "Minimum length of an maximal exact match (default 20).");
            parser.Parameter(ArgumentType.Optional, "OutputFile", ArgumentValueType.String, "o", "Output file");
            parser.Parameter(ArgumentType.Optional, "Reverse", ArgumentValueType.Bool, "e", "Use only the reverse complement of the query sequence.");
            parser.Parameter(ArgumentType.Optional, "NotExtend", ArgumentValueType.Bool, "n", "Toggle the outward extension of alignments from their anchoring clusters." +
                "Setting this flag will prevent alignment extensions but still align the DNA between clustered matches and create the .delta file.");
            parser.Parameter(ArgumentType.Optional, "Verbose", ArgumentValueType.Bool, "v", "Display verbose logging during processing.");
            parser.Parameter(ArgumentType.Optional, "FixedSeparation", ArgumentValueType.Bool, "s", "Maximum fixed diagonal difference.");

            if (args.Length > 1)
            {
                try
                {
                    parser.Parse(args, arguments);
                }
                catch (ArgumentException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.NUCmerUtilHelp);
                }

                if (arguments.Help)
                {
                    DisplayErrorMessage(Resources.NUCmerUtilHelp);
                }
                else if (arguments.FilePath.Length == 2)
                {
                    arguments.Align();
                }
                else
                {
                    DisplayErrorMessage(Resources.NUCmerUtilHelp);
                }
            }
            else
            {
                DisplayErrorMessage(Resources.NUCmerUtilHelp);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Parses ScaffoldGeneration command line parameters.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void ScaffoldGeneration(string[] args)
        {
            ScaffoldArguments arguments = new ScaffoldArguments();
            CommandLineArguments parser = new CommandLineArguments();

            // Add scaffold parameters
            parser.Parameter(ArgumentType.DefaultArgument, "FilePath", ArgumentValueType.MultipleUniqueStrings, "", "File path");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "h", "Print the help information.");
            parser.Parameter(ArgumentType.Optional, "OutputFile", ArgumentValueType.String, "o", "Output file");
            parser.Parameter(ArgumentType.Optional, "Verbose", ArgumentValueType.Bool, "v", "Display verbose logging during processing.");
            parser.Parameter(ArgumentType.Optional, "KmerLength", ArgumentValueType.Int, "k", "Length of k-mer");
            parser.Parameter(ArgumentType.Optional, "Redundancy", ArgumentValueType.Int, "r", "Number of paired read required to connect two contigs.");
            parser.Parameter(ArgumentType.Optional, "Depth", ArgumentValueType.Int, "d", "Depth for graph traversal.");
            parser.Parameter(ArgumentType.Optional, "CloneLibraryName", ArgumentValueType.String, "n", "Clone Library Name");
            parser.Parameter(ArgumentType.Optional, "MeanLengthOfInsert", ArgumentValueType.Int, "i", "Mean Length of clone library.");
            parser.Parameter(ArgumentType.Optional, "StandardDeviationOfInsert", ArgumentValueType.Int, "sd", "Standard Deviation of Clone Library.");

            if (args.Length > 1)
            {
                try
                {
                    parser.Parse(args, arguments);
                }
                catch (ArgumentParserException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.ScaffoldUtilHelp);
                    Environment.Exit(-1);
                }

                if (arguments.Help)
                {
                    DisplayErrorMessage(Resources.ScaffoldUtilHelp);
                }
                else if (arguments.FilePath.Length == 2)
                {
                    arguments.GenerateScaffolds();
                }
                else
                {
                    DisplayErrorMessage(Resources.ScaffoldUtilHelp);
                } 
            }
            else
            {
                DisplayErrorMessage(Resources.ScaffoldUtilHelp);
            }
        }
        public void ValidateCommandLineArguments()
        {
            AggregateNumbers aggregateNos = new AggregateNumbers();
            CommandLineArguments parser = new CommandLineArguments();

            //add parameters
            parser.Parameter(ArgumentType.Required, "InputFile", ArgumentValueType.String, "i", "File containing numbers to add");
            parser.Parameter(ArgumentType.Required, "ResultFile", ArgumentValueType.String, "r", "File to store output");
            string inputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string outputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string[] args = { "-InputFile:" + inputfileName , "-ResultFile:" + outputfileName };
            parser.Parse(args, aggregateNos);
            Assert.IsNotNull(parser);
            Assert.IsTrue(aggregateNos.InputFile.Contains(inputfileName));
            Assert.IsTrue(aggregateNos.ResultFile.Contains(outputfileName));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Parses RepeatResolver command line parameters.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void RepeatResolver(string[] args)
        {
            LayoutRefinementArguments arguments = new LayoutRefinementArguments();
            CommandLineArguments parser = new CommandLineArguments();

            // Add parameters
            parser.Parameter(ArgumentType.DefaultArgument, "FilePath", ArgumentValueType.MultipleUniqueStrings, "", "File path");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "h", "Print the help information.");
            parser.Parameter(ArgumentType.Optional, "OutputFile", ArgumentValueType.String, "o", "Output file");
            parser.Parameter(ArgumentType.Optional, "Verbose", ArgumentValueType.Bool, "v", "Display verbose logging during processing.");

            if (args.Length > 1)
            {
                try
                {
                    parser.Parse(args, arguments);
                }
                catch (ArgumentException ex)
                {
                    Output.WriteLine(OutputLevel.Error, ex.Message);
                    Output.WriteLine(OutputLevel.Required, Resources.LayoutRefinementUtilHelp);
                    return;
                }

                if (arguments.Help || arguments.FilePath.Length != 2)
                {
                    Output.WriteLine(OutputLevel.Required, Resources.LayoutRefinementUtilHelp);
                }
                else
                {
                    if (arguments.Verbose)
                        Output.TraceLevel = OutputLevel.Information | OutputLevel.Verbose;
                    else
                        Output.TraceLevel = OutputLevel.Information;

                    arguments.RefineLayout();
                }
            }
            else
            {
                Output.WriteLine(OutputLevel.Required, Resources.LayoutRefinementUtilHelp);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// ConvertFileFormat method that will call the appropriate class to perform
        /// file conversion, this class using the command line parser to parse
        /// command line options and then calls the FileFormatConverter.convertFile method
        /// which does the work
        /// </summary>
        /// <param name="args"></param>
        private static void ConvertFileFormat(string[] args)
        {
            var ffc = new FileFormatConverter();
            var parser = new CommandLineArguments();

            //add parameters
            parser.Parameter(
                ArgumentType.DefaultArgument,
                "FileList",
                ArgumentValueType.MultipleUniqueStrings,
                "",
                "Input and Output files.");

            if (args.Length > 0)
            {
                try
                {
                    parser.Parse(args, ffc);
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(Resources.UsageHelp);
                    Environment.Exit(-1);
                }

                if (ffc.FileList.Length != 2)
                {
                    Console.WriteLine(GetUsageMessage(ffc));
                }
                else
                {
                    ffc.InputFile = ffc.FileList[0];
                    ffc.OutputFile = ffc.FileList[1];

                    ffc.ConvertFile();
                }
            }
            else
            {
                Console.WriteLine(GetUsageMessage(ffc));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Parses RepeatResolver command line parameters.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void RepeatResolver(string[] args)
        {
            RepeatResolutionArguments arguments = new RepeatResolutionArguments();
            CommandLineArguments parser = new CommandLineArguments();

            // Add parameters
            parser.Parameter(ArgumentType.DefaultArgument, "FilePath", ArgumentValueType.MultipleUniqueStrings, "", "File path");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "h", "Print the help information.");
            parser.Parameter(ArgumentType.Optional, "OutputFile", ArgumentValueType.String, "o", "Output file.");
            parser.Parameter(ArgumentType.Optional, "Verbose", ArgumentValueType.Bool, "v", "Display verbose logging during processing.");

            if (args.Length > 1)
            {
                try
                {
                    parser.Parse(args, arguments);
                }
                catch (ArgumentException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.RepeatResolutionUtilHelp);
                    Environment.Exit(-1);
                }

                if (arguments.Help)
                {
                    DisplayErrorMessage(Resources.RepeatResolutionUtilHelp);
                }
                else if (arguments.FilePath.Length == 2)
                {
                    arguments.ResolveAmbiguity();
                }
                else
                {
                    DisplayErrorMessage(Resources.RepeatResolutionUtilHelp);
                }
            }
            else
            {
                DisplayErrorMessage(Resources.RepeatResolutionUtilHelp);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Parses ConsensusGeneration command line parameters.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void ConsensusGeneration(string[] args)
        {
            ConsensusArguments arguments = new ConsensusArguments();
            CommandLineArguments parser = new CommandLineArguments();

            // Add the parameters
            parser.Parameter(ArgumentType.DefaultArgument, "FilePath", ArgumentValueType.MultipleUniqueStrings, "", "File path");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "h", "Print the help information.");
            parser.Parameter(ArgumentType.Optional, "OutputFile", ArgumentValueType.String, "o", "Output file.");
            parser.Parameter(ArgumentType.Optional, "Verbose", ArgumentValueType.Bool, "v", "Display verbose logging during processing.");

            if (args.Length > 1)
            {
                try
                {
                    parser.Parse(args, arguments);
                }
                catch (ArgumentException ex)
                {
                    Output.WriteLine(OutputLevel.Error, ex.Message);
                    Output.WriteLine(OutputLevel.Required, Resources.ConsensusUtilHelp);
                    Environment.Exit(-1);
                }

                if (arguments.Help || arguments.FilePath.Length != 2)
                {
                    Output.WriteLine(OutputLevel.Required, Resources.ConsensusUtilHelp);
                }
                else
                {
                    arguments.GenerateConsensus();
                }
            }
            else
            {
                Output.WriteLine(OutputLevel.Required, Resources.ConsensusUtilHelp);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Assemble function.
        /// </summary>
        /// <param name="args">Arguments to Assemble.</param>
        private static void Assemble(string[] args)
        {
            AssembleArguments options = new AssembleArguments();
            CommandLineArguments parser = new CommandLineArguments();
            AddParameters(parser);

            if (args.Length > 0)
            {
                try
                {
                    parser.Parse(args, options);
                }
                catch (ArgumentParserException ex)
                {
                    Output.WriteLine(OutputLevel.Error, ex.Message);
                    Output.WriteLine(OutputLevel.Required, Resources.AssembleHelp);
                    Environment.Exit(-1);
                }

                if (options.Help || options.FilePath == null)
                {
                    Output.WriteLine(OutputLevel.Required, Resources.AssembleHelp);
                }
                else
                {
                    if (options.Verbose)
                        Output.TraceLevel = OutputLevel.Information | OutputLevel.Verbose;
                    else
                        Output.TraceLevel = OutputLevel.Information;

                    options.AssembleSequences();
                }
            }
            else
            {
                Output.WriteLine(OutputLevel.Required, Resources.AssembleHelp);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Parse command line arguments for Sequence Item Possible Occurence
        /// </summary>
        /// <param name="args">Array of command line arguments.</param>
        private static void SeqPossibleOccurence(string[] args)
        {

            SequenceCoverage options = new SequenceCoverage();
            CommandLineArguments parser = new CommandLineArguments();

            // Add the parameters
            parser.Parameter(ArgumentType.Optional, "SAMInput", ArgumentValueType.Bool, "S", "Input is SAM format");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "", "");

            try
            {
                parser.Parse(args, options);
            }
            catch (ArgumentParserException ex)
            {
                DisplayErrorMessage(ex.Message);
                DisplayErrorMessage(Resources.DNAPossibleOccurenceHelp);
                Environment.Exit(-1);
            }

            if (options.Help)
            {
                DisplayErrorMessage(Resources.DNAPossibleOccurenceHelp);
            }

            else
            {
                options.DisplaySequenceItemOccurences(args[0], true);
            }

        }
Ejemplo n.º 13
0
        /// <summary>
        /// Parse command line arguments for Length anomaly regions command
        /// </summary>
        /// <param name="args">Array of command line arguments.</param>
        private static void LengthAnomalyOption(string[] args)
        {
            LengthAnomaly options = new LengthAnomaly();

            if (args.Length > 2)
            {
                CommandLineArguments parser = new CommandLineArguments();

                // Add the parameters
                parser.Parameter(ArgumentType.Optional, "SAMInput", ArgumentValueType.Bool, "S", "Input is SAM format");
                parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "", "");

                try
                {
                    parser.Parse(args, options);
                }
                catch (ArgumentParserException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.LengthAnomalyHelp);
                    Environment.Exit(-1);
                }

                if (options.Help)
                {
                    DisplayErrorMessage(Resources.LengthAnomalyHelp);
                }
                else
                {
                    options.LengthAnamoly(args[0],
                       float.Parse(args[1]), float.Parse(args[2]));
                }
            }
            else
            {
                DisplayErrorMessage(Resources.LengthAnomalyHelp);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Parse command line arguments for Orphan regions command
        /// </summary>
        /// <param name="args">Array of command line arguments.</param>
        private static void OrphanRegionOption(string[] args)
        {
            Orphans options = new Orphans();
            CommandLineArguments parser = new CommandLineArguments();

            // Add the parameters
            parser.Parameter(ArgumentType.Optional, "SAMInput", ArgumentValueType.Bool, "S", "Input is SAM format");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "", "");

            try
            {
                parser.Parse(args, options);
            }
            catch (ArgumentParserException ex)
            {
                DisplayErrorMessage(ex.Message);
                DisplayErrorMessage(Resources.OrphanRegionsHelp);
                Environment.Exit(-1);
            }

            if (options.Help)
            {
                DisplayErrorMessage(Resources.OrphanRegionsHelp);
            }
            else
            {
                options.DisplayOrpanChromosomes(args[0]);
            }

        }
Ejemplo n.º 15
0
        /// <summary>
        /// Parse command line arguments for sort command
        /// </summary>
        /// <param name="args">Array of command line arguments.</param>
        private static void SortOption(string[] args)
        {
            Sort options = new Sort();
            CommandLineArguments parser = new CommandLineArguments();

            // Add the parameters
            parser.Parameter(ArgumentType.DefaultArgument, "InputFilename", ArgumentValueType.String, "", "File Paths");
            parser.Parameter(ArgumentType.Optional, "SortByReadName", ArgumentValueType.Bool, "n", "Sort by read name");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "", "");
            parser.Parameter(ArgumentType.Optional, "OutputFilename", ArgumentValueType.String, "o", "Output file name");

            if (args.Length > 0)
            {
                try
                {
                    parser.Parse(args, options);
                }
                catch (ArgumentParserException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.SortHelp);
                    Environment.Exit(-1);
                }
                if (options.Help)
                {
                    DisplayErrorMessage(Resources.SortHelp);
                }
                else
                {
                    options.DoSort();
                }
            }
            else
            {
                DisplayErrorMessage(Resources.SortHelp);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Parse command line arguments for Merge command
        /// </summary>
        /// <param name="args">Array of command line arguments.</param>
        private static void MergeOption(string[] args)
        {
            Merge options = new Merge();
            CommandLineArguments parser = new CommandLineArguments();

            //Add the parameters
            parser.Parameter(ArgumentType.Optional, "SortByReadName", ArgumentValueType.Bool, "n", "Sort by read name");
            parser.Parameter(ArgumentType.Optional, "HeaderFile", ArgumentValueType.String, "h", "Copy the Header from this file");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "", "");
            parser.Parameter(ArgumentType.Optional, "OutputFilename", ArgumentValueType.String, "o", "Output file name");
            parser.Parameter(ArgumentType.DefaultArgument, "FilePaths", ArgumentValueType.MultipleUniqueStrings, "", "File Paths");

            if (args != null && args.Length >= 2)
            {
                try
                {
                    parser.Parse(args, options);
                }
                catch (ArgumentParserException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.MergeHelp);
                    Environment.Exit(-1);
                }
                if (options.Help)
                {
                    DisplayErrorMessage(Resources.MergeHelp);
                }
                else
                {
                    options.DoMerge();
                }
            }
            else
            {
                DisplayErrorMessage(Resources.MergeHelp);
            }
        }
        public void InvalidateParseWithEmptyParam()
        {
            try
            {
                AggregateNumbers aggregateNos = new AggregateNumbers();
                CommandLineArguments parser = new CommandLineArguments();

                //add parameters
                parser.Parameter(ArgumentType.Required, "bValue", ArgumentValueType.Bool, "bv", "bool");
                parser.Parameter(ArgumentType.Required, "iValue", ArgumentValueType.Int, "iv", "int");

                string[] args = { "-:true", "-iValue:5" };
                parser.Parse(args, aggregateNos);
                Assert.Fail();
            }
            catch (ArgumentSyntaxException ex)
            {
                ApplicationLog.Write("Successfully caught ArgumentSyntaxException : " + ex.Message);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Process the command line arguments.
        /// </summary>
        /// <param name="args">commandline arguments.</param>
        /// <returns>Command line options.</returns>
        private static CommandLineOptions ProcessCommandLine(string[] args)
        {
            CommandLineOptions filterReadsParams = new CommandLineOptions();
            CommandLineArguments parser = new CommandLineArguments();

            // Add parameters
            parser.Parameter(ArgumentType.DefaultArgument, "Filename", ArgumentValueType.String, "", "Input fasta file to filter reads.");
            parser.Parameter(ArgumentType.Optional, "AmbiguousOutputFile", ArgumentValueType.String, "a", "Filtered ambiguous reads output file");
            parser.Parameter(ArgumentType.Optional, "OutputFile", ArgumentValueType.String, "o", "Output file");
            parser.Parameter(ArgumentType.Optional, "FilterAmbiguousReads", ArgumentValueType.Bool, "fa", "Filter ambiguous reads");
            parser.Parameter(ArgumentType.Optional, "Verbose", ArgumentValueType.Bool, "v", "Display Verbose logging");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "h", "Show the help information with program options and a description of program operation.");

            try
            {
                parser.Parse(args, filterReadsParams);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("\nException while processing Command Line arguments [{0}]", e.Message);
                Console.Error.WriteLine(Properties.Resource.FilterReadsUtilHelp);
                Environment.Exit(-1);
            }

            if (filterReadsParams.OutputFile != null)
            {   // redirect stdout
                FileStream fsConsoleOut = new FileStream(filterReadsParams.OutputFile, FileMode.Create);
                StreamWriter swConsoleOut = new StreamWriter(fsConsoleOut);
                Console.SetOut(swConsoleOut);
                swConsoleOut.AutoFlush = true;
            }

            return (filterReadsParams);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Parse command line arguments for view command.
        /// </summary>
        /// <param name="args">Array of command line arguments.</param>
        private static void ViewOption(string[] args)
        {
            View options = new View();
            CommandLineArguments parser = new CommandLineArguments();

            // Add the parameters
            parser.Parameter(ArgumentType.Optional, "BAMOutput", ArgumentValueType.Bool, "b", "Output BAM");
            parser.Parameter(ArgumentType.Optional, "Header", ArgumentValueType.Bool, "h", "Print header for the SAM output");
            parser.Parameter(ArgumentType.Optional, "HeaderOnly", ArgumentValueType.Bool, "H", "Print header only (no alignments)");
            parser.Parameter(ArgumentType.Optional, "SAMInput", ArgumentValueType.Bool, "S", "Input is SAM format");
            parser.Parameter(ArgumentType.Optional, "UnCompressedBAM", ArgumentValueType.Bool, "u", "Uncompressed BAM output");
            parser.Parameter(ArgumentType.Optional, "FlagInHex", ArgumentValueType.Bool, "x", "Output FLAG in HEX");
            parser.Parameter(ArgumentType.Optional, "FlagAsString", ArgumentValueType.Bool, "X", "Output FLAG in string");
            parser.Parameter(ArgumentType.Optional, "ReferenceNamesAndLength", ArgumentValueType.String, "t",
                "List of reference names and lengths in a tab limited file rest all field will be ignored.");
            parser.Parameter(ArgumentType.Optional, "ReferenceSequenceFile", ArgumentValueType.String, "T", "Reference sequence file");
            parser.Parameter(ArgumentType.Optional, "OutputFilename", ArgumentValueType.String, "o", "Output file name");
            parser.Parameter(ArgumentType.Optional, "FlagRequired", ArgumentValueType.Int, "f", "Required flag");
            parser.Parameter(ArgumentType.Optional, "FilteringFlag", ArgumentValueType.Int, "F", "Filtering flag");
            parser.Parameter(ArgumentType.Optional, "QualityMinimumMapping", ArgumentValueType.Int, "q", "Minimum mapping quality");
            parser.Parameter(ArgumentType.Optional, "Library", ArgumentValueType.String, "l", "Only output reads in library");
            parser.Parameter(ArgumentType.Optional, "ReadGroup", ArgumentValueType.String, "r", "Only output reads in read group");
            parser.Parameter(ArgumentType.Optional, "Region", ArgumentValueType.String, "R",
                "A region can be presented, for example, in the following format:\n" +
                        "          ‘chr2’ (the whole chr2),\n" +
                        "          ‘chr2:1000000’ (region starting from 1,000,000bp)\n" +
                        "          or ‘chr2:1,000,000-2,000,000’\n" +
                        "          (region between 1,000,000 and 2,000,000bp including the end points).\n" +
                        "          The coordinate is 1-based.\n");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "?", "");
            parser.Parameter(ArgumentType.DefaultArgument, "InputFilePath", ArgumentValueType.String, "", "Input SAM/BAM file path");

            if (args.Length > 0)
            {
                try
                {
                    parser.Parse(args, options);
                }
                catch (ArgumentParserException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.ViewHelp);
                    Environment.Exit(-1);
                }
                if (options.Help)
                {
                    DisplayErrorMessage(Resources.ViewHelp);
                }
                else
                {
                    options.ViewResult();
                }
            }
            else
            {
                DisplayErrorMessage(Resources.ViewHelp);
            }
        }
        public void InvalidateParseForNullArguments()
        {
            AggregateNumbers aggregateNos = new AggregateNumbers();
            CommandLineArguments parser = new CommandLineArguments();

            try
            {
                parser.Parse(null, aggregateNos);
                Assert.Fail("CommandLineArguments P2: Not validated parameter Method for null value");
            }
            catch (ArgumentNullException ex)
            {
                ApplicationLog.WriteLine("CommandLineArguments P2: Successfully validated Parameter Method for null value:", ex.Message);
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Assemble With Scaffolding.
        /// </summary>
        /// <param name="args">Arguments to Scaffolding.</param>
        private static void AssembleWithScaffolding(string[] args)
        {
            AssembleWithScaffoldArguments options = new AssembleWithScaffoldArguments();
            CommandLineArguments parser = new CommandLineArguments();

            // add assemble related parameters.
            AddAssembleParameters(parser);
            
            // Add scaffold parameters
            parser.Parameter(ArgumentType.Optional, "CloneLibraryName", ArgumentValueType.String, "n", "Clone Library Name");
            parser.Parameter(ArgumentType.Optional, "MeanLengthOfInsert", ArgumentValueType.Int, "m", "Mean Length of clone library.");
            parser.Parameter(ArgumentType.Optional, "StandardDeviationOfInsert", ArgumentValueType.Int, "s", "Standard Deviation of Clone Library.");
            parser.Parameter(ArgumentType.Optional, "Redundancy", ArgumentValueType.Int, "b", "Number of paired read required to connect two contigs.");
            parser.Parameter(ArgumentType.Optional, "Depth", ArgumentValueType.Int, "f", "Depth for graph traversal.");

            if (args.Length > 0)
            {
                try
                {
                    parser.Parse(args, options);
                }
                catch (ArgumentParserException ex)
                {
                    Output.WriteLine(OutputLevel.Error, ex.Message);
                    Output.WriteLine(OutputLevel.Required, Resources.AssembleWithScaffoldHelp);
                    Environment.Exit(-1);
                }

                if (options.Help)
                {
                    Output.WriteLine(OutputLevel.Required, Resources.AssembleWithScaffoldHelp);
                }
                else
                {
                    if (!options.ForceKmer)
                        ValidateKmerLength(options.KmerLength, options.AllowKmerLengthEstimation);
                    if (options.Verbose)
                        Output.TraceLevel = OutputLevel.Information | OutputLevel.Verbose;
                    else if (!options.Quiet)
                        Output.TraceLevel = OutputLevel.Information;
                    options.AssembleSequences();
                }
            }
            else
            {
                Output.WriteLine(OutputLevel.Required, Resources.AssembleWithScaffoldHelp);
            }
        }
        public void InvalidateParseWithMissingRequiredParam()
        {
            try
            {
                AggregateNumbers aggregateNos = new AggregateNumbers();
                CommandLineArguments parser = new CommandLineArguments();

                //add parameters
                parser.Parameter(ArgumentType.Required, "bValue", ArgumentValueType.Bool, "bv", "bool");
                parser.Parameter(ArgumentType.Required, "iValue", ArgumentValueType.Int, "iv", "int");
                parser.Parameter(ArgumentType.Required, "bArrValues", ArgumentValueType.Bool, "bmv", "boolArrValues");
                parser.Parameter(ArgumentType.Required, "fValue", ArgumentValueType.Int, "fv", "float");
                parser.Parameter(ArgumentType.Required, "dValue", ArgumentValueType.Int, "dv", "double");
                parser.Parameter(ArgumentType.DefaultArgument, "usValues", ArgumentValueType.MultipleUniqueStrings, "usv", "Unique strings");

                //not including the first required param
                string[] args = { "-iValue:5", "-bArrValues:true" ,"false",
                            "-fValue:3.45", "-dValue:78.9876", "Str1", "Str2","Str3"};
                parser.Parse(args, aggregateNos);
                Assert.Fail();
            }
            catch (RequiredArgumentMissingException ex)
            {
                ApplicationLog.WriteLine("Successfully caught RequiredArgumentMissingException : " + ex.Message);
            }
        }
        public void InvalidateParseWithDuplicateString()
        {
            try
            {
                AggregateNumbers aggregateNos = new AggregateNumbers();
                CommandLineArguments parser = new CommandLineArguments();

                //add parameters
                parser.Parameter(ArgumentType.Required, "bValue", ArgumentValueType.Bool, "bv", "bool");
                parser.Parameter(ArgumentType.Required, "iValue", ArgumentValueType.Int, "iv", "int");
                parser.Parameter(ArgumentType.Required, "fValue", ArgumentValueType.Int, "fv", "float");
                parser.Parameter(ArgumentType.Required, "dValue", ArgumentValueType.Int, "dv", "double");
                parser.Parameter(ArgumentType.DefaultArgument, "usValues", ArgumentValueType.MultipleUniqueStrings, "usv", "Unique strings");

                string[] args = { "-bValue:true", "-iValue:5", "-fValue:3.45", "-dValue:78.9876", "Str1", "Str2","Str1"};
                parser.Parse(args, aggregateNos);
            }
            catch (DuplicateArgumentValueException ex)
            {
                ApplicationLog.WriteLine("Successfully caught DuplicateArgumentValueException : " + ex.Message);
            }
        }
        public void InvalidateParseWithWrongParamName()
        {
            try
            {
                AggregateNumbers aggregateNos = new AggregateNumbers();
                CommandLineArguments parser = new CommandLineArguments();

                //add parameters
                parser.Parameter(ArgumentType.Required, "bValue", ArgumentValueType.Bool, "bv", "bool");
                parser.Parameter(ArgumentType.Required, "iValue", ArgumentValueType.Int, "iv", "int");
                parser.Parameter(ArgumentType.Required, "bArrValues", ArgumentValueType.Bool, "bmv", "boolArrValues");
                //pass char in integer array
                string[] args = { "/wrongname:true", "/iValue:5", "/bArrValues:true", "false" };
                parser.Parse(args, aggregateNos);
                Assert.Fail();
            }
            catch (ArgumentParserException ex)
            {
                ApplicationLog.Write("Successfully caught ArgumentNotFoundException : " + ex.Message);
            }
        }
        public void ValidateTypesInParameter()
        {
            AggregateNumbers aggregateNos = new AggregateNumbers();
            CommandLineArguments parser = new CommandLineArguments();

            //add parameters
            parser.Parameter(ArgumentType.Required, "bValue", ArgumentValueType.Bool, "bv", "bool");
            parser.Parameter(ArgumentType.Required, "iValue", ArgumentValueType.Int, "iv", "int");
            parser.Parameter(ArgumentType.Required, "fValue", ArgumentValueType.Int, "fv", "float");
            parser.Parameter(ArgumentType.Required, "dValue", ArgumentValueType.Int, "dv", "double");
            parser.Parameter(ArgumentType.DefaultArgument, "usValues", ArgumentValueType.MultipleUniqueStrings, "usv", "Unique strings");

            string[] args = { "-bValue:true", "-iValue:5", "-fValue:3.45", "-dValue:78.9876", "Str1", "Str2","Str3"};
            parser.Parse(args, aggregateNos);
            Assert.IsNotNull(parser);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Parse command line arguments for index command.
        /// </summary>
        /// <param name="args">Array of command line arguments.</param>
        private static void IndexOption(string[] args)
        {
            Index options = new Index();
            CommandLineArguments parser = new CommandLineArguments();

            // Add the parameters
            parser.Parameter(ArgumentType.DefaultArgument, "InputFilename", ArgumentValueType.String, "", "Input BAM file name");
            parser.Parameter(ArgumentType.Optional, "OutputFilename", ArgumentValueType.String, "o", "Output file name");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "", "");

            if (args.Length > 0)
            {
                try
                {
                    parser.Parse(args, options);
                }
                catch (ArgumentParserException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.IndexHelp);
                    Environment.Exit(-1);
                }
                if (options.Help)
                {
                    DisplayErrorMessage(Resources.IndexHelp);
                }
                else
                {
                    options.GenerateIndexFile();
                }
            }
            else
            {
                DisplayErrorMessage(Resources.IndexHelp);
            }
        }
Ejemplo n.º 27
0
        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)
            {
                Console.WriteLine(Resources.MumUtilHelp);
                Environment.Exit(-1);
            }

            /*
             * Process all the arguments for 'semantic' correctness
             */
            if ((myArgs.maxmatch && myArgs.mum)
                || (myArgs.maxmatch && myArgs.mumreference)
                || (myArgs.mum && myArgs.mumreference)
                )
            {
                Console.Error.WriteLine("\nError: only one of -maxmatch, -mum, -mumreference options can be specified.");
                Environment.Exit(-1);
            }
            if (!myArgs.mumreference && !myArgs.mum && !myArgs.maxmatch)
            {
                myArgs.mumreference = true;
            }
            if ((myArgs.fileList == null) || (myArgs.fileList.Length < 2))
            {
                Console.Error.WriteLine("\nError: A reference file and at least 1 query file are required.");
                Environment.Exit(-1);
            }
            if ((myArgs.length <= 0) || (myArgs.length >= (8 * 1024)))   // TODO: What are real reasonable mum length limits?
            {
                Console.Error.WriteLine("\nError: mum length must be between 1 and 1024.");
                Environment.Exit(-1);
            }
            if (myArgs.both && myArgs.reverseOnly)
            {
                Console.Error.WriteLine("\nError: only one of -both or -reverseOnly options can be specified.");
                Environment.Exit(-1);
            }
            if (myArgs.c && (!myArgs.both && !myArgs.reverseOnly))
            {
                Console.Error.WriteLine("\nError: c requires one of either /b or /r options.");
                Environment.Exit(-1);
            }
            if (myArgs.outputFile != null)
            {   // redirect stdout
                fsConsoleOut = new FileStream(myArgs.outputFile, FileMode.Create);
                swConsoleOut = new StreamWriter(fsConsoleOut);
                Console.SetOut(swConsoleOut);
                swConsoleOut.AutoFlush = true;
            }

            return (myArgs);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Parse command line arguments for Import command
        /// </summary>
        /// <param name="args">Array of command line arguments.</param>
        private static void ImportOption(string[] args)
        {
            Import options = new Import();
            CommandLineArguments parser = new CommandLineArguments();

            // Add the parameters
            parser.Parameter(ArgumentType.DefaultArgument, "InputFilename", ArgumentValueType.String, "", "Input filename");
            parser.Parameter(ArgumentType.Optional, "Help", ArgumentValueType.Bool, "", "");
            parser.Parameter(ArgumentType.Optional, "ReferenceListFile", ArgumentValueType.String, "r", "Tab delimited file");
            parser.Parameter(ArgumentType.Optional, "OutputFilename", ArgumentValueType.String, "o", "Output file name");

            if (args != null && args.Length > 0)
            {
                try
                {
                    parser.Parse(args, options);
                }
                catch (ArgumentParserException ex)
                {
                    DisplayErrorMessage(ex.Message);
                    DisplayErrorMessage(Resources.ImportHelp);
                    Environment.Exit(-1);
                }

                if (options.Help)
                {
                    DisplayErrorMessage(Resources.ImportHelp);
                }
                else
                {
                    options.DoImport();
                }
            }
            else
            {
                DisplayErrorMessage(Resources.ImportHelp);
            }
        }
Ejemplo n.º 29
0
        private static CommandLineOptions ProcessCommandLine(string[] args)
        {
            CommandLineOptions myArgs = new CommandLineOptions();
            CommandLineArguments parser = new CommandLineArguments();
            AddParameters(parser);
            try
            {
                parser.Parse(args, myArgs);
            }

            catch (ArgumentParserException e)
            {
                Console.Error.WriteLine("\nException while processing Command Line arguments [{0}]", e.Message);
                Console.Error.WriteLine(Resources.LisUtilHelp);
                Environment.Exit(-1);
            }

            if (myArgs.Help)
            {
                Console.WriteLine(Resources.LisUtilHelp);
                Environment.Exit(-1);
            }

            /*
             * Process all the arguments for 'semantic' correctness
             */
            if (!myArgs.PerformLISOnly)
            {
                if ((myArgs.MaxMatch && myArgs.Mum)
                    || (myArgs.MaxMatch && myArgs.Mumreference)
                    || (myArgs.Mum && myArgs.Mumreference))
                {
                    Console.Error.WriteLine("\nError: only one of -maxmatch, -mum, -mumreference options can be specified.");
                    Environment.Exit(-1);
                }

                if (!myArgs.Mumreference && !myArgs.Mum && !myArgs.MaxMatch)
                {
                    myArgs.Mumreference = true;
                }
            }

            if (myArgs.FileList == null || myArgs.FileList.Length == 0)
            {
                Console.Error.WriteLine("\nError: Atleast one input file needed.");
                Environment.Exit(-1);
            }

            if (myArgs.FileList.Length < 2 && !myArgs.PerformLISOnly)
            {
                Console.Error.WriteLine("\nError: A reference file and at least 1 query file are required.");
                Environment.Exit(-1);
            }

            if (myArgs.FileList.Length < 1 && myArgs.PerformLISOnly)
            {
                Console.Error.WriteLine("\nError: A file containing list of MUMs required.");
                Environment.Exit(-1);
            }

            if ((myArgs.Length <= 2) || (myArgs.Length >= (8 * 1024)))
            {
                // TODO: What are real reasonable mum length limits?
                Console.Error.WriteLine("\nError: mum length must be between 10 and 1024.");
                Environment.Exit(-1);
            }

            if (myArgs.Both && myArgs.ReverseOnly)
            {
                Console.Error.WriteLine("\nError: only one of -both or -reverseOnly options can be specified.");
                Environment.Exit(-1);
            }

            if (myArgs.C && (!myArgs.Both && !myArgs.ReverseOnly))
            {
                Console.Error.WriteLine("\nError: c requires one of either /b or /r options.");
                Environment.Exit(-1);
            }

            if (myArgs.OutputFile != null)
            {   // redirect stdout
                fileStreamConsoleOut = new FileStream(myArgs.OutputFile, FileMode.Create);
                streamWriterConsoleOut = new StreamWriter(fileStreamConsoleOut);
                Console.SetOut(streamWriterConsoleOut);
                streamWriterConsoleOut.AutoFlush = true;
            }

            return (myArgs);
        }
        public void InvalidateParseForNullArgumentsNo()
        {
            CommandLineArguments parser = new CommandLineArguments();

            //add parameters
            parser.Parameter(ArgumentType.Required, "InputFile", ArgumentValueType.String, "i", "File containing numbers to add");
            parser.Parameter(ArgumentType.Required, "ResultFile", ArgumentValueType.String, "r", "File to store output");

            string inputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string outputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string[] args = { "/InputFile:" + inputfileName, "/ResultFile:" + outputfileName };

            try
            {
                parser.Parse(args, null);
                Assert.Fail("CommandLineArguments P2: Not validated parameter Method for null value");
            }
            catch (ArgumentNullException ex)
            {
                ApplicationLog.WriteLine("CommandLineArguments P2: Successfully validated Parameter Method for null value:", ex.Message);
            }
        }