The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

dnd2svg.pl - draws newick trees as svg drawings.

SYNOPSIS

perl dnd2svg.pl [<options>]

OPTIONS

TREE INPUT OPTIONS

The treedrawer needs at least one of the following: a tree file from which it reads the first newick tree to draw, or a newick string.

-file <tree file>
-string <newick string>

TREE MODE AND SHAPE

The tree drawer has two drawing modes: clado, which draws a cladogram, and phylo for phylograms. If the tree does not specify branch lengths, clado is silently chosen.

-mode <clado|phylo>
-shape <curvy|rect|diag>

IMAGE DIMENSIONS

Image width and height apply to the entire SVG canvas, padding specifies the minimal distance of drawn elements from the edge of the canvas.

-width <image width in pixels>
-height <image height in pixels>
-padding <image padding in pixels>

TAXON NAME OPTIONS

Text width specifies the space allocated for text between the tallest tip of the tree and the right edge of the canvas. Vertical and horizontal offset specify the distance of the left corner of the taxon name (the "baseline") from the node.

-text_width <taxon name text width>
-text_vert_offset <taxon name vertical offset>
-text_horiz_offset <taxon name horizontal offset>

SCALE BAR OPTIONS

A scale bar can be used to show, for example, time in MYA from the root to the tip. You can either omit these options entirely (in which case no bar will be drawn) or you have to specify them all. The bar width can be specified as an integer, meaning pixels, or as a percentage, meaning the width relative to the longest root-to-tip path length. Likewise, major and minor ticks can be specified in pixels or percentages. The label argument is used to specify a string, e.g. "MYA", to be displayed next to the scale bar.

-scale_width <scale bar width>
-scale_minor <scale minor ticks>
-scale_major <scale major ticks>
-scale_label <scale bar label>

MISCELLANEOUS OPTIONS

-node_radius <node radius in pixels>
-help

DESCRIPTION

dnd2svg.pl is a program that draws newick trees (from file or string) as svg vector drawings. It can be used from the command line or as a CGI program. The OPTIONS section describes the options and arguments that can be provided on the command line, the html snippet below gives an example of how the script can be called through CGI and how the command line arguments map onto input element names.

Note that the html example below is fairly crude, some options could be better presented as menus with a limited number of choices (but are left as an exercise for the reader).

Additionally, this help document can be accessed through CGI by passing the script a help=1 argument, e.g. http://localhost/cgi-bin/dnd2svg.pl?help=1

    <!-- html snippet starts here -->
    <html>
    <head>
        <title>dnd2svg CGI form example</title>
        <style type="text/css">
        div { text-align:right }
        form { width:45%; display:inline; float:left }
        iframe { width:45%; display:inline; float:right; height:500px }
        </style>
    </head>
    <body>
        <form action="http://localhost/cgi-bin/dnd2svg.pl" method="get" target="view">
            <div>
                <label for="string">Newick string</label>
                <input type="text" name="string" id="string" value="((a:1,b:1):1,c:1):0;" />
            </div>
            <div>
                <label for="mode">Drawing mode</label>
                <input type="text" name="mode" id="mode" value="phylo" />
            </div>
            <div>
                <label for="shape">Tree shape</label>
                <input type="text" name="shape" id="shape" value="curvy" />
            </div>
            <div>
                <label for="width">Image width</label>
                <input type="text" name="width" id="width" value="400" />
            </div>
            <div>
                <label for="height">Image height</label>
                <input type="text" name="height" id="height" value="300" />
            </div>
            <div>
                <label for="padding">Padding</label>
                <input type="text" name="padding" id="padding" value="10" />
            </div>
            <div>
                <label for="text_width">Text width</label>
                <input type="text" name="text_width" id="text_width" value="100" />
            </div>
            <div>
                <label for="node_radius">Node radius</label>
                <input type="text" name="node_radius" id="node_radius" value="5" />
            </div>
            <div>
                <label for="text_vert_offset">Text vertical offset</label>
                <input type="text" name="text_vert_offset" id="text_vert_offset" value="5" />
            </div>
            <div>
                <label for="text_horiz_offset">Text horizontal offset</label>
                <input type="text" name="text_horiz_offset" id="text_horiz_offset" value="10" />
            </div>
            <div>
                <label for="scale_width">Scale width</label>
                <input type="text" name="scale_width" id="scale_width" value="100%" />
            </div>
            <div>
                <label for="scale_major">Scale major</label>
                <input type="text" name="scale_major" id="scale_major" value="40%" />
            </div>
            <div>
                <label for="scale_minor">Scale minor</label>
                <input type="text" name="scale_minor" id="scale_minor" value="4%" />
            </div>
            <div>
                <label for="scale_label">Scale label</label>
                <input type="text" name="scale_label" id="scale_label" value="MYA" />
            </div>
            <div><input type="submit" name="Submit" value="Submit" /></div>
        </form>
        <iframe name="view"></iframe>
    </body>
    </html>
    <!-- html snippet ends here -->

SEE ALSO

Rutger Vos: http://search.cpan.org/~rvosa

WARNINGS AND ERRORS

dnd2svg.pl uses CGI::Carp to mark up fatal messages in HTML and send them back to the browser. This is useful for CGI debugging.