-
Notifications
You must be signed in to change notification settings - Fork 0
/
wf_reveal_circ_isoform.py
73 lines (48 loc) · 2.08 KB
/
wf_reveal_circ_isoform.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
# !/usr/bin/env python
# -*- coding:utf-8 -*-
# author : zerodel
# Readme:
#
import argparse
import pysrc.wrapper.bwa
import pysrc.wrapper.ciri
import pysrc.wrapper.knife
import pysrc.body.cli_opts
import pysrc.body.config
import pysrc.body.logger
import pysrc.wrapper.ciri_as
__doc__ = ''' top level interface of detecting circular isoform
'''
__author__ = 'zerodel'
available_tools = {
"ciri_as": pysrc.wrapper.ciri_as,
}
WORK_FLOW_NAME = "workflow_circRNA_isoform_detection"
_logger = pysrc.body.logger.default_logger(WORK_FLOW_NAME)
_OPT_KEY_ISOFORM_DETECTOR = "isoform_detector"
def __cli_arg_parser():
parser = argparse.ArgumentParser()
parser.add_argument("cfg_file", help="file path to a configuration file of isoform detection")
parser.add_argument("-l", "--log_file", help="logging file path", default="")
return parser
def main(cfg):
_logger.debug("configure is a {} , and content is {}".format(type(cfg), str(cfg)))
user_config = pysrc.body.config.config(cfg) if cfg else pysrc.body.config.load_default_value()
detector_name = user_config[pysrc.body.config.SECTION_GLOBAL][_OPT_KEY_ISOFORM_DETECTOR]
_logger.debug("using %s as isoform detector " % detector_name)
_do_detect_circular_isoform(detector_name, user_config)
def _do_detect_circular_isoform(name_of_detector, user_config):
if name_of_detector not in available_tools:
raise KeyError("Error: no such circular RNA detection tool : {}".format(name_of_detector))
detector = available_tools[name_of_detector]
if detector.SECTION_DETECT not in user_config:
raise KeyError(
"Error@config file: no config part %s for detector %s" % (detector.SECTION_DETECT, name_of_detector))
config_detector = dict(user_config[detector.SECTION_DETECT])
_logger.debug("content of detector is =====\n{}\n".format(str(config_detector)))
detector.detect(config_detector)
if __name__ == "__main__":
arg_parser = __cli_arg_parser()
args = arg_parser.parse_args()
_logger = pysrc.body.logger.set_logger_file(_logger, args.log_file)
main(args.cfg_file)