Skip to content

Commit

Permalink
Add wordcloud (#1552)
Browse files Browse the repository at this point in the history
* The wordcloud.xml, macros.xml, and.shed.yml files were added

* The wordcloud.xml and macros.xml files were edited

* Edited the wordcloud.xml file

* The wordcloud.xml file was edited

* The related error was fixed

* The XML files were updated

* Update tools/wordcloud/wordcloud.xml

Co-authored-by: Björn Grüning <[email protected]>

* Update tools/wordcloud/wordcloud.xml

Co-authored-by: Björn Grüning <[email protected]>

* Merging the macros.xml content into the wordcloud.xml file

* The name and description were edited.

* a few fixes

* add image_diff

* update test data

* remove space

* style

---------

Co-authored-by: Björn Grüning <[email protected]>
Co-authored-by: Bjoern Gruening <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent 5ab6f94 commit 6d08a14
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/wordcloud/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: wordcloud
owner: bgruening
description: A little word cloud generator in Python.
long_description: |
The wordcloud library allows you to create word clouds from text data.
It is highly customizable and can generate word clouds in various shapes and colors.
The wordcloud library is available as an open-source project on GitHub.
remote_repository_url: https://github.com/bgruening/galaxytools/tree/master/tools/wordcloud
homepage_url: https://github.com/amueller/word_cloud
type:
categories:
- Visualization
Binary file added tools/wordcloud/test-data/font.ttf
Binary file not shown.
Binary file added tools/wordcloud/test-data/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tools/wordcloud/test-data/output_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tools/wordcloud/test-data/output_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tools/wordcloud/test-data/stopwords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
an
1 change: 1 addition & 0 deletions tools/wordcloud/test-data/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Galaxy is an open source, web-based platform for data intensive biomedical research.
212 changes: 212 additions & 0 deletions tools/wordcloud/wordcloud.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
<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@">0</token>
<token name="@PROFILE@">23.0</token>
</macros>
<requirements>
<requirement type="package" version="1.9.4">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 $fontfile
--fontfile $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
#if $background
--background '$background'
#end if
#if $mask
--mask $mask
#end if
#if $color_choice == "color":
--color '$color'
#else if $color_choice == "colormask":
--colormask $colormask
#end if
#if $colormap
--colormap $colormap
#end if
#if $mode
--mode $mode
#end if
#if $contour_width
--contour_width $contour_width
#end if
#if $contour_color
--contour_color '$contour_color'
#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 $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"/>
<param argument="--fontfile" type="data" format="binary" optional="true" label="Font file you wish to use " help="The font file you want to use"/>
<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"/>
<param argument="--background" 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>
<param argument="--mask" type="data" format="png" optional="true" label="Mask to use for the image form"/>
<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>
</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>
</conditional>
<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>
<param argument="--mode" type="select" value="RGB" optional="True" label="Use RGB or RGBA for transparent background">
<option value="RGB">RGB</option>
<option value="RGBA">RGBA</option>
</param>
<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>
<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" ftype="txt"/>
<param name="random_state" value="10"/>
<output name="output" file="output_1.png" compare="image_diff" />
</test>
<test expect_num_outputs="1">
<param name="text" value="test.txt" ftype="txt"/>
<param name="stopwords" value="stopwords.txt"/>
<param name="fontfile" value="font.ttf"/>
<param name="min_font_size" value="4"/>
<param name="max_font_size" value="100"/>
<param name="font_step" value="1"/>
<param name="min_word_length" value="0"/>
<param name="max_words" value="200"/>
<param name="width" value="800"/>
<param name="height" value="600"/>
<param name="margin" value="0"/>
<param name="background" value="#FFFFFF"/>
<param name="mask" value="mask.png"/>
<param name="color" value="#1F4068"/>
<param name="colormap" value="viridis"/>
<param name="mode" value="RGB"/>
<param name="contour_width" value="8"/>
<param name="contour_color" value="#1F4068"/>
<param name="prefer_horizontal" value="0.9"/>
<param name="scale" value="1.0"/>
<param name="relative_scaling" value="0.0"/>
<param name="no_collocations" value="True"/>
<param name="include_numbers" value="False"/>
<param name="no_normalize_plurals" value="True"/>
<param name="repeat" value="True"/>
<param name="random_state" value="10"/>
<output name="output" file="output_2.png" compare="image_diff" />
</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={Amueller, Sebastian},
year={2018},
url={https://amueller.github.io/word_cloud/}
}
</citation>
</citations>
</tool>

0 comments on commit 6d08a14

Please sign in to comment.