Mercurial > repos > bgruening > cp_save_images
comparison save_images.xml @ 0:6e0f244acd32 draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 6d73056a625002d0275b5a9a90a9fae329ce47f1"
author | bgruening |
---|---|
date | Thu, 26 Mar 2020 17:42:45 -0400 |
parents | |
children | 609911f19ab2 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6e0f244acd32 |
---|---|
1 <tool id="cp_save_images" name="SaveImages" version="@CP_VERSION@"> | |
2 <description>saves image or movie files</description> | |
3 | |
4 <macros> | |
5 <import>macros.xml</import> | |
6 <xml name="file_format"> | |
7 <param name="file_format" label="Saved file format" type="select"> | |
8 <option value="jpeg">jpeg</option> | |
9 <option value="npy">npy</option> | |
10 <option value="png">png</option> | |
11 <option value="tiff">tiff</option> | |
12 </param> | |
13 </xml> | |
14 <xml name="bit_depth"> | |
15 <param name="bit_depth" label="Image bit depth" type="select"> | |
16 <option value="8-bit integer">8-bit integer</option> | |
17 <option value="16-bit integer">16-bit integer</option> | |
18 <option value="32-bit floating point">32-bit floating point</option> | |
19 </param> | |
20 </xml> | |
21 </macros> | |
22 | |
23 <expand macro="py_requirements"/> | |
24 <expand macro="cmd_modules" /> | |
25 | |
26 <configfiles> | |
27 <inputs name="inputs" /> | |
28 <configfile name="script_file"> | |
29 import json | |
30 import sys | |
31 import os | |
32 | |
33 FOURSPACES=@SPACES@ | |
34 | |
35 input_json_path = sys.argv[1] | |
36 input_pipeline= sys.argv[2] | |
37 | |
38 params = json.load(open(input_json_path, "r")) | |
39 | |
40 def writesi(): | |
41 _str = "\nSaveImages:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:13|show_window:False|notes:\\x5B\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count | |
42 | |
43 _str += FOURSPACES + "Select the type of image to save:%s\n" % params['con_type_of_image']['type_of_image'] | |
44 | |
45 _str += FOURSPACES + "Select the image to save:%s\n" % params['image_to_save'] | |
46 | |
47 method_for_constructing = params['con_method_for_constructing']['method_for_constructing'] | |
48 _str += FOURSPACES + "Select method for constructing file names:%s\n" % method_for_constructing | |
49 | |
50 if method_for_constructing == "From image filename": | |
51 img_name_file_prefix = params['con_method_for_constructing']['name_for_file_prefix'] | |
52 append_suffix = params['con_method_for_constructing']['con_append_suffix']['append_suffix'] | |
53 | |
54 if append_suffix == "Yes": | |
55 text_append = params['con_method_for_constructing']['con_append_suffix']['text_to_append'] | |
56 else: | |
57 text_append = "" | |
58 else: | |
59 img_name_file_prefix = "None" | |
60 append_suffix = "No" | |
61 text_append = "" | |
62 | |
63 _str += FOURSPACES + "Select image name for file prefix:%s\n" % img_name_file_prefix | |
64 | |
65 if method_for_constructing == "Sequential numbers": | |
66 file_prefix = params['con_method_for_constructing']['file_prefix'] | |
67 no_of_digits = params['con_method_for_constructing']['no_of_digits'] | |
68 | |
69 _str += FOURSPACES + "Enter file prefix:%s\n" % file_prefix | |
70 elif method_for_constructing == "Single name": | |
71 _str += FOURSPACES + "Enter single file name:%s\n" % params['con_method_for_constructing'][ | |
72 'single_file_name'] | |
73 | |
74 no_of_digits = 4 | |
75 else: | |
76 _str += FOURSPACES + "Enter single file name:OrigBlue\n" | |
77 no_of_digits = 4 | |
78 append_suffix = params['con_method_for_constructing']['con_append_suffix']['append_suffix'] | |
79 | |
80 _str += FOURSPACES + "Number of digits:%d\n" % no_of_digits | |
81 _str += FOURSPACES + "Append a suffix to the image file name?:%s\n" % append_suffix | |
82 _str += FOURSPACES + "Text to append to the image name:%s\n" % text_append | |
83 | |
84 save_format = params['con_type_of_image']['con_save_file_format']['file_format'] | |
85 | |
86 _str += FOURSPACES + "Saved file format:%s\n" % save_format | |
87 | |
88 if save_format == "tiff": | |
89 bit_depth = params['con_type_of_image']['con_save_file_format']['bit_depth'] | |
90 else: | |
91 bit_depth = "8-bit integer" | |
92 | |
93 _str += FOURSPACES + "Output file location:Default Output Folder\\x7Coutput\n" | |
94 _str += FOURSPACES + "Image bit depth:%s\n" % bit_depth | |
95 _str += FOURSPACES + "Overwrite existing files without warning?:%s\n" % params['overwrite_without_warning'] | |
96 _str += FOURSPACES + "When to save:%s\n" % params['when_to_save'] | |
97 _str += FOURSPACES + "Record the file and path information to the saved image?:%s\n" % params['record_info'] | |
98 _str += FOURSPACES + "Create subfolders in the output folder?:%s\n" % params['subfolder_in_output'] | |
99 _str += FOURSPACES + "Base image folder:Elsewhere...\n" | |
100 | |
101 return _str | |
102 | |
103 with open(input_pipeline) as fin: | |
104 lines = fin.readlines() | |
105 | |
106 k, v = lines[4].strip().split(':') | |
107 | |
108 module_count = int(v) | |
109 new_count = module_count + 1 | |
110 lines[4] = k + ":%d\n" % new_count | |
111 | |
112 with open("output", "w") as f: | |
113 f.writelines(lines) | |
114 f.write(writesi()) | |
115 | |
116 f.close() | |
117 </configfile> | |
118 </configfiles> | |
119 | |
120 <inputs> | |
121 <expand macro="input_pipeline_macro" /> | |
122 <conditional name="con_type_of_image"> | |
123 <param name="type_of_image" type="select" label="Select the type of image to save" > | |
124 <option value="Image">Image</option> | |
125 <option value="Mask">Mask</option> | |
126 <option value="Cropping">Cropping</option> | |
127 <option value="Movie">Movie</option> | |
128 </param> | |
129 <when value="Image"> | |
130 <conditional name="con_save_file_format"> | |
131 <expand macro="file_format" /> | |
132 <when value="tiff"> | |
133 <expand macro="bit_depth" /> | |
134 </when> | |
135 <when value="jpeg" /> | |
136 <when value="npy" /> | |
137 <when value="png" /> | |
138 </conditional> | |
139 </when> | |
140 <when value="Mask"> | |
141 <expand macro="file_format" /> | |
142 </when> | |
143 <when value="Cropping"> | |
144 <expand macro="file_format" /> | |
145 </when> | |
146 <when value="Movie"> | |
147 <expand macro="bit_depth" /> | |
148 </when> | |
149 </conditional> | |
150 <param name="image_to_save" label="Select the image to save" type="text" /> | |
151 <conditional name="con_method_for_constructing"> | |
152 <param name="method_for_constructing" label="Select method for constructing file names" type="select" > | |
153 <option value="From image filename">From image filename</option> | |
154 <option value="Sequential numbers">Sequential numbers</option> | |
155 <option value="Single name">Single name</option> | |
156 </param> | |
157 <when value="From image filename"> | |
158 <param name="name_for_file_prefix" label="Select image name for file prefix" type="text"> | |
159 <expand macro="text_validator" /> | |
160 </param> | |
161 <conditional name="con_append_suffix"> | |
162 <param name="append_suffix" type="select" display="radio" label="Append a suffix to the image file name?"> | |
163 <option value="No">No</option> | |
164 <option value="Yes">Yes</option> | |
165 </param> | |
166 <when value="Yes"> | |
167 <param name="text_to_append" label="Text to append to the image name" type="text"> | |
168 <expand macro="text_validator" /> | |
169 </param> | |
170 </when> | |
171 <when value="No" /> | |
172 </conditional> | |
173 </when> | |
174 <when value="Sequential numbers"> | |
175 <param name="file_prefix" label="Enter file prefix" type="text"/> | |
176 <param name="no_of_digits" label="Number of digits" type="integer" value="4" min="0"/> | |
177 </when> | |
178 <when value="Single name"> | |
179 <param name="single_file_name" label="Enter single_file_name" type="text"> | |
180 <expand macro="text_validator" /> | |
181 </param> | |
182 </when> | |
183 </conditional> | |
184 <param name="overwrite_without_warning" label="Overwrite existing files without warning?" type="select" > | |
185 <option value="No">No</option> | |
186 <option value="Yes">Yes</option> | |
187 </param> | |
188 <param name="when_to_save" label="When to save" type="select" > | |
189 <option value="Every cycle">Every cycle</option> | |
190 <option value="First cycle">First cycle</option> | |
191 <option value="Last cycle">Last cycle</option> | |
192 </param> | |
193 <param name="record_info" label="Record the file and path information to the saved image?" type="select" display="radio"> | |
194 <option value="No">No</option> | |
195 <option value="Yes">Yes</option> | |
196 </param> | |
197 <param name="subfolder_in_output" label="Create subfolders in the output folder?" type="select" display="radio"> | |
198 <option value="No">No</option> | |
199 </param> | |
200 </inputs> | |
201 | |
202 <outputs> | |
203 <expand macro="output_pipeline_macro" /> | |
204 </outputs> | |
205 | |
206 <tests> | |
207 <test> | |
208 <expand macro="test_input_pipeline_param" /> | |
209 | |
210 <conditional name="con_type_of_image"> | |
211 <param name="type_of_image" value="Image" /> | |
212 <conditional name="con_save_file_format"> | |
213 <param name="file_format" value="tiff" /> | |
214 <param name="bit_depth" value="8-bit integer" /> | |
215 </conditional> | |
216 </conditional> | |
217 <param name="image_to_save" value="ImageDisplay" /> | |
218 <conditional name="con_method_for_constructing" > | |
219 <param name="method_for_constructing" value="From image filename" /> | |
220 <param name="name_for_file_prefix" value="DNA" /> | |
221 <conditional name="con_append_suffix"> | |
222 <param name="append_suffix" value="Yes" /> | |
223 <param name="text_to_append" value="_nucleiNumbers" /> | |
224 </conditional> | |
225 </conditional> | |
226 <param name="overwrite_without_warning" value="Yes" /> | |
227 <param name="when_to_save" value="Every cycle" /> | |
228 <param name="record_info" value="No" /> | |
229 <param name="subfolder_in_output" value="No" /> | |
230 | |
231 <expand macro="test_out_file" file="save_images.txt" /> | |
232 | |
233 </test> | |
234 </tests> | |
235 | |
236 <expand macro="help" module="RelateObjects" /> | |
237 <expand macro="citations" /> | |
238 | |
239 </tool> |