Beispiel #1
0
static OPrval parse_options(int *parsed_args, RegionCovArguments *arguments,
                            int argc, const char **argv, GtError *err)
{
  GtOptionParser *op;
  GtOption *o;
  OPrval oprval;
  gt_error_check(err);
  op = gt_option_parser_new("[option ...] GFF3_file",
                         "Show which parts of the given sequence regions are "
                         "covered by features.");
  /* -maxfeaturedist */
  o = gt_option_new_ulong("maxfeaturedist", "set the maximum distance two "
                       "features can have while still being in the same "
                       "``cluster''", &arguments->max_feature_dist, 0);
  gt_option_parser_add_option(op, o);
  /* -v */
  o = gt_option_new_verbose(&arguments->verbose);
  gt_option_parser_add_option(op, o);
  /* parse */
  gt_option_parser_set_min_max_args(op, 1, 1);
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);
  gt_option_parser_delete(op);
  return oprval;
}
Beispiel #2
0
static GtOPrval parse_options(GtStr *indexname,GtStrArray *indexnametab,
                              int *parsed_args, int argc,
                              const char **argv, GtError *err)
{
    GtOptionParser *op;
    GtOPrval oprval;
    GtOption *option;

    gt_error_check(err);
    op = gt_option_parser_new("storeindex <mkvindex1> <mkvindex2> ...",
                              "Merge indexes into one index.");
    gt_option_parser_set_mail_address(op,"<*****@*****.**>");
    option = gt_option_new_filename_array("ii",
                                          "specify input index files (mandatory)",
                                          indexnametab);
    gt_option_is_mandatory(option);
    gt_option_parser_add_option(op, option);

    option = gt_option_new_string("indexname",
                                  "specify index to be created",
                                  indexname, NULL);

    gt_option_is_mandatory(option);
    gt_option_parser_add_option(op, option);

    oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                    err);
    gt_option_parser_delete(op);
    return oprval;
}
Beispiel #3
0
int gt_tool_run(GtTool *tool, int argc, const char **argv, GtError *err)
{
  GtOPrval oprval;
  int parsed_args, had_err = 0;
  gt_error_check(err);
  gt_assert(tool);

  /* create tool arguments object */
  if (tool->tool_arguments_new && !tool->arguments)
    tool->arguments = tool->tool_arguments_new();

  /* create option parser object */
  if (tool->tool_option_parser_new && !tool->op)
    tool->op = tool->tool_option_parser_new(tool->arguments);
  else {
    /* make sure defaults are restored when reusing option parsers */
    gt_option_parser_reset(tool->op);
  }

  /* parse options */
  oprval = gt_option_parser_parse(tool->op, &parsed_args, argc, argv,
                                  gt_versionfunc, err);

  switch (oprval) {
    case GT_OPTION_PARSER_OK:
      break;
    case GT_OPTION_PARSER_ERROR:
      had_err = -1;
      break;
    case GT_OPTION_PARSER_REQUESTS_EXIT:
      if (tool->arguments) {
        tool->tool_arguments_delete(tool->arguments);
        tool->arguments = NULL;
      }
      return 0;
  }

  /* check tool arguments */
  if (!had_err && tool->tool_arguments_check) {
    had_err = tool->tool_arguments_check(argc - parsed_args, tool->arguments,
                                         err);
  }

  /* run tool */
  if (!had_err)
    had_err = tool->tool_runner(argc, argv, parsed_args, tool->arguments, err);

  /* return */
  if (had_err)
    return -1;
  return 0;
}
Beispiel #4
0
GtOPrval gtr_parse(GtR *gtr, int *parsed_args, int argc, const char **argv,
                   GtError *err)
{
  GtOptionParser *op;
  GtOPrval oprval;
  gt_error_check(err);
  gt_assert(gtr);
  op = gtr_option_parser_new(gtr);
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);
  gt_option_parser_delete(op);
  return oprval;
}
Beispiel #5
0
int gt_tool_run(GtTool *tool, int argc, const char **argv, GtError *err)
{
  void *tool_arguments = NULL;
  GtOptionParser *op;
  OPrval oprval;
  int parsed_args, had_err = 0;
  gt_error_check(err);
  gt_assert(tool);

  /* create tool arguments object */
  if (tool->tool_arguments_new)
    tool_arguments = tool->tool_arguments_new();

  /* parse options */
  op = tool->tool_option_parser_new(tool_arguments);
  oprval = gt_option_parser_parse(op, &parsed_args, argc, argv, gt_versionfunc,
                                  err);
  gt_option_parser_delete(op);
  switch (oprval) {
    case OPTIONPARSER_OK:
      break;
    case OPTIONPARSER_ERROR:
      had_err = -1;
      break;
    case OPTIONPARSER_REQUESTS_EXIT:
      if (tool_arguments)
        tool->tool_arguments_delete(tool_arguments);
      return 0;
  }

  /* check tool arguments */
  if (!had_err && tool->tool_arguments_check) {
    had_err = tool->tool_arguments_check(argc - parsed_args , tool_arguments,
                                         err);
  }

  /* run tool */
  if (!had_err)
    had_err = tool->tool_runner(argc, argv, parsed_args, tool_arguments, err);

  /* delete tool argument object */
  if (tool_arguments)
    tool->tool_arguments_delete(tool_arguments);

  /* return */
  if (had_err)
    return -1;
  return 0;
}
Beispiel #6
0
static OPrval parse_options(int *parsed_args, int argc, const char **argv,
                            GtError *err)
{
  GtOptionParser *op;
  OPrval oprval;
  op = gt_option_parser_new("[GFF3_file ...]",
                            "Parse GFF3 file(s) and show it as "
                            "GTF2.2.");
  /* parse */
  gt_option_parser_set_max_args(op, 1);
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);
  gt_option_parser_delete(op);
  return oprval;
}
static GtOPrval gthmkbssmfiles_parse_options(int *parsed_args, int argc,
                                             const char **argv, GtError *err)
{
  GtOptionParser *op;
  GtOPrval oprval;
  gt_error_check(err);
  op = gt_option_parser_new("output_path", "Write hard coded BSSM files to "
                         "output_path.");
  gt_option_parser_set_min_max_args(op, 1, 1);
  gt_option_parser_set_mail_address(op, "<*****@*****.**>");
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);
  gt_option_parser_delete(op);
  return oprval;
}
Beispiel #8
0
static GtOPrval parse_options(int *parsed_args, int argc, const char **argv,
                              GtError *err)
{
  GtOptionParser *op;
  GtOPrval oprval;
  gt_error_check(err);
  op = gt_option_parser_new("file [...]",
                            "Map the supplied files into memory and "
                            "read them once.");
  gt_option_parser_set_min_args(op, 1);
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);
  gt_option_parser_delete(op);
  return oprval;
}
static GtOPrval gthfilestat_parse_options(int *parsed_args,
                                          GthFileStatInfo *file_stat_info,
                                          int argc, const char **argv,
                                          const GthPlugins *plugins,
                                          GtError *err)
{
  GtOptionParser *op;
  GtOption *o;
  GtOPrval oprval;
  bool verbose;
  gt_error_check(err);

  op = gt_option_parser_new("[option ...] [file ...]", "Show statistics about "
                         "spliced alignments in GenomeThreader output files\n"
                         "containing intermediate results.");

  /* add sa_filter options */
  gth_sa_filter_register_options(op, file_stat_info->sa_filter, false);

  /* -v */
  o = gt_option_new_verbose(&verbose);
  gt_option_parser_add_option(op, o);

  gt_option_parser_set_mail_address(op, "<*****@*****.**>");
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv,
                                  plugins->gth_version_func, err);

  if (verbose)
    file_stat_info->showverbose = gth_show_on_stdout;

  /* save consensus files */
  if (oprval == GT_OPTION_PARSER_OK) {
    while (*parsed_args < argc) {
      gt_str_array_add_cstr(file_stat_info->consensusfiles,
                            argv[*parsed_args]);
      (*parsed_args)++;
    }
  }

  gt_option_parser_delete(op);

  return oprval;
}
Beispiel #10
0
static GtOPrval parse_env_options(int argc, const char **argv, GtError *err)
{
  GtOptionParser *op;
  GtOption *o;
  GtOPrval oprval;
  op = gt_option_parser_new("GT_ENV_OPTIONS='[option ...]' ...",
                         "Parse the options contained in the "
                         "environment variable GT_ENV_OPTIONS.");
  o = gt_option_new_bool("spacepeak", "show space peak on stdout upon deletion",
                         &spacepeak, false);
  gt_option_parser_add_option(op, o);
  o = gt_option_new_bool("showtime", "enable output for run-time statistics",
                         &showtime, false);
  gt_option_parser_add_option(op, o);
  gt_option_parser_set_max_args(op, 0);
  oprval = gt_option_parser_parse(op, NULL, argc, argv, gt_versionfunc, err);
  gt_option_parser_delete(op);
  return oprval;
}
Beispiel #11
0
static OPrval
parseChkIndexOptions(int *parsed_args, int argc, const char *argv[],
                     struct chkIndexOptions *params, GtError *err)
{
  GtOptionParser *op;
  GtOption *option;
  OPrval oprval;
  bool extRankCheck;

  gt_error_check(err);
  op = gt_option_parser_new("indexname",
                         "Map <indexname> block composition index"
                         "and bwt and check index integrity.");

  option = gt_option_new_bool("v",
                           "print verbose progress information",
                           &params->verboseOutput,
                           false);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_ulong("skip", "number of symbols to skip",
                            &params->skipCount, 0);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_ulong("ticks", "print dot after this many symbols"
                            " tested okay", &params->progressInterval,
                            DEFAULT_PROGRESS_INTERVAL);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_bool("ext-rank-check",
                           "do additional checks of rank query results",
                           &extRankCheck, false);
  gt_option_parser_add_option(op, option);

  gt_option_parser_set_min_max_args(op, 1, 1);
  oprval = gt_option_parser_parse(op, parsed_args, argc, (const char**) argv,
                               gt_versionfunc, err);
  gt_option_parser_delete(op);
  params->checkFlags = EIS_VERIFY_BASIC | (extRankCheck?EIS_VERIFY_EXT_RANK:0);
  params->EISFeatureSet = EIS_FEATURE_REGION_SUMS;
  params->encType = BWT_ON_BLOCK_ENC;
  return oprval;
}
Beispiel #12
0
static GtOPrval parse_options(int *parsed_args, ChseqidsArguments *arguments,
                              int argc, const char **argv, GtError *err)
{
  GtOptionParser *op;
  GtOutputFileInfo *ofi;
  GtOption *option;
  GtOPrval oprval;
  gt_error_check(err);

  /* init */
  op = gt_option_parser_new("[option ...] mapping_file [GFF3_file]",
                         "Change sequence ids by the mapping given in "
                         "mapping_file.");
  ofi = gt_outputfileinfo_new();

  /* -sort */
  option = gt_option_new_bool("sort",
                              "sort the GFF3 features after changing the "
                              "sequence ids\n(memory consumption is "
                              "proportional to the input file size)",
                              &arguments->sort, false);
  gt_option_parser_add_option(op, option);

  /* -v */
  option = gt_option_new_verbose(&arguments->verbose);
  gt_option_parser_add_option(op, option);

  /* output file options */
  gt_outputfile_register_options(op, &arguments->outfp, ofi);

  /* parse options */
  gt_option_parser_set_comment_func(op, gt_gtdata_show_help, NULL);
  gt_option_parser_set_min_max_args(op, 1, 2);
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);

  /* free */
  gt_outputfileinfo_delete(ofi);
  gt_option_parser_delete(op);

  return oprval;
}
static GtOPrval parse_options(int *parsed_args,
                              Cmppairwiseopt *pw,
                              int argc, const char **argv, GtError *err)
{
  GtOptionParser *op;
  GtOption *optionstrings,
         *optionfiles,
         *optioncharlistlen,
         *optiontext,
         *optionshowedist;
  GtStrArray *charlistlen;
  GtOPrval oprval;

  gt_error_check(err);
  charlistlen = gt_str_array_new();
  pw->strings = gt_str_array_new();
  pw->files = gt_str_array_new();
  pw->text = gt_str_new();
  pw->charlistlen = NULL;
  pw->showedist = false;
  op = gt_option_parser_new("options", "Apply function to pairs of strings.");
  gt_option_parser_set_mail_address(op, "<*****@*****.**>");

  optionstrings = gt_option_new_string_array("ss", "use two strings",
                                             pw->strings);
  gt_option_parser_add_option(op, optionstrings);

  optionfiles = gt_option_new_filename_array("ff", "use two files",
                                             pw->files);
  gt_option_parser_add_option(op, optionfiles);

  optioncharlistlen = gt_option_new_string_array("a",
                                             "use character list and length",
                                             charlistlen);
  gt_option_parser_add_option(op, optioncharlistlen);

  optiontext = gt_option_new_string("t", "use text", pw->text, NULL);
  gt_option_parser_add_option(op, optiontext);

  optionshowedist = gt_option_new_bool("e", "output unit edit distance",
                      &pw->showedist, false);
  gt_option_parser_add_option(op, optionshowedist);

  gt_option_exclude(optionstrings, optionfiles);
  gt_option_exclude(optionstrings, optioncharlistlen);
  gt_option_exclude(optionstrings, optiontext);
  gt_option_exclude(optionfiles, optioncharlistlen);
  gt_option_exclude(optionfiles, optiontext);
  gt_option_exclude(optioncharlistlen, optiontext);
  gt_option_imply(optionshowedist, optionstrings);

  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);
  if (oprval == GT_OPTION_PARSER_OK)
  {
    if (gt_option_is_set(optionstrings))
    {
      if (gt_str_array_size(pw->strings) != 2UL)
      {
        gt_error_set(err, "option -ss requires two string arguments");
        oprval = GT_OPTION_PARSER_ERROR;
      }
    } else
    {
      if (gt_option_is_set(optionfiles))
      {
        if (gt_str_array_size(pw->files) != 2UL)
        {
          gt_error_set(err, "option -ff requires two filename arguments");
          oprval = GT_OPTION_PARSER_ERROR;
        }
      } else
      {
        if (gt_option_is_set(optioncharlistlen))
        {
          GtWord readint;

          if (gt_str_array_size(charlistlen) != 2UL)
          {
            gt_error_set(err,
                         "option -a requires charlist and length argument");
            oprval = GT_OPTION_PARSER_ERROR;
          }
          pw->charlistlen = gt_malloc(sizeof *pw->charlistlen);
          pw->charlistlen->charlist =
            gt_str_ref(gt_str_array_get_str(charlistlen,
                                                                  0));
          if (sscanf(gt_str_array_get(charlistlen,1UL), GT_WD, &readint) != 1 ||
              readint < 1L)
          {
            gt_error_set(err,
                         "option -a requires charlist and length argument");
            oprval = GT_OPTION_PARSER_ERROR;
          }
          pw->charlistlen->len = (GtUword) readint;
        } else
        {
          if (!gt_option_is_set(optiontext))
          {
            gt_error_set(err,
                         "use exactly one of the options -ss, -ff, -a, -t");
            oprval = GT_OPTION_PARSER_ERROR;
          }
        }
      }
    }
  }
  gt_option_parser_delete(op);
  if (oprval == GT_OPTION_PARSER_OK && *parsed_args != argc)
  {
    gt_error_set(err, "superfluous program parameters");
    oprval = GT_OPTION_PARSER_ERROR;
  }
  gt_str_array_delete(charlistlen);
  return oprval;
}
Beispiel #14
0
static GtOPrval parse_options(int *parsed_args,
                              bool doesa,
                              Suffixeratoroptions *so,
                              int argc, const char **argv, GtError *err)
{
  GtOptionParser *op;
  GtOption *option,
           *optionshowprogress,
           *optiongenomediff,
           *optionii;
  GtOPrval oprval;
  gt_error_check(err);

  op = gt_option_parser_new("[option ...] (-db file [...] | -ii index)",
                            doesa ? "Compute enhanced suffix array."
                                  : "Compute packed index.");
  gt_option_parser_set_mail_address(op, "<*****@*****.**>");

  /* input info */
  so->indexname = gt_str_new();
  so->inputindex = gt_str_new();
  so->db = gt_str_array_new();

  /* register options for encoded sequence handling */
  so->encopts = gt_encseq_options_register_encoding(op, so->indexname, so->db);
  so->loadopts = gt_encseq_options_register_loading(op, so->indexname);

  /* register options for index handling */
  if (doesa)
    so->idxopts = gt_index_options_register_esa(op, so->encopts);
  else
    so->idxopts = gt_index_options_register_packedidx(op, so->indexname,
                                                      so->encopts);

  /* verbosity */
  option = gt_option_new_verbose(&so->beverbose);
  gt_option_parser_add_option(op, option);

  optionshowprogress = gt_option_new_bool("showprogress",
                                          "show a progress bar",
                                          &so->showprogress,
                                          false);
  gt_option_parser_add_option(op, optionshowprogress);

  optionii = gt_option_new_filename("ii", "specify existing encoded sequence",
                                    so->inputindex);
  gt_option_parser_add_option(op, optionii);
  gt_option_is_mandatory_either(gt_encseq_options_db_option(so->encopts),
                                optionii);
  gt_option_exclude(gt_encseq_options_db_option(so->encopts), optionii);
  gt_option_exclude(optionii, gt_encseq_options_smap_option(so->encopts));
  gt_option_exclude(optionii, gt_encseq_options_dna_option(so->encopts));
  gt_option_exclude(optionii, gt_encseq_options_protein_option(so->encopts));
  gt_option_exclude(optionii, gt_encseq_options_plain_option(so->encopts));
  gt_option_exclude(optionii, gt_encseq_options_sat_option(so->encopts));

  optiongenomediff = gt_option_new_bool("genomediff",
                                   "directly process the lcp intervals using "
                                   "the genomediff algorithm (suffix array and "
                                   "lcp-tables are not output)",
                                   &so->genomediff,
                                   false);
  gt_option_is_extended_option(optiongenomediff);
  if (gt_index_options_outsuftab_option(so->idxopts) != NULL) {
    gt_option_exclude(optiongenomediff,
                      gt_index_options_outsuftab_option(so->idxopts));
  }
  gt_option_parser_add_option(op, optiongenomediff);

  /* suffixerator and friends do not take arguments */
  gt_option_parser_set_min_max_args(op, 0U, 0U);

  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);

  if (gt_str_length(so->indexname) == 0UL) {
    /* we do not have an indexname yet, so there was none given in the
       -indexname option and it could not be derived from the input filenames.
       So it must be in the -ii parameter. */
    char *basenameptr;
    basenameptr = gt_basename(gt_str_get(so->inputindex));
    gt_str_set(so->indexname, basenameptr);
    gt_free(basenameptr);
  }

  gt_option_parser_delete(op);

  return oprval;
}
Beispiel #15
0
static GtOPrval gthsplit_parse_options(int *parsed_args,
                                       Gthsplitinfo *gthsplitinfo,
                                       int argc, const char **argv,
                                       const GthPlugins *plugins, GtError *err)
{
  GtOptionParser *op;
  GtOption *optalignmentscore, *optcoverage, *optrange, *optverbose, *optgzip,
           *optbzip2, *optforce;
  bool alignmentscore, coverage, verbose, gzip, bzip2;
  GtOPrval oprval;

  gt_error_check(err);

  op = gt_option_parser_new("-alignmentscore | -coverage [option ...] "
                            "[file ...]", "Split GenomeThreader output files "
                            "containing intermediate results.");

  /* specify all options with a corresponding help-text */
  optalignmentscore = gt_option_new_bool("alignmentscore", "split according to "
                                      "the overall alignment score (scr)",
                                      &alignmentscore, false);
  gt_option_parser_add_option(op, optalignmentscore);

  optcoverage = gt_option_new_bool("coverage", "split according to coverage "
                                   "(cov)", &coverage, false);
  gt_option_parser_add_option(op, optcoverage);

  optrange = gt_option_new_uint_max(RANGE_OPT_CSTR, "set the percentage range "
                                 "used to create the sets",
                                 &gthsplitinfo->range, DEFAULT_RANGE, 100);
  gt_option_parser_add_option(op, optrange);

  /* add sa_filter options */
  gth_sa_filter_register_options(op, gthsplitinfo->sa_filter, false);

  /* -v */
  optverbose = gt_option_new_verbose(&verbose);
  gt_option_parser_add_option(op, optverbose);

  optgzip = gt_option_new_bool("gzip", "write gzip compressed output file(s)",
                               &gzip, false);
  gt_option_parser_add_option(op, optgzip);

  optbzip2 = gt_option_new_bool("bzip2", "write bzip2 compressed output "
                                "file(s)", &bzip2, false);
  gt_option_parser_add_option(op, optbzip2);

  optforce = gt_option_new_bool(GT_FORCE_OPT_CSTR,"force writing to split "
                                "files", &gthsplitinfo->force, false);
  gt_option_parser_add_option(op, optforce);

  gt_option_exclude(optalignmentscore, optcoverage);
  gt_option_exclude(optgzip, optbzip2);
  gt_option_is_mandatory_either(optalignmentscore, optcoverage);

  gt_option_parser_set_mail_address(op, "<*****@*****.**>");
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv,
                                  plugins->gth_version_func, err);

  if (oprval == GT_OPTION_PARSER_OK && alignmentscore)
    gthsplitinfo->splitmode = ALIGNMENTSCORE_SPLIT;
  if (oprval == GT_OPTION_PARSER_OK && coverage)
    gthsplitinfo->splitmode = COVERAGE_SPLIT;
  if (oprval == GT_OPTION_PARSER_OK && 100 % gthsplitinfo->range) {
    gt_error_set(err, "argument to option %s must divide 100 without rest",
              RANGE_OPT_CSTR);
    oprval = GT_OPTION_PARSER_ERROR;
  }
  if (oprval == GT_OPTION_PARSER_OK && verbose)
    gthsplitinfo->showverbose = gth_show_on_stdout;
  if (oprval == GT_OPTION_PARSER_OK && gzip)
    gthsplitinfo->file_mode = GT_FILE_MODE_GZIP;
  if (oprval == GT_OPTION_PARSER_OK && bzip2)
    gthsplitinfo->file_mode = GT_FILE_MODE_BZIP2;

  /* save consensus files */
  if (oprval == GT_OPTION_PARSER_OK) {
    while (*parsed_args < argc) {
      gt_str_array_add_cstr(gthsplitinfo->consensusfiles, argv[*parsed_args]);
      (*parsed_args)++;
    }
  }

  if (oprval == GT_OPTION_PARSER_OK &&
      !gt_str_array_size(gthsplitinfo->consensusfiles) &&
      (gt_option_is_set(optgzip) || gt_option_is_set(optbzip2))) {
    gt_error_set(err, "to use compression, at least on input file has to be "
                      "supplied");
    oprval = GT_OPTION_PARSER_ERROR;
  }

  gt_option_parser_delete(op);

  return oprval;
}
Beispiel #16
0
static OPrval parse_options(int *parsed_args,
                            LTRharvestoptions *lo,
                            int argc, const char **argv, GtError *err)
{
  GtOptionParser *op;
  GtOption *optionindex,
         *optionltrsearchseqrange,
         *optionseed,
         *optionminlenltr,
         *optionmaxlenltr,
         *optionmindistltr,
         *optionmaxdistltr,
         *optionmintsd,
         *optionmaxtsd,
         *optionsimilar,
         *optionmotif,
         *optionmotifmis,
         *optionvic,
         *optionoverlaps,
         *optionxdrop,
         *optionmat,
         *optionmis,
         *optionins,
         *optiondel,
         *optionv,
         *optionoffset,
         *optionlongoutput,
         *optionout,
         *optionoutinner,
         *optiongff3;
  OPrval oprval;
  GtRange default_ltrsearchseqrange = {0,0};
  unsigned int vicinityforcorrectboundaries;

  static const char *overlaps[] = {
    "best", /* the default */
    "no",
    "all",
    NULL
  };

  gt_error_check(err);
  op = gt_option_parser_new("[option ...] -index filenameindex",
                         "Predict LTR retrotransposons.");

  /* -index */
  lo->str_indexname = gt_str_new();
  optionindex = gt_option_new_string("index",
                             "specify the name of the enhanced suffix "
                             "array index (mandatory)",
                             lo->str_indexname, NULL);
  gt_option_is_mandatory(optionindex);
  gt_option_parser_add_option(op, optionindex);

  /* -range */
  optionltrsearchseqrange
    = gt_option_new_range("range",
                          "specify sequence range in which LTRs are searched",
                          &lo->repeatinfo.ltrsearchseqrange,
                          &default_ltrsearchseqrange);
  gt_option_parser_add_option(op, optionltrsearchseqrange);

  /* -seed */
  optionseed = gt_option_new_ulong_min("seed",
                               "specify minimum seed length for"
                               " exact repeats",
                               &lo->minseedlength,
                               30UL,
                               1UL);
  gt_option_parser_add_option(op, optionseed);

  /* -minlenltr */
  optionminlenltr = gt_option_new_ulong_min_max("minlenltr",
                               "specify minimum length for each LTR",
                               &lo->repeatinfo.lmin,
                               100UL,
                               1UL,
                               GT_UNDEF_ULONG);
  gt_option_parser_add_option(op, optionminlenltr);

  /* -maxlenltr */
  optionmaxlenltr = gt_option_new_ulong_min_max("maxlenltr",
                               "specify maximum length for each LTR",
                               &lo->repeatinfo.lmax,
                               1000UL,
                               1UL,
                               GT_UNDEF_ULONG);
  gt_option_parser_add_option(op, optionmaxlenltr);

  /* -mindistltr */
  optionmindistltr = gt_option_new_ulong_min_max("mindistltr",
                               "specify minimum distance of "
                               "LTR startpositions",
                               &lo->repeatinfo.dmin,
                               1000UL,
                               1UL,
                               GT_UNDEF_ULONG);
  gt_option_parser_add_option(op, optionmindistltr);

  /* -maxdistltr */
  optionmaxdistltr = gt_option_new_ulong_min_max("maxdistltr",
                               "specify maximum distance of "
                               "LTR startpositions",
                               &lo->repeatinfo.dmax,
                               15000UL,
                               1UL,
                               GT_UNDEF_ULONG);
  gt_option_parser_add_option(op, optionmaxdistltr);

  /* -similar */
  optionsimilar = gt_option_new_double_min_max("similar",
                               "specify similaritythreshold in "
                               "range [1..100%]",
                               &lo->similaritythreshold,
                               (double) 85.0,
                               (double) 0.0,
                               100.0);
  gt_option_parser_add_option(op, optionsimilar);

  /* -mintsd */
  optionmintsd = gt_option_new_uint_min_max("mintsd",
                              "specify minimum length for each TSD",
                               &lo->minlengthTSD,
                               4U,
                               0,
                               GT_UNDEF_UINT);
  gt_option_parser_add_option(op, optionmintsd);

  /* -maxtsd */
  optionmaxtsd = gt_option_new_uint_min_max("maxtsd",
                              "specify maximum length for each TSD",
                               &lo->maxlengthTSD,
                               20U,
                               0,
                               GT_UNDEF_UINT);
  gt_option_parser_add_option(op, optionmaxtsd);

  /* -motif */
  /* characters will be tranformed later
     into characters from virtualtree alphabet */
  lo->motif.firstleft   = (GtUchar) 't';
  lo->motif.secondleft  = (GtUchar) 'g';
  lo->motif.firstright  = (GtUchar) 'c';
  lo->motif.secondright = (GtUchar) 'a';
  lo->motif.str_motif = gt_str_new();
  optionmotif = gt_option_new_string("motif",
                             "specify 2 nucleotides startmotif + "
                             "2 nucleotides endmotif: ****",
                             lo->motif.str_motif, NULL);
  gt_option_parser_add_option(op, optionmotif);

  /* -motifmis */
  optionmotifmis = gt_option_new_uint_min_max("motifmis",
                             "specify maximum number of "
                             "mismatches in motif [0,3]",
                             &lo->motif.allowedmismatches,
                             4U,
                             0,
                             3U);
  gt_option_parser_add_option(op, optionmotifmis);

  /* -vic */
  optionvic = gt_option_new_uint_min_max("vic",
                        "specify the number of nucleotides (to the left and "
                        "to the right) that will be searched "
                        "for TSDs and/or motifs around 5' and 3' boundary "
                        "of predicted LTR retrotransposons",
                        &vicinityforcorrectboundaries,
                        60U,
                        1U,
                        500U);
  gt_option_parser_add_option(op, optionvic);

  /* -overlaps */
  lo->str_overlaps = gt_str_new();
  optionoverlaps = gt_option_new_choice("overlaps",
               "specify no|best|all",
               lo->str_overlaps,
               overlaps[0],
               overlaps);
  gt_option_parser_add_option(op, optionoverlaps);

  /* -xdrop */
  optionxdrop = gt_option_new_int_min("xdrop",
                        "specify xdropbelowscore for extension-alignment",
                        &lo->xdropbelowscore,
                        (int)5,
                        (int)0);
  gt_option_parser_add_option(op, optionxdrop);

  /* -mat */
  lo->arbitscores.gcd  = 1;      /* set only for initialization,
                                        do not change! */
  optionmat = gt_option_new_int_min("mat",
                        "specify matchscore for extension-alignment",
                        &lo->arbitscores.mat,
                        2,
                        1);
  gt_option_parser_add_option(op, optionmat);

  /* -mis */
  optionmis = gt_option_new_int_max("mis",
                        "specify mismatchscore for extension-alignment",
                        &lo->arbitscores.mis,
                        -2,
                        -1);
  gt_option_parser_add_option(op, optionmis);

  /* -ins */
  optionins = gt_option_new_int_max("ins",
                        "specify insertionscore for extension-alignment",
                        &lo->arbitscores.ins,
                        -3,
                        -1);
  gt_option_parser_add_option(op, optionins);

  /* -del */
  optiondel = gt_option_new_int_max("del",
                        "specify deletionscore for extension-alignment",
                        &lo->arbitscores.del,
                        -3,
                        -1);
  gt_option_parser_add_option(op, optiondel);

  /* -v */
  optionv = gt_option_new_bool("v",
                           "verbose mode",
                           &lo->verbosemode,
                           false);
  gt_option_parser_add_option(op, optionv);

  /* -longoutput */
  optionlongoutput = gt_option_new_bool("longoutput",
                           "additional motif/TSD output",
                           &lo->longoutput,
                           false);
  gt_option_parser_add_option(op, optionlongoutput);

  /* -out */
  lo->fastaoutput = false;      /* by default no FASTA output */
  lo->str_fastaoutputfilename = gt_str_new();
  optionout = gt_option_new_string("out",
                             "specify FASTA outputfilename",
                             lo->str_fastaoutputfilename, NULL);
  gt_option_parser_add_option(op, optionout);

  /* -outinner */
  lo->fastaoutputinnerregion = false;
  lo->str_fastaoutputfilenameinnerregion = gt_str_new();
  optionoutinner = gt_option_new_string("outinner",
                             "specify FASTA outputfilename for inner regions",
                             lo->str_fastaoutputfilenameinnerregion, NULL);
  gt_option_parser_add_option(op, optionoutinner);

  /* -gff3 */
  lo->gff3output = false;       /* by default no gff3 output */
  lo->str_gff3filename = gt_str_new();
  optiongff3 = gt_option_new_string("gff3",
                             "specify GFF3 outputfilename",
                             lo->str_gff3filename, NULL);
  gt_option_parser_add_option(op, optiongff3);

  /* -offset */
  optionoffset = gt_option_new_ulong("offset",
                                     "offset added to GFF3 coordinates",
                                     &lo->offset,
                                     0UL);
  gt_option_parser_add_option(op, optionoffset);
  gt_option_is_extended_option(optionoffset);

  /* implications */
  gt_option_imply(optionmaxtsd, optionmintsd);
  gt_option_imply(optionmotifmis, optionmotif);

  gt_option_imply_either_2(optionlongoutput, optionmintsd, optionmotif);

  gt_option_parser_refer_to_manual(op);
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);
  lo->vicinityforcorrectboundaries = (Seqpos) vicinityforcorrectboundaries;
  if (oprval == OPTIONPARSER_OK)
  {
    if (lo->repeatinfo.lmin > lo->repeatinfo.lmax)
    {
      gt_error_set(err,"argument of -minlenltr is greater than argument of"
          " -maxlenltr");
      oprval = OPTIONPARSER_ERROR;
    }
    if (lo->repeatinfo.dmin > lo->repeatinfo.dmax)
    {
      gt_error_set(err,
          "argument of -mindistltr is greater than argument of -maxdistltr");
      oprval = OPTIONPARSER_ERROR;
    }
    if (lo->repeatinfo.lmax > lo->repeatinfo.dmin)
    {
      gt_error_set(err,"argument of -maxlenltr is greater than argument of"
                    " -mindistltr");
      oprval = OPTIONPARSER_ERROR;
    }
    if (lo->minlengthTSD > lo->maxlengthTSD)
    {
      gt_error_set(err,
          "argument of -mintsd is greater than argument of -maxtsd");
      oprval = OPTIONPARSER_ERROR;
    }

    /* If option motif is set,
       store characters, transform them later */
    if (gt_option_is_set(optionmotif))
    {
      if (gt_str_length(lo->motif.str_motif) != 4UL)
      {
        gt_error_set(err,
            "argument of -motif has not exactly 4 characters");
        oprval = OPTIONPARSER_ERROR;
      }
      lo->motif.firstleft = (GtUchar)  gt_str_get(lo->motif.str_motif)[0];
      lo->motif.secondleft = (GtUchar)  gt_str_get(lo->motif.str_motif)[1];
      lo->motif.firstright = (GtUchar)  gt_str_get(lo->motif.str_motif)[2];
      lo->motif.secondright = (GtUchar)  gt_str_get(lo->motif.str_motif)[3];
      /* default if motif specified */
      if (!gt_option_is_set(optionmotifmis))
      {
        lo->motif.allowedmismatches = 0;
      }
    }

    /* If option overlaps is set */
    if (gt_option_is_set(optionoverlaps))
    {
      if (strcmp(gt_str_get(lo->str_overlaps), "no") == 0)
      {
        lo->bestofoverlap = false;
        lo->nooverlapallowed = true;
      }
      else if (strcmp(gt_str_get(lo->str_overlaps), "best") == 0 )
      {
        lo->bestofoverlap = true;
        lo->nooverlapallowed = false;
      }
      else if (strcmp(gt_str_get(lo->str_overlaps), "all") == 0 )
      {
        lo->bestofoverlap = false;
        lo->nooverlapallowed = false;
      }
      else
      {
        gt_assert(0); /* cannot happen */
      }
    }
    else
    {
      /* default is "best" */
      lo->bestofoverlap = true;     /* take best prediction
                                       if overlap occurs, default */
      lo->nooverlapallowed = false; /* overlapping predictions (not)allowed*/
    }

    /* if FASTA output is set */
    if (gt_option_is_set(optionout))
    {
      lo->fastaoutput = true;
    }

    /* if FASTA output inner region is set */
    if (gt_option_is_set(optionoutinner))
    {
      lo->fastaoutputinnerregion = true;
    }

    /* if GFF3 output is set */
    if (gt_option_is_set(optiongff3))
    {
      lo->gff3output = true;
    }

    if (gt_option_is_set(optionltrsearchseqrange))
    {
      if (lo->repeatinfo.ltrsearchseqrange.start >
          lo->repeatinfo.ltrsearchseqrange.end)
      {
        gt_error_set(err,
            "arguments of -range: first arg must be <= than second arg");
        oprval = OPTIONPARSER_ERROR;
      }
    }
  }

  gt_option_parser_delete(op);
  return oprval;
}
Beispiel #17
0
static GtOPrval parsemkfmindex(Mkfmcallinfo *mkfmcallinfo,
                               int argc,
                               const char **argv,
                               GtError *err)
{
  GtOptionParser *op;
  GtOption *option, *optionfmout;
  GtOPrval oprval;
  int parsed_args;

  gt_error_check(err);
  mkfmcallinfo->indexnametab = gt_str_array_new();
  mkfmcallinfo->outfmindex = gt_str_new();
  mkfmcallinfo->leveldesc = gt_str_new();
  op = gt_option_parser_new("[option ...] -ii indexfile [...]",
                         "Compute FM-index.");
  gt_option_parser_set_mail_address(op, "<*****@*****.**>");
  optionfmout = gt_option_new_string("fmout",
                             "specify name of FM-index to be generated\n"
                             "(mandatory if more than one input index "
                             "is specified)",
                             mkfmcallinfo->outfmindex, NULL);
  gt_option_parser_add_option(op, optionfmout);

  option = gt_option_new_filename_array("ii", "specify indices to be used",
                                        mkfmcallinfo->indexnametab);
  gt_option_is_mandatory(option);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_string("size",
                             "specify size (tiny, small, medium, big)",
                             mkfmcallinfo->leveldesc, "medium");
  gt_option_parser_add_option(op, option);

  option = gt_option_new_bool("noindexpos",
                           "store no index positions (hence the positions of\n"
                           "matches in the index cannot be retrieved)",
                           &mkfmcallinfo->noindexpos,false);
  gt_option_parser_add_option(op, option);

  oprval = gt_option_parser_parse(op, &parsed_args, argc, argv, gt_versionfunc,
                                  err);
  if (oprval == GT_OPTION_PARSER_OK)
  {
    if (!gt_option_is_set(optionfmout))
    {
      if (gt_str_array_size(mkfmcallinfo->indexnametab) > 1UL)
      {
        gt_error_set(err,"if more than one index is given, then "
                          "option -fmout is mandatory");
        oprval = GT_OPTION_PARSER_ERROR;
      } else
      {
        char *basenameptr;

        basenameptr = gt_basename(gt_str_array_get(mkfmcallinfo->indexnametab,
                                  0));
        gt_str_set(mkfmcallinfo->outfmindex,basenameptr);
        gt_free(basenameptr);
      }
    }
  }
  gt_option_parser_delete(op);
  if (oprval == GT_OPTION_PARSER_OK && parsed_args != argc)
  {
    gt_error_set(err,"superfluous program parameters");
    oprval = GT_OPTION_PARSER_ERROR;
  }
  return oprval;
}
static GtOPrval
parseChkBWTOptions(int *parsed_args, int argc, const char **argv,
                   struct chkSearchOptions *params, const GtStr *projectName,
                   GtError *err)
{
  GtOptionParser *op;
  GtOPrval oprval;
  GtOption *option, *optionProgress;
  bool checkSuffixArrayValues, tryContextRetrieve, tryFullRegen;

  gt_error_check(err);
  op = gt_option_parser_new("indexname",
                         "Load (or build if necessary) BWT index for project"
                         " <indexname> and perform verification of search"
                         " results.");

  gt_registerPackedIndexOptions(op, &params->idx, BWTDEFOPT_MULTI_QUERY,
                             projectName);

  option = gt_option_new_long("minpatlen",
                           "minimum length of patterns searched for, -1 "
                           "implies automatic choice based on index "
                           "properties", &params->minPatLen, -1);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_long("maxpatlen",
                           "maximum length of patterns searched for, -1 "
                           "implies automatic choice based on index "
                           "properties", &params->maxPatLen, -1);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_ulong("nsamples",
                            "number of sequences to search for",
                            &params->numOfSamples, 1000);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_bool("chksfxarray",
                           "verify integrity of stored suffix array positions",
                           &checkSuffixArrayValues, false);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_bool("full-lfmap",
                           "verify complete backwards regeneration of "
                           "original sequence", &tryFullRegen, false);
  gt_option_parser_add_option(op, option);

  option = gt_option_new_bool("chkcontext",
                           "verify integrity of regenerated sequence context",
                           &tryContextRetrieve, false);
  gt_option_parser_add_option(op, option);

  optionProgress = gt_option_new_ulong("ticks",
                                    "print dot after this many symbols "
                                    "tested okay", &params->progressInterval,
                                    DEFAULT_PROGRESS_INTERVAL);
  gt_option_parser_add_option(op, optionProgress);

  option = gt_option_new_bool("v",
                           "print verbose progress information",
                           &params->verboseOutput,
                           false);
  gt_option_parser_add_option(op, option);

  gt_option_parser_set_min_max_args(op, 1, 1);
  oprval = gt_option_parser_parse(op, parsed_args, argc, argv, gt_versionfunc,
                                  err);

  /* condense boolean options to flags field */
  params->flags = (checkSuffixArrayValues?VERIFY_BWTSEQ_SUFVAL:0)
    | (tryFullRegen?VERIFY_BWTSEQ_LFMAPWALK:0)
    | (tryContextRetrieve?VERIFY_BWTSEQ_CONTEXT:0);
  /* compute parameters currently not set from command-line or
   * determined indirectly */
  gt_computePackedIndexDefaults(&params->idx, BWTBaseFeatures);

  gt_option_parser_delete(op);

  return oprval;
}