Mercurial > repos > bgruening > cp_gray_to_color
comparison gray_to_color.xml @ 0:d37580e3f4d0 draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 6d73056a625002d0275b5a9a90a9fae329ce47f1"
author | bgruening |
---|---|
date | Thu, 26 Mar 2020 17:46:36 -0400 |
parents | |
children | e5870c434f28 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d37580e3f4d0 |
---|---|
1 <tool id="cp_gray_to_color" name="GrayToColor" version="@CP_VERSION@"> | |
2 <description>takes grayscale images and produces a color image from them</description> | |
3 <macros> | |
4 <import>macros.xml</import> | |
5 <xml name="rgb"> | |
6 <param name="rgb_red" label="Select the image to be colored red" value="Leave this black" type="text"/> | |
7 <param name="rgb_red_weight" label="Relative weight for the red image" optional="true" type="float" value="0.8"/> | |
8 | |
9 <param name="rgb_green" label="Select the image to be colored green" value="Leave this black" type="text"/> | |
10 <param name="rgb_green_weight" label="Relative weight for the green image" optional="true" type="float" value="1.0" /> | |
11 | |
12 <param name="rgb_blue" label="Select the image to be colored blue" value="Leave this black" type="text"/> | |
13 <param name="rgb_blue_weight" label="Relative weight for the blue image" optional="true" type="float" value="0.5"/> | |
14 | |
15 <param name="name_output_image" label="Name the output image" value="ColorImage" type="text"/> | |
16 </xml> | |
17 <xml name="cmyk"> | |
18 <param name="cmyk_cyan" label="Select the image to be colored cyan" value="Leave this black" type="text"/> | |
19 <param name="cmyk_cyan_weight" label="Relative weight for the cyan image" optional="true" type="float" value="0.5"/> | |
20 | |
21 <param name="cmyk_magenta" label="Select the image to be colored magenta" value="Leave this black" type="text"/> | |
22 <param name="rgb_green_weight" label="Relative weight for the green image" optional="true" type="float" value="0.0"/> | |
23 | |
24 <param name="cmyk_yellow" label="Select the image to be colored yellow" value="Leave this black" type="text"/> | |
25 <param name="cmyk_yellow_weight" label="Relative weight for the yellow image" optional="true" type="float" value="0.0"/> | |
26 | |
27 <param name="cmyk_brightness" label="Select the image that determines brightness" value="Leave this black" type="text"/> | |
28 <param name="cmyk_brightness_weight" label="Relative weight for the brightness image" optional="true" type="float" value="0.5"/> | |
29 | |
30 <param name="name_output_image" label="Name the output image" value="ColorImage" type="text"> | |
31 <expand macro="text_validator" /> | |
32 </param> | |
33 | |
34 </xml> | |
35 <xml name="stack"> | |
36 <param name="name_output_image" label="Name the output image" value="ColorImage" type="text"> | |
37 <expand macro="text_validator" /> | |
38 </param> | |
39 <repeat name="rpt_image_name" title="Add another channel"> | |
40 <param name="image_name" type="text" label="Image name" > | |
41 <expand macro="text_validator" /> | |
42 </param> | |
43 </repeat> | |
44 </xml> | |
45 <xml name="composite"> | |
46 <param name="name_output_image" label="Name the output image" value="ColorImage" type="text"> | |
47 <expand macro="text_validator" /> | |
48 </param> | |
49 <repeat name="rpt_image_name" title="Add another channel"> | |
50 <param name="image_name" type="text" label="Image name"> | |
51 <expand macro="text_validator" /> | |
52 </param> | |
53 <param name="color" type="color" label="Color" /> | |
54 <param name="weight" type="float" label="Weight" value="0.8" min="0.0" max="1.0" /> | |
55 </repeat> | |
56 </xml> | |
57 </macros> | |
58 | |
59 <expand macro="py_requirements"/> | |
60 <expand macro="cmd_modules" /> | |
61 | |
62 <configfiles> | |
63 <inputs name="inputs" /> | |
64 | |
65 <configfile name="script_file"> | |
66 import json | |
67 import sys | |
68 import os | |
69 | |
70 FOURSPACES=@SPACES@ | |
71 | |
72 input_json_path = sys.argv[1] | |
73 input_pipeline= sys.argv[2] | |
74 | |
75 params = json.load(open(input_json_path, "r")) | |
76 | |
77 def writegtc(): | |
78 _str = "\nGrayToColor:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:3|show_window:False|notes:\\x5B\\'Combine masks nuclei + nucleoli with colors\\'\\x5D|batch_state:array(\\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count | |
79 | |
80 color_scheme = params['con_color_scheme']['color_scheme'] | |
81 | |
82 rgb_blue = params['con_color_scheme']['rgb_blue'] if 'rgb_blue' in params[ | |
83 'con_color_scheme'] else 'Leave this black' | |
84 rgb_blue_weight = 1.0 if params['con_color_scheme']['rgb_blue_weight'] == "" else params['con_color_scheme'][ | |
85 'rgb_blue_weight'] | |
86 | |
87 rgb_green = params['con_color_scheme']['rgb_green'] if 'rgb_green' in params[ | |
88 'con_color_scheme'] else 'Leave this black' | |
89 rgb_green_weight = 1.0 if params['con_color_scheme']['rgb_green_weight'] == "" else params['con_color_scheme'][ | |
90 'rgb_green_weight'] | |
91 | |
92 rgb_red = params['con_color_scheme']['rgb_red'] if 'rgb_red' in params['con_color_scheme'] else 'Leave this black' | |
93 rgb_red_weight = 1.0 if params['con_color_scheme']['rgb_red_weight'] == "" else params['con_color_scheme'][ | |
94 'rgb_red_weight'] | |
95 | |
96 name_output_image = params['con_color_scheme']['name_output_image'] | |
97 | |
98 cmyk_cyan = params['con_color_scheme']['cmyk_cyan'] if 'cmyk_cyan' in params[ | |
99 'con_color_scheme'] else 'Leave this black' | |
100 | |
101 if 'cmyk_cyan_weight' in params['con_color_scheme']: | |
102 if params['con_color_scheme']['cmyk_cyan_weight'] == "": | |
103 cmyk_cyan_weight = 1.0 | |
104 else: | |
105 cmyk_cyan_weight = params['con_color_scheme']['cmyk_cyan_weight'] | |
106 else: | |
107 cmyk_cyan_weight = 1.0 | |
108 | |
109 cmyk_magenta = params['con_color_scheme']['cmyk_magenta'] if 'cmyk_magenta' in params[ | |
110 'con_color_scheme'] else 'Leave this black' | |
111 | |
112 if 'cmyk_magenta_weight' in params['con_color_scheme']: | |
113 if params['con_color_scheme']['cmyk_magenta_weight'] == "": | |
114 cmyk_magenta_weight = 1.0 | |
115 else: | |
116 cmyk_magenta_weight = params['con_color_scheme']['cmyk_cyan_weight'] | |
117 else: | |
118 cmyk_magenta_weight = 1.0 | |
119 | |
120 cmyk_yellow = params['con_color_scheme']['cmyk_yellow'] if 'cmyk_yellow' in params[ | |
121 'con_color_scheme'] else 'Leave this black' | |
122 | |
123 if 'cmyk_yellow_weight' in params['con_color_scheme']: | |
124 if params['con_color_scheme']['cmyk_yellow_weight'] == "": | |
125 cmyk_yellow_weight = 1.0 | |
126 else: | |
127 cmyk_yellow_weight = params['con_color_scheme']['cmyk_yellow_weight'] | |
128 else: | |
129 cmyk_yellow_weight = 1.0 | |
130 | |
131 cmyk_brightness = params['con_color_scheme']['cmyk_brightness'] if 'cmyk_brightness' in params[ | |
132 'con_color_scheme'] else 'Leave this black' | |
133 | |
134 if 'cmyk_brightness_weight' in params['con_color_scheme']: | |
135 if params['con_color_scheme']['cmyk_brightness_weight'] == "": | |
136 cmyk_brightness_weight = 1.0 | |
137 else: | |
138 cmyk_brightness_weight = params['con_color_scheme']['cmyk_brightness_weight'] | |
139 else: | |
140 cmyk_brightness_weight = 1.0 | |
141 | |
142 count = len(params['con_color_scheme']['rpt_image_name']) if 'rpt_image_name' in params['con_color_scheme'] else 1 | |
143 | |
144 _str += FOURSPACES + "Select a color scheme:%s\n" % color_scheme | |
145 | |
146 _str += FOURSPACES + "Select the image to be colored red:%s\n" % rgb_red | |
147 _str += FOURSPACES + "Select the image to be colored green:%s\n" % rgb_green | |
148 _str += FOURSPACES + "Select the image to be colored blue:%s\n" % rgb_blue | |
149 _str += FOURSPACES + "Name the output image:%s\n" % name_output_image | |
150 _str += FOURSPACES + "Relative weight for the red image:%.1f\n" % rgb_red_weight | |
151 _str += FOURSPACES + "Relative weight for the green image:%.1f\n" % rgb_green_weight | |
152 _str += FOURSPACES + "Relative weight for the blue image:%.1f\n" % rgb_blue_weight | |
153 | |
154 _str += FOURSPACES + "Select the image to be colored cyan:%s\n" % cmyk_cyan | |
155 _str += FOURSPACES + "Select the image to be colored magenta:%s\n" % cmyk_magenta | |
156 _str += FOURSPACES + "Select the image to be colored yellow:%s\n" % cmyk_yellow | |
157 _str += FOURSPACES + "Select the image that determines brightness:%s\n" % cmyk_brightness | |
158 _str += FOURSPACES + "Relative weight for the cyan image:%.1f\n" % cmyk_cyan_weight | |
159 _str += FOURSPACES + "Relative weight for the magenta image:%.1f\n" % cmyk_magenta_weight | |
160 _str += FOURSPACES + "Relative weight for the yellow image:%.1f\n" % cmyk_yellow_weight | |
161 _str += FOURSPACES + "Relative weight for the brightness image:%.1f\n" % cmyk_brightness_weight | |
162 | |
163 _str += FOURSPACES + "Hidden:%d\n" % count | |
164 | |
165 if 'rpt_image_name' in params['con_color_scheme']: | |
166 for i in params['con_color_scheme']['rpt_image_name']: | |
167 image_name = params['con_color_scheme']['rpt_image_name']['image_name'] | |
168 if 'color' in params['con_color_scheme']['rpt_image_name']: | |
169 color = params['con_color_scheme']['rpt_image_name']['color'] | |
170 else: | |
171 color = '#FF0000' | |
172 | |
173 if 'weight' in params['con_color_scheme']['rpt_image_name']: | |
174 weight = params['con_color_scheme']['rpt_image_name']['weight'] | |
175 else: | |
176 weight = 1.0 | |
177 else: | |
178 image_name = 'None' | |
179 color = '#FF0000' | |
180 weight = 1.0 | |
181 | |
182 _str += FOURSPACES + "Image name:%s\n" % image_name | |
183 _str += FOURSPACES + "Color:%s\n" % color | |
184 _str += FOURSPACES + "Weight:%s\n" % weight | |
185 | |
186 return _str | |
187 | |
188 with open(input_pipeline) as fin: | |
189 lines = fin.readlines() | |
190 | |
191 k, v = lines[4].strip().split(':') | |
192 | |
193 module_count = int(v) | |
194 new_count = module_count + 1 | |
195 lines[4] = k + ":%d\n" % new_count | |
196 | |
197 with open("output", "w") as f: | |
198 f.writelines(lines) | |
199 f.write(writegtc()) | |
200 | |
201 f.close() | |
202 </configfile> | |
203 </configfiles> | |
204 | |
205 <inputs> | |
206 <expand macro="input_pipeline_macro" /> | |
207 <conditional name="con_color_scheme"> | |
208 <param name="color_scheme" label="Select a color scheme" type="select"> | |
209 <option value="RGB">RGB</option> | |
210 <option value="CMYK">CMYK</option> | |
211 <option value="Stack">Stack</option> | |
212 <option value="Composite">Composite</option> | |
213 </param> | |
214 <when value="RGB"> | |
215 <expand macro="rgb" /> | |
216 </when> | |
217 <when value="CMYK"> | |
218 <expand macro="cmyk" /> | |
219 </when> | |
220 <when value="Stack"> | |
221 <expand macro="stack" /> | |
222 </when> | |
223 <when value="Composite"> | |
224 <expand macro="composite" /> | |
225 </when> | |
226 </conditional> | |
227 </inputs> | |
228 | |
229 <outputs> | |
230 <expand macro="output_pipeline_macro" /> | |
231 </outputs> | |
232 | |
233 <tests> | |
234 <test> | |
235 <expand macro="test_input_pipeline_param" /> | |
236 <conditional name="con_color_scheme"> | |
237 <param name="color_scheme" value="RGB" /> | |
238 <param name="rgb_red" value="MaskNucleoli" /> | |
239 <param name="rgb_red_weight" value="0.8" /> | |
240 <param name="rgb_green" value="Leave this black" /> | |
241 <param name="rgb_blue" value="MaskNuclei" /> | |
242 <param name="rgb_blue_weight" value="0.5" /> | |
243 <param name="name_output_image" value="CombinedMask" /> | |
244 </conditional> | |
245 <expand macro="test_out_file" file="gray_to_color.txt" /> | |
246 </test> | |
247 </tests> | |
248 | |
249 <expand macro="help" module="GrayToColor" /> | |
250 <expand macro="citations" /> | |
251 | |
252 </tool> |