annotate image_math.py @ 2:609911f19ab2 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
author bgruening
date Thu, 16 Apr 2020 05:42:00 -0400
parents
children 4ecf93628f97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
1 #!/usr/bin/env python
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
2
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
3 import json
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
4 import sys
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
5 import os
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
6 import argparse
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
7 from cp_common_functions import *
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
8
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
9 MODULE_NAME = "ImageMath"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
10 OUTPUT_FILENAME = "output.cppipe"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
11
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
12 operator_map = {
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
13 "add": "Add",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
14 "subtract": "Subtract",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
15 "multiply": "Multiply",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
16 "divide": "Divide",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
17 "average": "Average",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
18 "minimum": "Minimum",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
19 "maximum": "Maximum",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
20 "invert": "Invert",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
21 "log_2": "Log transform (base 2)",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
22 "log_legacy": "Log transform (legacy)",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
23 "and": "And",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
24 "or": "Or",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
25 "not": "Not",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
26 "equals": "Equals"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
27 }
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
28
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
29
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
30 def build_main_block(input_params):
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
31 """Creates the main block of the CP pipeline with the parameters that don't depend on conditional choices"""
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
32 operation = operator_map[get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
33 input_params, 'operation.operation')]
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
34 result = INDENTATION.join([f"{INDENTATION}Operation:{operation}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
35 f"Raise the power of the result by:{get_json_value(input_params,'operation.op_results.raise_the_power_of_the_result_by')}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
36 f"Multiply the result by:{get_json_value(input_params,'operation.op_results.multiply_the_result_by')}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
37 f"Add to result:{get_json_value(input_params,'operation.op_results.add_to_result')}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
38 f"Set values less than 0 equal to 0?:{get_json_value(input_params,'operation.op_results.set_values_less_than_0_equal_to_0')}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
39 f"Set values greater than 1 equal to 1?:{get_json_value(input_params,'operation.op_results.set_values_greater_than_1_equal_to_1')}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
40 f"Ignore the image masks?:{get_json_value(input_params,'ignore_the_image_masks')}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
41 f"Name the output image:{get_json_value(input_params,'name_output_image')}"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
42 ])
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
43 return result
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
44
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
45
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
46 def build_variable_block(inputs_galaxy):
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
47 result = ""
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
48 first_image_block = build_first_image_block(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
49 get_json_value(inputs_galaxy, 'operation.first_image'))
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
50 result += f"\n{first_image_block}"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
51 second_image_block = build_second_image_block(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
52 get_json_value(inputs_galaxy, 'operation.second_image'))
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
53 result += f"\n{second_image_block}"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
54 return result
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
55
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
56
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
57 def build_first_image_block(input_params):
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
58 """Creates the block of parameters for the first operator in operations"""
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
59
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
60 value_select = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
61 input_params, 'image_or_measurement_first.image_or_measurement_first')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
62 image_name = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
63 input_params, 'image_or_measurement_first.select_the_first_image')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
64 value_multiply = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
65 input_params, 'multiply_the_first_image_by')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
66 category = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
67 input_params, 'image_or_measurement_first.category_first.category_first')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
68 measurement = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
69 input_params, 'image_or_measurement_first.category_first.measurement_first')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
70
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
71 result = INDENTATION.join(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
72 [f"{INDENTATION}Image or measurement?:{value_select}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
73 f"Select the first image:{image_name}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
74 f"Multiply the first image by:{value_multiply}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
75 f"Measurement:{concat_conditional(category, measurement)}"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
76 ])
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
77 return result
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
78
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
79
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
80 def build_second_image_block(input_params):
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
81 """Creates the block of parameters for the second operator in binary operations"""
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
82
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
83 value_select = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
84 input_params, 'image_or_measurement_second.image_or_measurement_second')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
85 image_name = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
86 input_params, 'image_or_measurement_second.select_the_second_image')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
87 value_multiply = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
88 input_params, 'multiply_the_second_image_by')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
89 category = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
90 input_params, 'image_or_measurement_second.category_second.category_second')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
91 measurement = get_json_value(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
92 input_params, 'image_or_measurement_second.category_second.measurement_second')
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
93
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
94 result = INDENTATION.join(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
95 [f"{INDENTATION}Image or measurement?:{value_select}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
96 f"Select the second image:{image_name}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
97 f"Multiply the second image by:{value_multiply}\n",
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
98 f"Measurement:{concat_conditional(category, measurement)}"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
99 ])
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
100 return result
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
101
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
102
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
103 if __name__ == "__main__":
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
104 parser = argparse.ArgumentParser()
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
105 parser.add_argument(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
106 '-p', '--pipeline',
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
107 help='CellProfiler pipeline'
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
108 )
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
109 parser.add_argument(
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
110 '-i', '--inputs',
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
111 help='JSON inputs from Galaxy'
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
112 )
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
113 args = parser.parse_args()
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
114
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
115 pipeline_lines = get_pipeline_lines(args.pipeline)
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
116 inputs_galaxy = json.load(open(args.inputs, "r"))
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
117
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
118 current_module_num = get_total_number_of_modules(pipeline_lines)
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
119 current_module_num += 1
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
120 pipeline_lines = update_module_count(pipeline_lines, current_module_num)
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
121
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
122 header_block = build_header(MODULE_NAME, current_module_num)
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
123 main_block = build_main_block(inputs_galaxy)
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
124 variable_block = build_variable_block(inputs_galaxy)
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
125
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
126 module_pipeline = f"\n{header_block}{main_block}{variable_block}\n"
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
127 pipeline_lines.append(module_pipeline)
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
128
609911f19ab2 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
bgruening
parents:
diff changeset
129 write_pipeline(OUTPUT_FILENAME, pipeline_lines)