forked from diegomcarvalho/biocomp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtester.py
More file actions
183 lines (174 loc) · 6.67 KB
/
tester.py
File metadata and controls
183 lines (174 loc) · 6.67 KB
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import parsl, apps, glob, bioconfig, os, logging, argparse, math, filecmp
from pandas.core import base
from datetime import datetime
from infra_manager import workflow_config, wait_for_all, CircularList
def test_raxml(bio_config, logger1 = None):
logger1.critical("Testing RAXML...")
basedir = {
"dir":os.path.join(os.getcwd(), "tests"),
"tree_method":"RAXML",
"network_method":"MPL",
"mapping":"",
"outgroup": ""
}
seed = 123
old_files = glob.glob(os.path.join(os.getcwd(), "tests/raxml/*.input"))
for f in old_files:
os.remove(f)
input_file = os.path.join(os.getcwd(), "tests/raxml/input.phy")
baseline_file = os.path.join(os.getcwd(), "tests/raxml/RAxML_bestTree.baseline")
out_file = os.path.join(os.getcwd(), "tests/raxml/RAxML_bestTree.input")
ret_tree = apps.raxml(basedir, bio_config, input_file=input_file, seed=seed)
try:
ret_tree.result()
if(filecmp.cmp(baseline_file, out_file)):
logger1.critical("\t...Passed!")
else:
logger1.critical("\t...Failed!")
except Exception as e:
logger1.critical("\t...Failed!")
def test_iqtree(bio_config, logger1 = None):
logger1.critical("Testing IQTREE...")
basedir = {
"dir":os.path.join(os.getcwd(), "tests"),
"tree_method":"IQTREE",
"network_method":"MPL",
"mapping":"",
"outgroup": ""
}
seed = 123
input_file = os.path.join(os.getcwd(), "tests/iqtree/input.phy")
baseline_file = os.path.join(os.getcwd(), "tests/iqtree/baseline.treefile")
out_file = os.path.join(os.getcwd(), "tests/iqtree/input.phy.treefile")
ret_tree = apps.iqtree(basedir, bio_config, input_file=input_file, seed=seed)
try:
ret_tree.result()
if(filecmp.cmp(baseline_file, out_file)):
logger1.critical("\t...Passed!")
else:
logger1.critical("\t...Failed!")
except Exception as e:
logger1.critical("\t...Failed!")
def test_astral(bio_config, logger1 = None):
logger1.critical("Testing ASTRAL...")
basedir = {
"dir":os.path.join(os.getcwd(), "tests"),
"tree_method":"RAXML",
"network_method":"MPL",
"mapping":"",
"outgroup": ""
}
seed = 123
input_file = os.path.join(os.getcwd(), "tests/astral/BSlistfiles")
baseline_file = os.path.join(os.getcwd(), "tests/astral/baseline.tre")
out_file = os.path.join(os.getcwd(), "tests/astral/besttree.tre")
ret_tree = apps.astral(basedir, bio_config, inputs=[input_file], seed=seed)
try:
ret_tree.result()
if(filecmp.cmp(baseline_file, out_file)):
logger1.critical("\t...Passed!")
else:
logger1.critical("\t...Failed!")
except Exception as e:
logger1.critical("\t...Failed!")
def test_mbsum(bio_config, logger1 = None):
logger1.critical("Testing MBSUM...")
basedir = {
"dir":os.path.join(os.getcwd(), "tests"),
"tree_method":"MRBAYES",
"network_method":"MPL",
"mapping":"",
"outgroup": ""
}
input_file = os.path.join(os.getcwd(), "tests/mrbayes/input.nex.run1.t")
baseline_file = os.path.join(os.getcwd(), "tests/mbsum/baseline.sum")
out_file = os.path.join(os.getcwd(), "tests/mbsum/input.nex.sum")
ret_tree = apps.mbsum(basedir, bio_config, inputs=[input_file])
try:
ret_tree.result()
if(filecmp.cmp(baseline_file, out_file)):
logger1.critical("\t...Passed!")
else:
logger1.critical("\t...Failed!")
except Exception as e:
logger1.critical("\t...Failed!")
def test_bucky(bio_config, logger1 = None):
pass
def test_mrbayes(bio_config, logger1 = None):
logger1.critical("Testing MrBayes...")
basedir = {
"dir":os.path.join(os.getcwd(), "tests"),
"tree_method":"MRBAYES",
"network_method":"MPL",
"mapping":"",
"outgroup": ""
}
input_file = os.path.join(os.getcwd(), "tests/mrbayes/input.nex")
baseline_file = os.path.join(os.getcwd(), "tests/mrbayes/baseline.nex.run1.t")
out_file = os.path.join(os.getcwd(), "tests/mrbayes/input.nex.run1.t")
ret_tree = apps.quartet_maxcut(basedir, bio_config, inputs=input_file)
try:
ret_tree.result()
if(filecmp.cmp(baseline_file, out_file)):
logger1.critical("\t...Passed!")
else:
logger1.critical("\t...Failed!")
except Exception as e:
logger1.critical("\t...Failed!")
def test_phylonet(bio_config, logger1 = None):
pass
def test_snaq(bio_config, logger1 = None):
pass
def test_quartetmaxcut(bio_config, logger1 = None):
logger1.critical("Testing Quartet Maxcut...")
basedir = {
"dir":os.path.join(os.getcwd(), "tests"),
"tree_method":"RAXML",
"network_method":"MPL",
"mapping":"",
"outgroup": ""
}
input_file = os.path.join(os.getcwd(), "tests/qmc/tests.txt")
baseline_file = os.path.join(os.getcwd(), "tests/qmc/baseline.tre")
out_file = os.path.join(os.getcwd(), "tests/qmc/tests.tre")
ret_tree = apps.quartet_maxcut(basedir, bio_config, inputs=input_file)
try:
ret_tree.result()
if(filecmp.cmp(baseline_file, out_file)):
logger1.critical("\t...Passed!")
else:
logger1.critical("\t...Failed!")
except Exception as e:
logger1.critical("\t...Failed!")
def main(config_file='default.ini', workload_file = None):
if workload_file is not None:
cf = bioconfig.ConfigFactory(config_file, custom_workload = workload_file)
else:
cf = bioconfig.ConfigFactory(config_file)
bio_config = cf.build_config()
now = datetime.now()
date_time = now.strftime("%d-%m-%Y_%H-%M-%S")
name = bio_config.workflow_name
parsl.set_file_logger(f'{name}_script_{date_time}.output', level=logging.CRITICAL)
parsl.set_stream_logger(level=logging.CRITICAL)
logger1 = logging.getLogger("parsl")
logger1.critical('Starting the Testing module')
dkf_config = workflow_config(bio_config)
dkf = parsl.load(dkf_config)
test_raxml(bio_config, logger1)
test_iqtree(bio_config, logger1)
test_astral(bio_config, logger1)
test_bucky(bio_config, logger1)
test_quartetmaxcut(bio_config, logger1)
test_mbsum(bio_config, logger1)
test_mrbayes(bio_config, logger1)
test_phylonet(bio_config, logger1)
test_snaq(bio_config, logger1)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Process the configuration file.')
parser.add_argument('--cf', help='Settings file', required=False, type=str)
args = parser.parse_args()
if args.cf is not None:
main(config_file=args.cf)
else:
main()