[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.9 - (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.9 -k keep_list - keep only the taxa listed # table: [id]
45 : fangfang 1.1 -l link_file - add URL to each tip # table: [id URL]
46 : fangfang 1.7 -lt link_w_text - add additional linked text # table: [id text URL]
47 : fangfang 1.1 -m popup_file - add simple mouseover to each tip # table: [id popup]
48 : fangfang 1.3 -nc n_colors - number of colors to use (D = 10)
49 : fangfang 1.1 -p g|s|file - collapse trees by genus, species,
50 :     or groups specified in a file # table: [id group]
51 : fangfang 1.7 -s show_list - preferred tips to show when collapsing subtrees
52 :     (D = Woese' list of 69 common organisms)
53 : fangfang 1.1 -t title - title for html page
54 : fangfang 1.4 -x min_dx - minimum horizontal space between consecutive nodes (D = 1)
55 :     -y dy - vertical separation of consecutive tips (D = 1)
56 : fangfang 1.1
57 :     -anno - use the annotator's SEED for URLs
58 :     -gray n - gray out name from the n-th word # default: 2
59 :     -pseed - use PSEED
60 : fangfang 1.9 -ppseed - use PUBLIC_SEED
61 : fangfang 1.1 -raw - do not color or collapse tree,
62 :     may be superseded by -c and -p
63 :    
64 :     =head2 Command-line options
65 :    
66 :     =over 4
67 :    
68 :     =item -a alias_file
69 :    
70 :     The sequence IDs in the FASTA file may not be what a user wants to see
71 :     in the visualized tree. The alias file is a two-column table
72 :     containing ID to alias mapping [ id alias ], and the tree tips will be
73 :     relabeled with the aliases.
74 :    
75 :     The alias file can also be used to supply a mapping from original
76 :     sequence ID to FIG peg ID. With FIG ids, taxonomoy and function
77 :     information can be automatically retrieved from the SEED server and
78 :     painted to the tree tips.
79 :    
80 : fangfang 1.4 =item -b
81 : fangfang 1.1
82 : fangfang 1.4 With the -b option, bootstrap values (or branch support values) are
83 :     shown in percent for internal nodes of the tree. min_dx and dy are set
84 :     to 2 unless they are explicitly specified.
85 : fangfang 1.1
86 :     =item -c tax | role | group_file
87 :    
88 :     The value for the -c option can be a string ('tax' or 'role') or the
89 :     name of a two-column table [ id, group ] that classifies the sequences
90 :     into multiple groups. Correspondingly, the tips of the tree will be
91 :     colord according to their major taxonomy group, functional role, or
92 :     the customized group.
93 :    
94 :     If tips are colored based on taxonomy groups, a taxonomy legend is
95 :     shown. Otherwise, a table of color group (functional role by default)
96 :     frequencies is shown.
97 :    
98 :     The default behavior is to color tree tips by taxonomy groups.
99 :    
100 :     =item -d description_file
101 :    
102 :     A two-column table [ id, description ]. The description string will
103 :     appear in parentheses after the sequence ID for each tip of the tree.
104 :    
105 : fangfang 1.4 =item -f focus_list
106 :    
107 :     A file with space-delimited IDs for sequences to be highlighted.
108 :    
109 : fangfang 1.9 =item -k keep_list
110 :    
111 :     Keep only the taxa listed (one per line) in the file keep.
112 :    
113 : fangfang 1.1 =item -l link_file
114 :    
115 :     A two-column table [ id, url ] for inserting URL for tree tips.
116 :    
117 : fangfang 1.7 =item -lt linked_text_file
118 :    
119 :     A three-column table [ id, text, url ] for inserting linked text for tree tips.
120 :    
121 : fangfang 1.1 =item -m mouseover_file
122 :    
123 :     A two-column table [ id, mouseover_description ]. The mouseover
124 :     description string will appear in the popup box for the specified tip.
125 :    
126 : fangfang 1.3 =item -nc n_colors
127 :    
128 :     The number of colors to use for tree tips (D = 10). Max: 20.
129 :    
130 : fangfang 1.1 =item -p g | s | group_file
131 :    
132 :     This option provides a rule for collapsing subtrees whose tips all
133 :     belong to the same group. The value for the -p option can be a string
134 :     ('g' for genus, or, 's' for species), or the name of a two-column
135 :     table [ id, group ] that classifies the sequenes into multiple groups.
136 :    
137 :     The default behavior is to collapse subtrees whose nodes all belong to
138 :     the same genus.
139 :    
140 : fangfang 1.7 =item -s show_list (D = Woese' list of 69 common organisms)
141 :    
142 :     Show a list of preferred tips when collapsing subtrees.
143 :    
144 : fangfang 1.1 =item -t html_title
145 :    
146 :     This title of the HTML page.
147 :    
148 : fangfang 1.4 =item -x n
149 :    
150 :     Specifies the minimum length of a distance between two nodes. (D = 1)
151 :    
152 :     =item -y n
153 :    
154 :     Specifies vertical separation of consecutive tips. (D = 1)
155 :    
156 : fangfang 1.1 =item -anno
157 :    
158 :     With the -anno option, the tree tips will be linked to the annotator's
159 :     SEED instead of the SEED viewer.
160 :    
161 :     =item -gray n
162 :    
163 :     Gray out the tip names after the n-th word. (D = 2)
164 :    
165 :     =item -pseed
166 :    
167 :     With the -pseed option, the taxonomy and function information is
168 :     retrieved from the PSEED server. Setting the environment variable
169 :     SAS_SERVER to 'PSEED' has the same effect.
170 :    
171 : fangfang 1.9 =item -ppseed
172 :    
173 :     With the -ppseed option, the taxonomy and function information is
174 :     retrieved from the PUBLIC_SEED server. Setting the environment variable
175 :     SAS_SERVER to 'PUBLIC_SEED' has the same effect.
176 :    
177 : fangfang 1.1 =item -raw
178 :    
179 :     Do not color or collapse the tree. This option maybe superseded if -c
180 :     or -p is present.
181 :    
182 :     =back
183 :    
184 :     =head2 Input
185 :    
186 :     The input tree is a newick file read from STDIN.
187 :    
188 :     =head2 Output
189 :    
190 :     The output is a HTML page written to STDOUT.
191 :    
192 :     =cut
193 :    
194 :     use AlignTree;
195 :     use ATserver;
196 :     use SeedUtils;
197 :    
198 :     use ffxtree;
199 :     use gjoalignment;
200 :     use gjoseqlib;
201 :    
202 :     my $usage = <<"End_of_Usage";
203 :    
204 :     usage: svr_tree_to_html [options] < tree.newick > tree.html
205 :    
206 :     -a alias_file - relabel tips using aliases # file: [id alias]
207 : fangfang 1.4 -b - show bootstrap/branch support values
208 : fangfang 1.1 -c tax|role|file - color tips by taxonomy, roles,
209 :     or groups specified in a file # file: [id group]
210 :     -d desc_file - add description to each tip # file: [id description]
211 : fangfang 1.5 -f focus_list - highlight a list of tips # file: [id]
212 : fangfang 1.9 -k keep_list - keep only the taxa listed # table: [id]
213 : fangfang 1.1 -l link_file - add URL to each tip # file: [id URL]
214 : fangfang 1.7 -lt link_w_text - add additional linked text # file: [id text URL]
215 : fangfang 1.1 -m popup_file - add simple mouseover to each tip # file: [id popup]
216 : fangfang 1.3 -nc n_colors - number of colors to use (D = 10)
217 : fangfang 1.1 -p g|s|file - collapse trees by genus, species,
218 :     or groups specified in a file # file: [id group]
219 : fangfang 1.7 -s show_list - preferred tips to show when collapsing subtrees
220 :     (D = Woese' list of 69 common organisms)
221 : fangfang 1.1 -t title - title for html page
222 : fangfang 1.4 -x min_dx - minimum horizontal space between consecutive nodes (D = 1)
223 :     -y dy - vertical separation of consecutive tips (D = 1)
224 : fangfang 1.1 -anno - use the annotator's SEED for URLs
225 :     -gray n - gray out name from the n-th word # default: 2
226 :     -pseed - use PSEED
227 : fangfang 1.9 -ppseed - use PUBLIC_SEED
228 : fangfang 1.1 -raw - do not color or collapse the tree,
229 :     may be superseded by -c and -p
230 :    
231 :     End_of_Usage
232 :    
233 : fangfang 1.7 my ($help, $url, $alias_file, $focus_file, $branch, $collapse_by, $show_file,
234 : fangfang 1.9 $desc_file, $keep_file, $link_file, $text_link, $popup_file, $id_file, $title,
235 :     $min_dx, $dy, $ncolor, $color_by, $anno, $gray, $pseed, $ppseed, $raw);
236 : fangfang 1.1
237 :     GetOptions("h|help" => \$help,
238 :     "a|alias=s" => \$alias_file,
239 : fangfang 1.4 "b|branch" => \$branch,
240 : fangfang 1.1 "c|color=s" => \$color_by,
241 :     "d|desc=s" => \$desc_file,
242 : fangfang 1.4 "f|focus=s" => \$focus_file,
243 : fangfang 1.1 "i|id=s" => \$id_file,
244 : fangfang 1.9 "k|keep=s" => \$keep_file,
245 : fangfang 1.1 "l|link=s" => \$link_file,
246 : fangfang 1.7 "lt=s" => \$text_link,
247 : fangfang 1.1 "m|popup=s" => \$popup_file,
248 :     "nc=i" => \$ncolor,
249 :     "p|collapse=s" => \$collapse_by,
250 : fangfang 1.7 "s|show=s" => \$show_file,
251 : fangfang 1.1 "t|title=s" => \$title,
252 : fangfang 1.4 "x|dx=i" => \$min_dx,
253 :     "y|dy=i" => \$dy,
254 : fangfang 1.1 "anno" => \$anno,
255 :     "g|gray=i" => \$gray,
256 :     "pseed" => \$pseed,
257 : fangfang 1.9 "ppseed" => \$ppseed,
258 : fangfang 1.1 "raw" => \$raw);
259 :    
260 :     $help and die $usage;
261 :    
262 :     my $opts;
263 :    
264 : fangfang 1.7 $opts->{show_branch} = $branch;
265 :     $opts->{color_by} = $color_by;
266 :     $opts->{collapse_by} = $collapse_by;
267 :     $opts->{focus_set} = ffxtree::read_set($focus_file) if $focus_file && -s $focus_file;
268 :     $opts->{alias} = ffxtree::read_hash($alias_file) if $alias_file && -s $alias_file;
269 :     $opts->{color_by} = ffxtree::read_hash($color_by) if $color_by && -s $color_by;
270 :     $opts->{collapse_by} = ffxtree::read_hash($collapse_by) if $collapse_by && -s $collapse_by;
271 :     $opts->{collapse_show} = ffxtree::read_set($show_file) if $show_file && -s $show_file;
272 : fangfang 1.9 $opts->{keep} = ffxtree::read_set($keep_file) if $keep_file && -s $keep_file;
273 : fangfang 1.7 $opts->{desc} = ffxtree::read_hash($desc_file) if $desc_file && -s $desc_file;
274 :     $opts->{popup} = ffxtree::read_hash($popup_file) if $popup_file && -s $popup_file;
275 :     $opts->{link} = ffxtree::read_hash($link_file) if $link_file && -s $link_file;
276 :     $opts->{text_link} = ffxtree::read_hash($text_link) if $text_link && -s $text_link;
277 :     $opts->{tree} = ffxtree::read_tree();
278 :     $opts->{ncolor} = $ncolor || 10;
279 :     $opts->{gray} = $gray || 2;
280 :     $opts->{min_dx} = $min_dx || $branch ? 2 : 1;
281 :     $opts->{dy} = $dy || $branch ? 2 : 1;
282 :     $opts->{title} = $title;
283 :     $opts->{anno} = $anno;
284 :     $opts->{raw} = $raw;
285 :    
286 :     $opts->{color_by} ||= $raw ? 'none' : 'taxonomy';
287 :     $opts->{collapse_by} ||= $raw ? 'none' : 'genus';
288 :     $opts->{collapse_show} ||= $raw ? 'none' : 'woese';
289 :    
290 : fangfang 1.8 $opts->{color_by} = 0 if $opts->{color_by} =~ /^none$/i;
291 :     $opts->{collapse_by} = 0 if $opts->{collapse_by} =~ /^none$/i;
292 :     $opts->{collapse_show} = 0 if $show_file =~ /^none$/i;
293 : fangfang 1.1
294 :     my $envParm = $ENV{SAS_SERVER};
295 :    
296 : fangfang 1.9 $ENV{SAS_SERVER} = 'PSEED' if $pseed;
297 :     $ENV{SAS_SERVER} = 'PUBLIC_SEED' if $ppseed;
298 : fangfang 1.1
299 :     my $html = ffxtree::tree_to_html($opts);
300 :    
301 : fangfang 1.9 $ENV{SAS_SERVER} = $envParm if $pseed || $ppseed;
302 : fangfang 1.1
303 :     print $html;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3