[Bio] / FigKernelScripts / gd_tree.pl Repository:
ViewVC logotype

View of /FigKernelScripts/gd_tree.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Mon Jun 22 18:55:33 2009 UTC (10 years, 5 months ago) by golsen
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, rast_rel_2009_07_09, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Add a command line program to make a png graphic from a newick tree file.

#
# Copyright (c) 2003-2009 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
# 
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#

my $usage = <<'End_of_Usage';

Usage:  gd_tree [ options ] < newick_tree > png_file

Options:

   -bc  r,g,b     #  Background color (D = transparent)
   -bp  position  #  Scale bar position: upper_left  | ul | lower_left  | ll
                  #                    | upper_right | ur | lower_right | lr
                  #                    (D = upper_left)
   -dx  pixels    #  Minimum delta x at node (D = 0)
   -dy  pixels    #  Vertical space between tips (D = 12)
   -f   font      #  GD font name: gdTinyFont | gdSmallFont | gdLargeFont
                  #       (D depends on dy)
   -lc  r,g,b     #  Line color (D = 0,0,0)
   -lt  pixels    #  Line thickness (D = 1)
   -tb  r,g,b     #  Text background color (D = none)
   -tc  r,g,b     #  Text color (D = 0,0,0)
   -ts  pixels    #  Text size (D = 0.8 * dy)
   -u             #  Display this usage information
   -w   pixels    #  Tree width without labels (D = 540)
   -xs  scale     #  Pixels per unit branch length (D = scaled to width)

   All color r,g,b values are on 0-255 color intensity range

Any node in the tree can have a comment of the form:

   [&&treeLayout: key => value; key => value; ...]

   Allowed key => value pairs within a tree are:

      bkg_color      => [r,g,b]
      line_color     => [r,g,b]
      thickness      => pixels
      text_bkg_color => [r,g,b]
      text_color     => [r,g,b]

End_of_Usage

use FIG;
use gjonewicklib;
use strict;
use gd_tree_0;  #  Note that the package name is just gd_tree

my %options = ();

my $val;
while ( @ARGV && $ARGV[0] =~ s/^-// )
{
    $_ = shift;
    if ( s/^bc// ) { $val = $_ || shift; $options{ bkg_color      } = [ split ',', $val ]; next }
    if ( s/^bp// ) { $val = $_ || shift; $options{ bar_position   } = $val; next }
    if ( s/^dx// ) { $val = $_ || shift; $options{ min_dx         } = $val; next }
    if ( s/^dy// ) { $val = $_ || shift; $options{ dy             } = $val; next }
    if ( s/^f//  ) { $val = $_ || shift; $options{ font           } = $val; next }
    if ( s/^lc// ) { $val = $_ || shift; $options{ line_color     } = [ split ',', $val ]; next }
    if ( s/^lt// ) { $val = $_ || shift; $options{ thickness      } = $val; next }
    if ( s/^tb// ) { $val = $_ || shift; $options{ text_bkg_color } = [ split ',', $val ]; next }
    if ( s/^tc// ) { $val = $_ || shift; $options{ text_color     } = [ split ',', $val ]; next }
    if ( s/^ts// ) { $val = $_ || shift; $options{ text_size      } = $val; next }
    if ( s/^u//  ) { print STDERR $usage; exit }
    if ( s/^w//  ) { $val = $_ || shift; $options{ width          } = $val; next }
    if ( s/^xs// ) { $val = $_ || shift; $options{ x_scale        } = $val; next }

    if ( /\S/ ) { print STDERR "Bad flag: '$_'\n", $usage; exit }
}

my $tree = gjonewicklib::parse_newick_tree_str( join('',<>) );

gd_tree::newick_gd_png( $tree, \%options );

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3