view measure_texture.xml @ 2:8f3f8c94626f draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 1907942bef43b20edfdbd1d1b5eb1cac3602848b"
author bgruening
date Thu, 16 Apr 2020 05:30:53 -0400
parents 0f751bb492de
children 658a2a451aec
line wrap: on
line source

<tool id="cp_measure_texture" name="MeasureTexture" version="@CP_VERSION@">
    <description>quantify their roughness and smoothness of the textures</description>
  
    <macros>
        <import>macros.xml</import>
        <xml name="measureImgObj">
            <repeat name="rpt_obj_to_measure" title="Add another object">
                <param name="obj_to_measure" label="Select objects to measure" type="text" />       
            </repeat>
        </xml>
    </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 = "\nMeasureTexture:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:5|show_window:False|notes:\\x5B\\'PARAMS\\x3A\\', \\'- Texture scale\'\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count

    img_count = len(params['rpt_image_to_measure'])
    obj_count = len(params['con_img_obj']['rpt_obj_to_measure'])
    scale_count = len(params['rpt_scale_to_measure'])

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

    _str += FOURSPACES + "Hidden:%d\n" % img_count
    _str += FOURSPACES + "Hidden:%d\n" % obj_count
    _str += FOURSPACES + "Hidden:%d\n" % scale_count

    for img in params['rpt_image_to_measure']:
        _str += FOURSPACES + "Select an image to measure:%s\n" % img['image_to_measure']

    if img_obj == "Images":
        _str += FOURSPACES + "Select objects to measure:None\n"
    else:
        for obj in params['con_img_obj']['rpt_obj_to_measure']:
            _str += FOURSPACES + "Select objects to measure:%s\n" % obj['obj_to_measure']

    for scale in params['rpt_scale_to_measure']:
        _str += FOURSPACES + "Texture scale to measure:%s\n" % str(scale['scale_to_measure'])

    _str += FOURSPACES + "Measure images or objects?:%s\n" % params['con_img_obj']['img_obj']

    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" />
        <repeat name="rpt_image_to_measure" title="Add another image">
            <param name="image_to_measure" label="Select an image to measure" type="text" >
                <expand macro="text_validator" />
            </param>
        </repeat>

        <conditional name="con_img_obj">
            <param name="img_obj" label="Measure images or objects?" type="select">
                <option value="Images">Images</option>
                <option value="Objects">Objects</option>
                <option value="Both">Both</option>
            </param>
            <when value="Objects">
                <expand macro="measureImgObj" />
            </when>
            <when value="Both">
                <expand macro="measureImgObj" />
            </when>
            <when value="Images" />
        </conditional>
        <repeat name="rpt_scale_to_measure" title="Add another scale">
            <param name="scale_to_measure" label="Texture scale to measure" type="integer" value="3" min="0" />
        </repeat>
    </inputs>

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

    <tests>
        <test>
            <expand macro="test_input_pipeline_param" />
            <repeat name="rpt_image_to_measure">
                <param name="image_to_measure" value="DNA" />
            </repeat>
            <conditional name="con_img_obj">
                <param name="img_obj" value="Objects" />
                <repeat name="rpt_obj_to_measure">
                    <param name="obj_to_measure" value="Nuclei" />
                </repeat>
            </conditional>

            <repeat name="rpt_scale_to_measure">
                <param name="scale_to_measure" value="3" />
            </repeat>

            <expand macro="test_out_file" file="measure_texture.txt" />
        </test>
    </tests>

    <expand macro="help" module="MeasureObjectSizeShape" />
    <expand macro="citations" /> 
</tool>