int vcf_tool_merge(int argc, char *argv[], const char *configuration_file, array_list_t *config_search_paths) { /* ****************************** * Modifiable options * * ******************************/ shared_options_t *shared_options = new_shared_cli_options(0); merge_options_t *merge_options = new_merge_cli_options(); // If no arguments or only --help are provided, show usage void **argtable; if (argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { argtable = merge_merge_options(merge_options, shared_options, arg_end(NUM_MERGE_OPTIONS)); show_usage("hpg-var-vcf merge", argtable); arg_freetable(argtable, NUM_MERGE_OPTIONS); return 0; } /* ****************************** * Execution steps * * ******************************/ // Step 1: read options from configuration file int config_errors = read_shared_configuration(configuration_file, shared_options); config_errors &= read_merge_configuration(configuration_file, merge_options, shared_options); if (config_errors) { LOG_FATAL("Configuration file read with errors\n"); return CANT_READ_CONFIG_FILE; } // Step 2: parse command-line options // If no arguments or only --help are provided, show usage argtable = parse_merge_options(argc, argv, merge_options, shared_options); // Step 3: check that all options are set with valid values // Mandatory that couldn't be read from the config file must be set via command-line // If not, return error code! int check_vcf_tools_opts = verify_merge_options(merge_options, shared_options); if (check_vcf_tools_opts > 0) { return check_vcf_tools_opts; } // Step 4: Create XXX_options_data_t structures from valid XXX_options_t shared_options_data_t *shared_options_data = new_shared_options_data(shared_options); merge_options_data_t *options_data = new_merge_options_data(merge_options, config_search_paths); init_log_custom(shared_options_data->log_level, 1, "hpg-var-vcf.log", "w"); // Step 5: Perform the requested task int result = run_merge(shared_options_data, options_data); free_merge_options_data(options_data); free_shared_options_data(shared_options_data); arg_freetable(argtable, NUM_MERGE_OPTIONS); return 0; }
int vcf_tool_split(int argc, char *argv[], const char *configuration_file) { /* ****************************** * Modifiable options * * ******************************/ shared_options_t *shared_options = new_shared_cli_options(); split_options_t *split_options = new_split_cli_options(); // If no arguments or only --help are provided, show usage void **argtable; if (argc == 1 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { argtable = merge_split_options(split_options, shared_options, arg_end(split_options->num_options + shared_options->num_options)); show_usage("hpg-var-vcf split", argtable, split_options->num_options + shared_options->num_options); arg_freetable(argtable, split_options->num_options + shared_options->num_options - 11); return 0; } /* ****************************** * Execution steps * * ******************************/ // Step 1: read options from configuration file int config_errors = read_shared_configuration(configuration_file, shared_options); config_errors &= read_split_configuration(configuration_file, split_options, shared_options); if (config_errors) { LOG_FATAL("Configuration file read with errors\n"); return CANT_READ_CONFIG_FILE; } // Step 2: parse command-line options argtable = parse_split_options(argc, argv, split_options, shared_options); // Step 3: check that all options are set with valid values // Mandatory that couldn't be read from the config file must be set via command-line // If not, return error code! int check_vcf_tools_opts = verify_split_options(split_options, shared_options); if (check_vcf_tools_opts > 0) { return check_vcf_tools_opts; } // Step 4: Create XXX_options_data_t structures from valid XXX_options_t shared_options_data_t *shared_options_data = new_shared_options_data(shared_options); split_options_data_t *options_data = new_split_options_data(split_options); // Step 5: Perform the requested task int result = run_split(shared_options_data, options_data); free_split_options_data(options_data); free_shared_options_data(shared_options_data); arg_freetable(argtable, split_options->num_options + shared_options->num_options - 11); return 0; }
int association(int argc, char *argv[], const char *configuration_file) { /* ****************************** * Modifiable options * * ******************************/ shared_options_t *shared_options = new_shared_cli_options(); assoc_options_t *assoc_options = new_assoc_cli_options(); // If no arguments or only --help are provided, show usage void **argtable; if (argc == 1 || !strcmp(argv[1], "--help")) { argtable = merge_assoc_options(assoc_options, shared_options, arg_end(assoc_options->num_options + shared_options->num_options)); show_usage("hpg-var-gwas assoc", argtable, assoc_options->num_options + shared_options->num_options); arg_freetable(argtable, assoc_options->num_options + shared_options->num_options); return 0; } /* ****************************** * Execution steps * * ******************************/ // Step 1: read options from configuration file int config_errors = read_shared_configuration(configuration_file, shared_options); config_errors &= read_assoc_configuration(configuration_file, assoc_options, shared_options); if (config_errors) { LOG_FATAL("Configuration file read with errors\n"); return CANT_READ_CONFIG_FILE; } // Step 2: parse command-line options argtable = parse_assoc_options(argc, argv, assoc_options, shared_options); // Step 3: check that all options are set with valid values // Mandatory options that couldn't be read from the config file must be set via command-line // If not, return error code! int check_assoc_opts = verify_assoc_options(assoc_options, shared_options); if (check_assoc_opts > 0) { return check_assoc_opts; } // Step 4: Create XXX_options_data_t structures from valid XXX_options_t shared_options_data_t *shared_options_data = new_shared_options_data(shared_options); assoc_options_data_t *options_data = new_assoc_options_data(assoc_options); // Step 5: Perform the operations related to the selected GWAS sub-tool // switch (options_data->task) { // case TDT: // run_tdt_test(shared_options_data, options_data); // break; // case ASSOCIATION_BASIC: // case FISHER: run_association_test(shared_options_data, options_data); // break; // } free_assoc_options_data(options_data); free_shared_options_data(shared_options_data); arg_freetable(argtable, assoc_options->num_options + shared_options->num_options); return 0; }