-
Notifications
You must be signed in to change notification settings - Fork 0
/
cv.py
68 lines (54 loc) · 1.59 KB
/
cv.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
import sys
from importlib import import_module
REPO_NAME="clusterV"
VERSION="1.2"
CV_SCRIPTS_FOLDER="cv"
cv_folder = [
"ClusterV",
"run_initial_call",
"run_ClusterV",
"get_consensus",
"update_vcf_af",
"tag_read",
"filter_large_indel",
"get_low_v_db"
]
def directory_for(submodule_name):
if submodule_name in cv_folder:
return CV_SCRIPTS_FOLDER
return ""
def print_help_messages():
from textwrap import dedent
print(dedent("""\
{0} submodule invocator:
Usage: python cv.py [submodule] [options of the submodule]
Version {1}
Available cv submodules:\n{2}
""".format(
REPO_NAME,
VERSION,
"\n".join(" - %s" % submodule_name for submodule_name in cv_folder),
)
))
def main():
if len(sys.argv) <= 1 or sys.argv[1] == "-h" or sys.argv[1] == "--help":
print_help_messages()
sys.exit(0)
if sys.argv[1] == "-v" or sys.argv[1] == "--version":
print("ClusterV: version {0}".format(VERSION))
sys.exit(0)
print("ClusterV: version {0}".format(VERSION))
submodule_name = sys.argv[1]
if (
submodule_name not in cv_folder
):
sys.exit("[ERROR] Submodule %s not found." % (submodule_name))
directory = directory_for(submodule_name)
submodule = import_module("%s.%s" % (directory, submodule_name))
sys.argv = sys.argv[1:]
sys.argv[0] += (".py")
# Note: need to make sure every submodule contains main() method
submodule.main()
sys.exit(0)
if __name__ == "__main__":
main()