@@ -64,6 +64,7 @@ def generate_boutiques_descriptor(
64
64
'description' ] = interface_name + ", as implemented in Nipype (module: " + module_name + ", interface: " + interface_name + ")."
65
65
tool_desc ['inputs' ] = []
66
66
tool_desc ['output-files' ] = []
67
+ tool_desc ['groups' ] = []
67
68
tool_desc ['tool-version' ] = interface .version if interface .version is not None else "No version provided."
68
69
tool_desc ['schema-version' ] = '0.5'
69
70
if container_image :
@@ -88,16 +89,21 @@ def generate_boutiques_descriptor(
88
89
if verbose :
89
90
print ("-> Adding input " + i ['name' ])
90
91
# Put inputs into a mutually exclusive group
91
- tool_desc ['groups' ] = [ {'id' : input [0 ]['id' ] + "_group" ,
92
- 'name' : input [0 ]['name' ],
93
- 'members' : mutex_group_members ,
94
- 'mutually-exclusive' : True }]
92
+ tool_desc ['groups' ]. append ( {'id' : input [0 ]['id' ] + "_group" ,
93
+ 'name' : input [0 ]['name' ] + " group" ,
94
+ 'members' : mutex_group_members ,
95
+ 'mutually-exclusive' : True })
95
96
else :
96
97
tool_desc ['inputs' ].append (input )
97
98
tool_desc ['command-line' ] += input ['value-key' ] + " "
98
99
if verbose :
99
100
print ("-> Adding input " + input ['name' ])
100
101
102
+ # Generates input groups
103
+ tool_desc ['groups' ] += get_boutiques_groups (interface .inputs .traits (transient = None ).items ())
104
+ if len (tool_desc ['groups' ]) == 0 :
105
+ del tool_desc ['groups' ]
106
+
101
107
# Generates tool outputs
102
108
for name , spec in sorted (outputs .traits (transient = None ).items ()):
103
109
output = get_boutiques_output (outputs , name , spec , interface , tool_desc ['inputs' ],
@@ -245,15 +251,6 @@ def get_boutiques_input(inputs, interface, input_name, spec,
245
251
if value_choices is not None :
246
252
input ['value-choices' ] = value_choices
247
253
248
- if spec .requires is not None :
249
- input ['requires-inputs' ] = spec .requires
250
-
251
- if spec .xor is not None :
252
- input ['disables-inputs' ] = list (spec .xor )
253
- # Make sure input does not disable itself
254
- if input ['id' ] in input ['disables-inputs' ]:
255
- input ['disables-inputs' ].remove (input ['id' ])
256
-
257
254
# Create unique, temporary value.
258
255
temp_value = must_generate_value (input_name , input ['type' ],
259
256
ignored_template_inputs , spec_info , spec ,
@@ -351,6 +348,37 @@ def get_boutiques_output(outputs, name, spec, interface, tool_inputs, verbose=Fa
351
348
return output
352
349
353
350
351
+ def get_boutiques_groups (input_traits ):
352
+ desc_groups = []
353
+ all_or_none_input_sets = []
354
+ mutex_input_sets = []
355
+
356
+ # Get all the groups
357
+ for name , spec in input_traits :
358
+ if spec .requires is not None :
359
+ group_members = set ([name ] + list (spec .requires ))
360
+ if group_members not in all_or_none_input_sets :
361
+ all_or_none_input_sets .append (group_members )
362
+ if spec .xor is not None :
363
+ group_members = set ([name ] + list (spec .xor ))
364
+ if group_members not in mutex_input_sets :
365
+ mutex_input_sets .append (group_members )
366
+
367
+ # Create a dictionary for each one
368
+ for i in range (0 , len (all_or_none_input_sets )):
369
+ desc_groups .append ({'id' : "all_or_none_group" + ("_" + str (i + 1 ) if i != 0 else "" ),
370
+ 'name' : "All or none group" + (" " + str (i + 1 ) if i != 0 else "" ),
371
+ 'members' : list (all_or_none_input_sets [i ]),
372
+ 'all-or-none' : True })
373
+
374
+ for i in range (0 , len (mutex_input_sets )):
375
+ desc_groups .append ({'id' : "mutex_group" + ("_" + str (i + 1 ) if i != 0 else "" ),
376
+ 'name' : "Mutex group" + (" " + str (i + 1 ) if i != 0 else "" ),
377
+ 'members' : list (mutex_input_sets [i ]),
378
+ 'mutually-exclusive' : True })
379
+
380
+ return desc_groups
381
+
354
382
def get_unique_value (type , id ):
355
383
'''
356
384
Returns a unique value of type 'type', for input with id 'id',
0 commit comments