|
| 1 | +#!/usr/bin/env python |
| 2 | +import galaxyxml.tool as gxt |
| 3 | +import galaxyxml.tool.parameters as gxtp |
| 4 | + |
| 5 | +# examplify the use of MacrosTool |
| 6 | +# |
| 7 | + |
| 8 | +tool = gxt.MacrosTool( |
| 9 | + name="aragorn", |
| 10 | + id="aragorn", |
| 11 | + version="1.2.36", |
| 12 | + description="Aragorn is a tRNA finder", |
| 13 | + executable="aragorn.exe", |
| 14 | + version_command="aragorn.exe --version", |
| 15 | +) |
| 16 | + |
| 17 | +inputs = tool.inputs |
| 18 | +outputs = tool.outputs |
| 19 | + |
| 20 | +# Add requirements |
| 21 | +requirements = gxtp.Requirements() |
| 22 | +requirements.append(gxtp.Requirement("package", "samtools", version="1.0.0")) |
| 23 | +requirements.append(gxtp.Container("docker", "one_super_image")) |
| 24 | +tool.requirements = requirements |
| 25 | + |
| 26 | +# A parameter |
| 27 | +param = gxtp.BooleanParam("flag", label="Flag label", help="Flag help", num_dashes=1) |
| 28 | +# Yes I know this is rubbish. Please make a PR!! |
| 29 | +param.space_between_arg = " " |
| 30 | +inputs.append(param) |
| 31 | + |
| 32 | + |
| 33 | +# A float in a section |
| 34 | +section = gxtp.Section("float_section", "Float section") |
| 35 | +param = gxtp.FloatParam("float", label="Float label", help="Float help", value=0, num_dashes=1) |
| 36 | +param.space_between_arg = " " |
| 37 | +section.append(param) |
| 38 | +inputs.append(section) |
| 39 | + |
| 40 | +# A conditional |
| 41 | +param = gxtp.Conditional("cond", label="Conditional") |
| 42 | +param.append(gxtp.SelectParam("Select", options={"hi": "1", "bye": "2"})) |
| 43 | +when_a = gxtp.When(value="hi") |
| 44 | +when_b = gxtp.When(value="bye") |
| 45 | +when_b.append(gxtp.IntegerParam("some_int", value=0, num_dashes=1, label="Advanced value")) |
| 46 | +param.append(when_a) |
| 47 | +param.append(when_b) |
| 48 | +inputs.append(param) |
| 49 | + |
| 50 | +# Integer parameters |
| 51 | +param_min = gxtp.IntegerParam("int_min", label="int_min label", help="int_min help", value=0, num_dashes=1) |
| 52 | +param_max = gxtp.IntegerParam("int_max", label="int_max label", help="int_max help", value=0, num_dashes=1) |
| 53 | + |
| 54 | +posint = gxtp.IntegerParam("posint", label="posint label", positional=True, help="posinthelp", value=0, num_dashes=2) |
| 55 | + |
| 56 | +param_min.command_line_override = "-i$int_min,$int_max" |
| 57 | +param_max.command_line_override = "" |
| 58 | +param_min.space_between_arg = " " |
| 59 | +param_max.space_between_arg = " " |
| 60 | +inputs.append(param_min) |
| 61 | +inputs.append(param_max) |
| 62 | +inputs.append(posint) |
| 63 | + |
| 64 | +# Add Select with options from_file with columns and filter |
| 65 | +param = gxtp.SelectParam("select_local") |
| 66 | +options = gxtp.Options(from_file="loc_file.loc") |
| 67 | +column_a = gxtp.Column("name", 0) |
| 68 | +options.append(column_a) |
| 69 | +column_b = gxtp.Column("value", 1) |
| 70 | +options.append(column_b) |
| 71 | +filter_a = gxtp.Filter("sort_by", name="sorted", column="1") |
| 72 | +options.append(filter_a) |
| 73 | +param.append(options) |
| 74 | +inputs.append(param) |
| 75 | + |
| 76 | +# Configfiles |
| 77 | +configfiles = gxtp.Configfiles() |
| 78 | +configfiles.append(gxtp.Configfile(name="testing", text="Hello <> World")) |
| 79 | +configfiles.append(gxtp.ConfigfileDefaultInputs(name="inputs")) |
| 80 | + |
| 81 | +# Outputs |
| 82 | +param = gxtp.OutputData("output", format="tabular", num_dashes=1) |
| 83 | +param.space_between_arg = " " |
| 84 | +outputs.append(param) |
| 85 | +# Collection |
| 86 | +collection = gxtp.OutputCollection("supercollection", label="a small label") |
| 87 | +discover = gxtp.DiscoverDatasets("(?P<designation>.+)\.pdf.fasta", format="fasta") |
| 88 | +collection.append(discover) |
| 89 | +outputs.append(collection) |
| 90 | + |
| 91 | +tool.inputs = inputs |
| 92 | +tool.outputs = outputs |
| 93 | +tool.help = "HI" |
| 94 | +tool.configfiles = configfiles |
| 95 | + |
| 96 | +# Add Tests sections |
| 97 | +tool.tests = gxtp.Tests() |
| 98 | +test_a = gxtp.Test() |
| 99 | +param = gxtp.TestParam("float", value=5.4) |
| 100 | +test_a.append(param) |
| 101 | +test_out = gxtp.TestOutput(name="output", value="file.out") |
| 102 | +test_a.append(test_out) |
| 103 | +tool.tests.append(test_a) |
| 104 | + |
| 105 | + |
| 106 | +# Add comment to the wrapper |
| 107 | +tool.add_comment("This tool descriptor has been generated using galaxyxml.") |
| 108 | + |
| 109 | +print(tool.export()) |
0 commit comments