view mask_image.xml @ 0:be10daacf27e draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 6d73056a625002d0275b5a9a90a9fae329ce47f1"
author bgruening
date Thu, 26 Mar 2020 20:09:44 +0000
parents
children bac6b8a0d0a9
line wrap: on
line source

<tool id="cp_mask_image" name="MaskImage" version="@CP_VERSION@">
    <description>hides certain portions of an image based on previously identified objects or a binary image</description>

    <macros>
        <import>macros.xml</import>
    </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 writemi():
    _str = "\nMaskImage:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:3|show_window:False|notes:\\x5B\'Keep only nucleoli inside the nuclei\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count

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

    img_obj = params['con_img_obj']['img_obj']

    _str += FOURSPACES + "Use objects or an image as a mask?:%s\n" % params['con_img_obj']['img_obj']

    if img_obj == "Objects":
        _str += FOURSPACES + "Select object for mask:%s\n" % params['con_img_obj']['select_obj']
        _str += FOURSPACES + "Select image for mask:None\n"
    else:
        _str += FOURSPACES + "Select object for mask:None\n"
        _str += FOURSPACES + "Select image for mask:%s\n" % params['con_img_obj']['select_img']

    _str += FOURSPACES + "Invert the mask?:%s\n" % params['invert_mask']

    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", "w") as f:
        f.writelines(lines)
        f.write(writemi())

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

    <inputs>

        <expand macro="input_pipeline_macro" />
        <param name="input_image" label="Select input image" type="text">
            <expand macro="text_validator" />
        </param>

        <param name="name_output_image" type="text" label="Name the output image">
            <expand macro="text_validator" />
        </param>

        <conditional name="con_img_obj">
            <param name="img_obj" label="Use objects or an image as a mask?" type="select">
                <option value="Objects">Objects</option>
                <option value="Image">Image</option>
            </param>
           <when value="Objects">
               <param name="select_obj" label="Select object for mask" type="text"/>
           </when>
           <when value="Image">
               <param name="select_img" label="Select image for mask" type="text"/>
           </when>
        </conditional>
        <param name="invert_mask" label="Invert the mask?" type="select" display="radio">
            <option value="Yes">Yes</option>
            <option value="No">No</option>
        </param>
    </inputs>

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

    <tests>
        <test>
            <expand macro="test_input_pipeline_param"/>
            <param name="input_image" value="DNAdarkholes" />
            <param name="name_output_image" value="MaskDNAdarkholes" />
            <conditional name="con_img_obj">
                <param name="img_obj" value="Objects" />
                <param name="select_obj" value="Nuclei" />
            </conditional>
            <param name="invert_mask" value="No" />
            <expand macro="test_out_file" file="mask_image.txt" />
        </test>
    </tests>

    <expand macro="help" module="GrayToColor" />
    <expand macro="citations" />

</tool>