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

Annotation of /FigKernelScripts/svr_tree_to_html.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (view) (download) (as text)

1 : fangfang 1.1 #
2 :     # This is a SAS Component
3 :     #
4 :    
5 :     #
6 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
7 :     # for Interpretations of Genomes. All Rights Reserved.
8 :     #
9 :     # This file is part of the SEED Toolkit.
10 :     #
11 :     # The SEED Toolkit is free software. You can redistribute
12 :     # it and/or modify it under the terms of the SEED Toolkit
13 :     # Public License.
14 :     #
15 :     # You should have received a copy of the SEED Toolkit Public License
16 :     # along with this program; if not write to the University of Chicago
17 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
18 :     # Genomes at veronika@thefig.info or download a copy from
19 :     # http://www.theseed.org/LICENSE.TXT.
20 :     #
21 :    
22 :     use strict;
23 :     use Data::Dumper;
24 :     use Carp;
25 :     use Getopt::Long;
26 :    
27 :     =head1 svr_tree_to_html
28 :    
29 :     svr_tree_to_html [options] < tree.newick > tree.html
30 :    
31 : fangfang 1.2 This script converts a newick tree into an HTML page. It has a rich
32 :     set of options.
33 : fangfang 1.1
34 :     =head1 Introduction
35 :    
36 :     usage: svr_tree_to_html [options] < tree.newick > tree.html
37 :    
38 :     -a alias_file - relabel tips using aliases # table: [id alias]
39 : fangfang 1.4 -b - show bootstrap/branch support values
40 : fangfang 1.1 -c tax|role|file - color tips by taxonomy, roles,
41 :     or groups specified in a file # table: [id group]
42 :     -d desc_file - add description to each tip # table: [id description]
43 : fangfang 1.4 -f focus_list - highlight a list of tips # table: [id]
44 : fangfang 1.1 -l link_file - add URL to each tip # table: [id URL]
45 :     -m popup_file - add simple mouseover to each tip # table: [id popup]
46 : fangfang 1.3 -nc n_colors - number of colors to use (D = 10)
47 : fangfang 1.1 -p g|s|file - collapse trees by genus, species,
48 :     or groups specified in a file # table: [id group]
49 :     -t title - title for html page
50 : fangfang 1.4 -x min_dx - minimum horizontal space between consecutive nodes (D = 1)
51 :     -y dy - vertical separation of consecutive tips (D = 1)
52 : fangfang 1.1
53 :     -anno - use the annotator's SEED for URLs
54 :     -gray n - gray out name from the n-th word # default: 2
55 :     -pseed - use PSEED
56 :     -raw - do not color or collapse tree,
57 :     may be superseded by -c and -p
58 :    
59 :     =head2 Command-line options
60 :    
61 :     =over 4
62 :    
63 :     =item -a alias_file
64 :    
65 :     The sequence IDs in the FASTA file may not be what a user wants to see
66 :     in the visualized tree. The alias file is a two-column table
67 :     containing ID to alias mapping [ id alias ], and the tree tips will be
68 :     relabeled with the aliases.
69 :    
70 :     The alias file can also be used to supply a mapping from original
71 :     sequence ID to FIG peg ID. With FIG ids, taxonomoy and function
72 :     information can be automatically retrieved from the SEED server and
73 :     painted to the tree tips.
74 :    
75 : fangfang 1.4 =item -b
76 : fangfang 1.1
77 : fangfang 1.4 With the -b option, bootstrap values (or branch support values) are
78 :     shown in percent for internal nodes of the tree. min_dx and dy are set
79 :     to 2 unless they are explicitly specified.
80 : fangfang 1.1
81 :     =item -c tax | role | group_file
82 :    
83 :     The value for the -c option can be a string ('tax' or 'role') or the
84 :     name of a two-column table [ id, group ] that classifies the sequences
85 :     into multiple groups. Correspondingly, the tips of the tree will be
86 :     colord according to their major taxonomy group, functional role, or
87 :     the customized group.
88 :    
89 :     If tips are colored based on taxonomy groups, a taxonomy legend is
90 :     shown. Otherwise, a table of color group (functional role by default)
91 :     frequencies is shown.
92 :    
93 :     The default behavior is to color tree tips by taxonomy groups.
94 :    
95 :     =item -d description_file
96 :    
97 :     A two-column table [ id, description ]. The description string will
98 :     appear in parentheses after the sequence ID for each tip of the tree.
99 :    
100 : fangfang 1.4 =item -f focus_list
101 :    
102 :     A file with space-delimited IDs for sequences to be highlighted.
103 :    
104 : fangfang 1.1 =item -l link_file
105 :    
106 :     A two-column table [ id, url ] for inserting URL for tree tips.
107 :    
108 :     =item -m mouseover_file
109 :    
110 :     A two-column table [ id, mouseover_description ]. The mouseover
111 :     description string will appear in the popup box for the specified tip.
112 :    
113 : fangfang 1.3 =item -nc n_colors
114 :    
115 :     The number of colors to use for tree tips (D = 10). Max: 20.
116 :    
117 : fangfang 1.1 =item -p g | s | group_file
118 :    
119 :     This option provides a rule for collapsing subtrees whose tips all
120 :     belong to the same group. The value for the -p option can be a string
121 :     ('g' for genus, or, 's' for species), or the name of a two-column
122 :     table [ id, group ] that classifies the sequenes into multiple groups.
123 :    
124 :     The default behavior is to collapse subtrees whose nodes all belong to
125 :     the same genus.
126 :    
127 :     =item -t html_title
128 :    
129 :     This title of the HTML page.
130 :    
131 : fangfang 1.4 =item -x n
132 :    
133 :     Specifies the minimum length of a distance between two nodes. (D = 1)
134 :    
135 :     =item -y n
136 :    
137 :     Specifies vertical separation of consecutive tips. (D = 1)
138 :    
139 : fangfang 1.1 =item -anno
140 :    
141 :     With the -anno option, the tree tips will be linked to the annotator's
142 :     SEED instead of the SEED viewer.
143 :    
144 :     =item -gray n
145 :    
146 :     Gray out the tip names after the n-th word. (D = 2)
147 :    
148 :     =item -pseed
149 :    
150 :     With the -pseed option, the taxonomy and function information is
151 :     retrieved from the PSEED server. Setting the environment variable
152 :     SAS_SERVER to 'PSEED' has the same effect.
153 :    
154 :     =item -raw
155 :    
156 :     Do not color or collapse the tree. This option maybe superseded if -c
157 :     or -p is present.
158 :    
159 :     =back
160 :    
161 :     =head2 Input
162 :    
163 :     The input tree is a newick file read from STDIN.
164 :    
165 :     =head2 Output
166 :    
167 :     The output is a HTML page written to STDOUT.
168 :    
169 :     =cut
170 :    
171 :     use AlignTree;
172 :     use ATserver;
173 :     use SeedUtils;
174 :    
175 :     use ffxtree;
176 :     use gjoalignment;
177 :     use gjoseqlib;
178 :    
179 :     my $usage = <<"End_of_Usage";
180 :    
181 :     usage: svr_tree_to_html [options] < tree.newick > tree.html
182 :    
183 :     -a alias_file - relabel tips using aliases # file: [id alias]
184 : fangfang 1.4 -b - show bootstrap/branch support values
185 : fangfang 1.1 -c tax|role|file - color tips by taxonomy, roles,
186 :     or groups specified in a file # file: [id group]
187 :     -d desc_file - add description to each tip # file: [id description]
188 : fangfang 1.5 -f focus_list - highlight a list of tips # file: [id]
189 : fangfang 1.1 -l link_file - add URL to each tip # file: [id URL]
190 :     -m popup_file - add simple mouseover to each tip # file: [id popup]
191 : fangfang 1.3 -nc n_colors - number of colors to use (D = 10)
192 : fangfang 1.1 -p g|s|file - collapse trees by genus, species,
193 :     or groups specified in a file # file: [id group]
194 :     -t title - title for html page
195 : fangfang 1.4 -x min_dx - minimum horizontal space between consecutive nodes (D = 1)
196 :     -y dy - vertical separation of consecutive tips (D = 1)
197 : fangfang 1.1 -anno - use the annotator's SEED for URLs
198 :     -gray n - gray out name from the n-th word # default: 2
199 :     -pseed - use PSEED
200 :     -raw - do not color or collapse the tree,
201 :     may be superseded by -c and -p
202 :    
203 :     End_of_Usage
204 :    
205 : fangfang 1.4 my ($help, $url, $alias_file, $focus_file, $branch, $collapse_by,
206 :     $desc_file, $link_file, $popup_file, $id_file, $title, $min_dx, $dy,
207 : fangfang 1.1 $ncolor, $color_by, $anno, $gray, $pseed, $raw);
208 :    
209 :     GetOptions("h|help" => \$help,
210 :     "a|alias=s" => \$alias_file,
211 : fangfang 1.4 "b|branch" => \$branch,
212 : fangfang 1.1 "c|color=s" => \$color_by,
213 :     "d|desc=s" => \$desc_file,
214 : fangfang 1.4 "f|focus=s" => \$focus_file,
215 : fangfang 1.1 "i|id=s" => \$id_file,
216 :     "l|link=s" => \$link_file,
217 :     "m|popup=s" => \$popup_file,
218 :     "nc=i" => \$ncolor,
219 :     "p|collapse=s" => \$collapse_by,
220 :     "t|title=s" => \$title,
221 : fangfang 1.4 "x|dx=i" => \$min_dx,
222 :     "y|dy=i" => \$dy,
223 : fangfang 1.1 "anno" => \$anno,
224 :     "g|gray=i" => \$gray,
225 :     "pseed" => \$pseed,
226 :     "raw" => \$raw);
227 :    
228 :     $help and die $usage;
229 :    
230 :     my $opts;
231 :    
232 : fangfang 1.4 $opts->{show_branch} = $branch;
233 : fangfang 1.1 $opts->{color_by} = $color_by;
234 :     $opts->{collapse_by} = $collapse_by;
235 : fangfang 1.6 $opts->{focus_set} = ffxtree::read_set($focus_file) if $focus_file && -s $focus_file;
236 : fangfang 1.1 $opts->{alias} = ffxtree::read_hash($alias_file) if $alias_file && -s $alias_file;
237 :     $opts->{color_by} = ffxtree::read_hash($color_by) if $color_by && -s $color_by;
238 :     $opts->{collapse_by} = ffxtree::read_hash($collapse_by) if $collapse_by && -s $collapse_by;
239 :     $opts->{desc} = ffxtree::read_hash($desc_file) if $desc_file && -s $desc_file;
240 :     $opts->{popup} = ffxtree::read_hash($popup_file) if $popup_file && -s $popup_file;
241 :     $opts->{link} = ffxtree::read_hash($link_file) if $link_file && -s $link_file;
242 :     $opts->{tree} = ffxtree::read_tree();
243 :     $opts->{ncolor} = $ncolor || 10;
244 : fangfang 1.4 $opts->{gray} = $gray || 2;
245 :     $opts->{min_dx} = $min_dx || $branch ? 2 : 1;
246 :     $opts->{dy} = $dy || $branch ? 2 : 1;
247 : fangfang 1.1 $opts->{title} = $title;
248 :     $opts->{anno} = $anno;
249 :     $opts->{raw} = $raw;
250 :    
251 :     $opts->{color_by} ||= $raw ? 'none' : 'taxonomy';
252 :     $opts->{collapse_by} ||= $raw ? 'none' : 'genus';
253 :     $opts->{color_by} = undef if $opts->{color_by} =~ /none/i;
254 :     $opts->{collapse_by} = undef if $opts->{collapse_by} =~ /none/i;
255 :    
256 :     my $envParm = $ENV{SAS_SERVER};
257 :    
258 :     $ENV{SAS_SERVER} = 'PSEED' if $pseed;
259 :    
260 :     my $html = ffxtree::tree_to_html($opts);
261 :    
262 :     $ENV{SAS_SERVER} = $envParm if $pseed;
263 :    
264 :     print $html;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3