-
Notifications
You must be signed in to change notification settings - Fork 1
/
tooldir
81 lines (67 loc) · 3.24 KB
/
tooldir
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
#!/usr/bin/env python3
import os
import rich_click as click
from lib import core as cl
@click.version_option("4.1", prog_name="ToolDirectory")
@click.group(context_settings=dict(help_option_names=["-h", "--help"]))
def cli():
"""
ToolDirectory: A dynamic visualization of pieces of software managed by a Bioinformatics Core Facility
"""
@cli.command()
@click.option('--name', '-n', type=str, required=True, help='Tool name')
@click.option('--bid', '-b', type=str, help='Bio.tools tool ID')
@click.option('--version', '-v', type=str, required=True, help='Tool version')
@click.option('--owner', '-o', type=str, required=True, help='Installer uid')
@click.option('--cmd', '-c', type=click.Choice(['true', 'false']), default='true', help='Available in cmdline [True]')
@click.option('--galaxy', '-g', type=click.Choice(['true', 'false']), default='false',
help='Available in Galaxy [False]')
@click.option('--environment', '-e', type=click.Choice(['conda', 'bash', 'docker', 'singularity', 'other']), default='conda',
help='conda/bash/docker/singularity/other [conda]')
@click.option('--workflow', '-w', type=click.Choice(['false', 'true']), default='false', help='Is a workflow')
@click.option('--path', '-p', type=click.Path(exists=True), required=True, help='Path to modulefiles')
@click.option('--date', '-d', type=str, help='Installation date [Current date]')
def create(name, bid, version, owner, cmd, galaxy, environment, workflow, path, date):
"""Create tool properties or add a new version"""
cl.check_path(path, name, version)
properties = os.path.join(path, name, 'properties.json')
if os.path.isfile(properties):
cl.add_version(name, version, date, owner, environment, cmd, galaxy, workflow, properties)
else:
cl.create_properties(name, bid, version, owner, cmd, galaxy, environment, workflow, date, properties)
@cli.command()
@click.option('--json', '-j', type=str, required=True, help='Path to json')
@click.option('--bid', '-b', type=str, help='Force update using Bio.tools ID')
def update(json, bid):
"""Update metadata of a tool"""
cl.update(json, bid)
@cli.command()
@click.option('--jp', '-j', type=str, required=True, help='Path to json')
@click.option('--status', '-s', type=click.Choice(['active', 'inactive']), default='inactive',
help='Version status [active]')
@click.option('--version', '-v', type=(str, int), required=True, multiple=True, help='Version(s) to set status')
def status(json, status, version):
"""Set installation status of a tool's version"""
cl.set_status(json, version, status)
@cli.command()
@click.option('--path', '-p', type=click.Path(exists=True), required=True, help='Tools main folder')
@click.option('--csv', '-c', type=str, required=True, help='Output csv name')
def kcsv(path, csv):
"""Create csv for Keshif visualisation"""
directories = cl.walk_level(path)
prop_json = cl.get_json(directories)
cl.kcsv_writing(csv, prop_json)
click.rich_click.COMMAND_GROUPS = {
"tooldir": [
{
"name": "Main usage",
"commands": ["create", "update", "status"],
},
{
"name": "Visualization",
"commands": ["kcsv"],
},
]
}
if __name__ == "__main__":
cli()