Package com.martiansoftware.jsap

Examples of com.martiansoftware.jsap.SimpleJSAP


    if (args == null) {
      args = new String[0];
    }

    // Initialize the argument parser
    SimpleJSAP jsap = new SimpleJSAP("java -jar Mockey.jar", "Starts a Jetty server running Mockey");
    jsap.registerParameter(new FlaggedOption(ARG_PORT, JSAP.INTEGER_PARSER, "8080", JSAP.NOT_REQUIRED, 'p',
        ARG_PORT, "port to run Jetty on"));
    jsap.registerParameter(new FlaggedOption(BSC.FILE, JSAP.STRING_PARSER,
        MockeyXmlFileManager.MOCK_SERVICE_DEFINITION, JSAP.NOT_REQUIRED, 'f', BSC.FILE,
        "Relative path to a mockey-definitions file to initialize Mockey, relative to where you're starting Mockey"));

    jsap.registerParameter(new FlaggedOption(BSC.URL, JSAP.STRING_PARSER, "", JSAP.NOT_REQUIRED, 'u', BSC.URL,
        "URL to a mockey-definitions file to initialize Mockey"));

    jsap.registerParameter(new FlaggedOption(BSC.TRANSIENT, JSAP.BOOLEAN_PARSER, "true", JSAP.NOT_REQUIRED, 't',
        BSC.TRANSIENT, "Read only mode if set to true, no updates are made to the file system."));

    jsap.registerParameter(new FlaggedOption(
        BSC.DEFINITION_LOCATION,
        JSAP.STRING_PARSER,
        "",
        JSAP.NOT_REQUIRED,
        'l',
        BSC.DEFINITION_LOCATION,
        "Absolute or relative path/location for Mockey to save it's definitions and configuration. By default, relative to where Mockey is started. "));

    jsap.registerParameter(new FlaggedOption(BSC.FILTERTAG, JSAP.STRING_PARSER, "", JSAP.NOT_REQUIRED, 'F',
        BSC.FILTERTAG,
        "Filter tag for services and scenarios, useful for 'only use information with this tag'. "));

    jsap.registerParameter(new FlaggedOption(BSC.HEADLESS, JSAP.BOOLEAN_PARSER, "false", JSAP.NOT_REQUIRED, 'H',
        BSC.HEADLESS,
        "Headless flag. Default is 'false'. Set to 'true' if you do not want Mockey to spawn a browser thread upon startup."));

    jsap.registerParameter(new Switch(BSC.VERSION, 'v', BSC.VERSION,
        "Prints out Mockey's version (semantic versioning http://semver.org/)"));

    // parse the command line options
    JSAPResult config = jsap.parse(args);

    // Bail out if they asked for the --help
    if (jsap.messagePrinted()) {
      System.exit(1);
    }

    if (config.getBoolean(BSC.VERSION)) {
View Full Code Here


    FileStringParser myFileParser = FileStringParser.getParser();
    myFileParser.setMustBeFile(true);
    myFileParser.setMustExist(true);
   
    // build the jsap object
    SimpleJSAP jsap = new SimpleJSAP(
              "spectralHMM",
              "Analyze temporal data using a spectral HMM method.",
              new Parameter[] {
          new FlaggedOption( "inputFile", myFileParser, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'f', "inputFile", "Specify an input file. See documentation for formatting." ),
          new Switch ("mutSelBalance", 'j', "mutSelBalance", "Set the initial condition to be selection-drift balance."),
          new Switch ("mutDriftBalance", 'd', "mutDriftBalance", "Set the initial condition to be mutation-drift balance."),
          new FlaggedOption( "initFrequency", JSAP.BIGDECIMAL_PARSER, "-0.5", JSAP.NOT_REQUIRED, 'i', "initFrequency", "Set the initial frequency." ),
          new FlaggedOption( "initTime", JSAP.BIGDECIMAL_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 't', "initTime", "The initial time. If not given, the initial time is expected to be in the file with each dataset. Also, this only works with multiplexing." ),
          new FlaggedOption( "mutToBenef", JSAP.BIGDECIMAL_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'a', "mutToBenef", "The mutation rate from the wild type allele to the selected allele." ),
          new FlaggedOption( "mutFromBenef", JSAP.BIGDECIMAL_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'b', "mutFromBenef", "The mutation rate from the selected allele to the wild-type allele." ),
          new FlaggedOption( "selection", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 's', "selection", "Selection coefficient s (can be a range: [start:step:stop])." ),
          new FlaggedOption( "dominance", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'h', "dominance", "Dominance parameter h (can be a range: [start:step:stop])." ),
          new FlaggedOption( "hetF", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'w', "hetF", "Fitness of the heterozygote (can be a range: [start:step:stop])." ),
          new FlaggedOption( "homF", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'v', "homF", "Fitness of the homozygote (can be a range: [start:step:stop])." ),
          new FlaggedOption( "effPopSize", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'e', "effPopSize", "The effective population size (diploid)." ),
          new FlaggedOption( "yearsPerGen", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'y', "yearsPerGen", "Specify how many years a generation takes." ),
          new FlaggedOption( "matrixCutoff", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'c', "matrixCutoff", "The cutoff for the matrix whose eigenvectors yield the coefficients for the eigenfunctions." ),
          new FlaggedOption( "maxM", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'm', "maxM", "Specify how many summands to use in the infinite sum for each eigenfunction." ),
          new FlaggedOption( "maxN", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'n', "maxN", "Specify how many eigenfunctions/-values to use in the computations." ),
          new FlaggedOption( "precision", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'p', "precision", "Specify a precision to be used for the computations. This gives the number of significant digits used." ),
          new Switch ("ignoreBinomials", 'z', "ignoreBinomials", "If set, the likelihood is calculated without the binomial coefficients required to make it a probability."),
          new Switch ("multiplex", JSAP.NO_SHORTFLAG, "multiplex", "Analyze each of the multiple datasests given in the input file using all the selection parameters specified."),
          new Switch ("condOnLastSegregating", JSAP.NO_SHORTFLAG, "condOnLastSegregating", "When set, condition on the last sample being segregating."),
              }
          );

    JSAPResult config = jsap.parse(args);
    if (jsap.messagePrinted()) { System.exit(1); }
   
    // what about the binomials
    boolean ignoreBinomials = config.getBoolean ("ignoreBinomials");
    // what about multiplexing
    boolean multiplex = config.getBoolean ("multiplex");
View Full Code Here

      isMaster = nodeType != null && nodeType.equals("master");
      cfgFile = commandLineOptions.getString("configFile");
   }

   protected JSAPResult parseParameters(String[] args) throws Exception {
      SimpleJSAP jsap = buildCommandLineOptions();

      JSAPResult config = jsap.parse(args);
      if (!config.success() || jsap.messagePrinted()) {
         Iterator<?> messageIterator = config.getErrorMessageIterator();
         while (messageIterator.hasNext()) System.err.println(messageIterator.next());
         System.err.println(jsap.getHelp());
         return null;
      }

      return config;
   }
View Full Code Here

      }
   }

   @Override
   protected SimpleJSAP buildCommandLineOptions() throws JSAPException {
      return new SimpleJSAP("PiApproximationDemo",
                            "Approximate Pi using Infinispan DistributedExecutorService ", new Parameter[]{
                  new FlaggedOption("configFile", JSAP.STRING_PARSER, "config-samples/distributed-udp.xml",
                                    JSAP.NOT_REQUIRED, 'c', "configFile",
                                    "Infinispan config file"),
                  new FlaggedOption("nodeType", JSAP.STRING_PARSER, "slave", JSAP.REQUIRED,
View Full Code Here

      }
   }

   @Override
   protected SimpleJSAP buildCommandLineOptions() throws JSAPException {
      return new SimpleJSAP(
            "WordCountDemo",
            "Count words in Infinispan cache usin MapReduceTask ",
            new Parameter[]{
                  new FlaggedOption("configFile", JSAP.STRING_PARSER, "config-samples/distributed-udp.xml",
                                    JSAP.NOT_REQUIRED, 'c', "configFile",
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public static void main(String[] args) throws JSAPException, IOException, ClassNotFoundException {

    final SimpleJSAP jsap = new SimpleJSAP(ClusterSequences.class.getName(),
        "Parses input sequences to do clustering on them. Input sequences should have one sequence per line. "
            + "Each sequence is a tab-separated list of symbols.", new Parameter[] {
            new Switch("verbose", 'v', "verbose", "Set verbose output"),
            new FlaggedOption("taxonomy-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 't', "taxonomy-file",
                "File containing the description of the taxonomy."),
            new FlaggedOption("clusters", JSAP.INTEGER_PARSER, Integer.toString(DEFAULT_CLUSTERS), JSAP.NOT_REQUIRED, 'c', "clusters",
                "Number of clusters to use."),
            new FlaggedOption("passes", JSAP.INTEGER_PARSER, Integer.toString(DEFAULT_PASSES), JSAP.NOT_REQUIRED, 'p', "passes",
                "Number of passes of the algorithm to do."),

            new Switch("init-all-leaves", 'l', "init-all-leaves", "Initial model states are all leaves from taxonomy."),
            new FlaggedOption("init-all-level", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'e', "init-all-level",
                "Initial model states are leaves or internal nodes at level <= x."),
            new FlaggedOption("init-explicit", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'x', "init-explicit",
                "Initial model states are a quote-enclosed, space-separated list, given as input."),
            new FlaggedOption("max-iterations", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'm', "max-iterations",
                "Maximum number of iterations to try for building the model."),
            new FlaggedOption("batch-size", JSAP.INTEGER_PARSER, Integer.toString(LearnModel.DEFAULT_BATCH_SIZE), JSAP.NOT_REQUIRED, 'b', "batch-size",
                "How many candidates to evaluate at a time before adding their children to the priority queue."),
            new FlaggedOption("search-method", JSAP.STRING_PARSER, SearchStrategy.DEFAULT_SEARCH_STRATEGY.getSimpleName(), JSAP.NOT_REQUIRED, 's',
                "search-method", "Search method, allowed values: " + LearnModel.getSearchCriteriaAsString()),
            new FlaggedOption("search-method-weight-1", JSAP.DOUBLE_PARSER, Double.toString(CloserToOrigin.DEFAULT_PROBABILITY_WEIGHT), JSAP.NOT_REQUIRED,
                'w', "search-method-weight-1", "For the method " + CloserToOrigin.class.getSimpleName()
                    + ", the relative importance of having low probability versus having less states"),
            new FlaggedOption("winner-model-maxstates", JSAP.INTEGER_PARSER, Integer.toString(LearnModel.DEFAULT_OUTPUT_MAX_STATES), JSAP.NOT_REQUIRED, 'u',
                "winner-model-maxstates",
                "Output model (winner) must have at most this number of states; this is taken only as a hint, so if there is no model with that few states, "
                    + "the one with the lower number of states will be selected"),

            new FlaggedOption("input-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'i', "input-file", "File containing the input sequences."),
            new FlaggedOption("output-assignment", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'a', "output-assignment",
                "File for writing the output cluster assignments."),
            new FlaggedOption("output-models-basename", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "output-models-basename",
                "Base filename for writing the models."),

        });

    final JSAPResult jsapResult = jsap.parse(args);
    if (jsap.messagePrinted())
      return;

    if (jsapResult.getBoolean("verbose")) {
      logger.setLevel(Level.DEBUG);
    }
View Full Code Here

   * @throws IOException
   * @throws JSAPException
   */
  public static void main(String[] args) throws IOException, JSAPException {
   
    final SimpleJSAP jsap = new SimpleJSAP(
        GenerateSequences.class.getName(),
        "Generates sequences given a HMM.",
        new Parameter[] {
            new Switch("verbose", 'v', "verbose", "Set the verbose output"),
            new FlaggedOption("num-sequences", JSAP.INTEGER_PARSER, Integer.toString(DEFAULT_SEQUENCES), JSAP.NOT_REQUIRED, 'n', "num-sequences",
            "Number of sequences to generate."),
            new FlaggedOption("model-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'm', "model-file",
                "File containing the description of the HMM."),
            new FlaggedOption("taxonomy-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 't', "taxonomy-file",
                "File containing the taxonomy."),
    });
   
    final JSAPResult jsapResult = jsap.parse(args);
    if (jsap.messagePrinted())
      return;
    if (jsapResult.getBoolean("verbose")) {
      logger.setLevel(Level.DEBUG);
    }
   
View Full Code Here

   */
  public static void main(String[] args) throws IOException, JSAPException {

    logger.setLevel(Level.INFO);

    final SimpleJSAP jsap = new SimpleJSAP(ComputeProbabilities.class.getName(), "Computes the probabilities of a set of sequences given a HMM.", new Parameter[] {
        new Switch("verbose", 'v', "verbose", "Set verbose output"),
        new FlaggedOption("model-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'm', "model-file", "File containing the description of the HMM."),
        new FlaggedOption("taxonomy-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 't', "taxonomy-file", "File containing the taxonomy."),
        new FlaggedOption("input-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'i', "input-file", "File containing the input sequences."),
        new FlaggedOption("sequence", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 's', "sequence",
            "Optionally, pass a single sequence as a string. Place it between quotes, with space-separated symbols.") });

    final JSAPResult jsapResult = jsap.parse(args);
    if (jsap.messagePrinted())
      return;
    if (jsapResult.getBoolean("verbose")) {
      logger.setLevel(Level.DEBUG);
    }

View Full Code Here

  @SuppressWarnings("unchecked")
  public static void main(String[] args) throws IOException, JSAPException, ClassNotFoundException, InstantiationException, IllegalAccessException {

    String searchCriteria = getSearchCriteriaAsString();

    final SimpleJSAP jsap = new SimpleJSAP(
        LearnModel.class.getName(),
        "Learns a HMM based on the frequency of the transitions observed. Requires a list of acceptable states where not there can not be an state and one of its descendants in the taxonomy.",
        new Parameter[] {
            new Switch("verbose", 'v', "verbose", "Set verbose output"),
            new FlaggedOption("taxonomy-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 't', "taxonomy-file",
                "File containing the description of the taxonomy."),
            new Switch("init-all-leaves", 'l', "init-all-leaves", "Initial model states are all leaves from taxonomy."),
            new FlaggedOption("init-all-level", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'e', "init-all-level",
                "Initial model states are leaves or internal nodes at level <= x."),
            new FlaggedOption("init-explicit", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'x', "init-explicit",
                "Initial model states are a quote-enclosed, space-separated list, given as input."),
            new FlaggedOption("input-file", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'i', "input-file", "File containing the input sequences."),
            new FlaggedOption("max-iterations", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'm', "max-iterations",
              "Maximum number of iterations to try for building the model."),
            new FlaggedOption("batch-size", JSAP.INTEGER_PARSER, Integer.toString(DEFAULT_BATCH_SIZE), JSAP.NOT_REQUIRED, 'b', "batch-size",
              "How many candidates to evaluate at a time before adding their children to the priority queue."),
            new FlaggedOption("search-method", JSAP.STRING_PARSER, SearchStrategy.DEFAULT_SEARCH_STRATEGY.getSimpleName(), JSAP.NOT_REQUIRED, 's',
                "search-method", "Search method, allowed values: " + searchCriteria.toString()),
            new FlaggedOption("search-method-weight-1", JSAP.DOUBLE_PARSER, Double.toString(CloserToOrigin.DEFAULT_PROBABILITY_WEIGHT), JSAP.NOT_REQUIRED,
                'w', "search-method-weight-1", "For the method " + CloserToOrigin.class.getSimpleName()
                    + ", the relative importance of having low probability versus having less states"),
            new FlaggedOption("output-log", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'g', "output-log",
                "Output file for logging all searched models"),
            new FlaggedOption("output-model", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "output-model",
                "Output file for writing the winner model"),
            new FlaggedOption("winner-model-maxstates", JSAP.INTEGER_PARSER, Integer.toString(DEFAULT_OUTPUT_MAX_STATES), JSAP.NOT_REQUIRED, 'u',
                "winner-model-maxstates",
                "Output model (winner) must have at most this number of states; this is taken only as a hint, so if there is no model with that few states, "
                    + "the one with the lower number of states will be selected"),
           
        });

    final JSAPResult jsapResult = jsap.parse(args);
    if (jsap.messagePrinted())
      return;

    if (jsapResult.getBoolean("verbose")) {
      logger.setLevel(Level.DEBUG);
    }
View Full Code Here

TOP

Related Classes of com.martiansoftware.jsap.SimpleJSAP

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.