-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.py
executable file
·165 lines (132 loc) · 3.73 KB
/
run.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env python2
__author__ = "Yadollah Shahryary Dizaji"
__title__ = "run.py"
__description__ = "Running main menu."
__license__ = "GPL"
__version__ = "1.0.0"
__email__ = "[email protected]"
import sys
import os
import subprocess
import shutil
import pwd
from src.py.pipeline import rcolor, ycolor, qucolor,mcolor
# Main definition - constants
menu_actions = {}
def get_username():
return pwd.getpwuid(os.getuid())[0]
# =======================
# checking lib packages
# =======================
ToNULL = open(os.devnull, 'w')
try:
detected_parallel_location = subprocess.check_output(['which', 'parallel'])
except subprocess.CalledProcessError:
user = get_username()
subprocess.call(["cp", "./src/bash/ins_parallel.sh", '/home/' + user + '/'])
subprocess.call(['chmod', '0755', '/home/' + user + '/ins_parallel.sh'])
subprocess.call(['sh', '/home/' + user + '/ins_parallel.sh'])
os.remove('/home/' + user + '/ins_parallel.sh')
try:
os.remove('/home/' + user + '/parallel-20190122.tar.bz2')
os.remove('/home/' + user + '/parallel-20190122.tar.bz2.sig')
shutil.rmtree('/home/' + user + '/parallel-20190122')
shutil.rmtree('/home/' + user + '/share')
except Exception as e:
pass
'''
try:
if not found:
main(['install', "--user", "npyscreen"])
#restart_program()
except Exception as e:
logging.error(traceback.format_exc())
'''
# =======================
# MENUS FUNCTIONS
# =======================
# Main menu
def main_menu():
print("=="*25)
print(ycolor("\n\tWelcome to MethylStar\n"))
print("=="*25)
print("Please choose from the menu:\n")
print(ycolor("\t1.")+" Run Pipeline (WGBS)")
print(ycolor("\t2.")+" Outputs/Reports")
print(ycolor("\t3.")+" Access JBrowse")
print(ycolor("\t4.")+" Clean-up files")
print(ycolor("\t5.")+" Help\n")
print(ycolor("\tC.")+" Configuration")
print(rcolor("Q.")+" Quit\n")
choice = raw_input(">> ")
exec_menu(choice)
return
# Execute menu
def exec_menu(choice):
#os.system('clear')
ch = choice #.lower()
if ch == '':
menu_actions['main_menu']()
else:
try:
menu_actions[ch]()
except KeyError:
print("Invalid selection, please try again.\n")
menu_actions['main_menu']()
return
def run_pipeline():
from src.py.pipeline import __pipeline__
__pipeline__()
menu_actions['main_menu']()
def run_output():
from src.py.part_output import __dmr__
__dmr__()
menu_actions['main_menu']()
def jbrowse():
s = "\nAccess Jbrowse\n"
s += "Please open the following URL in your web browser:\n"
s += "http://jlabdata.org/jbrowse\n\n"
print(qucolor(s))
menu_actions['main_menu']()
def help_doc():
s = "\nDocumentation:\n"
s += "Please open the following URL in your web browser:\n"
s += "https://github.com/jlab-code/MethylStar/blob/master/docs/runPipeline.md\n\n"
print(qucolor(s))
menu_actions['main_menu']()
def run_remove():
from src.py.part_removing import __removing__
__removing__()
menu_actions['main_menu']()
def config():
from src.py.configuration import __running__
__running__()
menu_actions['main_menu']()
# Back to main menu
def back():
menu_actions['main_menu']()
# Exit program
def exit():
sys.exit()
# =======================
# MENUS DEFINITIONS
# =======================
# Menu definition
menu_actions = {
'main_menu': main_menu,
'1': run_pipeline,
'2': run_output,
'3': jbrowse,
'4': run_remove,
'5': help_doc,
'9': back,
'c': config,
'q': exit,
}
# =======================
# MAIN PROGRAM
# =======================
# Main Program
if __name__ == "__main__":
# Launch main menu
main_menu()