view wordcloud.xml @ 3:e00cb408785a draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/wordcloud commit 91a79a90a63fc6f14b8a99aaa224d1dfd74c9f68
author bgruening
date Wed, 29 Oct 2025 10:25:34 +0000
parents 04fe94223792
children
line wrap: on
line source

<tool id="wordcloud" name="Generate a word cloud" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@" license="MIT">
    <description>with highly customizable appearance</description>
    <macros>
        <token name="@TOOL_VERSION@">1.9.4</token>
        <token name="@VERSION_SUFFIX@">4</token>
        <token name="@PROFILE@">23.0</token>
    </macros>
    <requirements>
        <requirement type="package" version="@TOOL_VERSION@">wordcloud</requirement>
    </requirements>
    <version_command>wordcloud_cli --version</version_command>
    <command detect_errors="exit_code"><![CDATA[
        wordcloud_cli
            --imagefile 'output.png'
            --text $text 
            #if $stopwords
                --stopwords $stopwords
            #end if

            #if $fonts.fonts_selector == 'cached':
                --fontfile ${fonts.fonts_select.fields.path}
            #elif $fonts.fonts_selector == 'history':
                --fontfile ${fonts.fontfile}
            #end if

            #if $min_font_size
                --min_font_size $min_font_size
            #end if
            #if $max_font_size
                --max_font_size $max_font_size
            #end if
            #if $font_step
                --font_step $font_step
            #end if
            #if $min_word_length
                --min_word_length $min_word_length
            #end if
            #if str($max_words):
                --max_words $max_words
            #end if
            #if str($width):
                --width $width
            #end if
            #if str($height):
                --height $height
            #end if
            #if str($margin):
                --margin $margin
            #end if
            --mode $background_options.mode
            #if str($background_options.mode) == 'RGB'
                --background '$background_options.background_color'
                #if str($background_options.cloud_shape.cloud_shape_options) == 'mask'
                    --mask $background_options.cloud_shape.mask
                    --contour_width $background_options.cloud_shape.contour_width
                    --contour_color '$background_options.cloud_shape.contour_color'
                #end if
            #else
                --background None
                #if str($background_options.cloud_shape.cloud_shape_options) == 'mask'
                    --mask $background_options.cloud_shape.mask
                #end if
            #end if
            #if $color_choice.color_option == "color":
                --color '$color_choice.color'
            #else if $color_choice.color_option == "colormask":
                --colormask $color_choice.colormask
            #else if $color_choice.colormap == "colormap":
                --colormap $color_choice.colormap
            #end if
            #if str($prefer_horizontal):
                --prefer_horizontal $prefer_horizontal
            #end if
            #if str($scale):
                --scale $scale
            #end if
            #if str($relative_scaling):
                --relative_scaling $relative_scaling
            #end if
            $no_collocations
            $include_numbers
            $no_normalize_plurals
            $repeat
            #if str($random_state):
                --random_state $random_state
            #end if
        ]]>
    </command>
    <inputs>
        <param argument="--text" type="data" format="txt" label="Input file" help="Input file to process"/>
        <param argument="--stopwords" type="data" format="txt" optional="true" label="Stopwords file" help="Specify file of stopwords (containing one word per line) to remove from the given text after parsing"/>

        <conditional name="fonts">
            <param name="fonts_selector" type="select" label="Do you want to select a special font?" help="You can pass a specific file from your history or select a few prebuild fonts. By default DroidSansMono is used.">
                <option value="none">Use the default DroidSansMono font</option>
                <option value="cached">Select from a list of fonts</option>
                <option value="history">Choose a font from your history</option>
            </param>
            <when value="none"/>
            <when value="cached">
                <param name="fonts_select" type="select" label="Select font from list">
                    <options from_data_table="fonts">
                        <filter type="sort_by" column="2" />
                        <validator type="no_options" message="No fonts are available" />
                    </options>
                </param>
            </when>
            <when value="history">
                <param argument="--fontfile" type="data" format="binary" optional="true" label="Font file you wish to use" help="The font file you want to use"/>
            </when>
        </conditional>

        <param argument="--min_font_size" type="integer" min="1" value="4" optional="true" label=" Smallest font size to use" />
        <param argument="--max_font_size" type="integer" min="1" optional="true" label="Maximum font size for the largest word" />
        <param argument="--font_step" type="integer" value="1" label="Step size for the font" help="Font_step &gt; 1 might speed up computation but give a worse fit"/>
        <param argument="--min_word_length" type="integer" value="0" optional ="True" label="Minimum number of letters a word must have to be included"/>
        <param argument="--max_words" type="integer" min="1" value="200" optional="true" label="Maximum number of words"/>
        <param argument="--width" type="integer" min="1" value="400" optional="true" label="Define output image width"/>
        <param argument="--height" type="integer" min="1" value="200" optional="true" label="Define output image height"/>
        <param argument="--margin" type="integer" value="2" label="Spacing to leave around words"/>
        <conditional name="background_options">
            <param argument="--mode" type="select" label="Use RGB or RGBA for transparent background">
                <option value="RGB" selected="true">RGB</option>
                <option value="RGBA">RGBA</option>
            </param>
            <when value="RGB">
                <param argument="--background_color" type="color" value="#000000" optional="true" label="Use given color as background color for the image">
                    <validator type="regex" message="Please select a valid RGB color">[#][0-9A-Fa-f]{6}</validator>
                </param>
                <conditional name="cloud_shape">
                    <param name="cloud_shape_options" type="select" label="Choose word cloud shape">
                        <option value="rectangle" selected="true">Default - Rectangle</option>
                        <option value="mask">Mask from image input</option>
                    </param>
                    <when value="rectangle"/>
                    <when value="mask">
                        <param argument="--mask" type="data" format="png" optional="true" label="Mask to use for the image form"/>
                        <param argument="--contour_width" type="float" min="0" value="0" optional="true" label="Contour width" help="Use given color as mask contour color"/>
                        <param argument="--contour_color" type="color" value="#000000" optional="true" label="Contour color">
                            <validator type="regex" message="Please select a valid RGB color">[#][0-9A-Fa-f]{6}</validator>
                        </param>
                    </when>
                </conditional>
            </when>
            <when value="RGBA">
                <conditional name="cloud_shape">
                    <param name="cloud_shape_options" type="select" label="Choose word cloud shape">
                        <option value="rectangle" selected="true">Default - Rectangle</option>
                        <option value="mask">Mask from image input</option>
                    </param>
                    <when value="rectangle"/>
                    <when value="mask">
                        <param argument="--mask" type="data" format="png" optional="true" label="Mask to use for the image form"/>
                    </when>
                </conditional>
            </when>
        </conditional>
        <conditional name="color_choice" label="Choose color option">
            <param name="color_option" type="select" label="Color option">
                <option value="color">Color</option>
                <option value="colormask">Color Mask</option>
                <option value="colormap">Colormap</option>
            </param>
            <when value="color">
                <param argument="--color" type="color" value="#00ff00" optional="true" label="Use given color as coloring for the image">
                    <validator type="regex" message="Please select a valid RGB color">[#][0-9A-Fa-f]{6}</validator>
                </param>
            </when>
            <when value="colormask">
                <param argument="--colormask" type="data" format="png" optional="true" label="Color Mask" help="Upload a color mask image"/>
            </when>
            <when value="colormap">
                <param argument="--colormap" type="select" value="viridis" optional="true" label="Matplotlib colormap name">
                    <option value="viridis">viridis</option>
                    <option value="plasma">plasma</option>
                    <option value="inferno">inferno</option>
                    <option value="magma">magma</option>
                    <option value="cividis">cividis</option>
                    <option value="Greys">Greys</option>
                    <option value="Purples">Purples</option>
                    <option value="Blues">Blues</option>
                    <option value="Greens">Greens</option>
                    <option value="Oranges">Oranges</option>
                    <option value="Reds">Reds</option>
                    <option value="YlOrBr">YlOrBr</option>
                    <option value="YlOrRd">YlOrRd</option>
                    <option value="OrRd">OrRd</option>
                    <option value="PuRd">PuRd</option>
                    <option value="RdPu">RdPu</option>
                    <option value="BuPu">BuPu</option>
                    <option value="GnBu">GnBu</option>
                    <option value="PuBu">PuBu</option>
                    <option value="YlGnBu">YlGnBu</option>
                    <option value="PuBuGn">PuBuGn</option>
                    <option value="BuGn">BuGn</option>
                    <option value="YlGn">YlGn</option>
                </param>
            </when>
        </conditional>
        <param argument="--prefer_horizontal" type="float" min="0" max="1" value="0.9" optional="true" label="Ratio of times to try horizontal fitting as opposed to vertical"/>
        <param argument="--scale" type="float" value="1.0" optional="True" label="Scaling between computation and drawing"/>
        <param argument="--relative_scaling" type="float" min="0.0" max="1.0" value="0.0" optional="true" label="Scaling of words by frequency (0 - 1)"/>
        <param argument="--no_collocations" type="boolean" truevalue="--no_collocations" falsevalue="" value="True" label="Do not add collocations (bigrams) to word cloud"/>
        <param argument="--include_numbers" type="boolean" truevalue="--include_numbers" falsevalue="" value="False" label="Whether to include numbers as phrases or not"/>
        <param argument="--no_normalize_plurals" type="boolean" truevalue="--no_normalize_plurals" falsevalue="" label="Whether to remove trailing s from words"/>
        <param argument="--repeat" type="boolean" truevalue="--repeat" falsevalue="" label="Whether to repeat words and phrases until max_words or min_font_size is reached"/>
        <param argument="--random_state" type="integer" value="10" label="Random seed" />
    </inputs>
    <outputs>
        <data name="output" format="png" label="Word cloud image" from_work_dir="output.png"/>
    </outputs>
    <tests>
        <test expect_num_outputs="1">
            <param name="text" value="test.txt"/>
            <param name="font_step" value="2"/>
            <param name="min_word_length" value="2"/>
            <param name="width" value="200"/>
            <param name="height" value="100"/>
            <conditional name="color_choice">
                <param name="color_option" value="colormap"/>
                <param name="colormap" value="inferno"/>
            </conditional>
            <param name="scale" value="1.8"/>
            <param name="no_collocations" value="false"/>
            <conditional name="fonts">
                <param name="fonts_selector" value="none"/>
            </conditional>
            <output name="output" file="output0.png" ftype="png"/>
        </test>
        
        <test expect_num_outputs="1">
            <param name="text" value="test.txt"/>
            <param name="stopwords" value="stopwords.txt"/>
            <conditional name="fonts">
                <param name="fonts_selector" value="cached"/>
                <param name="fonts_select" value="Test Font"/>
            </conditional>
            <output name="output" file="output1.png" ftype="png"/>
        </test>
        
        <test expect_num_outputs="1">
            <param name="text" value="test.txt"/>
            <param name="stopwords" value="stopwords.txt"/>
            <conditional name="fonts">
                <param name="fonts_selector" value="history"/>
                <param name="fontfile" value="font.ttf"/>
            </conditional>
            <output name="output" file="output1.png" ftype="png"/>
        </test>
        
        <test expect_num_outputs="1">
            <param name="text" value="test.txt"/>
            <param name="stopwords" value="stopwords.txt"/>
            <conditional name="background_options">
                <param name="mode" value="RGB"/>
                <param name="background_color" value="#9141ac"/>
                <conditional name="cloud_shape">
                    <param name="cloud_shape_options" value="mask"/>
                    <param name="mask" value="mask.png"/>
                    <param name="contour_width" value="1.8"/>
                    <param name="contour_color" value="#e01b24"/>
                </conditional>
            </conditional>
            <output name="output" file="output2.png" ftype="png"/>
        </test>
    
        <test expect_num_outputs="1">
            <param name="text" value="test.txt"/>
            <param name="stopwords" value="stopwords.txt"/>
            <param name="include_numbers" value="true"/>
            <param name="no_normalize_plurals" value="false"/>
            <param name="repeat" value="false"/>
            <param name="random_state" value="10"/>
            <conditional name="color_choice">
                <param name="color_option" value="color"/>
                <param name="color" value="#99c1f1"/>
            </conditional>
            <conditional name="background_options">
                <param name="mode" value="RGBA"/>
                <conditional name="cloud_shape">
                    <param name="cloud_shape_options" value="rectangle"/>
                </conditional>
            </conditional>
            <output name="output" file="output3.png" ftype="png"/>
        </test>
        
        <test expect_num_outputs="1">
            <param name="text" value="test.txt"/>
            <param name="stopwords" value="stopwords.txt"/>
            <conditional name="color_choice">
                <param name="color_option" value="colormask"/>
                <param name="colormask" value="mask.png"/>
            </conditional>
            <output name="output" file="output4.png" ftype="png"/>
        </test>
    </tests>
    <help><![CDATA[
A word cloud is a visual representation (image) of word data. In other words, it is a collection, or cluster, of words depicted in different sizes.
The bigger and bolder the word appears, the more often it's mentioned within a given text and the more important it is.
    ]]></help>
    <citations>
        <citation type="bibtex">
            @misc{amueller2018wordcloud,
                title={Word Clouds with Python},
                author={Mueller, Andreas Christian},
                year={2018},
                url={https://github.com/amueller/word_cloud}
            }
        </citation>
    </citations>
</tool>