comparison measure_image_area_occupied.xml @ 0:c75596eadae1 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 6d73056a625002d0275b5a9a90a9fae329ce47f1"
author bgruening
date Thu, 26 Mar 2020 17:46:10 -0400
parents
children 534ed7b8ca34
comparison
equal deleted inserted replaced
-1:000000000000 0:c75596eadae1
1 <tool id="cp_measure_image_area_occupied" name="MeasureImageAreaOccupied" version="@CP_VERSION@">
2 <description>measures the total area in an image that is occupied by objects</description>
3
4 <macros>
5 <import>macros.xml</import>
6 </macros>
7
8 <expand macro="py_requirements"/>
9 <expand macro="cmd_modules" />
10
11 <configfiles>
12 <inputs name="inputs" />
13 <configfile name="script_file">
14 import json
15 import sys
16 import os
17
18 FOURSPACES=@SPACES@
19
20 input_json_path = sys.argv[1]
21 input_pipeline= sys.argv[2]
22
23 params = json.load(open(input_json_path, "r"))
24
25 def writemiao():
26 _str = "\nMeasureImageAreaOccupied:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:4|show_window:False|notes:\\x5B\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count
27
28 hidden = len(params['rpt_area'])
29
30 _str += FOURSPACES + "Hidden:%d\n" % hidden
31
32 for area in params['rpt_area']:
33 _str += FOURSPACES + "Measure the area occupied in a binary image, or in objects?:%s\n" % area['con_area']['objects_or_image']
34
35 obj_flag = area['con_area']['objects_or_image']
36
37 if obj_flag == "Objects":
38 _str += FOURSPACES + "Select objects to measure:%s\n" % area['con_area']['objects_to_measure']
39 _str += FOURSPACES + "Select a binary image to measure:None\n"
40 else:
41 _str += FOURSPACES + "Select objects to measure:None\n"
42 _str += FOURSPACES + "Select a binary image to measure:%s\n" % area['con_area']['image_to_measure']
43
44 return _str
45
46
47 with open(input_pipeline) as fin:
48 lines = fin.readlines()
49
50 k, v = lines[4].strip().split(':')
51
52 module_count = int(v)
53 new_count = module_count + 1
54 lines[4] = k + ":%d\n" % new_count
55 with open("output", "w") as f:
56 f.writelines(lines)
57 f.write(writemiao())
58
59 f.close()
60 </configfile>
61 </configfiles>
62
63 <inputs>
64 <expand macro="input_pipeline_macro" />
65 <repeat name="rpt_area" title="Add another area">
66 <conditional name="con_area">
67 <param name="objects_or_image" label="Measure the area occupied in a binary image, or in objects?" type="select">
68 <option value="Binary image">Binary image</option>
69 <option value="Objects">Objects</option>
70 </param>
71 <when value="Objects">
72 <param name="objects_to_measure" label="Select objects to measure" type="text">
73 <expand macro="text_validator" />
74 </param>
75 </when>
76 <when value="Binary image">
77 <param name="image_to_measure" label="Select a binary image to measure" type="text">
78 <expand macro="text_validator" />
79 </param>
80 </when>
81 </conditional>
82 </repeat>
83 </inputs>
84
85 <outputs>
86 <expand macro="output_pipeline_macro" />
87 </outputs>
88
89 <tests>
90 <test>
91 <expand macro="test_input_pipeline_param" />
92 <repeat name="rpt_area">
93 <conditional name="con_area">
94 <param name="objects_or_image" value="Objects" />
95 <param name="objects_to_measure" value="Nuclei" />
96 </conditional>
97 </repeat>
98 <repeat name="rpt_area">
99 <conditional name="con_area">
100 <param name="objects_or_image" value="Objects" />
101 <param name="objects_to_measure" value="Nucleoli" />
102 </conditional>
103 </repeat>
104 <expand macro="test_out_file" file="measure_image_area_occupied.txt" />
105 </test>
106 </tests>
107
108 <expand macro="help" module="MeasureImageAreaOccupied" />
109 <expand macro="citations" />
110 </tool>