int main (int argc, char **argv) { struct gengetopt_args_info args_info; /* let's call our cmdline parser */ if (my_cmdline_parser (argc, argv, &args_info) != 0) exit(1) ; if (args_info.help_given) { printf ("This is a simple test for gengetopt\n"); my_cmdline_parser_print_help (); } if (args_info.full_help_given) { printf ("This is a simple test for gengetopt\n"); my_cmdline_parser_print_full_help (); } if (args_info.version_given) { printf ("Here is the version\n"); my_cmdline_parser_print_version (); } return 0; }
int main(int argc, char * argv[]) { int isExitWithHelp = 0; alder_gc_option_t option; struct gengetopt_args_info args_info; if (my_cmdline_parser (argc, argv, &args_info) != 0) exit(1) ; isExitWithHelp = alder_gc_option_init(&option, &args_info); if (isExitWithHelp == 1) { my_cmdline_parser_free(&args_info); alder_gc_option_free(&option); exit(1); } if (args_info.dpgc_given) { main_dpgb(); } if (args_info.bdwgc_given) { alder_bdwgc(); } my_cmdline_parser_free(&args_info); alder_gc_option_free(&option); return 0; }
int main(int argc, char * argv[]) { int isExitWithHelp = 0; alder_mcas_option_t option; struct gengetopt_args_info args_info; if (my_cmdline_parser (argc, argv, &args_info) != 0) exit(1) ; isExitWithHelp = alder_mcas_option_init(&option, &args_info); if (isExitWithHelp == 1) { my_cmdline_parser_free(&args_info); alder_mcas_option_free(&option); exit(1); } my_cmdline_parser_free(&args_info); alder_mcas_option_free(&option); return 0; }
int main(int argc, char * argv[]) { /////////////////////////////////////////////////////////////////////////// // Check the command line arguments. alder_file_option_t option; struct gengetopt_args_info args_info; if (my_cmdline_parser (argc, argv, &args_info) != 0) exit(1) ; int isExitWithHelp = alder_file_option_init(&option, &args_info); if (isExitWithHelp == 1) { alder_file_option_free(&option); my_cmdline_parser_free(&args_info); exit(1); } if (args_info.summary_flag) { for (size_t i = 0; i < args_info.inputs_num; i++) { alder_file(args_info.inputs[i]); } } if (args_info.numline_flag) { fprintf(option.fout, "--- Number of Lines in the Files ---\n"); for (size_t i = 0; i < args_info.inputs_num; i++) { if (alder_file_isfile(args_info.inputs[i]) && !alder_file_isbinary(args_info.inputs[i])) { int64_t n = alder_file_numline(args_info.inputs[i]); fprintf(option.fout, "%s: %lld\n", args_info.inputs[i], n); } } } if (args_info.disk_flag) { for (size_t i = 0; i < args_info.inputs_num; i++) { unsigned long space_mb = 0; int s = alder_file_availablediskspace(args_info.inputs[i], &space_mb); if (s == 0) { fprintf(option.fout, "Available space in %s: %lu MB\n", args_info.inputs[i], space_mb); } } } if (args_info.estimate_sequence_file_flag) { for (size_t i = 0; i < args_info.inputs_num; i++) { unsigned long space_mb = 0; int s = alder_file_sequencefilesize(args_info.inputs[i], &space_mb); if (s == 0) { fprintf(option.fout, "Estimated sequence size in %s: %lu MB\n", args_info.inputs[i], space_mb); } else { fprintf(option.fout, "File %s is not a proper file.\n", args_info.inputs[i]); } } } if (args_info.mkdir_given) { alder_file_mkdir(args_info.mkdir_arg); } if (args_info.cpu_flag) { int ncpu = alder_file_sysctl(); fprintf(stdout, "Number of CPU: %d\n", ncpu); } if (args_info.memory_flag) { alder_file_memory_test(); } if (args_info.io_flag) { alder_file_io_test03(args_info.inputs[0]); // alder_file_io_test01(); // alder_file_io_test(); } if (args_info.stdin_flag) { alder_file_io_stdin(); } if (args_info.stdout_flag) { alder_file_io_stdout(); } alder_file_option_free(&option); my_cmdline_parser_free(&args_info); return 0; }
/** * This function is the main function where commands are called via * other functions in the kmer library. * * @param argc argc * @param argv argv * * @return program exit value (0 on SUCCESS, otherwise other values) */ int main(int argc, char * argv[]) { time_t start = time(NULL); int s = ALDER_STATUS_SUCCESS; int isExitWithHelp = 0; alder_kmer_option_t option; struct gengetopt_args_info args_info; if (my_cmdline_parser (argc, argv, &args_info) != 0) exit(1) ; isExitWithHelp = alder_kmer_option_init(&option, &args_info, argc); if (isExitWithHelp != 0) { my_cmdline_parser_free(&args_info); alder_kmer_option_free(&option); exit(isExitWithHelp); } /////////////////////////////////////////////////////////////////////////// // Set up a log file if needed. alder_file_rm(args_info.log_arg); if (args_info.log_given) { alder_logger_initialize(args_info.log_arg, (int)args_info.loglevel_arg); alder_logger_error_initialize(LOG_WARNING); } else { alder_logger_initialize(args_info.log_arg, LOG_SILENT); alder_logger_error_initialize(LOG_BASIC); } /////////////////////////////////////////////////////////////////////////// // Timing: alder_log("START: %.*s", (int)(strlen(ctime(&start))-1), ctime(&start)); /////////////////////////////////////////////////////////////////////////// // Count: if (args_info.count_flag) { PlantSeeds(args_info.seed_arg); SelectStream(1); command_count_t count; if (args_info.dsk_flag == 0) { count = &alder_kmer_topkmer; args_info.only_init_flag = (int)option.format; args_info.no_count_flag = args_info.save_all_flag; } else { count = &alder_kmer_count; args_info.select_version_arg = 7; } s = (*count)(args_info.select_version_arg, (int)args_info.kmer_arg, args_info.totalmaxkmer_arg, args_info.disk_arg, args_info.memory_arg, (int)args_info.lower_count_arg, (int)args_info.upper_count_arg, option.maxfile, args_info.inbuffer_arg, args_info.outbuffer_arg, (int)args_info.ni_arg, (int)args_info.np_arg, (int)args_info.nh_arg, (int)args_info.nthread_arg, args_info.progress_flag, args_info.progress_to_stderr_flag, args_info.only_init_flag, args_info.no_delete_flag, args_info.no_partition_flag, args_info.no_count_flag, option.infile, args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // Partition: if (args_info.partition_flag) { s = alder_kmer_partition(args_info.select_version_arg, (int)args_info.kmer_arg, args_info.disk_arg, args_info.memory_arg, args_info.min_table_memory_arg, args_info.max_table_memory_arg, option.maxfile, args_info.inbuffer_arg, args_info.outbuffer_arg, (int)args_info.ni_arg, (int)args_info.np_arg, (int)args_info.nh_arg, (int)args_info.nthread_arg, args_info.progress_flag, args_info.progress_to_stderr_flag, args_info.use_seqfile_flag, args_info.binfile_arg, args_info.binfile_given, option.infile, args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // Table: if (args_info.table_flag) { s = alder_kmer_table(args_info.select_version_arg, 0, // -1, why -1? (int)args_info.kmer_arg, // args_info.disk_arg, args_info.memory_arg, option.maxfile, args_info.inbuffer_arg, args_info.outbuffer_arg, (int)args_info.ni_arg, (int)args_info.np_arg, (int)args_info.nh_arg, (int)args_info.nthread_arg, args_info.progress_flag, args_info.progress_to_stderr_flag, (int)args_info.lower_count_arg, (int)args_info.upper_count_arg, args_info.parfile_arg, args_info.parfile_given, option.infile, args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // Report/Dump: if (args_info.report_flag) { if (args_info.dsk_flag == 1) { args_info.select_version_arg = 7; } if (args_info.query_given) { s = alder_kmer_report(args_info.select_version_arg, bdata(option.infile->entry[0]), args_info.summary_flag, args_info.sequence_arg); } else { s = alder_kmer_report(args_info.select_version_arg, bdata(option.infile->entry[0]), args_info.summary_flag, NULL); } } /////////////////////////////////////////////////////////////////////////// // Query: if (args_info.query_flag) { s = alder_kmer_query(args_info.select_version_arg, bdata(option.infile->entry[0]), args_info.summary_flag, args_info.sequence_arg); } /////////////////////////////////////////////////////////////////////////// // Simulation: if (args_info.simulate_flag) { PlantSeeds(args_info.seed_arg); SelectStream(1); if (args_info.error_rate_arg > 0) { s = alder_kmer_simulate2(args_info.select_version_arg, args_info.outfile_given, args_info.outfile_arg, args_info.outdir_arg, option.format, (int)args_info.nf_arg, args_info.seed_arg, (int)args_info.error_rate_arg, (int)args_info.error_initial_arg, (int)args_info.error_iteration_arg, (int)args_info.error_duplicate_arg, (int)args_info.kmer_arg, (int)args_info.seqlen_arg, (size_t)args_info.maxkmer_arg, args_info.progress_flag, args_info.progress_to_stderr_flag); } else { s = alder_kmer_simulate(args_info.select_version_arg, args_info.outfile_given, args_info.outfile_arg, args_info.outdir_arg, option.format, args_info.with_parfile_flag, (int)args_info.nf_arg, (int)args_info.ni_arg, (int)args_info.np_arg, (int)args_info.kmer_arg, (int)args_info.seqlen_arg, (size_t)args_info.maxkmer_arg, args_info.progress_flag, args_info.progress_to_stderr_flag); } } /////////////////////////////////////////////////////////////////////////// // Decode/Kmer: if (args_info.decode_flag) { s = alder_kmer_decode((int)args_info.kmer_arg, args_info.progress_flag, option.infile, args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // List: if (args_info.list_flag) { s = alder_kmer_list((int)args_info.kmer_arg, args_info.with_index_flag, option.infile, args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // Match: if (args_info.match_flag) { s = alder_kmer_match(args_info.progress_flag, option.infile, args_info.tabfile_arg, args_info.format_arg, args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // Uncompress: if (args_info.uncompress_flag) { alder_kmer_uncompress(args_info.progress_flag, option.infile, args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // View: if (args_info.view_flag) { alder_kmer_view((int)args_info.format_arg, option.infile, args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg, (int)args_info.kmer_arg); } /////////////////////////////////////////////////////////////////////////// // Binary: if (args_info.binary_flag) { size_t n_byte = 0; uint64_t n_kmer = 0; uint64_t n_dna = 0; uint64_t n_seq = 0; size_t n_totalfilesize = 0; size_t subsize = ALDER_KMER_BUFSIZE; s = alder_kmer_binary(NULL, 0, subsize, &n_kmer, &n_dna, &n_seq, &n_totalfilesize, &n_byte, args_info.select_version_arg, (int)args_info.kmer_arg, args_info.disk_arg, args_info.memory_arg, args_info.min_table_memory_arg, args_info.max_table_memory_arg, (int)args_info.nsplit_arg, args_info.progress_flag, args_info.progress_to_stderr_flag, option.infile, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // Assess: if (args_info.assess_flag) { alder_kmer_assess((int)args_info.upper_count_arg, args_info.tabfile_arg, option.infile, (int)args_info.outfile_given, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // Inspect: if (args_info.inspect_flag) { alder_kmer_inspect(option.infile, args_info.outdir_arg, args_info.outfile_arg); } /////////////////////////////////////////////////////////////////////////// // Timing: time_t end = time(NULL); alder_log("END: %.*s", (int)(strlen(ctime(&end))-1), ctime(&end)); double run_time = difftime(end, start); alder_log("RUN TIME: %.f (s) = %.f (m) = %.f (h)", run_time, run_time/60, run_time/3600); /////////////////////////////////////////////////////////////////////////// // Cleanup! alder_logger_finalize(); alder_logger_error_finalize(); if (!args_info.log_given) { alder_file_rm(args_info.log_arg); } my_cmdline_parser_free(&args_info); alder_kmer_option_free(&option); return s; }