deps/kb_meme/meme-5.0.1/src/meme2meme.c
/**************************************************************************
 * Process the command line arguments and put the results in the
 * options structure.
 **************************************************************************/
Process the command line arguments and put the results in the
options structure.
Process the command line arguments and put the results in the options structure .
void process_arguments(int argc, char **argv, OPTIONS_T *options) {
  bool bad_argument = false;
  int i;
  struct option arg_opts[] = {
    {"help", no_argument, NULL, 'h'},
    {"consensus", no_argument, NULL, 'c'},
    {"numbers", no_argument, NULL, 'n'},
    {"logodds", no_argument, NULL, 'l'},
    {"forceurl", no_argument, NULL, 'f'},
    {"bg", required_argument, NULL, 'b'},
    {"url", required_argument, NULL, 'u'},
    {"xalph", no_argument, NULL, 'x'},
    {NULL, 0, NULL, 0} 
  };
  memset(options, 0, sizeof(OPTIONS_T));
  options->use_consensus = false;
  options->use_numbers = false;
  options->print_logodds = false;
  options->replace_url = false;
  options->bg_filename = NULL;
  options->url_pattern = NULL;
  options->motif_files = NULL;
  options->motif_file_count = 0;
  while (1) {
    int opt = getopt_long_only(argc, argv, "", arg_opts, NULL);
    if (opt == -1) break;
    switch (opt) {
      case 'h':           
        usage(NULL);
        break;
      case 'c':
        options->use_consensus = true;
        break;
      case 'n':
        options->use_numbers = true;
        break;
      case 'l':
        options->print_logodds = true;
        break;
      case 'f':
        options->replace_url = true;
        break;
      case 'b':
        options->bg_filename = optarg;
        break;
      case 'u':
        options->url_pattern = optarg;
        break;
      case 'x':
        options->xalph = true;
        break;
      case '?':           
        bad_argument = true;
    }
  }
  if (bad_argument) usage("One or more unknown or ambiguous options were supplied.");
  if (options->bg_filename && !file_exists(options->bg_filename)) {
    usage("Background file \"%s\" does not exist!", options->bg_filename); 
  }
  if (options->replace_url && options->url_pattern == NULL) {
    usage("The URL can only be replaced when a default is provided.");
  }
  if (optind >= argc) usage("No motif file!");
  options->motif_files = argv+optind;
  options->motif_file_count = argc - optind;
  for (i = 0; i < options->motif_file_count; i++) {
    if (!file_exists(options->motif_files[i])) {
      usage("Motif file \"%s\" does not exist!", options->motif_files[i]);
    }
  }
}
void process_arguments ( int argc , char * * argv , OPTIONS_T * options ) { bool bad_argument = false ; int i ; struct option arg_opts [ ] = { { " " , no_argument , NULL , ' ' } , { " " , no_argument , NULL , ' ' } , { " " , no_argument , NULL , ' ' } , { " " , no_argument , NULL , ' ' } , { " " , no_argument , NULL , ' ' } , { " " , required_argument , NULL , ' ' } , { " " , required_argument , NULL , ' ' } , { " " , no_argument , NULL , ' ' } , { NULL , 0 , NULL , 0 } } ; memset ( options , 0 , sizeof ( OPTIONS_T ) ) ; options -> use_consensus = false ; options -> use_numbers = false ; options -> print_logodds = false ; options -> replace_url = false ; options -> bg_filename = NULL ; options -> url_pattern = NULL ; options -> motif_files = NULL ; options -> motif_file_count = 0 ; while ( 1 ) { int opt = getopt_long_only ( argc , argv , " " , arg_opts , NULL ) ; if ( opt == -1 ) break ; switch ( opt ) { case ' ' : usage ( NULL ) ; break ; case ' ' : options -> use_consensus = true ; break ; case ' ' : options -> use_numbers = true ; break ; case ' ' : options -> print_logodds = true ; break ; case ' ' : options -> replace_url = true ; break ; case ' ' : options -> bg_filename = optarg ; break ; case ' ' : options -> url_pattern = optarg ; break ; case ' ' : options -> xalph = true ; break ; case ' ' : bad_argument = true ; } } if ( bad_argument ) usage ( " " ) ; if ( options -> bg_filename && ! file_exists ( options -> bg_filename ) ) { usage ( " \" \" " , options -> bg_filename ) ; } if ( options -> replace_url && options -> url_pattern == NULL ) { usage ( " " ) ; } if ( optind >= argc ) usage ( " " ) ; options -> motif_files = argv + optind ; options -> motif_file_count = argc - optind ; for ( i = 0 ; i < options -> motif_file_count ; i ++ ) { if ( ! file_exists ( options -> motif_files [ i ] ) ) { usage ( " \" \" " , options -> motif_files [ i ] ) ; } } }
Process the command line arguments and put the results in the
 options structure.
Process the command line arguments and put the results in the options structure .
//boundary indicator // set defaults // parse optional arguments //-help //unrecognised or ambiguous argument // check background exists // get the motif files