Skip to content

Commit e0a011b

Browse files
authored
Merge pull request #130 from brinkmanlab/local-tools
Add tool_deps tool to allow triggering installation of local tool dep…
2 parents 32d90d2 + 496be1f commit e0a011b

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

docs/commands.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ Commands
1010
commands/run-data-managers
1111
commands/setup-data-libraries
1212
commands/shed-tools
13+
commands/install-tool-deps
1314
commands/workflow-install
1415
commands/workflow-to-tools
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Install-tool-deps
2+
=================
3+
4+
.. automodule :: ephemeris.tool_deps
5+
6+
Usage
7+
----------
8+
9+
.. argparse::
10+
:module: ephemeris.tool_deps
11+
:func: _parser
12+
:prog: install-tool-deps

src/ephemeris/install_tool_deps.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python
2+
'''Tool to install tool dependencies on a Galaxy instance.'''
3+
import argparse
4+
import os
5+
import xml.etree.ElementTree as ET
6+
7+
import yaml
8+
from bioblend.galaxy.tools import ToolClient
9+
10+
from ephemeris import get_galaxy_connection
11+
from ephemeris.common_parser import get_common_args
12+
13+
14+
def _parser():
15+
parent = get_common_args()
16+
parser = argparse.ArgumentParser(parents=[parent])
17+
parser.add_argument("-t", "--tool", help='Path to a tool file, tool_conf file, or yaml file containing sequence of tool ids', nargs='*')
18+
parser.add_argument("-i", "--id", help='Comma seperated list of tool ids', nargs='*')
19+
20+
return parser
21+
22+
23+
def main():
24+
"""
25+
This script uses bioblend to trigger dependencies installations for the provided tools
26+
"""
27+
args = _parser().parse_args()
28+
gi = get_galaxy_connection(args)
29+
tool_client = ToolClient(gi)
30+
31+
for tool_conf_path in args.tool: # type: str
32+
_, ext = os.path.splitext(tool_conf_path)
33+
if (ext == '.xml'):
34+
# install all
35+
root = ET.ElementTree(file=tool_conf_path).getroot()
36+
if root.tag == "toolbox":
37+
# Install all from tool_conf
38+
tool_path = root.get('tool_path', '')
39+
tool_path.replace('${tool_conf_dir}', os.path.abspath(args.tool))
40+
for tool in root.findall("tool[@file]"):
41+
tool_id = ET.ElementTree(file=tool.get('file')).getroot().get('id')
42+
if tool_id:
43+
tool_client.install_dependencies(tool_id)
44+
elif root.tag == "tool" and root.get('id'):
45+
# Install from single tool file
46+
tool_client.install_dependencies(root.get('id'))
47+
else:
48+
for tool_id in yaml.safe_load(tool_conf_path):
49+
# Install from yaml file
50+
tool_client.install_dependencies(tool_id)
51+
52+
for tool_id in args.id: # type: str
53+
tool_client.install_dependencies(tool_id.strip())
54+
55+
56+
if __name__ == '__main__':
57+
main()

0 commit comments

Comments
 (0)