forked from koksal/tps
-
Notifications
You must be signed in to change notification settings - Fork 3
/
tps_workflow.py
78 lines (58 loc) · 1.83 KB
/
tps_workflow.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
import yaml
import argparse
import workflow
from typing import Dict, Any
from workflow.workflow import Runner, Annotations, Visualize
yaml.warnings({'YAMLLoadWarning': False})
def get_parser() -> argparse.ArgumentParser:
'''
:return: an argparse ArgumentParser object for parsing command
line parameters
'''
parser = argparse.ArgumentParser(
description='Run TPS pipeline.')
parser.add_argument('--config', default='config.yaml',
help='Path to config file')
parser.add_argument('--execute',
default='all',
choices=['all', 'tps', 'annotations'],
help='choose steps of workflow to execute')
return parser
def parse_arguments() -> Dict[str, Any]:
'''
Initialize a parser and use it to parse the command line arguments
:return: parsed dictionary of command line arguments
'''
parser = get_parser()
opts = parser.parse_args()
return opts
def main():
opts = parse_arguments()
config_file = opts.config
rule = opts.execute
with open(config_file, 'r') as conf:
params = workflow.ConfigParser.parse(conf)
if rule.lower() == 'all':
runner = Runner(params).run_tps()
annotations = Annotations(
params.annot_input_settings,
runner
).generate_annotations()
Visualize(
params.cytoscape_input_settings,
runner,
annotations
).load_cytoscape()
elif rule == 'annotations':
runner = Runner(params).run_tps()
annotations = Annotations(
params.annot_input_settings,
runner
).generate_annotations()
elif rule == 'tps':
runner = Runner(params).run_tps()
else:
print(f'rule {rule} not specified')
print('Evaluation complete')
if __name__ == '__main__':
main()