Mercurial > repos > dfornika > newick_display
changeset 0:2073ce44237f draft default tip
planemo upload
author | dfornika |
---|---|
date | Wed, 10 Jan 2018 18:11:18 -0500 |
parents | |
children | |
files | nwdisplay.xml test-data/tree.nwk test-data/tree.svg test-data/tree2.svg |
diffstat | 4 files changed, 275 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nwdisplay.xml Wed Jan 10 18:11:18 2018 -0500 @@ -0,0 +1,258 @@ +<tool id="nwdisplay" name="Newick Display" version="1.6"> + <description>Display a phylogenetic tree as SVG</description> + <edam_operations> + <edam_operation>operation_0567</edam_operation> + </edam_operations> + <requirements> + <requirement type="package" version="1.6">newick_utils</requirement> + </requirements> + <command> + nw_display + -s + $scalebar + -u "$legend" + -I 'r' + -i + #if $condbranchsupport.branchsupport == "true": + "fill:$condbranchsupport.supcolor; + font-size:$condbranchsupport.supfontsize; + transform:$condbranchsupport.suptransform;" + #else: + "visibility:hidden;" + #end if + -b + #if $condbranchlength.branchlength == "true": + "fill:$condbranchlength.lencolor; + font-size:$condbranchlength.lenfontsize; + transform:$condbranchlength.lentransform;" + #else: + "visibility:hidden;" + #end if + + -l "font-family:$leafFont;font-size:$leafSize;" + -d "stroke:grey;fill:none;stroke-width:2;stoke-linecap:round;" + -w $width + $radial + + $fileNewick > $output + + </command> + <inputs> + <param name="fileNewick" format="txt,nw,nwk,nhx" type="data" label="Newick file" /> + <param name="scalebar" type="boolean" truevalue="" falsevalue="-S" checked="True" label="Display scale bar" /> + <param name="legend" type="text" value="" label="Unit name scale" /> + <param name="leafFont" type="text" value="sans-serif" label="Leaf font" /> + <param name="leafSize" type="text" value="10px" label="Leaf font-size" /> + <conditional name="condbranchsupport"> + <param name="branchsupport" type="select" label="Branch support"> + <option value="true">Display branch support</option> + <option value="false" selected="true">Hide branch support</option> + </param> + <when value="true"> + <param name="supcolor" type="color" value="red" label="color" /> + <param name="supfontsize" type="text" value="10px" label="font-size" /> + <param name="suptransform" type="text" value="translateY(1.5em)" label="move" /> + </when> + <when value="false" /> + </conditional> + <conditional name="condbranchlength"> + <param name="branchlength" type="select" label="Branch length"> + <option value="true">Display branch length</option> + <option value="false" selected="true">Hide branch length</option> + </param> + <when value="true"> + <param name="lencolor" type="color" value="blue" label="color" /> + <param name="lenfontsize" type="text" value="10px" label="font-size" /> + <param name="lentransform" type="text" value="translate(-1.5em,0em)" label="move" /> + </when> + <when value="false" /> + </conditional> + <param name="width" type="integer" value="800" label="SVG Tree width (px)" /> + <param name="radial" type="boolean" truevalue="-r" falsevalue="" checked="False" label="Draw a radial tree" /> + </inputs> + <outputs> + <data name="output" format="svg" label="${fileNewick.name}.svg" /> + </outputs> + <tests> + <test> + <param name="fileNewick" value="tree.nwk"/> + <param name="width" value="400"/> + <param name="leafFont" value="courier"/> + <output name="output" file="tree.svg" lines_diff="2"/> + </test> + <test> + <param name="fileNewick" value="tree.nwk"/> + <param name="radial" value="-r"/> + <param name="branchlength" value="true"/> + <output name="output" file="tree2.svg" lines_diff="2"/> + </test> + </tests> + <help> +<![CDATA[ +**Displays a tree as a graph, as text or SVG.** + + +Synopsis +-------- + +nw_display [options] <tree filename|-> + +Input +----- + +Argument is the name of the file containing one or more trees, +or '-' (in which case the tree is read on stdin). + +Output +------ + +Outputs a graph representing the tree, either as text (default) or +as SVG (option -s). Underscores in labels are replaced with spaces. +Trees with no branch lengths are taken to be cladograms and are +drawn with leaves aligned. Otherwise, the tree is assumed to be a +phylogram: branch lengths are honored and a scale bar is drawn. + +SVG graphics can be converted to other formats with converters +such as Inkscape (e.g. to PDF) or ImageMagick (e.g. to PNG or JPEG). +Inkscape is available from www.inkscape.org and ImageMagick from +www.imagemagick.org. + +Options +------- + + -a <number>: rotate all labels by this amount (radians, default: 0) + [only SVG radial] + -A <number>: rotate left-side labels by this amount (radians, + default: 0.0349 (=~ 2°)) [only SVG radial] + -b <string>: CSS for branch length labels. [only SVG] + Default: 'font-size:small;font-family:sans'. + setting 'opacity:0' disables printing of branch lengths. + -c <filename>: use specified file as CSS map [only SVG]. A CSS map + is a text file which specifies a style (CSS) for a clade. + Each line has the following structure: + <CSS> <flag> <label>+ + <CSS> is a valid CSS style specification (no spaces allowed) + e.g. 'font-size:small;font-family:italics;stroke:green'. + <flag> is either 'Individual' or 'Clade' (case is not important, can + be abbreviated down to 'I' or 'C'). If set to 'Clade', the style is + applied to the clade defined by the labels. If 'Individual', the + style is applied to each node individually. + <label>+ is a nonempty, whitespace-separated list of Newick labels + (spaces are allowed IFF the label is enclosed in ''). If a label + matches more than one node, all matching nodes are used. + Default: no CSS map, whole tree is black (unless specified otherwise + via option -d). + <CSS>, <flag>, and <labels>+ are separated by whitespace. + The following specifies red stroke for a clade defined by A, B and C; + and 2-pixel wide, blue stroke for individual nodes D, E, and F: + stroke:red Clade A B C + stroke:blue;stroke-width:2 I D E F + If no colormap is specified, the default is (but see option -d): + stroke:black;fill:none;stroke-width:1;stroke-linecap:round + -d <string>: CSS for 'plain' tree nodes (i.e., unless overridden by -c) + [only SVG] + Default: stroke:black;fill:none;stroke-width:1;stroke-linecap:round + + -h: prints this message and exits + + -i <string>: CSS for inner node labels. [only SVG] + Default: 'font-size:small;font-family:sans'. + + setting 'visibility:hidden' disables printing of inner node labels. + -I <char> sets the position of the inner node label. Valid options are + 'l' (near the leaves), 'm' (middle) or 'r' (near the root). Default + is 'l'. + + -l <string>: CSS for leaf node labels. [only SVG] + Default: 'font-size:medium;font-family:sans'. + setting 'visibility:hidden' disables printing of leaf node labels. + Note: if you change this, you will probably need to adjust the + space allocated to leaf labels - see option -W. + -n <number> add this number of pixels to the horizontal position of + node labels. [SVG only] + + -o <filename>: use specified file as ornament map. Works like the CSS + map (see option -c), except that it specifies arbitrary SVG snippets + instead of CSS styles. For example, the following + "<circle style='fill:red' r='5'>" Clade A B C + will draw a red circle of radius 5 at the root of the clade defined + by nodes A, B, and C. Keyword 'Individual' is also accepted and + works like for CSS. + + -R <integer>: use that many pixels for the root [only SVG] + + -r: draw a radial tree (default: orthogonal) [only SVG] + + -s: output graph as SVG (default: ASCII graphics). All output is on + stdout, so if there is more than one tree, stdout will be a + concatenation of SVG documents. These can be split into individual + files with the csplit(1) command: + + $ nw_display -s many_trees.nw > multiple_svg + $ csplit -zs -f tree\_ -b '%02d.svg' multiple_svg '/<?xml/' {*} + + will generate as many SVG files as there are Newick trees in + many_trees.nw. The files will be named tree_01.svg, tree_02.svg, etc. + + -S: suppress scale bar (ignored for cladograms) + + -t: set the zero of the scale at the maximum depth instead of the root. + This is useful when the branch lengths are in time units: zero marks + the present, and the scale shows the age of the ancestral nodes. + -u <string>: string is used as unit name for scale bar (ignored + if no scale bar is drawn). + -U <URL_filename>: use specified URL map [only SVG]. A URL map + is a text file which specifies a URL for a label. + Each line has the following structure: + <label> <URL> + Clicking on a label will follow the link (if any). + -v <number>: number of pixels between leaves (default: 40) [only SVG + orthogonal] + -w <number>: graph should be no wider than <number>, measured in + characters for text and pixels for SVG. Defaults: 80 (text), + 300 (SVG) + -W <number>: use this as an estimate of the width of a leaf label + character (in pixels) [only SVG]. This affects the space left for + the tree nodes. Default: 5.0 You will probably need this if you + change the leaf label font properties (option -l), especially size. + You will probably need trial and error to find the right value. + +LibXML +...... + +If LibXML is being used, the handling of ornaments (-o) is more elaborate. +See the tutorial, section 2.2 (displaying) for details. +This executable uses LibXML2. + +Examples +-------- + +# display tree as ASCII:: + +$ nw_display data/catarrhini + +# display tree as SVG, using a color map:: + +$ nw_display -s -c data/color.map data/catarrhini + +# ditto, convert to other graphics formats:: + +$ nw_display -s -c data/color.map data/catarrhini > catarrhini.svg +$ convert catarrhini.svg catarrhini.png # PNG, with ImageMagick +$ convert catarrhini.svg catarrhini.jpeg # JPEG, with ImageMagick +$ inkscape -z -f catarrhini.svg -A catarrhini.pdf # PDF, with Inkscape + +# the same; no branch lengths:: + +$ nw_display -s -b 'visibility:hidden' -c data/color.map data/catarrhini + +# radial tree, leaf labels in italics:: + +$ nw_display -s -r -l 'font-style:italics' data/catarrhini + +]]> +</help> + <citations> + <citation type="doi">10.1186/1748-7188-3-7</citation> + </citations> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/tree.nwk Wed Jan 10 18:11:18 2018 -0500 @@ -0,0 +1,1 @@ +((raccoon:19.19959,bear:6.80041):0.84600,((sea_lion:11.99700, seal:12.00300):7.52973,((monkey:100.85930,cat:47.14069):20.59201, weasel:18.87953):2.09460):3.87382,dog:25.46154); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/tree.svg Wed Jan 10 18:11:18 2018 -0500 @@ -0,0 +1,8 @@ +<?xml version='1.0' standalone='no'?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg width='400' height='350' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' ><defs><style type='text/css'><![CDATA[ + .clade_0 {stroke:grey;fill:none;stroke-width:2;stoke-linecap:round;} + .leaf-label {font-family:courier;font-size:10px;} + .inner-label {visibility:hidden;} + .edge-label {visibility:hidden;} +]]></style></defs> +<!-- arguments: -s -u -I r -i visibility:hidden; -b visibility:hidden; -l font-family:courier;font-size:10px; -d stroke:grey;fill:none;stroke-width:2;stoke-linecap:round; -w 400 /home/correia/galaxy/database/files/001/dataset_1871.dat --> +<g transform='translate(0,20)'><g style='stroke:black;fill:none;stroke-width:1;stroke-linecap:round'><line class='clade_0' x1='12.0981' y1='0.0000' x2='59.7129' y2='0.0000'/><line class='clade_0' x1='12.0981' y1='40.0000' x2='28.9630' y2='40.0000'/><line class='clade_0' x1='12.0981' y1='0.0000' x2='12.0981' y2='40.0000'/><line class='clade_0' x1='10.0000' y1='20.0000' x2='12.0981' y2='20.0000'/><line class='clade_0' x1='38.2807' y1='80.0000' x2='68.0332' y2='80.0000'/><line class='clade_0' x1='38.2807' y1='120.0000' x2='68.0481' y2='120.0000'/><line class='clade_0' x1='38.2807' y1='80.0000' x2='38.2807' y2='120.0000'/><line class='clade_0' x1='19.6070' y1='100.0000' x2='38.2807' y2='100.0000'/><line class='clade_0' x1='75.8697' y1='160.0000' x2='326.0000' y2='160.0000'/><line class='clade_0' x1='75.8697' y1='200.0000' x2='192.7782' y2='200.0000'/><line class='clade_0' x1='75.8697' y1='160.0000' x2='75.8697' y2='200.0000'/><line class='clade_0' x1='24.8016' y1='180.0000' x2='75.8697' y2='180.0000'/><line class='clade_0' x1='24.8016' y1='240.0000' x2='71.6227' y2='240.0000'/><line class='clade_0' x1='24.8016' y1='180.0000' x2='24.8016' y2='240.0000'/><line class='clade_0' x1='19.6070' y1='210.0000' x2='24.8016' y2='210.0000'/><line class='clade_0' x1='19.6070' y1='100.0000' x2='19.6070' y2='210.0000'/><line class='clade_0' x1='10.0000' y1='155.0000' x2='19.6070' y2='155.0000'/><line class='clade_0' x1='10.0000' y1='280.0000' x2='73.1444' y2='280.0000'/><line class='clade_0' x1='10.0000' y1='20.0000' x2='10.0000' y2='280.0000'/><line x1='0' y1='150.0000' x2='10.0000' y2='150.0000'/></g><g style='stroke:none'><text class='leaf-label' x='69.7129' y='4.0000'>raccoon</text><text class='edge-label' x='35.905495' y='-4.000000'>19.19959</text><text class='leaf-label' x='38.9630' y='44.0000'>bear</text><text class='edge-label' x='20.530557' y='36.000000'>6.80041</text><text class='edge-label' x='11.049037' y='16.000000'>0.84600</text><text class='leaf-label' x='78.0332' y='84.0000'>sea lion</text><text class='edge-label' x='53.156957' y='76.000000'>11.99700</text><text class='leaf-label' x='78.0481' y='124.0000'>seal</text><text class='edge-label' x='53.164397' y='116.000000'>12.00300</text><text class='edge-label' x='28.943883' y='96.000000'>7.52973</text><text class='leaf-label' x='336.0000' y='164.0000'>monkey</text><text class='edge-label' x='200.934836' y='156.000000'>100.85930</text><text class='leaf-label' x='202.7782' y='204.0000'>cat</text><text class='edge-label' x='134.323956' y='196.000000'>47.14069</text><text class='edge-label' x='50.335655' y='176.000000'>20.59201</text><text class='leaf-label' x='81.6227' y='244.0000'>weasel</text><text class='edge-label' x='48.212186' y='236.000000'>18.87953</text><text class='edge-label' x='22.204342' y='206.000000'>2.09460</text><text class='edge-label' x='14.803523' y='151.000000'>3.87382</text><text class='leaf-label' x='83.1444' y='284.0000'>dog</text><text class='edge-label' x='41.572217' y='276.000000'>25.46154</text></g><g transform='translate(10,330)' style='stroke:black;stroke-width:1' ><path d='M 0 0 h 316'/><path d='M 0 0 v -7'/><text style='stroke:none;text-anchor:end' x='2' y='-9'>0</text><path d='M 61.9998 0 v -7'/><text style='stroke:none;text-anchor:end' x='63.9998' y='-9'>25</text><path d='M 124 0 v -7'/><text style='stroke:none;text-anchor:end' x='126' y='-9'>50</text><path d='M 185.999 0 v -7'/><text style='stroke:none;text-anchor:end' x='187.999' y='-9'>75</text><path d='M 247.999 0 v -7'/><text style='stroke:none;text-anchor:end' x='249.999' y='-9'>100</text><path d='M 309.999 0 v -7'/><text style='stroke:none;text-anchor:end' x='311.999' y='-9'>125</text><text style='font-size:small;stroke:none' x='0' y='-20'></text></g></g></svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/tree2.svg Wed Jan 10 18:11:18 2018 -0500 @@ -0,0 +1,8 @@ +<?xml version='1.0' standalone='no'?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg width='800' height='800' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' ><defs><style type='text/css'><![CDATA[ + .clade_0 {stroke:grey;fill:none;stroke-width:2;stoke-linecap:round;} + .leaf-label {font-family:sans-serif;font-size:10px;} + .inner-label {visibility:hidden;} + .edge-label {fill:blue; font-size:10px; transform:translate(-1.5em,0em);} +]]></style></defs> +<!-- arguments: -s -u -I r -i visibility:hidden; -b fill:blue; font-size:10px; transform:translate(-1.5em,0em); -l font-family:sans-serif;font-size:10px; -d stroke:grey;fill:none;stroke-width:2;stoke-linecap:round; -w 800 -r /home/correia/galaxy/database/files/001/dataset_1871.dat --> +<g transform='translate(400,400)'><g style='stroke:black;fill:none;stroke-width:1;stroke-linecap:round'><line class='clade_0' x1='59.7129' y1='0.0000' x2='12.0981' y2='0.0000'/><line class='clade_0' x1='21.2682' y1='19.6601' x2='8.8839' y2='8.2122'/><path class='clade_0' d='M12.0981,0.0000 A12.098074,12.098074 0 0 1 8.8839 8.2122'/><line class='clade_0' x1='11.2659' y1='4.4094' x2='9.3121' y2='3.6447'/><line class='clade_0' x1='5.3378' y1='67.8235' x2='3.0035' y2='38.1627'/><line class='clade_0' x1='-42.1282' y1='53.4393' x2='-23.6994' y2='30.0625'/><path class='clade_0' d='M3.0035,38.1627 A38.280721,38.280721 0 0 1 -23.6994 30.0625'/><line class='clade_0' x1='-11.1123' y1='36.6324' x2='-5.6916' y2='18.7628'/><line class='clade_0' x1='-321.9864' y1='50.9976' x2='-74.9356' y2='11.8686'/><line class='clade_0' x1='-160.2892' y1='-107.1019' x2='-63.0833' y2='-42.1509'/><path class='clade_0' d='M-74.9356,11.8686 A75.869672,75.869672 0 0 1 -63.0833 -42.1509'/><line class='clade_0' x1='-74.1069' y1='-16.2596' x2='-24.2254' y2='-5.3152'/><line class='clade_0' x1='-16.7200' y1='-69.6438' x2='-5.7898' y2='-24.1164'/><path class='clade_0' d='M-24.2254,-5.3152 A24.801638,24.801638 0 0 1 -5.7898 -24.1164'/><line class='clade_0' x1='-17.7087' y1='-17.3644' x2='-13.9997' y2='-13.7275'/><path class='clade_0' d='M-5.6916,18.7628 A19.607045,19.607045 0 0 1 -13.9997 -13.7275'/><line class='clade_0' x1='-18.9958' y1='4.8574' x2='-9.6883' y2='2.4774'/><line class='clade_0' x1='35.7399' y1='-63.8182' x2='4.8862' y2='-8.7250'/><path class='clade_0' d='M9.3121,3.6447 A10.000000,10.000000 0 1 1 4.8862 -8.7250'/><line x1='0' y1='0' x2='-9.4154' y2='3.3689'/></g><g style='stroke:none'><text class='leaf-label' transform='rotate(0,69.7129,0)' x='69.7129' y='0.0000'>raccoon</text><text class='edge-label' transform='rotate(0,35.9055,-3)' x='35.9055' y='-3.0000'>19.19959</text><text class='leaf-label' transform='rotate(42.75,28.6114,26.4481)' x='28.6114' y='26.4481'>bear</text><text class='edge-label' transform='rotate(42.75,17.1125,11.7332)' x='17.1125' y='11.7332'>6.80041</text><text class='edge-label' transform='rotate(21.375,11.3824,1.2334)' x='11.3824' y='1.2334'>0.84600</text><text class='leaf-label' transform='rotate(85.5,6.12241,77.7926)' x='6.1224' y='77.7926'>sea lion</text><text class='edge-label' transform='rotate(85.5,7.1614,52.7577)' x='7.1614' y='52.7577'>11.99700</text><text class='leaf-label' style='text-anchor:end;' transform='rotate(128.250000,-48.3191,61.2925) rotate(180,-48.3191,61.2925)' x='-48.3191' y='61.2925'>seal</text><text class='edge-label' style='text-anchor:end;' transform='rotate(128.250000,-35.2697,39.8936) rotate(180,-35.2697,39.8936)' x='-35.2697' y='39.8936'>12.00300</text><text class='edge-label' style='text-anchor:end;' transform='rotate(106.875000,-11.2728,26.8267) rotate(180,-11.2728,26.8267)' x='-11.2728' y='26.8267'>7.52973</text><text class='leaf-label' style='text-anchor:end;' transform='rotate(171.000000,-331.863,52.562) rotate(180,-331.863,52.562)' x='-331.8633' y='52.5620'>monkey</text><text class='edge-label' style='text-anchor:end;' transform='rotate(171.000000,-198.93,28.4701) rotate(180,-198.93,28.4701)' x='-198.9303' y='28.4701'>100.85930</text><text class='leaf-label' style='text-anchor:end;' transform='rotate(213.750000,-168.604,-112.658) rotate(180,-168.604,-112.658)' x='-168.6039' y='-112.6576'>cat</text><text class='edge-label' style='text-anchor:end;' transform='rotate(213.750000,-110.02,-77.1208) rotate(180,-110.02,-77.1208)' x='-110.0196' y='-77.1208'>47.14069</text><text class='edge-label' style='text-anchor:end;' transform='rotate(192.375000,-48.5232,-13.7177) rotate(180,-48.5232,-13.7177)' x='-48.5232' y='-13.7177'>20.59201</text><text class='leaf-label' style='text-anchor:end;' transform='rotate(256.500000,-19.0544,-79.3675) rotate(180,-19.0544,-79.3675)' x='-19.0544' y='-79.3675'>weasel</text><text class='edge-label' style='text-anchor:end;' transform='rotate(256.500000,-8.3378,-47.5804) rotate(180,-8.3378,-47.5804)' x='-8.3378' y='-47.5804'>18.87953</text><text class='edge-label' style='text-anchor:end;' transform='rotate(224.437500,-13.7538,-17.688) rotate(180,-13.7538,-17.688)' x='-13.7538' y='-17.6880'>2.09460</text><text class='edge-label' style='text-anchor:end;' transform='rotate(165.656250,-15.0853,0.760927) rotate(180,-15.0853,0.760927)' x='-15.0853' y='0.7609'>3.87382</text><text class='leaf-label' transform='rotate(299.25,40.6261,-72.5432)' x='40.6261' y='-72.5432'>dog</text><text class='edge-label' transform='rotate(299.25,17.6956,-37.7375)' x='17.6956' y='-37.7375'>25.46154</text></g></g><g transform='translate(10,800)' style='stroke:black;stroke-width:1' ><path d='M 0 0 h 316'/><path d='M 0 0 v -7'/><text style='stroke:none;text-anchor:end' x='2' y='-9'>0</text><path d='M 61.9998 0 v -7'/><text style='stroke:none;text-anchor:end' x='63.9998' y='-9'>25</text><path d='M 124 0 v -7'/><text style='stroke:none;text-anchor:end' x='126' y='-9'>50</text><path d='M 185.999 0 v -7'/><text style='stroke:none;text-anchor:end' x='187.999' y='-9'>75</text><path d='M 247.999 0 v -7'/><text style='stroke:none;text-anchor:end' x='249.999' y='-9'>100</text><path d='M 309.999 0 v -7'/><text style='stroke:none;text-anchor:end' x='311.999' y='-9'>125</text><text style='font-size:small;stroke:none' x='0' y='-20'></text></g></svg>