diff --git a/src/Common.hpp b/src/Common.hpp index f67ee5c..bdfaffa 100644 --- a/src/Common.hpp +++ b/src/Common.hpp @@ -75,6 +75,7 @@ struct Bustools_opt std::string dump; bool dump_bool = false; bool split_correct = false; + bool parse_error = false; /* predict */ std::string predict_input; //specified the same way as the output for count - count and histogram filenames will be created from this diff --git a/src/bustools_main.cpp b/src/bustools_main.cpp index ab954a8..857eb71 100644 --- a/src/bustools_main.cpp +++ b/src/bustools_main.cpp @@ -172,6 +172,9 @@ void parse_ProgramOptions_sort(int argc, char **argv, Bustools_opt &opt) case 'p': opt.stream_out = true; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -213,6 +216,9 @@ void parse_ProgramOptions_merge(int argc, char **argv, Bustools_opt &opt) case 'e': opt.count_ecs = optarg; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -245,6 +251,9 @@ void parse_ProgramOptions_mash(int argc, char **argv, Bustools_opt &opt) case 'o': opt.output = optarg; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -312,6 +321,9 @@ void parse_ProgramOptions_capture(int argc, char **argv, Bustools_opt &opt) case 'p': opt.stream_out = true; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -375,6 +387,9 @@ void parse_ProgramOptions_count(int argc, char **argv, Bustools_opt &opt) case 'm': opt.count_gene_multimapping = true; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -446,6 +461,9 @@ void parse_ProgramOptions_umicorrect(int argc, char **argv, Bustools_opt& opt) { case 'e': opt.count_ecs = optarg; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -480,6 +498,9 @@ void parse_ProgramOptions_predict(int argc, char **argv, Bustools_opt& opt) { case 't': opt.predict_t = atof(optarg); break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -521,6 +542,9 @@ void parse_ProgramOptions_dump(int argc, char **argv, Bustools_opt &opt) case 'd': opt.text_dumppad = true; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -560,6 +584,9 @@ void parse_ProgramOptions_fromtext(int argc, char **argv, Bustools_opt& opt) { case 'p': opt.stream_out = true; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -608,6 +635,9 @@ void parse_ProgramOptions_correct(int argc, char **argv, Bustools_opt &opt) case 'p': opt.stream_out = true; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -650,12 +680,15 @@ void parse_ProgramOptions_whitelist(int argc, char **argv, Bustools_opt &opt) case 'f': opt.threshold = atoi(optarg); break; + case '?': + opt.parse_error = true; + break; default: break; } } - /* All other argumuments are (sorted) BUS files. */ + /* All other arguments are (sorted) BUS files. */ while (optind < argc) opt.files.push_back(argv[optind++]); @@ -717,12 +750,15 @@ void parse_ProgramOptions_project(int argc, char **argv, Bustools_opt &opt) case 'p': opt.stream_out = true; break; + case '?': + opt.parse_error = true; + break; default: break; } } - /* All other argumuments are (sorted) BUS files. */ + /* All other arguments are (sorted) BUS files. */ while (optind < argc) opt.files.push_back(argv[optind++]); @@ -763,12 +799,15 @@ void parse_ProgramOptions_inspect(int argc, char **argv, Bustools_opt &opt) case 'p': opt.stream_out = true; break; + case '?': + opt.parse_error = true; + break; default: break; } } - /* All other argumuments are (sorted) BUS files. */ + /* All other arguments are (sorted) BUS files. */ while (optind < argc) opt.files.push_back(argv[optind++]); @@ -809,12 +848,15 @@ void parse_ProgramOptions_linker(int argc, char **argv, Bustools_opt &opt) case 'p': opt.stream_out = true; break; + case '?': + opt.parse_error = true; + break; default: break; } } - /* All other argumuments are (sorted) BUS files. */ + /* All other arguments are (sorted) BUS files. */ while (optind < argc) opt.files.push_back(argv[optind++]); @@ -856,6 +898,9 @@ void parse_ProgramOptions_collapse(int argc, char** argv, Bustools_opt& opt) { case 'e': opt.count_ecs = optarg; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -904,6 +949,9 @@ void parse_ProgramOptions_clusterhist(int argc, char** argv, Bustools_opt& opt) case 'c': opt.cluster_input_file = optarg; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -947,12 +995,15 @@ void parse_ProgramOptions_extract(int argc, char **argv, Bustools_opt &opt) case 'p': opt.stream_out = true; break; + case '?': + opt.parse_error = true; + break; default: break; } } - /* All other argumuments are (sorted) BUS files. */ + /* All other arguments are (sorted) BUS files. */ while (optind < argc) opt.files.push_back(argv[optind++]); @@ -994,6 +1045,9 @@ bool parse_ProgramOptions_inflate(int argc, char **argv, Bustools_opt &opt) case 'h': print_usage = true; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -1074,6 +1128,9 @@ bool parse_ProgramOptions_compress(int argc, char **argv, Bustools_opt &opt) case 'h': print_usage = true; break; + case '?': + opt.parse_error = true; + break; default: break; } @@ -1093,7 +1150,11 @@ bool check_ProgramOptions_sort(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + size_t max_threads = std::thread::hardware_concurrency(); if (opt.threads <= 0) @@ -1220,7 +1281,11 @@ bool check_ProgramOptions_sort(Bustools_opt &opt) bool check_ProgramOptions_merge(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + // check for output directory if (!opt.stream_out) { @@ -1309,7 +1374,11 @@ bool check_ProgramOptions_merge(Bustools_opt &opt) bool check_ProgramOptions_mash(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (opt.output.empty()) { std::cerr << "Error: missing output directory" << std::endl; @@ -1378,7 +1447,11 @@ bool check_ProgramOptions_mash(Bustools_opt &opt) bool check_ProgramOptions_dump(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (!opt.stream_out) { if (opt.output.empty()) @@ -1416,7 +1489,11 @@ bool check_ProgramOptions_dump(Bustools_opt &opt) bool check_ProgramOptions_fromtext(Bustools_opt& opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (!opt.stream_out) { if (opt.output.empty()) @@ -1455,7 +1532,11 @@ bool check_ProgramOptions_fromtext(Bustools_opt& opt) bool check_ProgramOptions_capture(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (opt.filter) { // check if output directory exists or if we can create it @@ -1567,7 +1648,11 @@ bool check_ProgramOptions_capture(Bustools_opt &opt) bool check_ProgramOptions_correct(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (!opt.stream_out) { if (opt.output.empty()) @@ -1630,6 +1715,10 @@ bool check_ProgramOptions_correct(Bustools_opt &opt) bool check_ProgramOptions_count(Bustools_opt &opt) { bool ret = true; + + if (opt.parse_error) { + ret = false; + } // check for output directory if (opt.output.empty()) @@ -1775,7 +1864,11 @@ bool check_ProgramOptions_count(Bustools_opt &opt) bool check_ProgramOptions_predict(Bustools_opt& opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + // check for output directory if (opt.output.empty()) { std::cerr << "Error: Missing output directory" << std::endl; @@ -1846,7 +1939,11 @@ bool check_ProgramOptions_predict(Bustools_opt& opt) { bool check_ProgramOptions_umicorrect(Bustools_opt& opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (!opt.stream_out) { if (opt.output.empty()) { std::cerr << "Error: missing output file" << std::endl; @@ -1907,7 +2004,11 @@ bool check_ProgramOptions_umicorrect(Bustools_opt& opt) { bool check_ProgramOptions_whitelist(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (opt.output.empty()) { std::cerr << "Error: missing output file" << std::endl; @@ -1956,7 +2057,11 @@ bool check_ProgramOptions_whitelist(Bustools_opt &opt) bool check_ProgramOptions_project(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (opt.output.empty()) { std::cerr << "Error: Missing output file" << std::endl; @@ -2068,7 +2173,11 @@ bool check_ProgramOptions_project(Bustools_opt &opt) bool check_ProgramOptions_inspect(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (opt.output.size() && !checkOutputFileValid(opt.output)) { std::cerr << "Error: unable to open output file" << std::endl; @@ -2124,7 +2233,11 @@ bool check_ProgramOptions_inspect(Bustools_opt &opt) bool check_ProgramOptions_linker(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (!opt.stream_out) { if (opt.output.empty()) @@ -2164,7 +2277,11 @@ bool check_ProgramOptions_linker(Bustools_opt &opt) bool check_ProgramOptions_collapse(Bustools_opt& opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + // check for output directory if (opt.output.empty()) { std::cerr << "Error: Missing output directory" << std::endl; @@ -2245,7 +2362,11 @@ bool check_ProgramOptions_collapse(Bustools_opt& opt) { bool check_ProgramOptions_clusterhist(Bustools_opt& opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + // check for output directory if (opt.output.empty()) { std::cerr << "Error: Missing output directory" << std::endl; @@ -2343,7 +2464,11 @@ bool check_ProgramOptions_clusterhist(Bustools_opt& opt) { bool check_ProgramOptions_extract(Bustools_opt &opt) { bool ret = true; - + + if (opt.parse_error) { + ret = false; + } + if (opt.output.empty()) { std::cerr << "Error: missing output directory" << std::endl; @@ -2434,9 +2559,12 @@ bool check_ProgramOptions_extract(Bustools_opt &opt) bool check_ProgramOptions_inflate(Bustools_opt &opt) { - bool ret = true; + if (opt.parse_error) { + ret = false; + } + if (!opt.stream_out) { if (opt.output.empty()) @@ -2479,6 +2607,10 @@ bool check_ProgramOptions_compress(Bustools_opt &opt) { bool ret = true; + if (opt.parse_error) { + ret = false; + } + if (!opt.stream_out) { if (opt.output.empty()) @@ -2656,7 +2788,7 @@ void Bustools_count_Usage() << " --genecounts Aggregate counts to genes only" << std::endl << " --umi-gene Perform gene-level collapsing of UMIs" << std::endl << " --em Estimate gene abundances using EM algorithm" << std::endl - << " --cm Count multiplicites instead of UMIs" << std::endl + << " --cm Count multiplicities instead of UMIs" << std::endl << "-m, --multimapping Include bus records that pseudoalign to multiple genes" << std::endl << " --hist Output copy per UMI histograms for all genes" << std::endl << "-d --downsample Specify a factor between 0 and 1 specifying how much to downsample" << std::endl