-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_run_funarts.py
More file actions
135 lines (115 loc) · 6.46 KB
/
docker_run_funarts.py
File metadata and controls
135 lines (115 loc) · 6.46 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
#!/usr/bin/env python
# Copyright (C) 2023 Turgut Mesut YILMAZ
# University of Tuebingen
# Interfaculty Institute of Microbiology and Infection Medicine
# Lab of Nadine Ziemert, Div. of Microbiology/Biotechnology
# Funding by the German Centre for Infection Research (DZIF)
#
# This file is part of FunARTS
# FunARTS 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
#
# License: You should have received a copy of the GNU General Public License v3 with FunARTS
# A copy of the GPLv3 can also be found at: <http://www.gnu.org/licenses/>.
import argparse, os
def call_startquery(args):
reference= "/funarts/reference/ascomycota/"
container_volume_list = []
container_argument_list = []
docker_run_cmd = "docker run -it --rm "
###Input volume - path in container
input_paths = []
if "," in args.input:
input_list = args.input.split(",")
for i in input_list:
path,file = os.path.split(i)
input_paths.append("/funarts/uploads/%s" % file)
container_volume_list.append("-v %s:/funarts/uploads/" % path)
else:
path, file = os.path.split(args.input)
input_paths.append("/funarts/uploads/%s" % file)
container_volume_list.append("-v %s:/funarts/uploads/" % path)
##Reference volume - path
if args.refdir != reference:
path, file = os.path.split(args.refdir)
container_ref_arg = "/custom_reference/%s" % file
container_volume_list.append("-v %s:/custom_reference/" % path)
else:
container_ref_arg = reference
### Directory to store results
path, file = os.path.split(args.resultdir)
container_volume_list.append("-v %s:/funarts/results/" % path)
container_argument_list.append("-rd /funarts/results/%s" % file)
### Antismash path
if args.runantismash is True:
container_argument_list.append("-ras -asp /usr/local/bin/antismash")
else:
container_argument_list.append("-asp /usr/local/bin/antismash")
### Custom hmm models list
if args.hmmdblist is not None:
path, file = os.path.split(args.hmmdblist)
container_argument_list.append("-hmms /funarts/custom_files/%s"%file)
container_volume_list.append("-v %s:/funarts/custom_files/" % path)
### Known Resistance models hmms
if "kres" in args.options:
container_argument_list.append("-khmms /funarts/reference/knownresistance.hmm")
### Domains of unknown function hmm file
if "duf" in args.options:
container_argument_list.append("-duf /funarts/reference/dufmodels.hmm")
### User supplied core models
if args.custcorehmms is True:
path, file = os.path.split(args.custcorehmms)
container_argument_list.append("-cchmms /funarts/custom_files/%s"%file)
container_volume_list.append("-v %s:/funarts/custom_files/" % path)
### User supplied resistance models
if args.customhmms is True:
path, file = os.path.split(args.customhmms)
container_argument_list.append("-chmms /funarts/custom_files/%s"%file)
container_volume_list.append("-v %s:/funarts/custom_files/" % path)
### RNA hmm models to run
if args.rnahmmdb is True:
path, file = os.path.split(args.rnahmmdb)
container_argument_list.append("-rhmm /funarts/custom_files/%s"%file)
container_volume_list.append("-v %s:/funarts/custom_files/" % path)
### Hmm reporting threshold
if args.thresh is not None:
container_argument_list.append("-t %s"%args.thresh)
### Multi processing set - CPU
if args.multicpu > 1:
container_argument_list.append("-cpu %s" % args.multicpu)
docker_run_cmd += "--cpus=%s"%args.multicpu + " "
### Opions for Analysis to run
container_argument_list.append("-opt %s"%args.options)
### Explicitly specify organism name
if args.orgname is not None:
container_argument_list.append("-org %s"%args.orgname)
### Run BiG-Scape Path:
if args.runbigscape is True:
container_argument_list.append("-rbsc -bcp /funarts/BiG-SCAPE/bigscape.py")
## Docker Run FunARTS
docker_run_cmd += " ".join(list(set(container_volume_list)))
docker_run_cmd += " ziemertlab/funarts:latest "
docker_run_cmd += ",".join(input_paths) + " " + container_ref_arg + " "
docker_run_cmd += " ".join(container_argument_list)
print(docker_run_cmd)
os.system(docker_run_cmd)
# Commandline Execution
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="""Start from genbank file and compare with pre-computed reference for Duplication and Transfers""")
parser.add_argument("input", help="gbk file to start query. For multi-genome input, put commas without any space between the paths.")
parser.add_argument("resultdir", help="Directory to store results")
parser.add_argument("-refdir", help="Directory of precomputed reference files (default='~/ascomycota/')",default="/funarts/reference/ascomycota/")
parser.add_argument("-hmms","--hmmdblist", help="hmm file, directory, or list of hmm models for core gene id",default=None)
parser.add_argument("-cchmms","--custcorehmms", help="User supplied core models. hmm file",default=False)
parser.add_argument("-chmms","--customhmms", help="User supplied resistance models. hmm file",default=False)
parser.add_argument("-rhmm","--rnahmmdb", help="RNA hmm models to run (default: None)",default=None)
parser.add_argument("-t","--thresh", help="Hmm reporting threshold. Use global bitscore value or Model specific options: gathering= GA, trusted= TC, noise= NC(default: None)",default=None)
parser.add_argument("-cpu", "--multicpu", help="Turn on Multi processing set # Cpus (default: Off, 1)", type=int, default=1)
parser.add_argument("-opt", "--options", help="Analysis to run. expert=Exploration mode, kres=Known resistance, duf=Domain of unknown function (default: None)",default=None)
parser.add_argument("-org", "--orgname", help="Explicitly specify organism name", default=None)
parser.add_argument("-ras", "--runantismash", help="Run input file through antismash first", action='store_true', default=False)
parser.add_argument("-rbsc", "--runbigscape",help="Run antismash results through bigscape", action='store_true', default=False )
args = parser.parse_args()
call_startquery(args)