comparison starting_modules.py @ 4:f8fa0f6718a3 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 35da2dcd86747c9bff138e100dbe08c6106f3780"
author bgruening
date Sat, 06 Feb 2021 10:07:37 +0000
parents 72a7f23f3a79
children d0178bdcd00e
comparison
equal deleted inserted replaced
3:72a7f23f3a79 4:f8fa0f6718a3
1 import json 1 import json
2 import sys 2 import sys
3 import os
4 3
5 FOURSPACES = " " 4 FOURSPACES = " "
6 5
7 input_json_path = sys.argv[1] 6 input_json_path = sys.argv[1]
8 7
11 10
12 def write_images(): 11 def write_images():
13 filter_images = params['images']['filter_images'] 12 filter_images = params['images']['filter_images']
14 13
15 _str = "\nImages:[module_num:1|svn_version:\\'Unknown\\'|variable_revision_number:2|show_window:False|notes:\\x5B\\'To begin creating your project, use the Images module to compile a list of files and/or folders that you want to analyze. You can also specify a set of rules to include only the desired files in your selected folders.\\'\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" 14 _str = "\nImages:[module_num:1|svn_version:\\'Unknown\\'|variable_revision_number:2|show_window:False|notes:\\x5B\\'To begin creating your project, use the Images module to compile a list of files and/or folders that you want to analyze. You can also specify a set of rules to include only the desired files in your selected folders.\\'\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n"
16 _str += FOURSPACES+":\n" 15 _str += FOURSPACES + ":\n"
17 _str += FOURSPACES + "Filter images?:%s\n" % filter_images 16 _str += FOURSPACES + "Filter images?:%s\n" % filter_images
18 _str += FOURSPACES + "Select the rule criteria:and (extension does isimage) (directory doesnot startwith \".\")\n" 17 _str += FOURSPACES + "Select the rule criteria:and (extension does isimage) (directory doesnot startwith \".\")\n"
19 18
20 return _str 19 return _str
21 20
43 _str += FOURSPACES + "Select the filtering criteria:and (file does contain \"\")\n" 42 _str += FOURSPACES + "Select the filtering criteria:and (file does contain \"\")\n"
44 _str += FOURSPACES + "Metadata file location:\n" 43 _str += FOURSPACES + "Metadata file location:\n"
45 _str += FOURSPACES + "Match file and image metadata:\x5B\x5D\n" 44 _str += FOURSPACES + "Match file and image metadata:\x5B\x5D\n"
46 _str += FOURSPACES + "Use case insensitive matching?:No\n" 45 _str += FOURSPACES + "Use case insensitive matching?:No\n"
47 else: 46 else:
48 _str += FOURSPACES + "Metadata data type:Text\n" #default Text,not possible to select in Galaxy 47 _str += FOURSPACES + "Metadata data type:Text\n" # default Text,not possible to select in Galaxy
49 _str += FOURSPACES + "Metadata types:{}\n" 48 _str += FOURSPACES + "Metadata types:{}\n"
50 _str += FOURSPACES + "Extraction method count:%d\n" % method_count 49 _str += FOURSPACES + "Extraction method count:%d\n" % method_count
51 50
52 for methods in metadata_extraction["extraction_method"]: 51 for methods in metadata_extraction["extraction_method"]:
53 _str += FOURSPACES + "Metadata extraction method:%s\n" % methods["metadata_extraction_method"] 52 _str += FOURSPACES + "Metadata extraction method:%s\n" % methods["metadata_extraction_method"]
68 _str += FOURSPACES + "Regular expression to extract from folder name:%s\n" % folder_regex 67 _str += FOURSPACES + "Regular expression to extract from folder name:%s\n" % folder_regex
69 68
70 _str += FOURSPACES + "Extract metadata from:%s\n" % methods["con_metadata_extract_from"]["extract_metadata_from"] 69 _str += FOURSPACES + "Extract metadata from:%s\n" % methods["con_metadata_extract_from"]["extract_metadata_from"]
71 70
72 if methods["con_metadata_extract_from"]["extract_metadata_from"] == "Images matching a rule": 71 if methods["con_metadata_extract_from"]["extract_metadata_from"] == "Images matching a rule":
73 rule_str ="" 72 rule_str = ""
74 for r in methods["con_metadata_extract_from"]["r_match"]: 73 for r in methods["con_metadata_extract_from"]["r_match"]:
75 if r["con_match"]["rule_type"] == "extension": 74 if r["con_match"]["rule_type"] == "extension":
76 rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " + \ 75 rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " + \
77 r["con_match"]["match_type"]+")" 76 r["con_match"]["match_type"] + ")"
78 else: 77 else:
79 rule_str +=" (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " +\ 78 rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " +\
80 r["con_match"]["contain"] + " \"" + r["con_match"]["match_value"] +"\")" 79 r["con_match"]["contain"] + " \"" + r["con_match"]["match_value"] + "\")"
81 80
82 81 _str += FOURSPACES + "Select the filtering criteria:" + methods["con_metadata_extract_from"]["match_all_any"] + rule_str + "\n"
83 _str += FOURSPACES + "Select the filtering criteria:" + methods["con_metadata_extract_from"]["match_all_any"] + rule_str +"\n" 82 else:
84 else: 83 _str += FOURSPACES + "Select the filtering criteria:and (file does contain \"\")\n" # this line is required even if it's not used
85 _str += FOURSPACES + "Select the filtering criteria:and (file does contain \"\")\n" #this line is required even if it's not used
86 84
87 _str += FOURSPACES + "Metadata file location:\n" 85 _str += FOURSPACES + "Metadata file location:\n"
88 _str += FOURSPACES + "Match file and image metadata:\x5B\x5D\n" 86 _str += FOURSPACES + "Match file and image metadata:\x5B\x5D\n"
89 _str += FOURSPACES + "Use case insensitive matching?:No\n" 87 _str += FOURSPACES + "Use case insensitive matching?:No\n"
90 88
125 _str += FOURSPACES + "Single images count:0\n" 123 _str += FOURSPACES + "Single images count:0\n"
126 _str += FOURSPACES + "Maximum intensity:%.1f\n" % max_intensity 124 _str += FOURSPACES + "Maximum intensity:%.1f\n" % max_intensity
127 _str += FOURSPACES + "Process as 3D?:%s\n" % process_3d 125 _str += FOURSPACES + "Process as 3D?:%s\n" % process_3d
128 126
129 else: 127 else:
130 #the below lines are not relevant to "images matching rules", but needed in pipeline file 128 # the below lines are not relevant to "images matching rules", but needed in pipeline file
131 _str += FOURSPACES + "Select the image type:Grayscale image\n" 129 _str += FOURSPACES + "Select the image type:Grayscale image\n"
132 _str += FOURSPACES + "Name to assign these images:DNA\n" 130 _str += FOURSPACES + "Name to assign these images:DNA\n"
133 _str += FOURSPACES + "Match metadata:[]\n" 131 _str += FOURSPACES + "Match metadata:[]\n"
134 132
135 _str += FOURSPACES + "Image set matching method:%s\n" % nameandtypes['con_assign_a_name_to']['matching_method'] 133 _str += FOURSPACES + "Image set matching method:%s\n" % nameandtypes['con_assign_a_name_to']['matching_method']
145 143
146 if assign_a_name == "Images matching rules": 144 if assign_a_name == "Images matching rules":
147 for rule in nameandtypes["con_assign_a_name_to"]["r_match_rule"]: 145 for rule in nameandtypes["con_assign_a_name_to"]["r_match_rule"]:
148 146
149 rule_str = "" 147 rule_str = ""
150 if len(rule["r_match"]) >0 : 148 if len(rule["r_match"]) > 0:
151 for r in rule["r_match"]: 149 for r in rule["r_match"]:
152 if r["con_match"]["rule_type"] == "file" or r["con_match"]["rule_type"] == "directory": 150 if r["con_match"]["rule_type"] == "file" or r["con_match"]["rule_type"] == "directory":
153 rule_str += " (" + r["con_match"]["rule_type"] + " "+r["con_match"]["operator"]+" "+\ 151 rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " + \
154 r["con_match"]["contain"]+" \"" + r["con_match"]["match_value"] +"\")" 152 r["con_match"]["contain"] + " \"" + r["con_match"]["match_value"] + "\")"
155 else: 153 else:
156 rule_str += " ("+ r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " + \ 154 rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " + \
157 r["con_match"]["match_type"] + ")" 155 r["con_match"]["match_type"] + ")"
158 else: 156 else:
159 rule_str = " (file does contain \"\")" #need to have a value even if it is not used 157 rule_str = " (file does contain \"\")" # need to have a value even if it is not used
160 158
161 _str += FOURSPACES + "Select the rule criteria:" + rule["match_all_any"] + rule_str +"\n" 159 _str += FOURSPACES + "Select the rule criteria:" + rule["match_all_any"] + rule_str + "\n"
162 160
163 img_or_obj = rule["con_select_image_type"]["select_image_type"] 161 img_or_obj = rule["con_select_image_type"]["select_image_type"]
164 162
165 if img_or_obj == "Objects": 163 if img_or_obj == "Objects":
166 _str += FOURSPACES + "Name to assign these images:DNA\n" 164 _str += FOURSPACES + "Name to assign these images:DNA\n"
169 _str += FOURSPACES + "Name to assign these images:%s\n" % rule["con_select_image_type"]["name_to_assign"] 167 _str += FOURSPACES + "Name to assign these images:%s\n" % rule["con_select_image_type"]["name_to_assign"]
170 _str += FOURSPACES + "Name to assign these objects:Cell\n" 168 _str += FOURSPACES + "Name to assign these objects:Cell\n"
171 169
172 _str += FOURSPACES + "Select the image type:%s\n" % img_or_obj 170 _str += FOURSPACES + "Select the image type:%s\n" % img_or_obj
173 171
174 172 intensity_range = "Image metadata" # default value
175 intensity_range="Image metadata" #default value
176 if img_or_obj == "Grayscale image" or img_or_obj == "Color image": 173 if img_or_obj == "Grayscale image" or img_or_obj == "Color image":
177 intensity_range = rule["con_select_image_type"]["con_set_intensity"]["set_intensity_range_from"] 174 intensity_range = rule["con_select_image_type"]["con_set_intensity"]["set_intensity_range_from"]
178 175
179 _str += FOURSPACES + "Set intensity range from:%s\n" % intensity_range 176 _str += FOURSPACES + "Set intensity range from:%s\n" % intensity_range
180 177
181 if intensity_range == "Manual": 178 if intensity_range == "Manual":
182 _str += FOURSPACES + "Maximum intensity:%s\n" % rule["con_select_image_type"]["con_set_intensity"]["maximum_intensity"] 179 _str += FOURSPACES + "Maximum intensity:%s\n" % rule["con_select_image_type"]["con_set_intensity"]["maximum_intensity"]
183 else: 180 else:
184 _str += FOURSPACES + "Maximum intensity:255.0\n" 181 _str += FOURSPACES + "Maximum intensity:255.0\n"
185 182
186
187 return _str 183 return _str
188 184
189 185
190 def write_groups(): 186 def write_groups():
191 groups = params['groups'] 187 groups = params['groups']
192 188
193 _str = "\nGroups:[module_num:4|svn_version:\\'Unknown\\'|variable_revision_number:2|show_window:False|notes:\\x5B\\\'The Groups module optionally allows you to split your list of images into image subsets (groups) which will be processed independently of each other. Examples of groupings include screening batches, microtiter plates, time-lapse movies, etc.\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" 189 _str = "\nGroups:[module_num:4|svn_version:\\'Unknown\\'|variable_revision_number:2|show_window:False|notes:\\x5B\\\'The Groups module optionally allows you to split your list of images into image subsets (groups) which will be processed independently of each other. Examples of groupings include screening batches, microtiter plates, time-lapse movies, etc.\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n"
194 190
195 group_images = groups["con_groups"]["group_images"] 191 group_images = groups["con_groups"]["group_images"]
196 192
197 _str += FOURSPACES + "Do you want to group your images?:%s\n" % group_images 193 _str += FOURSPACES + "Do you want to group your images?:%s\n" % group_images
198 _str += FOURSPACES + "grouping metadata count:1\n" 194 _str += FOURSPACES + "grouping metadata count:1\n"
199 195
200 if group_images == "Yes": 196 if group_images == "Yes":