[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.2 - (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 :     -b bold_list - highlight a list of tips # table: [id]
40 :     -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 :     -l link_file - add URL to each tip # table: [id URL]
44 :     -m popup_file - add simple mouseover to each tip # table: [id popup]
45 :     -p g|s|file - collapse trees by genus, species,
46 :     or groups specified in a file # table: [id group]
47 :     -t title - title for html page
48 :    
49 :     -anno - use the annotator's SEED for URLs
50 :     -gray n - gray out name from the n-th word # default: 2
51 :     -pseed - use PSEED
52 :     -raw - do not color or collapse tree,
53 :     may be superseded by -c and -p
54 :    
55 :     =head2 Command-line options
56 :    
57 :     =over 4
58 :    
59 :     =item -a alias_file
60 :    
61 :     The sequence IDs in the FASTA file may not be what a user wants to see
62 :     in the visualized tree. The alias file is a two-column table
63 :     containing ID to alias mapping [ id alias ], and the tree tips will be
64 :     relabeled with the aliases.
65 :    
66 :     The alias file can also be used to supply a mapping from original
67 :     sequence ID to FIG peg ID. With FIG ids, taxonomoy and function
68 :     information can be automatically retrieved from the SEED server and
69 :     painted to the tree tips.
70 :    
71 :     =item -b bold_list
72 :    
73 :     A file with space-delimited IDs for sequences to be highlighted.
74 :    
75 :     =item -c tax | role | group_file
76 :    
77 :     The value for the -c option can be a string ('tax' or 'role') or the
78 :     name of a two-column table [ id, group ] that classifies the sequences
79 :     into multiple groups. Correspondingly, the tips of the tree will be
80 :     colord according to their major taxonomy group, functional role, or
81 :     the customized group.
82 :    
83 :     If tips are colored based on taxonomy groups, a taxonomy legend is
84 :     shown. Otherwise, a table of color group (functional role by default)
85 :     frequencies is shown.
86 :    
87 :     The default behavior is to color tree tips by taxonomy groups.
88 :    
89 :     =item -d description_file
90 :    
91 :     A two-column table [ id, description ]. The description string will
92 :     appear in parentheses after the sequence ID for each tip of the tree.
93 :    
94 :     =item -l link_file
95 :    
96 :     A two-column table [ id, url ] for inserting URL for tree tips.
97 :    
98 :     =item -m mouseover_file
99 :    
100 :     A two-column table [ id, mouseover_description ]. The mouseover
101 :     description string will appear in the popup box for the specified tip.
102 :    
103 :     =item -p g | s | group_file
104 :    
105 :     This option provides a rule for collapsing subtrees whose tips all
106 :     belong to the same group. The value for the -p option can be a string
107 :     ('g' for genus, or, 's' for species), or the name of a two-column
108 :     table [ id, group ] that classifies the sequenes into multiple groups.
109 :    
110 :     The default behavior is to collapse subtrees whose nodes all belong to
111 :     the same genus.
112 :    
113 :     =item -t html_title
114 :    
115 :     This title of the HTML page.
116 :    
117 :     =item -anno
118 :    
119 :     With the -anno option, the tree tips will be linked to the annotator's
120 :     SEED instead of the SEED viewer.
121 :    
122 :     =item -gray n
123 :    
124 :     Gray out the tip names after the n-th word. (D = 2)
125 :    
126 :     =item -pseed
127 :    
128 :     With the -pseed option, the taxonomy and function information is
129 :     retrieved from the PSEED server. Setting the environment variable
130 :     SAS_SERVER to 'PSEED' has the same effect.
131 :    
132 :     =item -raw
133 :    
134 :     Do not color or collapse the tree. This option maybe superseded if -c
135 :     or -p is present.
136 :    
137 :     =back
138 :    
139 :     =head2 Input
140 :    
141 :     The input tree is a newick file read from STDIN.
142 :    
143 :     =head2 Output
144 :    
145 :     The output is a HTML page written to STDOUT.
146 :    
147 :     =cut
148 :    
149 :     use AlignTree;
150 :     use ATserver;
151 :     use SeedUtils;
152 :    
153 :     use ffxtree;
154 :     use gjoalignment;
155 :     use gjoseqlib;
156 :    
157 :     my $usage = <<"End_of_Usage";
158 :    
159 :     usage: svr_tree_to_html [options] < tree.newick > tree.html
160 :    
161 :     -a alias_file - relabel tips using aliases # file: [id alias]
162 :     -b bold_list - highlight a list of tips # file: [id]
163 :     -c tax|role|file - color tips by taxonomy, roles,
164 :     or groups specified in a file # file: [id group]
165 :     -d desc_file - add description to each tip # file: [id description]
166 :     -l link_file - add URL to each tip # file: [id URL]
167 :     -m popup_file - add simple mouseover to each tip # file: [id popup]
168 :     -p g|s|file - collapse trees by genus, species,
169 :     or groups specified in a file # file: [id group]
170 :     -t title - title for html page
171 :     -anno - use the annotator's SEED for URLs
172 :     -gray n - gray out name from the n-th word # default: 2
173 :     -pseed - use PSEED
174 :     -raw - do not color or collapse the tree,
175 :     may be superseded by -c and -p
176 :    
177 :     End_of_Usage
178 :    
179 :     my ($help, $url, $alias_file, $bold_file, $collapse_by,
180 :     $desc_file, $link_file, $popup_file, $id_file, $title,
181 :     $ncolor, $color_by, $anno, $gray, $pseed, $raw);
182 :    
183 :     GetOptions("h|help" => \$help,
184 :     "a|alias=s" => \$alias_file,
185 :     "b|bold=s" => \$bold_file,
186 :     "c|color=s" => \$color_by,
187 :     "d|desc=s" => \$desc_file,
188 :     "i|id=s" => \$id_file,
189 :     "l|link=s" => \$link_file,
190 :     "m|popup=s" => \$popup_file,
191 :     "nc=i" => \$ncolor,
192 :     "p|collapse=s" => \$collapse_by,
193 :     "t|title=s" => \$title,
194 :     "anno" => \$anno,
195 :     "g|gray=i" => \$gray,
196 :     "pseed" => \$pseed,
197 :     "raw" => \$raw);
198 :    
199 :     $help and die $usage;
200 :    
201 :     my $opts;
202 :    
203 :     $opts->{color_by} = $color_by;
204 :     $opts->{collapse_by} = $collapse_by;
205 :     $opts->{alias} = ffxtree::read_hash($alias_file) if $alias_file && -s $alias_file;
206 :     $opts->{bold_set} = ffxtree::read_set($bold_file) if $bold_file && -s $bold_file;
207 :     $opts->{color_by} = ffxtree::read_hash($color_by) if $color_by && -s $color_by;
208 :     $opts->{collapse_by} = ffxtree::read_hash($collapse_by) if $collapse_by && -s $collapse_by;
209 :     $opts->{desc} = ffxtree::read_hash($desc_file) if $desc_file && -s $desc_file;
210 :     $opts->{popup} = ffxtree::read_hash($popup_file) if $popup_file && -s $popup_file;
211 :     $opts->{link} = ffxtree::read_hash($link_file) if $link_file && -s $link_file;
212 :     $opts->{tree} = ffxtree::read_tree();
213 :     $opts->{ncolor} = $ncolor || 10;
214 :     $opts->{title} = $title;
215 :     $opts->{gray} = $gray || 2;
216 :     $opts->{anno} = $anno;
217 :     $opts->{raw} = $raw;
218 :    
219 :     $opts->{color_by} ||= $raw ? 'none' : 'taxonomy';
220 :     $opts->{collapse_by} ||= $raw ? 'none' : 'genus';
221 :     $opts->{color_by} = undef if $opts->{color_by} =~ /none/i;
222 :     $opts->{collapse_by} = undef if $opts->{collapse_by} =~ /none/i;
223 :    
224 :     my $envParm = $ENV{SAS_SERVER};
225 :    
226 :     $ENV{SAS_SERVER} = 'PSEED' if $pseed;
227 :    
228 :     my $html = ffxtree::tree_to_html($opts);
229 :    
230 :     $ENV{SAS_SERVER} = $envParm if $pseed;
231 :    
232 :     print $html;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3