-
Notifications
You must be signed in to change notification settings - Fork 6
/
pigx.in
102 lines (80 loc) · 3.31 KB
/
pigx.in
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
#!@PYTHON@
# PiGx -- Pipelines in Genomics
#
# Copyright © 2017, 2018 Bora Uyar <bora.uyar@mdc-berlin.de>
# Copyright © 2017, 2018 Jonathan Ronen <yablee@gmail.com>
# Copyright © 2017, 2018 Bren Osberg <brendan.osberg@mdc-berlin.de>
# Copyright © 2017, 2018 Alexander Gosdschan <alexander.gosdschan@mdc-berlin.de>
# Copyright © 2017, 2018 Katarzyna Wreczycka <katwre@gmail.com>
# Copyright © 2017, 2018 Altuna Akalin <altuna.akalin@mdc-berlin.de>
# Copyright © 2017-2022 Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
#
# This file is part of PiGx.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import argparse
import shutil
description = """\
PiGx Pipelines.
PiGx is a collection of data processing pipelines.
"""
epilog = 'These pipelines were developed by the Akalin group at MDC in Berlin in 2017-2022.'
version = """\
PiGx Pipelines.
Version: @PACKAGE_VERSION@
Copyright © 2017-2022 BIMSB Bioinformatics (Akalin Lab).
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
"""
def formatter(prog):
return argparse.RawTextHelpFormatter(prog, max_help_position=80)
parser = argparse.ArgumentParser(description=description,
epilog=epilog,
formatter_class=formatter)
parser.add_argument('-v', '--version', action='version',
version=version)
parser.add_argument('pipeline',
help="""\
The pipeline to run. The following pipelines are available:@pipelines@\
""")
parser.add_argument('arguments', nargs=argparse.REMAINDER,
help="""\
Arguments to the selected pipeline. Run "pigx [pipeline] --help" to see
list of supported arguments.
""")
args = parser.parse_args()
if os.getenv('PIGX_PIPELINES_PATH'):
pipeline_script = shutil.which("pigx-" + args.pipeline, path=os.getenv('PIGX_PIPELINES_PATH'))
else:
scripts = {
"bsseq" : "@PIGX_BSSEQ@",
"rnaseq" : "@PIGX_RNASEQ@",
"chipseq" : "@PIGX_CHIPSEQ@",
"scrnaseq" : "@PIGX_SCRNASEQ@",
"sars-cov-2": "@PIGX_SARS_COV_2@",
"crispr" : "@PIGX_CRISPR@"
}
pipeline_script = scripts.get(args.pipeline)
pipelines = "@pipelines@".split()
if args.pipeline not in pipelines or not pipeline_script:
print("Pipeline not available: {}\nTry setting PIGX_PIPELINES_PATH.".format(args.pipeline), file=sys.stderr)
exit(1)
if os.path.isfile(pipeline_script) and os.access(pipeline_script, os.X_OK):
os.execv("@PYTHON@", ["pigx", pipeline_script] + args.arguments)
else:
print("Cannot execute {}.".format(pipeline_script), file=sys.stderr)
exit(1)