Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Altered if clasuses around selection of commands in umi_tools.py #537

Merged
merged 6 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions umi_tools/count.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
5 changes: 5 additions & 0 deletions umi_tools/count_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def main(argv=None):
usage=usage,
description=globals()["__doc__"])

if len(argv) == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this to catch use of tool with no options

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",
Expand Down
5 changes: 5 additions & 0 deletions umi_tools/dedup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions umi_tools/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions umi_tools/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 13 additions & 5 deletions umi_tools/umi_tools.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -50,12 +48,22 @@ def main(argv=None):

return

elif argv[2] in ["--help", "-h", "--help-extended"]:
elif len(argv) > 2 and argv[2] in ["--help", "-h", "--help-extended"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this elif can be removed. The tools all have -h/--help/--help-extended options so no need to catch anything here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is that this was added because the standard --help within each tool doesn't output the version number?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, maybe.

On a related note, the --version options for each tool also don't properly return the version. Should probably just remove that option from the tools and make it available via umi_tools --version only

print("UMI-Tools: Version %s" % __version__)

command = argv[1]

module = importlib.import_module("umi_tools." + command, "umi_tools")
try:
module = importlib.import_module("umi_tools." + command, "umi_tools")
except ImportError:
print("Command %s not recognosied" % command)
print()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the print() for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lazy way to add a blank line 😬

print("For full UMI-tools documentation, see: "
"https://umi-tools.readthedocs.io/en/latest/\n")
print(globals()["__doc__"])

return (1)

# remove 'umi-tools' from sys.argv
del sys.argv[0]
module.main(sys.argv)
Expand Down
4 changes: 4 additions & 0 deletions umi_tools/whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down