Esempio n. 1
0
def get_xml(usermod, module_name, short_name):
    """
    Get the galaxy XML describing a single tool.
    @param usermod: module object
    @param module_name: something like '20100707a'
    @param short_name: something like 'plot_pca_3d'
    @return: contents of a galaxy XML interface file
    """
    # get module info
    form_objects = usermod.get_form()
    if hasattr(usermod, 'get_form_out'):
        form_out = usermod.get_form_out()
    else:
        raise FormOutError('snippet %s provides no output '
                           'format information' % module_name)
    doc_lines = Util.get_stripped_lines(usermod.__doc__.splitlines())
    try:
        tags = usermod.g_tags
    except AttributeError:
        tags = []
    # create the python command string with wildcards
    cmd = make_command(module_name, form_objects)
    # build the xml
    desc_prefix, desc_suffix = galaxyutil.get_split_title(doc_lines[0])
    tool = etree.Element('tool',
                         id=short_name,
                         name=desc_prefix,
                         version='1.0.0')
    if desc_suffix:
        etree.SubElement(tool, 'description').text = desc_suffix
    etree.SubElement(tool, 'command', interpreter='python').text = cmd
    inputs = etree.SubElement(tool, 'inputs')
    outputs = etree.SubElement(tool, 'outputs')
    # add inputs
    for obj in form_objects:
        if not obj.web_only():
            obj.add_galaxy_xml(inputs)
    # add output
    etree.SubElement(outputs,
                     'data',
                     format=form_out.get_galaxy_format(),
                     name='out_file1')
    # Add the format tweak if there is an image.
    # This is a hack required because galaxy does not
    # play well with apps which have varying output formats.
    # See the EMBOSS apps for more examples.
    if 'imageformat' in [x.label for x in form_objects]:
        etree.SubElement(tool, 'code', file='galaxy_format_tweak.py')
    # serialize the xml
    return etree.tostring(etree.ElementTree(tool), pretty_print=True)
Esempio n. 2
0
def get_xml(usermod, module_name, short_name):
    """
    Get the galaxy XML describing a single tool.
    @param usermod: module object
    @param module_name: something like '20100707a'
    @param short_name: something like 'plot_pca_3d'
    @return: contents of a galaxy XML interface file
    """
    # get module info
    form_objects = usermod.get_form()
    if hasattr(usermod, 'get_form_out'):
        form_out = usermod.get_form_out()
    else:
        raise FormOutError(
                'snippet %s provides no output '
                'format information' % module_name)
    doc_lines = Util.get_stripped_lines(usermod.__doc__.splitlines())
    try:
        tags = usermod.g_tags
    except AttributeError:
        tags = []
    # create the python command string with wildcards
    cmd = make_command(module_name, form_objects)
    # build the xml
    desc_prefix, desc_suffix = galaxyutil.get_split_title(doc_lines[0])
    tool = etree.Element('tool',
            id=short_name, name=desc_prefix, version='1.0.0')
    if desc_suffix:
        etree.SubElement(tool, 'description').text = desc_suffix
    etree.SubElement(tool, 'command', interpreter='python').text = cmd
    inputs = etree.SubElement(tool, 'inputs')
    outputs = etree.SubElement(tool, 'outputs')
    # add inputs
    for obj in form_objects:
        if not obj.web_only():
            obj.add_galaxy_xml(inputs)
    # add output
    etree.SubElement(outputs, 'data',
            format=form_out.get_galaxy_format(),
            name='out_file1')
    # Add the format tweak if there is an image.
    # This is a hack required because galaxy does not
    # play well with apps which have varying output formats.
    # See the EMBOSS apps for more examples.
    if 'imageformat' in [x.label for x in form_objects]:
        etree.SubElement(tool, 'code', file='galaxy_format_tweak.py')
    # serialize the xml
    return etree.tostring(etree.ElementTree(tool), pretty_print=True)
Esempio n. 3
0
def get_suite_config_xml(added_infos, suite_name):
    """
    Create suite_config.xml contents for a galaxy tool suite archive.
    @param added_infos: ImportedModuleInfo objects for added tools
    @param suite_name: the name of the suite directory, not the whole path
    @return: contents of suite_config.xml
    """
    suite = etree.Element('suite', id=suite_name,
            name='Suite of misc tools', version='1.0.0')
    suite_description = 'Suite of misc tools for Galaxy'
    etree.SubElement(suite, 'description').text = suite_description
    for info in added_infos:
        module_id = info.get_identifier()
        module_name = galaxyutil.get_split_title(info.get_title())[0]
        module_description = info.get_title()
        tool = etree.SubElement(suite, 'tool',
                id=module_id, name=module_name, version='1.0.0')
        etree.SubElement(tool, 'description').text = module_description
    return etree.tostring(etree.ElementTree(suite), pretty_print=True)
Esempio n. 4
0
def get_suite_config_xml(added_infos, suite_name):
    """
    Create suite_config.xml contents for a galaxy tool suite archive.
    @param added_infos: ImportedModuleInfo objects for added tools
    @param suite_name: the name of the suite directory, not the whole path
    @return: contents of suite_config.xml
    """
    suite = etree.Element('suite',
                          id=suite_name,
                          name='Suite of misc tools',
                          version='1.0.0')
    suite_description = 'Suite of misc tools for Galaxy'
    etree.SubElement(suite, 'description').text = suite_description
    for info in added_infos:
        module_id = info.get_identifier()
        module_name = galaxyutil.get_split_title(info.get_title())[0]
        module_description = info.get_title()
        tool = etree.SubElement(suite,
                                'tool',
                                id=module_id,
                                name=module_name,
                                version='1.0.0')
        etree.SubElement(tool, 'description').text = module_description
    return etree.tostring(etree.ElementTree(suite), pretty_print=True)