-
Notifications
You must be signed in to change notification settings - Fork 3
/
gomap.py
executable file
·105 lines (91 loc) · 3.76 KB
/
gomap.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
#!/usr/bin/env python2
'''
Importing all the modules necessary for running the pipeline
pprint is only needed for debugging purposes
'''
import os, re, logging, json, sys, argparse, jsonmerge, yaml
from argparse import RawTextHelpFormatter
from pprint import pprint
from code.gomap_aggregate import aggregate
from code.gomap_setup import setup
from code.gomap_seqsim import run_seqsim
from code.gomap_domain import run_domain
from code.gomap_mixmeth_blast import run_mixmeth_blast
from code.gomap_mm_preproc import run_mm_preproc
from code.gomap_mixmeth import run_mixmeth
from code.gomap_fanngo import run_fanngo
from code.utils.basic_utils import init_dirs, copy_input
from code.utils.logging_utils import setlogging
BUFFERSIZE_KIB = 16000
from jsonmerge import Merger
schema = {
"properties": {
"bar": {
"mergeStrategy": "append"
}
}
}
merger = Merger(schema)
'''
Parsing the input config file that will be supplied by the user.
'''
main_parser = argparse.ArgumentParser(description='Welcome to running the GOMAP pipeline',formatter_class=RawTextHelpFormatter)
main_parser.add_argument('--config',help="The config file in yaml format. \nPlease see test/config.yml for an example.",required=True)
main_parser.add_argument('--step',help="GO-MAP has two distinct steps. Choose the step to run \n1) preprocess \n2) annotate", choices=['setup','seqsim','domain','mixmeth-blast','mixmeth-preproc','mixmeth','fanngo','aggregate'],required=True)
main_args = main_parser.parse_args()
'''
This section loads the pipeline base config file from the pipeline script
location. and loads the pipleine configutation
'''
os.chdir("/opt/GOMAP/")
with open("config/pipeline.yml") as tmp_file:
pipe_config = yaml.load(tmp_file)
config_file = pipe_config["input"]["workdir"]+"/"+main_args.config
with open(config_file) as tmp_file:
user_config = yaml.load(tmp_file)
user_config["input"]["workdir"] = os.path.dirname(config_file)
config = merger.merge(pipe_config, user_config)
config = init_dirs(config)
copy_input(config)
conf_out = config["input"]["gomap_dir"]+"/"+config["input"]["basename"]+".all.yml"
config["input"]["config_file"] = conf_out
with open(conf_out,"w") as out_f:
yaml.dump(config,out_f)
'''
Depending the step selected by the user we are going to run the relevant part of GO-MAP
'''
if main_args.step == "seqsim":
print("Running Sequence-similarity based Annotation Step")
setlogging(config,"seqsim")
logging.info("Running Sequence-similarity based Annotation Step")
run_seqsim(config)
elif main_args.step == "domain":
print("Running Domain Based Annotation Step")
setlogging(config,"domain")
logging.info("Running Domain Based Annotation Step")
run_domain(config)
elif main_args.step == "mixmeth-blast":
print("Running uniprot blast for mixed-methods")
setlogging(config,"mixmeth-preproc")
logging.info("Running uniprot blast for mixed-methods")
run_mixmeth_blast(config)
elif main_args.step == "mixmeth-preproc":
print("Running preprocessing step for mixed-methods")
setlogging(config,"mixmeth-preproc")
logging.info("Running preprocessing step for mixed-methods")
run_mm_preproc(config)
elif main_args.step == "mixmeth":
print("Running mixed-method based annotations")
setlogging(config,"mixmeth")
logging.info("Running mixed-method based annotations")
run_mixmeth(config)
elif main_args.step == "fanngo":
print("Running run_fanngo based annotations")
setlogging(config,"fanngo")
logging.info("Running run_fanngo based annotations")
run_fanngo(config)
elif main_args.step == "aggregate":
print("Running Aggregate Step")
setlogging(config,"aggregate")
logging.info("Running Aggregate Step")
aggregate(config)