view convert_objects_to_image.xml @ 5:ac2cca6d0637 draft default tip

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 7d7a519c3a2cc612d38695b335d0f6c75a099de3"
author bgruening
date Fri, 26 Feb 2021 14:01:43 +0000
parents a23af23c3134
children
line wrap: on
line source

<tool id="cp_convert_objects_to_image" name="ConvertObjectsToImage" version="@CP_VERSION@+galaxy@VERSION_SUFFIX@">
    <description>convert the identified objects into an image</description>
    <macros>
        <import>macros.xml</import>
        <token name="@VERSION_SUFFIX@">0</token>
    </macros>
    <expand macro="py_requirements"/>
    <expand macro="cmd_modules" />
    <configfiles>
        <inputs name="inputs" />
        <configfile name="script_file">
import json
import sys
import os

FOURSPACES=@SPACES@

input_json_path = sys.argv[1]
input_pipeline= sys.argv[2]

params = json.load(open(input_json_path, "r"))


def writecoti():
    _str = "\nConvertObjectsToImage:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:1|show_window:True|notes:\\x5B\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count

    _str += FOURSPACES + "Select the input objects:%s\n" % params['input_object']
    _str += FOURSPACES + "Name the output image:%s\n" % params['name_output_image']

    color_format = params['con_color_format']['color_format']

    _str += FOURSPACES + "Select the color format:%s\n" % color_format

    if color_format == "Color":
        _str += FOURSPACES + "Select the colormap:%s\n" % params['con_color_format']['color_map']
    else:
        _str += FOURSPACES + "Select the colormap:Default\n"

    return _str


with open(input_pipeline) as fin:
    lines = fin.readlines()
    k, v = lines[4].strip().split(':')

    module_count = int(v)
    new_count = module_count + 1
    lines[4] = k + ":%d\n" % new_count
    with open("output.cppipe", "w") as f:
        f.writelines(lines)
        f.write(writecoti())

f.close()
        </configfile>
    </configfiles>

    <inputs>
        <expand macro="input_pipeline_param" />
        <param name="input_object" type="text" label="Enter the name of the input objects you want to convert to an image" />
        <param name="name_output_image" type="text" label="Enter the name of the resulting image">
            <expand macro="text_validator" />
        </param>

        <conditional name="con_color_format">
            <param name="color_format" type="select" label="Select the color format">
                <option value="Color">Color</option>
                <option value="Binary (black &amp; white)">Binary (black &amp; white)</option>
                <option value="Grayscale">Grayscale</option>
                <option value="unit16">unit16</option>
                <sanitizer sanitize="false"/>
            </param>
            <when value="Binary (black &amp; white)" />
            <when value="Grayscale" />
            <when value="unit16" />
            <when value="Color">
                <param name="color_map" type="select" label="Select the colormap" help="The colormap affects how the objects are colored." >
                    <option value="Default">Default</option>
                    <option value="Accent">Accent</option>
                    <option value="Blues">Blues</option>
                    <option value="BrBG">BrBG</option>
                    <option value="BuGn">BuGn</option>
                    <option value="BuPu">BuPu</option>
                    <option value="Dark2">Dark2</option>
                    <option value="GnBu">GnBu</option>
                    <option value="Greens">Greens</option>
                    <option value="Greys">Greys</option>
                    <option value="OrRd">OrRd</option>
                    <option value="Oranges">Oranges</option>
                    <option value="PRGn">PRGn</option>
                    <option value="Paired">Paired</option>
                    <option value="Pastel1">Pastel1</option>
                    <option value="Pastel2">Pastel2</option>
                    <option value="PiYG">PiYG</option>
                    <option value="PuBu">PuBu</option>
                    <option value="PuBuGn">PuBuGn</option>
                    <option value="PuOr">PuOr</option>
                    <option value="PuRd">PuRd</option>
                    <option value="Purples">Purples</option>
                    <option value="RdBu">RdBu</option>
                    <option value="RdGy">RdGy</option>
                    <option value="RdPu">RdPu</option>
                    <option value="RdYIBu">RdYIBu</option>
                    <option value="RdYiGn">RdYiGn</option>
                    <option value="Reds">Reds</option>
                    <option value="Set1">Set1</option>
                    <option value="Set2">Set2</option>
                    <option value="Set3">Set3</option>
                    <option value="Spectral">Spectral</option>
                    <option value="YIGn">YIGn</option>
                    <option value="YIGnBu">YIGnBu</option>
                    <option value="YIOrBr">YIOrBr</option>
                    <option value="YIOrRd">YIOrRd</option>
                    <option value="autumn">autumn</option>
                    <option value="binary">binary</option>
                    <option value="bone">bone</option>
                    <option value="cool">cool</option>
                    <option value="copper">copper</option>
                    <option value="flag">flag</option>
                    <option value="gist_earth">gist_earth</option>
                    <option value="gist_gray">gist_gray</option>
                    <option value="gist_heat">gist_heat</option>
                    <option value="gist_ncar">gist_ncar</option>
                    <option value="gist_rainbow">gist_rainbow</option>
                    <option value="gist_stern">gist_stern</option>
                    <option value="gist_yarg">gist_yarg</option>
                    <option value="gray">gray</option>
                    <option value="hot">hot</option>
                    <option value="hsv">hsv</option>
                    <option value="jet">jet</option>
                    <option value="pink">pink</option>
                    <option value="prism">prism</option>
                    <option value="spectral">spectral</option>
                    <option value="spring">spring</option>
                    <option value="summer">summer</option>
                    <option value="winter">winter</option>
                </param>
            </when>
        </conditional>
    </inputs>

    <outputs>
        <expand macro="output_pipeline_param" />
    </outputs>

    <tests>
        <test>
            <expand macro="test_input_pipeline_param" />
            <param name="input_object" value="Nuclei" />
            <param name="name_output_image" value="MaskNuclei" />
            <conditional name="con_color_format">
                <param name="color_format" value="Binary (black &amp; white)" />
            </conditional>
            <expand macro="test_out_file" file="convert_objects_to_image.cppipe" />
        </test>
    </tests>

    <help>
        <![CDATA[
            .. class:: infomark

            **What it does**

            This module allows you to take previously identified objects and convert them into an image according to a colormap you select, which can then be saved with the *SaveImages* module. 
            
            For the *colormap*, you have the following options: 
            
            - *Color*: Allows you to choose a colormap that will produce jumbled colors for your objects. 
            
            - *Binary (black & white)*: All object pixels will be assigned 1 and all background pixels will be assigned 0, creating a binary image. 
            
            - *Grayscale*: Assigns all background pixels to 0 and each object a different number from 1 to 255 (the maximum value that you can put in an 8-bit integer) and numbers all pixels in each object with the object’s number. This creates an image where objects in the top left corner of the image are very dark and where the colors progress to white toward the bottom right corner of the image.
            
            - *uint16*: Assigns all background pixels to 0 and each object a different number from 1 to 65535 (the maximum value that you can put in a 16-bit integer) and numbers all pixels in each object with the object’s number. This creates an image where objects in the top left corner of the image are very dark and where the colors progress to white toward the bottom right corner of the image (though this can usually only be seen in a scientific image viewer since standard image viewers only handle 8-bit images).
            
            You can choose Color with a Gray colormap to produce jumbled gray objects. 
            
            @COMMON_HELP@
            ]]>
    </help>
    <expand macro="citations" />
</tool>