view measure_granularity.xml @ 0:1062c9e44147 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 6d73056a625002d0275b5a9a90a9fae329ce47f1"
author bgruening
date Thu, 26 Mar 2020 17:42:07 -0400
parents
children 88dd3674c4d0
line wrap: on
line source

<tool id="cp_measure_granularity" name="MeasureGranularity" version="@CP_VERSION@">
    <description>outputs spectra of size measurements of the textures in the 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 writemg():
    _str = "\nMeasureGranularity:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:3|show_window:False|notes:\\x5B\\'PARAMS\\x3A\\', \\'- Radius\\', \'- Range\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count

    image_count = len(params['rpt_image'])

    _str += FOURSPACES + "Image count:%d\n" % image_count

    for img in params['rpt_image']:
        obj_count = len(img['rpt_object'])

        _str += FOURSPACES + "Object count:%d\n" % obj_count

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

        _str += FOURSPACES + "Subsampling factor for granularity measurements:%s\n" % img['subsampling_factor_granularity']

        _str += FOURSPACES + "Subsampling factor for background reduction:%.2f\n" % img['subsampling_factor_background_reduction']

        _str += FOURSPACES + "Radius of structuring element:%d\n" % img['radius']
        _str += FOURSPACES + "Range of the granular spectrum:%d\n" % img['range_granular_spectrum']

        for obj in img['rpt_object']:
            _str += FOURSPACES + "Select objects to meausre:%s\n" % obj['object_to_measure']

    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(writemg())

f.close()
        </configfile>
    </configfiles>
    
    <inputs>
        <expand macro="input_pipeline_macro" />
        <repeat name="rpt_image" title="Add another image">
            <param name="image_to_measure" type="text" label="Select an image to measure">
                <expand macro="text_validator" />
            </param>

            <param name="subsampling_factor_granularity" type="float" value="0.25" label="Subsampling factor for granularity measurements" /> 

            <param name="subsampling_factor_background_reduction" type="float" value="0.25" min="0.125" max="0.25" label="Subsampling factor for background reduction" /> 
            
            <param name="radius" type="integer" value="10" label="Radius of structuring element" /> 
            
            <param name="range_granular_spectrum" type="integer" value="16" label="Range of the granular spectrum" /> 

            <repeat name="rpt_object" title="Add another object">
                <param name="object_to_measure" type="text" label="Select object to measure" >
                    <expand macro="text_validator" />
                </param>
            </repeat>
        </repeat>
    </inputs>

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

    <tests>
        <test>
            <expand macro="test_input_pipeline_param" />
            <repeat name="rpt_image">
                <param name="image_to_measure" value="DNA" />
                <param name="subsampling_factor_granularity" value="0.25" />
                <param name="subsampling_factor_background_reduction" value="0.25" />
                <param name="radius" value="10" />
                <param name="range_granular_spectrum" value="16" />
            </repeat>
            <expand macro="test_out_file" file="measure_granularity.txt" />
        </test>
    </tests>

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