void ParsePhase2Option(int argc, char *argv[]) { OptionsDescription desc; desc.AddOption("host_mem", "", phase2_options.host_mem, "memory to be used. No more than 95% of the free memory is recommended. 0 for auto detect."); desc.AddOption("gpu_mem", "", phase2_options.gpu_mem, "gpu memory to be used. 0 for auto detect."); desc.AddOption("num_cpu_threads", "t", phase2_options.num_cpu_threads, "number of CPU threads. At least 2."); desc.AddOption("num_output_threads", "", phase2_options.num_output_threads, "number of threads for output. Must be less than num_cpu_threads"); desc.AddOption("input_prefix", "", phase2_options.input_prefix, "files input_prefix.edges.* output by count module, can be gzip'ed."); desc.AddOption("num_edge_files", "", phase2_options.num_edge_files, "the number of files with name input_prefix.edges.*"); desc.AddOption("output_prefix", "o", phase2_options.output_prefix, "output prefix"); desc.AddOption("need_mercy", "", phase2_options.need_mercy, "to add mercy edges. The file input_prefix.cand output by count module should exist."); desc.AddOption("max_read_length", "", phase2_options.max_read_length, "max read length"); desc.AddOption("mem_flag", "", phase2_options.mem_flag, "memory options. 0: minimize memory usage; 1: automatically use moderate memory; other: use all available mem specified by '--host_mem'"); try { desc.Parse(argc, argv); if (phase2_options.input_prefix == "") { throw std::logic_error("No input prefix!"); } if (phase2_options.num_edge_files == 0) { throw std::logic_error("Number of edge files cannot be 0!"); } if (phase2_options.num_cpu_threads == 0) { phase2_options.num_cpu_threads = omp_get_max_threads(); } if (phase2_options.num_output_threads == 0) { phase2_options.num_output_threads = std::max(1, phase2_options.num_cpu_threads / 3); } if (phase2_options.host_mem == 0) { throw std::logic_error("Please specify the host memory!"); } if (phase2_options.gpu_mem == 0) { #ifndef DISABLE_GPU size_t free_gpu_mem, total_gpu_mem; get_cuda_memory(free_gpu_mem, total_gpu_mem); phase2_options.gpu_mem = free_gpu_mem; #else // we "simulate" the GTX680 here phase2_options.gpu_mem = 4243689472ULL; #endif } if (phase2_options.num_cpu_threads == 1) { throw std::logic_error("Number of CPU threads is at least 2!"); } if (phase2_options.num_output_threads >= phase2_options.num_cpu_threads) { throw std::logic_error("Number of output threads must be less than number of CPU threads!"); } } catch (std::exception &e) { std::cerr << e.what() << std::endl; std::cerr << "Usage: builder build --input_prefix input --num_edge_files num -o out" << std::endl; std::cerr << "Options:" << std::endl; std::cerr << desc << std::endl; exit(1); } }
void ParsePhase1Option(int argc, char *argv[]) { OptionsDescription desc; desc.AddOption("kmer_k", "k", phase1_options.kmer_k, "kmer size"); desc.AddOption("min_kmer_frequency", "m", phase1_options.min_edge_freq, "min frequency to output an edge"); desc.AddOption("host_mem", "", phase1_options.host_mem, "memory to be used. No more than 95% of the free memory is recommended. 0 for auto detect."); desc.AddOption("gpu_mem", "", phase1_options.gpu_mem, "gpu memory to be used. 0 for auto detect."); desc.AddOption("max_read_length", "", phase1_options.max_read_length, "max read length"); desc.AddOption("num_cpu_threads", "", phase1_options.num_cpu_threads, "number of CPU threads. At least 2."); desc.AddOption("num_output_threads", "", phase1_options.num_output_threads, "number of threads for output. Must be less than num_cpu_threads"); desc.AddOption("input_file", "", phase1_options.input_file, "input fastx file, can be gzip'ed. \"-\" for stdin."); desc.AddOption("output_prefix", "", phase1_options.output_prefix, "output prefix"); try { desc.Parse(argc, argv); if (phase1_options.input_file == "") { throw std::logic_error("No input file!"); } if (phase1_options.num_cpu_threads == 0) { phase1_options.num_cpu_threads = omp_get_max_threads(); } if (phase1_options.num_output_threads == 0) { phase1_options.num_output_threads = std::max(1, phase1_options.num_cpu_threads / 3); } if (phase1_options.host_mem == 0) { throw std::logic_error("Please specify the host memory!"); // struct sysinfo s_info; // sysinfo(&s_info); // phase1_options.host_mem = (s_info.freeram + s_info.bufferram) * 0.95; } if (phase1_options.gpu_mem == 0) { #ifndef DISABLE_GPU size_t free_gpu_mem, total_gpu_mem; get_cuda_memory(free_gpu_mem, total_gpu_mem); phase1_options.gpu_mem = free_gpu_mem; #else // we "simulate" the GTX680 here phase1_options.gpu_mem = 4243689472ULL; #endif } if (phase1_options.num_cpu_threads == 1) { throw std::logic_error("Number of CPU threads is at least 2!"); } if (phase1_options.num_output_threads >= phase1_options.num_cpu_threads) { throw std::logic_error("Number of output threads must be less than number of CPU threads!"); } } catch (std::exception &e) { std::cerr << e.what() << std::endl; std::cerr << "Usage: builder count --input_file fastx_file -o out" << std::endl; std::cerr << "Options:" << std::endl; std::cerr << desc << std::endl; exit(1); } }