forked from MaWeffm/ReCo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ReCo.py
executable file
·114 lines (90 loc) · 2.87 KB
/
ReCo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""Main entry for ReCo."""
import argparse
import sys
from reco.reco import ReCo
from reco._version import get_versions
def gui(subparser):
gui_command = subparser.add_parser("gui", help="Available soon: Run ReCo in a GUI")
optional = gui_command.add_argument_group(
title="Optional arguments", description=""
)
optional.add_argument(
"-r", "--remove_unused_files", action="store_true", help="Remove unused files."
)
optional.add_argument("-j", "--cores", type=int, help="The number of cores to use.")
def cli(subparser):
cli_command = subparser.add_parser("cli", help="Run ReCo from the command line")
required = cli_command.add_argument_group(
title="Required arguments", description=""
)
required.add_argument(
"-s",
"--sample_sheet",
type=str,
required=True,
help="A sample sheet containing sample information. See documentation for file format.",
)
required.add_argument(
"-o",
"--output-dir",
type=str,
required=True,
help="The path to an output dir. Will be created if it does not exist.",
)
optional = cli_command.add_argument_group(
title="Optional arguments", description=""
)
optional.add_argument(
"-r", "--remove_unused_files", action="store_true", help="Remove unused files."
)
optional.add_argument("-j", "--cores", type=int, help="The number of cores to use.")
def parse_args():
"""
Parse command line arguments.
Returns
-------
args : Namespace
Namespace populated with attributes.
"""
parent_parser = argparse.ArgumentParser(
description=f"ReCo v{get_versions()['version']}: find gRNA read counts (ReCo) in fastq files."
)
parent_parser.add_argument(
"-v", "--version", action="version", version=f"{get_versions()['version']}"
)
parent_parser.add_argument(
"-r", "--remove_unused_files", action="store_true", help="Remove unused files."
)
parent_parser.add_argument(
"-j", "--cores", type=int, help="The number of cores to use."
)
subparser = parent_parser.add_subparsers(
help="Commands to run different flavors of ReCo",
title="Subcommands",
dest="subcmd",
)
gui(subparser)
cli(subparser)
args = parent_parser.parse_args()
return args
def main():
"""
ReCo main function.
Returns
-------
"""
args = parse_args()
if args.subcmd == "gui":
print("Running GUI")
elif args.subcmd == "cli":
r = ReCo(
sample_sheet_file=args.sample_sheet,
output_dir=args.output_dir,
)
r.run(remove_unused_files=args.remove_unused_files, cores=args.cores)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
sys.stderr.write("Terminated!\n")
sys.exit(0)