diff --git a/umi_tools/count.py b/umi_tools/count.py index f8786c2..6d0d609 100644 --- a/umi_tools/count.py +++ b/umi_tools/count.py @@ -75,6 +75,10 @@ def main(argv=None): parser = U.OptionParser(version="%prog version: $Id$", usage=usage, description=globals()["__doc__"]) + if len(argv) == 1: + parser.print_usage() + print ("Required options missing, see --help for more details") + return 1 group = U.OptionGroup(parser, "count-specific options") diff --git a/umi_tools/count_tab.py b/umi_tools/count_tab.py index 842ac09..4e7cfa1 100644 --- a/umi_tools/count_tab.py +++ b/umi_tools/count_tab.py @@ -92,6 +92,11 @@ def main(argv=None): usage=usage, description=globals()["__doc__"]) + if len(argv) == 1: + parser.print_usage() + print ("Required options missing, see --help for more details") + return 1 + group = U.OptionGroup(parser, "count_tab-specific options") group.add_option("--barcode-separator", dest="bc_sep", diff --git a/umi_tools/dedup.py b/umi_tools/dedup.py index 47f6c6c..27cf886 100644 --- a/umi_tools/dedup.py +++ b/umi_tools/dedup.py @@ -187,6 +187,11 @@ def main(argv=None): parser = U.OptionParser(version="%prog version: $Id$", usage=usage, description=globals()["__doc__"]) + if len(argv) == 1: + parser.print_usage() + print ("Required options missing, see --help for more details") + return 1 + group = U.OptionGroup(parser, "dedup-specific options") group.add_option("--output-stats", dest="stats", type="string", diff --git a/umi_tools/extract.py b/umi_tools/extract.py index 43e0042..e5a3f65 100644 --- a/umi_tools/extract.py +++ b/umi_tools/extract.py @@ -186,6 +186,11 @@ def main(argv=None): usage=usage, description=globals()["__doc__"]) + if len(argv) == 1: + parser.print_usage() + print ("Required options missing, see --help for more details") + return 1 + group = U.OptionGroup(parser, "extract-specific options") # (Experimental option) Retain the UMI in the sequence read" diff --git a/umi_tools/group.py b/umi_tools/group.py index 921d1d8..2e0c835 100644 --- a/umi_tools/group.py +++ b/umi_tools/group.py @@ -127,6 +127,11 @@ def main(argv=None): usage=usage, description=globals()["__doc__"]) + if len(argv) == 1: + parser.print_usage() + print ("Required options missing, see --help for more details") + return 1 + group = U.OptionGroup(parser, "group-specific options") group.add_option("--group-out", dest="tsv", type="string", diff --git a/umi_tools/umi_tools.py b/umi_tools/umi_tools.py index 0e6969a..4fdc89a 100644 --- a/umi_tools/umi_tools.py +++ b/umi_tools/umi_tools.py @@ -1,10 +1,8 @@ ''' umi_tools.py - Tools for UMI analyses -=============================================== +===================================== :Author: Tom Smith & Ian Sudbury, CGAT -:Release: $Id$ -:Date: |today| :Tags: Genomics UMI There are 6 tools: @@ -43,18 +41,30 @@ def main(): if argv[1] == "--version" or argv[1] == "-v": print("UMI-tools version: %s" % __version__) + + return 0 + + elif len(argv) > 2 and argv[2] in ["--help", "-h", "--help-extended"]: + print("UMI-Tools: Version %s" % __version__) + return 0 command = argv[1] - + try: module = importlib.import_module("umi_tools." + command, "umi_tools") - except ModuleNotFoundError: - print("'%s' is not a UMI-tools command. See 'umi_tools -h'." % command) + except ImportError: + print("'%s' is not a UMI-tools command. See 'umi_tools -h'.\n" % command) + print("For full UMI-tools documentation, see: " + "https://umi-tools.readthedocs.io/en/latest/\n") + print(globals()["__doc__"]) + return 1 - del sys.argv[0] # remove 'umi-tools' from sys.argv - return module.main(sys.argv) + # remove 'umi-tools' from sys.argv + del sys.argv[0] + module.main(sys.argv) + if __name__ == "__main__": sys.exit(main()) diff --git a/umi_tools/whitelist.py b/umi_tools/whitelist.py index 5a5fb9e..40cd122 100644 --- a/umi_tools/whitelist.py +++ b/umi_tools/whitelist.py @@ -249,6 +249,10 @@ def main(argv=None): parser = U.OptionParser(version="%prog version: $Id$", usage=usage, description=globals()["__doc__"]) + if len(argv) == 1: + parser.print_usage() + print ("Required options missing, see --help for more details") + return 1 group = U.OptionGroup(parser, "whitelist-specific options")