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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3