def _add_format_ui(root, format_record): if issubclass(format_record.format, model.DirectoryFormat): for field in format_record.format._fields: file_attr = getattr(format_record.format, field) if isinstance(file_attr, model.FileCollection): _add_collection_ui(root, file_attr) else: section = XMLNode("section", name=f'import_{file_attr.name}', expanded='true') _add_data_ui(section, file_attr) root.append(section) else: section = XMLNode("section", name='import', expanded='true') section.append( XMLNode('param', type='hidden', name='name', value=galaxy_esc(None))) section.append( XMLNode('param', type='data', name='data', help=_format_help_text(format_record.format))) root.append(section)
def inputs_xml(self): predicate = self.spec.qiime_type.predicate if predicate is not None and predicate.name == 'Choices': param = make_select(self.name, self.spec, predicate.template.choices) else: param = XMLNode('param', name=self.name, type='text') if self.spec.has_default(): if self.spec.default is None: self.add_help(param) self.add_label(param) param = make_optional(param) else: param.set('value', self.spec.default) else: param.append( XMLNode( # validator type='length' fails on empty input 'validator', 'value is not None and len(value) > 0', type='expression', message='Please verify this parameter.')) self.add_help(param) self.add_label(param) return param
def make_tests(action): tests = XMLNode('tests') for idx, example in enumerate(action.examples.values()): use = GalaxyTestUsage(example_path=(action, idx)) example(use) tests.append(use.xml) return tests
def make_tests(action): tests = XMLNode('tests') for example in action.examples.values(): use = TemplateTestUsage() example(use) tests.append(use.xml) return tests
def inputs_xml(self): param = XMLNode('param', name=self.name, type='text', value='NOT YET IMPLEMENTED') param.append( XMLNode('validator', 'False', type='expression', message='NOT YET IMPLEMENTED')) return param
class GalaxyTestUsage(GalaxyBaseUsage): _USE_TSV_INDEX = True def __init__(self, example_path, write_dir=None): super().__init__() self.prefix = f'{example_path[0].id}.test{example_path[1]}' self.xml = XMLNode('test') self.output_lookup = {} self.write_dir = write_dir self.created_files = [] def usage_variable(self, name, factory, var_type): return GalaxyTestUsageVariable(name, factory, var_type, self, self.prefix) def init_artifact(self, name, factory): var = super().init_artifact(name, factory) if self.write_dir is not None: status = var.write_file(self.write_dir) self.created_files.append(status) return var def init_metadata(self, name, factory): var = super().init_metadata(name, factory) if self.write_dir is not None: status = var.write_file(self.write_dir) self.created_files.append(status) return var def action(self, action, inputs, outputs): vars_ = super().action(action, inputs, outputs) sig = action.get_action().signature mapped = inputs.map_variables(lambda v: v.to_interface_name()) for case in signature_to_galaxy(sig, mapped): test_xml = case.tests_xml() if test_xml is None: continue if type(test_xml) is not list: test_xml = [test_xml] for xml in test_xml: self.xml.append(xml) for output_name, output in outputs.items(): xml_out = XMLNode('output', name=output_name, ftype='qza') self.output_lookup[output] = xml_out self.xml.append(xml_out) return vars_
def inputs_xml(self): root = XMLNode('repeat', name=self.name, title=f'{self.name}: {str(self.spec.qiime_type)}') self.add_help(root) if not self.spec.has_default(): root.set('min', '1') to_repeat = identify_arg_case('element', self.inner_spec, self.arg) root.append(to_repeat.inputs_xml()) return root
class TemplateTestUsage(TestDataUsage): def __init__(self): super().__init__() self.xml = XMLNode('test') self._output_lookup = {} def _make_params(self, action, input_opts): _, sig = action.get_action() for case in signature_to_galaxy(sig, input_opts): test_xml = case.tests_xml() if test_xml is None: continue if type(test_xml) is not list: test_xml = [test_xml] for xml in test_xml: self.xml.append(xml) def _make_outputs(self, output_opts): for output_name, output in output_opts.items(): output_xml = XMLNode('output', name=output_name, ftype='qza') self._output_lookup[output] = output_xml self.xml.append(output_xml) def _action_(self, action, input_opts: dict, output_opts: dict): self._make_params(action, input_opts) self._make_outputs(output_opts) return super()._action_(action, input_opts, output_opts) def _get_metadata_column_(self, column_name, record): if record.result is None: return None md = self._factories[record.ref]() column = str(list(md.columns.keys()).index(column_name) + 2) return (record.result, column) def _assert_has_line_matching_(self, ref, label, path, expression): output = self._output_lookup[ref] contents = output.find('assert_contents') if contents is None: contents = XMLNode('assert_contents') output.append(contents) path = f'.*/data/{path}' archive = contents.find(f'has_archive_member[@path="{path}"]') if archive is None: archive = XMLNode('has_archive_member', path=path) contents.append(archive) archive.append(XMLNode('has_line_matching', expression=expression))
def tests_xml(self): roots = [] if self.arg is None: return None for idx, arg in enumerate(self.arg): root = XMLNode('repeat', name=self.name) to_repeat = identify_arg_case('element', self.inner_spec, arg) root.append(to_repeat.tests_xml()) roots.append(root) return roots
def make_select(name, spec, choices, display_func=str): param = XMLNode('param', name=name, type='select') default = None if spec.has_default(): if spec.default is None: param.append(XMLNode('option', 'None (Use default behavior)', value=galaxy_esc(None), selected='true')) else: default = spec.default elif len(choices) > 1: # A validator for this is added a few lines down (after options) # this is done to force the XML structure to look right param.append(XMLNode('option', 'Selection required', value=galaxy_esc(None))) if len(choices) < 5: param.set('display', 'radio') for choice in choices: option = XMLNode('option', display_func(choice), value=galaxy_esc(choice)) if choice == default: option.set('selected', 'true') param.append(option) if not spec.has_default() and len(choices) > 1: param.append(XMLNode( 'validator', f'value != {repr(galaxy_esc(None))}', type='expression', message='Please verify this parameter.')) return param
def _assert_has_line_matching_(self, ref, label, path, expression): output = self._output_lookup[ref] contents = output.find('assert_contents') if contents is None: contents = XMLNode('assert_contents') output.append(contents) path = f'.*/data/{path}' archive = contents.find(f'has_archive_member[@path="{path}"]') if archive is None: archive = XMLNode('has_archive_member', path=path) contents.append(archive) archive.append(XMLNode('has_line_matching', expression=expression))
def _galaxy_has_line_matching(self, path, expression): output = self.use.output_lookup[self.name] contents = output.find('assert_contents') if contents is None: contents = XMLNode('assert_contents') output.append(contents) path = (r'[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]' r'{3}-[0-9a-f]{12}\/') + path archive = contents.find(f'has_archive_member[@path="{path}"]') if archive is None: archive = XMLNode('has_archive_member', path=path) contents.append(archive) archive.append(XMLNode('has_line_matching', expression=expression))
def make_tool(conda_meta, plugin, action): signature = action.signature inputs = XMLNode('inputs') advanced = [] for case in signature_to_galaxy(signature): xml = case.inputs_xml() if case.is_advanced(): if type(xml) is list: advanced.extend(xml) else: advanced.append(xml) else: if type(xml) is list: inputs.extend(xml) else: inputs.append(xml)
def make_citations(plugin=None, action=None): citations_xml = XMLNode('citations') citations = [] if action is not None: citations.extend(action.citations) if plugin is not None: citations.extend(plugin.citations) citations.extend(qiime2.__citations__) for idx, cite_record in enumerate(citations, 1): with io.StringIO() as fh: sdk.Citations([(f'cite{idx}', cite_record)]).save(fh) citations_xml.append(XMLNode('citation', fh.getvalue(), type='bibtex')) return citations_xml
def make_requirements(conda_meta, *project_names): # HACK: # use a single environment when templating instead of following the full # trail. An exception to this is q2-mystery-stew if len(project_names) == 1 and project_names[0] == 'q2-mystery-stew': pass else: pm = sdk.PluginManager() project_names = [p.project_name for p in pm.plugins.values()] requirements = XMLNode('requirements') for dep, version in conda_meta.iter_deps(*project_names, include_self=True): r = XMLNode('requirement', dep, type='package', version=version) requirements.append(r) requirements.append(XMLNode('requirement', 'q2galaxy', type='package', version=q2galaxy.__version__)) return requirements
def inputs_xml(self): predicate = self.spec.qiime_type.predicate if predicate is not None and predicate.name == 'Choices': param = make_select(self.name, self.spec, predicate.template.choices) else: param = XMLNode('param', name=self.name, type='text') # sanitizer prevents default replacement with 'X' for some # punctuation characters. It appears that this sanitizing requires # an enumeration of valid characters, so supporting arbitrary # unicode will likely require a change to Galaxy itself. sanitizer = XMLNode('sanitizer') valid = XMLNode('valid', initial='string.printable') sanitizer.append(valid) param.append(sanitizer) if self.spec.has_default(): if self.spec.default is None: self.add_help(param) self.add_label(param) param = make_optional(param) else: param.set('value', self.spec.default) else: param.append(XMLNode( # validator type='length' fails on empty input 'validator', 'value is not None and len(value) > 0', type='expression', message='Please verify this parameter.')) self.add_help(param) self.add_label(param) return param
def inputs_xml(self): file_ref = self.name + '_source_data' param1 = XMLNode('param', type='data', format='tabular', name=file_ref) self.add_label(param1) self.add_default(param1) param2 = XMLNode('param', type='data_column', use_header_names='true', data_ref=file_ref, name=self.name, label=' ') self.add_help(param2) self.add_default(param2) param2.append( XMLNode('validator', 'value != "1"', type='expression', message='The first column cannot be selected (' 'they are IDs).')) return [param1, param2]
def tests_xml(self): arg = str(self.arg) if type(self.arg) is str or type(self.arg) is bool or self.arg is None: arg = galaxy_esc(self.arg) param = XMLNode('param', name=self.name, value=arg) selected_branch = None for galaxy_name, type_ in self.branches.items(): if self.arg in type_: selected_branch = galaxy_name break else: raise Exception("How did this happen?") conditional = XMLNode( 'conditional', name=galaxy_ui_var(tag='conditional', name=self.name)) select = XMLNode('param', name=galaxy_ui_var(name='select'), value=selected_branch) conditional.append(select) conditional.append(param) return conditional
def _add_data_ui(root, file_attr): name = XMLNode('param', type='text', name='name') if _guess_regex(file_attr.pathspec): name.set( 'help', 'Filename to import the data as. Must match' f' regex: {_regex_xml_escape(file_attr.pathspec)}') name.append( XMLNode('validator', file_attr.pathspec, type='regex', message='This filename doesn\'t match the regex.')) else: name.set( 'help', 'Filename to import the data as. You shouldn\'t need' ' to change this unless something is wrong.') name.set('value', file_attr.pathspec) root.append(name) root.append( XMLNode('param', type='data', name='data', help=_format_help_text(file_attr.format)))
def tests_xml(self): if self.arg is None: return type_, source, column = self.arg cond = XMLNode('conditional', name=self.name) cond.append(XMLNode('param', name='type', value=type_)) if type_ == 'tsv': type_ = 'qiime2.tabular' cond.append(XMLNode('param', name='source', value=source, ftype=type_)) cond.append(XMLNode('param', name='column', value=column)) return cond
def inputs_xml(self): param = XMLNode('param', type='data', format='qza', name=self.name) self.add_help(param) self.add_default(param) self.add_label(param) if self.multiple: param.set('multiple', 'true') options = XMLNode('options', options_filter_attribute='metadata.semantic_type') for t in self.qiime_type: options.append(XMLNode('filter', type='add_value', value=repr(t))) param.append(options) if not self.multiple: param.append(self._make_validator()) return param
def tests_xml(self): if self.arg is None: return arg = self.arg if type(self.arg) is not list: arg = [self.arg] merged = [] for type_, source in arg: repeat = XMLNode('repeat', name=self.name) cond = XMLNode('conditional', name=galaxy_ui_var(tag='conditional', name=self.name)) cond.append(XMLNode('param', name='type', value=type_)) if type_ == 'tsv': type_ = 'qiime2.tabular' cond.append(XMLNode('param', name='source', value=source, ftype=type_)) repeat.append(cond) merged.append(repeat) return merged
def make_builtin_import(meta, tool_id): pm = sdk.PluginManager() inputs = XMLNode('inputs') # Not a galaxy_ui_var() because this will be taken by name from the # Cheetah searchList (see `def _inline_code` below) conditional = XMLNode('conditional', name='import_root') inputs.append(conditional) type_ = XMLNode('param', name='type', type='select', label=('Type of data to import:')) type_.append( XMLNode('option', 'Select a QIIME 2 type to import.', value='None')) conditional.append(type_) when = XMLNode('when', value="None") conditional.append(when) default_formats = _get_default_formats(pm) plugins = set() known_formats = set() for record in sorted(pm.get_semantic_types().values(), key=lambda x: str(x.semantic_type)): plugins.add(record.plugin) type_option = XMLNode('option', str(record.semantic_type), value=galaxy_esc(str(record.semantic_type))) type_.append(type_option) when = XMLNode('when', value=galaxy_esc(str(record.semantic_type))) fmt_conditional = XMLNode('conditional', name=galaxy_ui_var(tag='cond', name='format')) select = XMLNode('param', type='select', name='format', label="QIIME 2 file format to import from:") fmt_conditional.append(select) when.append(fmt_conditional) default_format = default_formats[record.semantic_type] for fmt_rec in sorted(pm.get_formats( filter=GetFormatFilters.IMPORTABLE, semantic_type=record.semantic_type).values(), key=lambda x: x.format.__name__): if issubclass(fmt_rec.format, model.SingleFileDirectoryFormatBase): # These are really just noise for the galaxy UI # an implicit transformation from the backing file format # is simpler and removes the redundancy continue plugins.add(fmt_rec.plugin) known_formats.add(fmt_rec.format) option = XMLNode( 'option', pretty_fmt_name(fmt_rec.format), value=galaxy_esc(fmt_rec.format.__name__), selected=str(fmt_rec.format == default_format).lower()) select.append(option) fmt_when = XMLNode('when', value=galaxy_esc(fmt_rec.format.__name__)) fmt_conditional.append(fmt_when) _add_format_ui(fmt_when, fmt_rec) conditional.append(when) outputs = XMLNode('outputs') outputs.append( XMLNode('data', name='imported_data', format='qza', from_work_dir='imported_data.qza')) tool = XMLNode('tool', id=tool_id, name=make_tool_name_from_id(tool_id), version=make_builtin_version(plugins)) tool.append(inputs) tool.append(outputs) tool.append(XMLNode('command', "q2galaxy run tools import '$inputs'")) tool.append(_make_config()) tool.append(XMLNode('description', 'Import data into a QIIME 2 artifact')) tool.append(make_citations()) tool.append(make_requirements(meta, *[p.project_name for p in plugins])) tool.append(_make_help(known_formats)) return tool
def make_config(): configfiles = XMLNode('configfiles') configfiles.append(XMLNode('inputs', name='inputs', data_style='paths')) return configfiles
if type(xml) is list: inputs.extend(xml) else: inputs.append(xml) if advanced: section = XMLNode('section', name=galaxy_ui_var(tag='section', name='extra_opts'), title='Click here for additional options') section.extend(advanced) inputs.append(section) outputs = XMLNode('outputs') for name, spec in signature.outputs.items(): output = make_output(name, spec) outputs.append(output) tool = XMLNode('tool', id=make_tool_id(plugin.id, action.id), name=make_tool_name(plugin.name, action.id), version=f'{plugin.version}+q2galaxy.{q2galaxy.__version__}') tool.append(XMLNode('description', action.name)) tool.append(make_command(plugin, action)) tool.append(make_version_command(plugin)) tool.append(make_config()) tool.append(inputs) tool.append(outputs) tool.append(make_tests(action)) tool.append(make_help(plugin, action)) tool.append(make_citations(plugin, action)) tool.append(make_requirements(conda_meta, plugin.project_name))
def make_optional(param): name = param.get('name') help_ = param.attrib.pop('help') label = param.attrib.pop('label') conditional = XMLNode('conditional', name=galaxy_ui_var(tag='conditional', name=name)) use_default = galaxy_ui_var(value='default') use_value = galaxy_ui_var(value='provide') picker = XMLNode('param', name=galaxy_ui_var(tag='select'), type='select', help=help_, label=label) picker.append( XMLNode('option', 'None (Use default behavior)', value=use_default, selected='true')) picker.append(XMLNode('option', 'Provide a value', value=use_value)) conditional.append(picker) when = XMLNode('when', value=use_default) when.append( XMLNode('param', type='hidden', name=name, value=galaxy_esc(None))) conditional.append(when) when = XMLNode('when', value=use_value) when.append(param) conditional.append(when) return conditional
def make_builtin_export(meta, tool_id): pm = sdk.PluginManager() inputs = XMLNode('inputs') # This also works for qzvs even though the format just says qza so. . . qza_input = 'input' inputs.append(XMLNode('param', format="qza", name=qza_input, type='data', label='input: The path to the artifact you ' 'want to export')) type_peek = XMLNode('param', type='select', name='type_peek', display='radio', label="The type of your input qza is:") type_peek_opts = XMLNode('options') type_peek_filter = XMLNode('filter', type='data_meta', ref=qza_input, key='semantic_type') type_peek_opts.append(type_peek_filter) type_peek.append(type_peek_opts) inputs.append(type_peek) fmt_peek = XMLNode('param', type='select', name='fmt_peek', display='radio', label="The current QIIME 2 format is:") fmt_peek_opts = XMLNode('options') fmt_peek_filter = XMLNode('filter', type='data_meta', ref=qza_input, key='format') fmt_peek_opts.append(fmt_peek_filter) fmt_peek.append(fmt_peek_opts) inputs.append(fmt_peek) conditional = XMLNode('conditional', name='fmt_finder') inputs.append(conditional) type_ = XMLNode('param', name='type', type='select', label=('To change the format, select the type indicated' ' above:')) type_.append(XMLNode('option', 'export as is (no conversion)', value='None', selected='true')) conditional.append(type_) when = XMLNode('when', value="None") select = XMLNode('param', type='select', name='output_format', label="QIIME 2 file format to convert to:") select.append(XMLNode('option', 'export as is (no conversion)', value='None', selected='true')) when.append(select) conditional.append(when) plugins = set() known_formats = set() for record in sorted(pm.get_semantic_types().values(), key=lambda x: str(x.semantic_type)): plugins.add(record.plugin) type_option = XMLNode('option', str(record.semantic_type), value=galaxy_esc(str(record.semantic_type))) type_.append(type_option) when = XMLNode('when', value=galaxy_esc(str(record.semantic_type))) select = XMLNode('param', type='select', name='output_format', label="QIIME 2 file format to convert to:") select.append(XMLNode('option', 'export as is (no conversion)', value='None', selected='true')) for fmt_rec in sorted( pm.get_formats(filter=GetFormatFilters.EXPORTABLE, semantic_type=record.semantic_type).values(), key=lambda x: x.format.__name__): plugins.add(fmt_rec.plugin) known_formats.add(fmt_rec.format) if not issubclass(fmt_rec.format, model.SingleFileDirectoryFormatBase): option = XMLNode('option', pretty_fmt_name(fmt_rec.format), value=galaxy_esc(fmt_rec.format.__name__)) select.append(option) when.append(select) conditional.append(when) outputs = XMLNode('outputs') # default collection: collection = XMLNode('collection', name='exported', type='list', label='${tool.name} on ${on_string} as ${fmt_peek}') _filter_set = repr({galaxy_esc(x.__name__) for x in known_formats}) collection.append(XMLNode('filter', "fmt_finder['output_format'] == 'None'" f" and fmt_peek not in {_filter_set}")) collection.append(XMLNode('discover_datasets', visible='false', pattern='__designation_and_ext__')) outputs.append(collection) for fmt in sorted(known_formats, key=lambda x: x.__name__): esc_fmt = galaxy_esc(fmt.__name__) filter_exp = (f"fmt_finder['output_format'] == '{esc_fmt}'" " or (fmt_finder['output_format'] == 'None' and fmt_peek" f" == '{esc_fmt}')") label = '${tool.name} on ${on_string} as ' + fmt.__name__ if issubclass(fmt, model.DirectoryFormat): dyn_data = None for field in fmt._fields: # file attrs of the dirfmt file_attr = getattr(fmt, field) pattern, has_ext = pathspec_to_galaxy_regex(file_attr.pathspec) extras = {} if not has_ext: if issubclass(file_attr.format, model.TextFileFormat): extras['ext'] = 'txt' else: extras['ext'] = 'data' if isinstance(file_attr, model.FileCollection): col = XMLNode('collection', type='list', name='_'.join([esc_fmt, file_attr.name]), label=label + f' ({file_attr.name})') col.append(XMLNode('filter', filter_exp)) col.append(XMLNode('discover_datasets', visible='false', pattern=pattern, **extras)) outputs.append(col) else: if dyn_data is None: # init a root for all of the discoverable datasets dyn_data = XMLNode('data', name=esc_fmt, label=label) dyn_data.append(XMLNode('filter', filter_exp)) # only the first one, will take over the history item extras['assign_primary_output'] = 'true' dyn_data.append(XMLNode('discover_datasets', visible='true', pattern=pattern, **extras)) if dyn_data is not None: outputs.append(dyn_data) else: # as it is not a directory, we don't know much about the original # filename anymore, so we will let galaxy sort it out # .gz may be considered the format instead of fastq.gz, but users # can always re-sniff a history item for the format collection = XMLNode('data', name=esc_fmt, label=label) collection.append(XMLNode('filter', filter_exp)) collection.append(XMLNode('discover_datasets', visible='true', assign_primary_output='true', pattern='__designation_and_ext__')) outputs.append(collection) tool = XMLNode('tool', id=tool_id, name=make_tool_name_from_id(tool_id), version=make_builtin_version(plugins)) tool.append(XMLNode('description', 'Export data from QIIME 2 artifacts')) tool.append(XMLNode('command', "q2galaxy run tools export '$inputs'")) tool.append(make_config()) tool.append(inputs) tool.append(outputs) tool.append(make_requirements(meta, *[p.project_name for p in plugins])) tool.append(XMLNode('help', '')) return tool
def inputs_xml(self): base_types = [] for t in self.spec.qiime_type: if t.predicate is not None and is_union(t.predicate): for pred in t.predicate.unpack_union(): base_types.append(t.duplicate(predicate=pred)) else: base_types.append(t) to_add = [] for t in base_types: if ((t.name == "Str" and t.predicate is None) or t.name == 'Float' or t.name == 'Int'): to_add.append(t) root = None if to_add: root = XMLNode('conditional', name=galaxy_ui_var(tag='conditional', name=self.name)) select = XMLNode('param', type='select', name=galaxy_ui_var(tag='select')) root.append(select) else: select = XMLNode('param', type='select', name=self.name) choices = [] for t in base_types: if t.predicate is not None and t.predicate.name == 'Choices': choices.extend(t.predicate.template.choices) elif t.name == 'Bool': choices.extend([True, False]) display = None if not self.spec.has_default(): display = 'Selection required' elif self.spec.default is None: display = 'None (Use default behavior)' if display is not None: value = galaxy_esc(None) select.append( XMLNode('option', display, value=value, selected='true')) if root is not None: when = XMLNode('when', value=value) hidden = XMLNode('param', type='hidden', name=self.name, value=value) when.append(hidden) root.append(when) for choice in choices: value = galaxy_esc(choice) option = XMLNode('option', self._display_func(choice), value=value) if self.spec.has_default() and self.spec.default == choice: option.set('selected', 'true') select.append(option) if root is not None: when = XMLNode('when', value=value) hidden = XMLNode('param', type='hidden', name=self.name, value=value) when.append(hidden) root.append(when) default = self.spec.default # NOVALUE is fine for addition in to_add: value = galaxy_ui_var(value=galaxy_esc( # Galaxy will convert % to X internally and then complain # about a lack of matching cases, so we'll just do it now str(addition).replace('%', 'X'))) option = XMLNode('option', f'Provide a value ({addition})', value=value) select.append(option) when = XMLNode('when', value=value) dispatch = { 'Float': NumericCase, 'Int': NumericCase, 'Str': StrCase } try: ParamCase = dispatch[addition.name] except KeyError: raise NotImplementedError if default in addition: spec_default = default option.set('selected', 'true') else: spec_default = self.spec.NOVALUE new_spec = self.spec.duplicate(qiime_type=addition, default=spec_default) sub_ui = ParamCase(self.name, new_spec).inputs_xml() when.append(sub_ui) root.append(when) self.add_help(select) self.add_label(select) if not self.spec.has_default(): select.append( XMLNode('validator', f'value != {repr(galaxy_esc(None))}', type='expression', message='Please verify this parameter.')) if root is None: return select else: return root
def _make_config(): configfiles = XMLNode("configfiles") configfiles.append( XMLNode("configfile", _make_cheetah_config(), name="inputs")) return configfiles
def _add_collection_ui(root, file_attr): section = XMLNode("section", name=f'import_{file_attr.name}', expanded='true') conditional = XMLNode("conditional", name=galaxy_ui_var(tag='cond', name=file_attr.name)) select = XMLNode("param", type='select', label='Select a mechanism', name=galaxy_ui_var(tag='select', name='picker')) select.append( XMLNode("option", "Use collection to import", value='collection', selected='true')) select.append( XMLNode("option", "Associate individual files", value='individual')) conditional.append(select) when_collection = XMLNode("when", value='collection') when_collection.append( XMLNode('param', type='data_collection', name='elements', help=_format_help_text(file_attr.format) + ' Elements must match regex:' f' {_regex_xml_escape(file_attr.pathspec)}')) add_ext_cond = XMLNode("conditional", name=galaxy_ui_var(tag='cond', name='add_ext')) ext_select = XMLNode("param", type='select', label='Append an extension?', help='This is needed if your element identifiers lack' ' one.', name=galaxy_ui_var(tag='select', name='ext_pick')) ext_select.append( XMLNode("option", "No, use element identifiers as is", value="no")) ext_select.append( XMLNode("option", "Yes, append an extension", value="yes")) add_ext_cond.append(ext_select) ext_when = XMLNode("when", value="yes") ext_when.append( XMLNode("param", type='text', name='ext', label="Extension to append (e.g. '.fastq.gz')")) add_ext_cond.append(ext_when) add_ext_cond.append(XMLNode("when", value="no")) when_collection.append(add_ext_cond) when_individual = XMLNode("when", value='individual') repeat = XMLNode("repeat", name='elements', min='1') _add_data_ui(repeat, file_attr) when_individual.append(repeat) conditional.append(when_collection) conditional.append(when_individual) section.append(conditional) root.append(section)