Search in sources :

Example 76 with GnuParser

use of org.apache.commons.cli.GnuParser in project goci by EBISPOT.

the class ParentMappingApplication method parseArguments.

private static int parseArguments(String[] args) {
    CommandLineParser parser = new GnuParser();
    HelpFormatter help = new HelpFormatter();
    Options options = bindOptions();
    int parseArgs = 0;
    try {
        CommandLine cl = parser.parse(options, args, true);
        // check for mode help option
        if (cl.hasOption("")) {
            // print out mode help
            help.printHelp("mapper", options, true);
            parseArgs += 1;
        } else {
            // find -o option (for asserted output file)
            if (cl.hasOption("o")) {
                outputFile = new File(cl.getOptionValue("o"));
            } else {
                System.err.println("-o (output file) argument is required");
                help.printHelp("mapper", options, true);
                parseArgs += 2;
            }
        }
    } catch (ParseException e) {
        System.err.println("Failed to read supplied arguments");
        help.printHelp("mapper", options, true);
        parseArgs += 4;
    }
    return parseArgs;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File)

Example 77 with GnuParser

use of org.apache.commons.cli.GnuParser in project goci by EBISPOT.

the class AssociationFilterApplication method parseArguments.

private static int parseArguments(String[] args) {
    CommandLineParser parser = new GnuParser();
    HelpFormatter help = new HelpFormatter();
    Options options = bindOptions();
    int parseArgs = 0;
    try {
        CommandLine cl = parser.parse(options, args, true);
        // check for mode help option
        if (cl.hasOption("")) {
            // print out mode help
            help.printHelp("filter", options, true);
            parseArgs += 1;
        } else {
            // find -o option (for asserted output file)
            if (cl.hasOption("o")) {
                outputFile = new File(cl.getOptionValue("o"));
            } else {
                System.err.println("-o (output file) argument is required");
                help.printHelp("filter", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("f")) {
                inputFile = new File(cl.getOptionValue("f"));
            } else {
                System.err.println("-f (input file) argument is required");
                help.printHelp("filter", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("p")) {
                prune = true;
            }
            if (cl.hasOption("t")) {
                threshold = Double.valueOf(cl.getOptionValue("t"));
            }
        }
    } catch (ParseException e) {
        System.err.println("Failed to read supplied arguments");
        help.printHelp("filter", options, true);
        parseArgs += 4;
    }
    return parseArgs;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File)

Example 78 with GnuParser

use of org.apache.commons.cli.GnuParser in project goci by EBISPOT.

the class SnpListBuilderApp method parseArguments.

private static int parseArguments(String[] args) {
    CommandLineParser parser = new GnuParser();
    HelpFormatter help = new HelpFormatter();
    Options options = bindOptions();
    int parseArgs = 0;
    try {
        CommandLine cl = parser.parse(options, args, true);
        // check for mode help option
        if (cl.hasOption("")) {
            // print out mode help
            help.printHelp("publish", options, true);
            parseArgs += 1;
        } else {
            // find -o option (for asserted output file)
            if (cl.hasOption("o")) {
                outputFilePath = cl.getOptionValue("o");
            } else {
                System.err.println("-o (ontology output file) argument is required");
                help.printHelp("publish", options, true);
                parseArgs += 2;
            }
        }
    } catch (ParseException e) {
        System.err.println("Failed to read supplied arguments");
        help.printHelp("publish", options, true);
        parseArgs += 3;
    }
    return parseArgs;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException)

Example 79 with GnuParser

use of org.apache.commons.cli.GnuParser in project goci by EBISPOT.

the class GOCIDataReleaseQCDriver method parseArguments.

private int parseArguments(String[] args) {
    CommandLineParser parser = new GnuParser();
    HelpFormatter help = new HelpFormatter();
    Options options = bindOptions();
    int parseArgs = 0;
    try {
        CommandLine cl = parser.parse(options, args, true);
        // check for mode help option
        if (cl.hasOption("")) {
            // print out mode help
            help.printHelp("qc", options, true);
            parseArgs += 1;
        } else {
            // find -o option (for asserted output file)
            if (cl.hasOption("a")) {
                this.opMode = OperationMode.ALL;
            } else if (cl.hasOption("k")) {
                this.opMode = OperationMode.KNOWLEDGE_BASE;
            } else if (cl.hasOption("e")) {
                this.opMode = OperationMode.SUMMARY_EMAIL;
            } else if (cl.hasOption("d")) {
                this.opMode = OperationMode.DIAGRAM;
            } else if (cl.hasOption("s")) {
                this.opMode = OperationMode.SOLR_INDEX;
            } else {
                System.err.println("-o (ontology output file) argument is required");
                help.printHelp("publish", options, true);
                parseArgs += 2;
            }
        }
    } catch (ParseException e) {
        System.err.println("Failed to read supplied arguments");
        help.printHelp("publish", options, true);
        parseArgs += 4;
    }
    return parseArgs;
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) GnuParser(org.apache.commons.cli.GnuParser) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException)

Example 80 with GnuParser

use of org.apache.commons.cli.GnuParser in project goci by EBISPOT.

the class KBMetricsDriver method parseArguments.

private static int parseArguments(String[] args) {
    CommandLineParser parser = new GnuParser();
    HelpFormatter help = new HelpFormatter();
    Options options = bindOptions();
    int parseArgs = 0;
    try {
        CommandLine cl = parser.parse(options, args, true);
        // check for mode help option
        if (cl.hasOption("")) {
            // print out mode help
            help.printHelp("evaluate", options, true);
            parseArgs += 1;
        } else {
            System.out.println("Metrics will be calculated with the following options...");
            for (Option opt : cl.getOptions()) {
                System.out.println("\t" + opt.getLongOpt() + ": " + opt.getValue() + " (" + opt.getArgName() + ")");
            }
            if (cl.hasOption("efo")) {
                _efoLocation = new URL(cl.getOptionValue("efo"));
                System.out.println(_efoLocation);
            } else {
                System.err.println("-efo (EFO location) argument is required");
                help.printHelp("evaluate", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("gwas")) {
                _gwasSchemaLocation = new File(cl.getOptionValue("gwas")).toURI().toURL();
                System.out.println(_gwasSchemaLocation);
            } else {
                System.err.println("-gwas (GWAS Schema File) argument is required");
                help.printHelp("evaluate", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("kb")) {
                _kbLocation = new File(cl.getOptionValue("kb")).toURI().toURL();
                System.out.println(_kbLocation);
            } else {
                System.err.println("-kb (Knowledgebase File) argument is required");
                help.printHelp("evaluate", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("w")) {
                _watershedCutoff = Integer.parseInt(cl.getOptionValue("w"));
            //                    System.setProperty("watershed.cutoff", String.valueOf(_watershedCutoff));
            } else {
                System.err.println("-w (Watershed cutoff) argument is required");
                help.printHelp("evaluate", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("out")) {
                String outOpt = cl.getOptionValue("out");
                _out = new BufferedOutputStream(new FileOutputStream(new File(outOpt)));
            } else {
                System.out.println("No output file specified, report will be written to standard out");
                _out = System.out;
            }
        }
    } catch (ParseException e) {
        System.err.println("Failed to read supplied arguments (" + e.getMessage() + ")");
        help.printHelp("evaluate", options, true);
        parseArgs += 4;
    } catch (FileNotFoundException e) {
        System.err.println("Failed to read supplied arguments - file not found (" + e.getMessage() + ")");
        help.printHelp("evaluate", options, true);
        parseArgs += 5;
    } catch (MalformedURLException e) {
        System.err.println("Failed to read supplied arguments - a supplied argument was not a valid URL " + "(" + e.getMessage() + ")");
        help.printHelp("evaluate", options, true);
        parseArgs += 6;
    }
    return parseArgs;
}
Also used : Options(org.apache.commons.cli.Options) MalformedURLException(java.net.MalformedURLException) GnuParser(org.apache.commons.cli.GnuParser) FileNotFoundException(java.io.FileNotFoundException) URL(java.net.URL) HelpFormatter(org.apache.commons.cli.HelpFormatter) CommandLine(org.apache.commons.cli.CommandLine) FileOutputStream(java.io.FileOutputStream) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Aggregations

GnuParser (org.apache.commons.cli.GnuParser)208 CommandLine (org.apache.commons.cli.CommandLine)187 Options (org.apache.commons.cli.Options)165 CommandLineParser (org.apache.commons.cli.CommandLineParser)158 ParseException (org.apache.commons.cli.ParseException)139 HelpFormatter (org.apache.commons.cli.HelpFormatter)92 Path (org.apache.hadoop.fs.Path)40 Option (org.apache.commons.cli.Option)39 IOException (java.io.IOException)32 Job (org.apache.hadoop.mapreduce.Job)27 File (java.io.File)24 Configuration (org.apache.hadoop.conf.Configuration)19 FileInputStream (java.io.FileInputStream)14 ArrayList (java.util.ArrayList)14 Properties (java.util.Properties)13 FileSystem (org.apache.hadoop.fs.FileSystem)11 MissingArgumentException (org.apache.commons.cli.MissingArgumentException)9 FileNotFoundException (java.io.FileNotFoundException)7 URI (java.net.URI)7 URISyntaxException (java.net.URISyntaxException)6