コード例 #1
0
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;
}
コード例 #2
0
static GtOptionParser* gt_linspace_align_option_parser_new(void *tool_arguments)
{
  GtLinspaceArguments *arguments = tool_arguments;
  GtOptionParser *op;
  GtOption *optionstrings, *optionfiles, *optionglobal, *optionlocal,
           *optiondna, *optionprotein, *optioncostmatrix, *optionlinearcosts,
           *optionaffinecosts, *optionoutputfile, *optionshowscore,
           *optionshowsequences, *optiondiagonal, *optiondiagonalbonds,
           *optionsimilarity, *optiontsfactor, *optionspacetime,
           *optionscoreonly, *optionwildcardsymbol;

  gt_assert(arguments);

  /* init */
  op = gt_option_parser_new("[ss|ff] sequence1 sequence2 [dna|protein] "
                            "[global|local] [a|l] costs/scores "
                            "[additional options]",
                            "Apply function to compute alignment.");
  gt_option_parser_set_mail_address(op,
                          "<*****@*****.**>");

  /* -bool */
  optionglobal = gt_option_new_bool("global", "global alignment",
                                    &arguments->global, false);
  gt_option_parser_add_option(op, optionglobal);

  optionlocal = gt_option_new_bool("local", "local alignment",
                                   &arguments->local, false);
  gt_option_parser_add_option(op, optionlocal);

  optiondiagonal = gt_option_new_bool("d", "diagonalband alignment",
                                      &arguments->diagonal, false);
  gt_option_parser_add_option(op, optiondiagonal);

  optiondna = gt_option_new_bool("dna", "type of sequences: DNA",
                                 &arguments->dna, false);
  gt_option_parser_add_option(op, optiondna);

  optionprotein = gt_option_new_bool("protein", "type of sequences: protein",
                                      &arguments->protein, false);
  gt_option_parser_add_option(op, optionprotein);

  optionwildcardsymbol = gt_option_new_bool("wildcard", "show symbol used to "
                                            "represented wildcards in output",
                                            &arguments->wildcardshow, false);
  gt_option_parser_add_option(op, optionwildcardsymbol);

  /* special case, if given matrix includes cost values in place of scores */
  optioncostmatrix = gt_option_new_bool("costmatrix", "describes type of "
                                        "given substituation matrix",
                                        &arguments->has_costmatrix, false);
  gt_option_parser_add_option(op, optioncostmatrix);

  optionshowscore = gt_option_new_bool("showscore", "show score for alignment, "
                                       "please note it will calculate costs "
                                       "for global alignments and scores for "
                                       "local alignemnts always, independtly "
                                       "of input ",
                                       &arguments->showscore, false);
  gt_option_parser_add_option(op, optionshowscore);

  optionshowsequences = gt_option_new_bool("showsequences", "show sequences u "
                                           "and v in front of alignment",
                                       &arguments->showsequences, false);
  gt_option_parser_add_option(op, optionshowsequences);

  optionscoreonly = gt_option_new_bool("showonlyscore", "show only score for "
                                       "generated alignment to compare with "
                                       "other algorithms",
                                       &arguments->scoreonly, false);
  gt_option_parser_add_option(op, optionscoreonly);

  optionspacetime = gt_option_new_bool("spacetime", "write space peak and time"
                                       " overall on stdout",
                                       &arguments->spacetime, false);
  gt_option_parser_add_option(op, optionspacetime);

  /* -str */
  optionstrings = gt_option_new_string_array("ss", "input, use two strings",
                                             arguments->strings);
  gt_option_parser_add_option(op, optionstrings);

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

  optionlinearcosts = gt_option_new_string_array("l", "lineargapcosts, "
                                                 "use match, mismatch and "
                                                 "gapcost, alternatively "
                                                 "substituationmatrix and "
                                                 "gapcost",
                                                 arguments->linearcosts);
  gt_option_parser_add_option(op, optionlinearcosts);

  optionaffinecosts = gt_option_new_string_array("a", "affinegapcosts, "
                                           "use match, mismatch, gap_extension "
                                           "and gap_opening, alternatively "
                                           "substituationmatrix, gap_extension "
                                           "and gap_opening",
                                           arguments->affinecosts);
  gt_option_parser_add_option(op, optionaffinecosts);

  optiondiagonalbonds = gt_option_new_string_array("lr", "specified left and "
                                                   "right shift of diagonal",
                                                   arguments->diagonalbonds);
  gt_option_parser_add_option(op, optiondiagonalbonds);

  optionoutputfile = gt_option_new_string("o", "print alignment, "
                                          "use outputfile",
                                          arguments->outputfile, "stdout");
  gt_option_parser_add_option(op, optionoutputfile);

  /* -ulong */
  optiontsfactor = gt_option_new_ulong("t", "timesquarefactor to organize "
                                       "time and space",
                                       &arguments->timesquarefactor,1);
  gt_option_parser_add_option(op, optiontsfactor);

  /* -double */
  optionsimilarity = gt_option_new_probability("similarity", "specified left "
                                               "and right shift of diagonal by "
                                               "similarity of sequences, "
                                               "0 <= similarty <= 1",
                                               &arguments->similarity, 0);
  gt_option_parser_add_option(op, optionsimilarity);

  /* dependencies */
  gt_option_is_mandatory_either(optionstrings, optionfiles);
  gt_option_is_mandatory_either(optiondna, optionprotein);
  gt_option_exclude(optionlocal, optionglobal);
  gt_option_exclude(optionlinearcosts, optionaffinecosts);
  gt_option_exclude(optiondna, optionprotein);
  gt_option_exclude(optionshowsequences, optionscoreonly);
  gt_option_exclude(optionsimilarity, optiondiagonalbonds);
  gt_option_imply_either_2(optionfiles, optionglobal, optionlocal);
  gt_option_imply_either_2(optiondna, optionstrings, optionfiles);
  gt_option_imply_either_2(optionstrings, optionglobal, optionlocal);
  gt_option_imply_either_2(optionprotein, optionstrings, optionfiles);
  gt_option_imply_either_2(optionlocal, optionlinearcosts, optionaffinecosts);
  gt_option_imply_either_2(optionglobal, optionlinearcosts, optionaffinecosts);
  gt_option_imply_either_2(optionshowscore,optionlinearcosts,optionaffinecosts);
  gt_option_imply_either_2(optionshowsequences, optionstrings, optionfiles);
  gt_option_imply_either_2(optionscoreonly,optionlinearcosts,optionaffinecosts);
  gt_option_imply(optiondiagonal, optionglobal);
  gt_option_imply(optiondiagonalbonds, optiondiagonal);
  gt_option_imply(optionsimilarity, optiondiagonal);
  gt_option_imply(optioncostmatrix, optionprotein);

  /* extended options */
  gt_option_is_extended_option(optiontsfactor);
  gt_option_is_extended_option(optionshowscore);
  gt_option_is_extended_option(optionwildcardsymbol);
  gt_option_is_extended_option(optioncostmatrix);

  /* development option(s) */
  gt_option_is_development_option(optionspacetime);
  gt_option_is_development_option(optionscoreonly);/*only useful to test*/

  return op;
}
コード例 #3
0
static GtIndexOptions* gt_index_options_register_generic_create(
                                                      GtOptionParser *op,
                                                      GtIndexOptionsIndexType t)
{
  GtIndexOptions *idxo;
  gt_assert(op != NULL && t != GT_INDEX_OPTIONS_UNDEFINED);
  idxo = gt_index_options_new();
  idxo->type = t;
  idxo->optionprefixlength = gt_option_new_uint_min("pl",
                                    "specify prefix length for bucket sort\n"
                                    "recommendation: use without argument;\n"
                                    "then a reasonable prefix length is "
                                    "automatically determined.",
                                    &idxo->prefixlength,
                                    GT_PREFIXLENGTH_AUTOMATIC,
                                    1U);
  gt_option_argument_is_optional(idxo->optionprefixlength);
  gt_option_parser_add_option(op, idxo->optionprefixlength);

  idxo->optionuserdefinedsortmaxdepth
    = gt_option_new_uint_min("sortmaxdepth","sort only up to the given depth.",
                             &idxo->sfxstrategy.userdefinedsortmaxdepth,
                             0,
                             1U);
  gt_option_parser_add_option(op, idxo->optionuserdefinedsortmaxdepth);
  gt_option_is_development_option(idxo->optionuserdefinedsortmaxdepth);

  idxo->optiondifferencecover = gt_option_new_uint_min("dc",
                                    "specify difference cover value",
                                    &idxo->sfxstrategy.differencecover,
                                    0,
                                    4U);
  gt_option_parser_add_option(op, idxo->optiondifferencecover);
  gt_option_exclude(idxo->optionuserdefinedsortmaxdepth,
                    idxo->optiondifferencecover);

  idxo->optioncmpcharbychar = gt_option_new_bool("cmpcharbychar",
                                           "compare suffixes character "
                                           "by character",
                                           &idxo->sfxstrategy.cmpcharbychar,
                                           false);
  gt_option_is_development_option(idxo->optioncmpcharbychar);
  gt_option_parser_add_option(op, idxo->optioncmpcharbychar);

  idxo->optionnoshortreadsort = gt_option_new_bool("noshortreadsort",
                                           "do not use short read sort",
                                           &idxo->sfxstrategy.noshortreadsort,
                                           false);
  gt_option_is_development_option(idxo->optionnoshortreadsort);
  gt_option_parser_add_option(op, idxo->optionnoshortreadsort);

  idxo->optionmaxwidthrealmedian = gt_option_new_uword("maxwidthrealmedian",
                                                 "compute real median for "
                                                 "intervals of at most the "
                                                 "given widthprefixes",
                                                 &idxo->sfxstrategy.
                                                      maxwidthrealmedian,
                                                 1UL);
  gt_option_is_development_option(idxo->optionmaxwidthrealmedian);
  gt_option_parser_add_option(op, idxo->optionmaxwidthrealmedian);

  idxo->optionalgbounds
    = gt_option_new_string_array("algbds",
                                 "length boundaries for the different "
                                 "algorithms to sort buckets of suffixes\n"
                                 "first number: maxbound for insertion sort\n"
                                 "second number: maxbound for blindtrie sort\n"
                                 "third number: maxbound for counting sort",
                                 idxo->algbounds);
  gt_option_is_development_option(idxo->optionalgbounds);
  gt_option_parser_add_option(op, idxo->optionalgbounds);

  idxo->optionstorespecialcodes
    = gt_option_new_bool("storespecialcodes",
                         "store special codes (this may speed up the program)",
                         &idxo->sfxstrategy.storespecialcodes,false);

  gt_option_is_development_option(idxo->optionstorespecialcodes);
  gt_option_parser_add_option(op, idxo->optionstorespecialcodes);

  idxo->optionparts
    = gt_option_new_uint_max("parts",
                             "specify number of parts in which the index "
                             "construction is performed",
                             &idxo->numofparts, 1U, (unsigned) ((1 << 22) - 1));
  gt_option_is_development_option(idxo->optionparts);
  gt_option_parser_add_option(op, idxo->optionparts);

  if (idxo->type == GT_INDEX_OPTIONS_ESA)
  {
    idxo->optionspmopt = gt_option_new_uint_min("spmopt",
                                            "optimize esa-construction for "
                                            "suffix-prefix matching",
                                            &idxo->sfxstrategy.spmopt_minlength,
                                            0,1U);
    gt_option_parser_add_option(op, idxo->optionspmopt);
    gt_option_exclude(idxo->optionspmopt, idxo->optiondifferencecover);
    idxo->optionmemlimit = gt_option_new_string("memlimit",
                           "specify maximal amount of memory to be used during "
                           "index construction (in bytes, the keywords 'MB' "
                           "and 'GB' are allowed)",
                           idxo->memlimit, NULL);
    gt_option_parser_add_option(op, idxo->optionmemlimit);
    gt_option_exclude(idxo->optionmemlimit, idxo->optionparts);
  }

  idxo->option = gt_option_new_bool("iterscan",
                                   "use iteratorbased-kmer scanning",
                                   &idxo->sfxstrategy.iteratorbasedkmerscanning,
                                   false);
  gt_option_is_development_option(idxo->option);
  gt_option_parser_add_option(op, idxo->option);

  idxo->option = gt_option_new_bool("samplewithprefixlengthnull",
                                  "sort sample with prefixlength=0",
                                  &idxo->sfxstrategy.samplewithprefixlengthnull,
                                  false);
  gt_option_is_development_option(idxo->option);
  gt_option_parser_add_option(op, idxo->option);

  idxo->option = gt_option_new_bool("suftabuint",
                                    "use uint32_t for suftab",
                                    &idxo->sfxstrategy.suftabuint,
                                    false);
  gt_option_is_development_option(idxo->option);
  gt_option_parser_add_option(op, idxo->option);

  idxo->option = gt_option_new_bool("onlybucketinsertion",
                                    "perform only bucket insertion",
                                    &idxo->sfxstrategy.onlybucketinsertion,
                                    false);
  gt_option_is_development_option(idxo->option);
  gt_option_parser_add_option(op, idxo->option);

  idxo->option = gt_option_new_bool("kmerswithencseqreader",
                               "always perform kmerscanning with encseq-reader",
                               &idxo->sfxstrategy.kmerswithencseqreader,
                               false);
  gt_option_is_development_option(idxo->option);
  gt_option_parser_add_option(op, idxo->option);

  idxo->option = gt_option_new_bool("dccheck",
                               "check intermediate results in difference cover",
                               &idxo->sfxstrategy.dccheck,
                               false);
  gt_option_is_development_option(idxo->option);
  gt_option_parser_add_option(op, idxo->option);

  idxo->option = gt_option_new_bool("withradixsort",
                                    "use radixsort to sort the buckets",
                                    &idxo->sfxstrategy.withradixsort,
                                    false);
  gt_option_is_development_option(idxo->option);
  gt_option_parser_add_option(op, idxo->option);

  idxo->option = gt_option_new_bool("compressedoutput",
                                    "output suftab and lcptab in compressed "
                                    "form",
                                    &idxo->sfxstrategy.compressedoutput,
                                    false);
  gt_option_is_development_option(idxo->option);
  gt_option_parser_add_option(op, idxo->option);

  gt_option_parser_register_hook(op, gt_index_options_check_set_create_opts,
                                 idxo);
  return idxo;
}
コード例 #4
0
static GtOptionParser* gt_matstat_option_parser_new(void *tool_arguments)
{
  Gfmsubcallinfo *arguments = tool_arguments;
  GtOptionParser *op;
  gt_assert(arguments);

  op = gt_option_parser_new("[options ...] -query queryfile [...]",
                         arguments->doms
                         ? "Compute matching statistics."
                         : "Compute length of minimum unique prefixes.");
  gt_option_parser_set_mail_address(op,"<*****@*****.**>");

  arguments->optionfmindex = gt_option_new_string("fmi", "specify fmindex",
                                                  arguments->indexname,NULL);
  gt_option_parser_add_option(op, arguments->optionfmindex);

  arguments->optionesaindex = gt_option_new_string("esa",
                                                   "specify suffix array",
                                                   arguments->indexname,NULL);
  gt_option_parser_add_option(op, arguments->optionesaindex);

  arguments->optionpckindex = gt_option_new_string("pck",
                                                   "specify packed index",
                                                   arguments->indexname,NULL);
  gt_option_parser_add_option(op, arguments->optionpckindex);

  gt_option_exclude(arguments->optionfmindex,arguments->optionesaindex);
  gt_option_exclude(arguments->optionpckindex,arguments->optionesaindex);
  gt_option_exclude(arguments->optionpckindex,arguments->optionfmindex);

  arguments->optionquery = gt_option_new_filename_array("query",
                                                     "specify queryfiles",
                                                     arguments->queryfilenames);
  gt_option_is_mandatory(arguments->optionquery);
  gt_option_parser_add_option(op, arguments->optionquery);

  arguments->optionmin = gt_option_new_uword_min("min",
                                   "only output length "
                                   "if >= given minimum length",
                                   &arguments->minlength.
                                          valueunsignedlong,
                                   0,(GtUword) 1);
  gt_option_parser_add_option(op, arguments->optionmin);

  arguments->optionmax = gt_option_new_uword_min("max",
                                   "only output length "
                                   "if <= given maximum length",
                                   &arguments->maxlength.
                                          valueunsignedlong,
                                   0,(GtUword) 1);
  gt_option_parser_add_option(op, arguments->optionmax);

  arguments->optionoutput = gt_option_new_string_array("output",
                   arguments->doms
                     ? "set output flags (sequence, querypos, subjectpos)"
                     : "set output flags (sequence, querypos)",
                   arguments->flagsoutputoption);
  gt_option_parser_add_option(op, arguments->optionoutput);

  if (arguments->doms) {
    arguments->optionverify = gt_option_new_bool("verify",
                                                 "verify witness positions",
                                                 &arguments->verifywitnesspos,
                                                 false);
    gt_option_is_development_option(arguments->optionverify);
    gt_option_parser_add_option(op, arguments->optionverify);
  } else
  {
    arguments->verifywitnesspos = false;
  }

  gt_option_parser_refer_to_manual(op);

  return op;
}