annotate tools/mytools/dreme_out/dreme.html @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2 <html>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 <head>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 <title>DREME</title>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 <style type="text/css">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 /* START INCLUDED FILE "meme.css" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 /* The following is the content of meme.css */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 body { background-color:white; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 div.help {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 display: inline-block;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 margin: 0px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 padding: 0px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 width: 12px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 height: 13px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 cursor: pointer;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 background-image: url("help.gif");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAANAQMAAACn5x0BAAAAAXNSR0IArs4c6QAAAAZQTFRFAAAAnp6eqp814gAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH2gMJBQgGYqhNZQAAACZJREFUCNdj+P+BoUGAoV+AYeYEEGoWYGgTYGgRAAm2gRGQ8f8DAOnhC2lYnqs6AAAAAElFTkSuQmCC");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 div.help2 {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24 color: #999;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 display: inline-block;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 width: 12px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 height: 12px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 border: 1px solid #999;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 font-size: 13px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 line-height:12px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 font-family: Helvetica, sans-serif;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 font-weight: bold;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 font-style: normal;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 cursor: pointer;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 div.help2:hover {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 color: #000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 border-color: #000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 p.spaced { line-height: 1.8em;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
42
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
43 span.citation { font-family: "Book Antiqua", "Palatino Linotype", serif; color: #004a4d;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
44
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
45 p.pad { padding-left: 30px; padding-top: 5px; padding-bottom: 10px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
46
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
47 td.jump { font-size: 13px; color: #ffffff; background-color: #00666a;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
48 font-family: Georgia, "Times New Roman", Times, serif;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
49
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
50 a.jump { margin: 15px 0 0; font-style: normal; font-variant: small-caps;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
51 font-weight: bolder; font-family: Georgia, "Times New Roman", Times, serif;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
52
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
53 h2.mainh {font-size: 1.5em; font-style: normal; margin: 15px 0 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
54 font-variant: small-caps; font-family: Georgia, "Times New Roman", Times, serif;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
55
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
56 h2.line {border-bottom: 1px solid #CCCCCC; font-size: 1.5em; font-style: normal;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
57 margin: 15px 0 0; padding-bottom: 3px; font-variant: small-caps;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
58 font-family: Georgia, "Times New Roman", Times, serif;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
59
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
60 h4 {border-bottom: 1px solid #CCCCCC; font-size: 1.2em; font-style: normal;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
61 margin: 10px 0 0; padding-bottom: 3px; font-family: Georgia, "Times New Roman", Times, serif;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
62
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
63 h5 {margin: 0px}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
64
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
65 a.help { font-size: 9px; font-style: normal; text-transform: uppercase;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
66 font-family: Georgia, "Times New Roman", Times, serif;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
67
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
68 div.pad { padding-left: 30px; padding-top: 5px; padding-bottom: 10px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
69
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
70 div.pad1 { margin: 10px 5px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
71
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
72 div.pad2 { margin: 25px 5px 5px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
73 h2.pad2 { padding: 25px 5px 5px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
74
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
75 div.pad3 { padding: 5px 0px 10px 30px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
76
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
77 div.box { border: 2px solid #CCCCCC; padding:10px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
78
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
79 div.bar { border-left: 7px solid #00666a; padding:5px; margin-top:25px; }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
80
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
81 div.subsection {margin:25px 0px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
82
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
83 img {border:0px none;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
84
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
85 th.majorth {text-align:left;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
86 th.minorth {font-weight:normal; text-align:left; width:8em; padding: 3px 0px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
87 th.actionth {font-weight:normal; text-align:left;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
88
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
89 .strand_name {text-align:left;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
90 .strand_side {padding:0px 10px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
91 .strand_start {padding:0px 10px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
92 .strand_pvalue {text-align:center; padding:0px 10px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
93 .strand_lflank {text-align:right; padding-right:5px; font-weight:bold; font-size:large; font-family: 'Courier New', Courier, monospace; color:gray;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
94 .strand_seq {text-align:center; font-weight:bold; font-size:large; font-family: 'Courier New', Courier, monospace;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
95 .strand_rflank {text-align:left; padding-left:5px; font-weight:bold; font-size:large; font-family: 'Courier New', Courier, monospace; color:gray;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
96
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
97 .block_td {height:25px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
98 .block_container {position:relative; width:99%; height:25px; padding:0px; margin:0px;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
99 .block_motif {position:absolute; z-index:3; height:12px; top:0px; text-align:center; vertical-align:middle; background-color:cyan;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
100 .block_rule {position:absolute; z-index:2; width:100%; height:1px; top:12px; left:0px; background-color:gray;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
101 .block_plus_sym {position:absolute; z-index:4; width:12px; height:12px; top:0px; left:0px; color:gray;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
102 .block_minus_sym {position:absolute; z-index:4; width:12px; height:12px; top:13px; left:0px; color:gray;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
103
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
104 .tic_major {position:absolute; border-left:2px solid blue; height:0.5em; top:0em;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
105 .tic_minor {position:absolute; border-left:1px solid blue; height:0.2em; top:0em;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
106 .tic_label {position:absolute; top:0.5em; height: 1em; text-align:center; vertical-align:middle}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
107
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
108 .explain h5 {font-size:1em; margin-left: 1em;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
109
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
110 div.doc {margin-left: 2em; margin-bottom: 3em;}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
111
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
112 div.tabArea {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
113 font-size: 80%;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
114 font-weight: bold;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
115 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
116
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
117 a.tab {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
118 background-color: #ddddff;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
119 border: 1px solid #000000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
120 padding: 2px 1em 2px 1em;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
121 text-decoration: none;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
122 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
123 div.tabArea.base a.tab {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
124 border-top-width: 0px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
125 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
126 div.tabArea.top a.tab {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
127 border-bottom-width: 0px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
128 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
129
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
130 a.tab, a.tab:visited {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
131 color: #808080;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
132 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
133
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
134 a.tab:hover {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
135 background-color: #d0d0d0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
136 color: #606060;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
137 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
138 a.tab.activeTab, a.tab.activeTab:hover, a.tab.activeTab:visited {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
139 background-color: #f0f0f0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
140 color: #000000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
141 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
142 div.tabMain {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
143 border: 1px solid #000000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
144 background-color: #ffffff;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
145 padding: 5px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
146 margin-right: 5px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
147 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
148 th.trainingset {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
149 border-bottom: thin dashed black;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
150 font-weight:normal;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
151 padding:0px 10px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
152 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
153 .dnaseq {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
154 font-weight: bold;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
155 font-size: large;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
156 font-family: 'Courier New', Courier, monospace;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
157 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
158 .dna_A {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
159 color: rgb(204,0,0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
160 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
161 .dna_C {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
162 color: rgb(0,0,204);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
163 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
164 .dna_G {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
165 color: rgb(255,179,0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
166 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
167 .dna_T {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
168 color: rgb(0,128,0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
169 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
170 /* END INCLUDED FILE "meme.css" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
171
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
172
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
173
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
174 /* START INCLUDED FILE "dreme-to-html.css" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
175 table.dreme_motifs tr th, table.dreme_motifs tr td {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
176 padding: 0px 10px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
177 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
178
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
179 div.popup_wrapper {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
180 position:fixed;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
181 z-index:2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
182 width:100%;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
183 height:0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
184 top:50%;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
185 left:0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
186 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
187
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
188 div.popup {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
189 width: 400px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
190 z-index:2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
191 margin-left: auto;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
192 margin-right: auto;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
193 padding: 5px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
194 background: #FFF;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
195 border-style: double;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
196 border-width: 5px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
197 border-color: #00666a;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
198 position:relative;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
199 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
200
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
201 div.grey_background {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
202 position:fixed;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
203 z-index: 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
204 background-color: #000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
205 -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
206 filter: alpha(opacity=50);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
207 opacity: 0.5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
208 left: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
209 top: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
210 width: 100%;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
211 height: 100%;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
212
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
213 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
214 td.symaction {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
215 text-align: center;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
216 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
217 *.symaction {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
218 font-size: 20px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
219 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
220
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
221 div.close {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
222 cursor: pointer;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
223 border: 1px solid black;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
224 width:15px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
225 height:15px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
226 line-height:15px; /* this causes vertical centering */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
227 text-align:center;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
228 background-color:#FFF;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
229 color:#000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
230 font-size:15px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
231 font-family:monospace;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
232 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
233
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
234 div.close:hover {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
235 color:#FFF;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
236 background-color:#000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
237 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
238
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
239 div.navnum {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
240 width:100%;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
241 height:20px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
242 line-height:20px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
243 text-align:center;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
244 font-size:medium;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
245 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
246
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
247 a.navarrow {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
248 font-size: 30px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
249 text-decoration:none;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
250 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
251
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
252 a.inactive {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
253 color:#CCC;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
254 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
255
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
256 div.actionbutton {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
257 cursor: pointer;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
258 font-size: 18px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
259 line-height:20px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
260 padding: 5px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
261 margin: 10px 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
262 border: 1px solid black;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
263 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
264
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
265 div.actionbutton:hover {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
266 color:#FFF;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
267 background-color:#000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
268 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
269
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
270 div.pop_content {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
271 position:absolute;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
272 z-index:1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
273 width:300px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
274 padding: 5px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
275 background: #E4ECEC;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
276 font-size: 12px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
277 font-family: Arial;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
278 border-style: double;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
279 border-width: 3px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
280 border-color: #AA2244;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
281 display:none;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
282 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
283 span.sort_dir {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
284 text-decoration: none;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
285 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
286
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
287 div.section_title {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
288 font-weight: bold;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
289 cursor: pointer;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
290 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
291
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
292 div.section_title.inactive {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
293 color: #000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
294 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
295
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
296 div.section_title.inactive:hover {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
297 color: #000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
298 text-decoration:underline;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
299 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
300
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
301 div.section_title label {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
302 cursor: pointer;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
303 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
304
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
305 span.ellipsis {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
306 display: inline-block;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
307 border: 1px solid black;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
308 padding: 0 2px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
309 margin: 0 2px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
310 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
311
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
312 div.section_title.inactive:hover span.ellipsis {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
313 color: #FFF;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
314 background-color: #000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
315 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
316
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
317 div.section_title.inactive span.toggle {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
318 color: #000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
319 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
320
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
321 div.section_data {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
322 margin-left: 20px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
323 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
324 tr.rule td, tr.rule th {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
325 border-bottom: 1px solid #CCC;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
326 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
327
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
328 h1.compact, h2.compact, h3.compact, h4.compact, h5.compact, h6.compact {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
329 margin:0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
330 padding:0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
331 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
332
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
333 ul.programs {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
334 margin-top: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
335 padding-top: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
336 margin-bottom: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
337 padding-bottom: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
338 margin-left: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
339 padding-left: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
340 list-style: none;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
341 border-bottom: 1px solid black;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
342 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
343
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
344 ul.programs li {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
345 border: 1px solid black;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
346 border-bottom-width: 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
347 background-color: #EFE;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
348 cursor: default;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
349 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
350
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
351 ul.programs li.active {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
352 background-color: #CFC;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
353 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
354
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
355 ul.programs li.selected {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
356 background-color: #262;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
357 color: #FFF;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
358 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
359
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
360 div.programs_scroll {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
361 width: 100%;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
362 height: 90px;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
363 overflow-y: auto;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
364 overflow-x: hidden;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
365 margin: 0 auto;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
366 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
367 /* END INCLUDED FILE "dreme-to-html.css" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
368
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
369 </style>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
370 <script type="text/javascript">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
371 var pos_count = 3;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
372 var neg_count = 3;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
373 var motif_seqs = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
374
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
375
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
376 /* START INCLUDED FILE "delay_draw.js" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
377 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
378 // Functions to measure the position of page elements relative to the size of the page
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
379 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
380
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
381 // gets the offset of the top of the page due to scrolling
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
382 // from: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
383 function get_scroll_xy() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
384 var scrOfX = 0, scrOfY = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
385 if( typeof( window.pageYOffset ) == 'number' ) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
386 //Netscape compliant
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
387 scrOfY = window.pageYOffset;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
388 scrOfX = window.pageXOffset;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
389 } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
390 //DOM compliant
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
391 scrOfY = document.body.scrollTop;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
392 scrOfX = document.body.scrollLeft;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
393 } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
394 //IE6 standards compliant mode
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
395 scrOfY = document.documentElement.scrollTop;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
396 scrOfX = document.documentElement.scrollLeft;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
397 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
398 return [ scrOfX, scrOfY ];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
399 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
400
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
401 // gets the width and height of the visible page
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
402 // from: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
403 function get_page_size() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
404 var myWidth = 0, myHeight = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
405 if( typeof( window.innerWidth ) == 'number' ) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
406 //Non-IE
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
407 myWidth = window.innerWidth;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
408 myHeight = window.innerHeight;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
409 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
410 //IE 6+ in 'standards compliant mode'
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
411 myWidth = document.documentElement.clientWidth;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
412 myHeight = document.documentElement.clientHeight;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
413 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
414 //IE 4 compatible
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
415 myWidth = document.body.clientWidth;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
416 myHeight = document.body.clientHeight;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
417 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
418 return [myWidth, myHeight];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
419 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
420
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
421 // gets the x and y offset of an element
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
422 // from http://www.quirksmode.org/js/findpos.html
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
423 function get_elem_xy(elem) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
424 var myX = myY = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
425 if (elem.offsetParent) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
426 do {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
427 myX += elem.offsetLeft;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
428 myY += elem.offsetTop;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
429 } while (elem = elem.offsetParent);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
430 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
431 return [myX, myY];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
432 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
433
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
434 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
435 // Functions to delay a drawing task until it is required or it would not lag the display to do so
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
436 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
437
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
438 // a list of items still to be drawn
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
439 var drawable_list = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
440 // the delay between drawing objects that are not currently visible
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
441 var draw_delay = 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
442 // the delay after a user interaction
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
443 var user_delay = 300;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
444 // the delay after a user has stopped scrolling and is viewing the stuff drawn on the current page
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
445 var stop_delay = 2000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
446 // the timer handle; allows resetting of the timer after user interactions
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
447 var draw_timer = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
448
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
449 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
450 // Drawable
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
451 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
452 // elem - a page element which defines the position on the page that drawing is to be done
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
453 // task - an object with the method run which takes care of painting the object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
454 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
455 function Drawable(elem, task) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
456 this.elem = elem;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
457 this.task = task;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
458 this.is_visible = Drawable_is_visible;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
459 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
460
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
461 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
462 // Drawable_is_visible
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
463 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
464 // Determines if the drawable object is in the visible part of the page.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
465 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
466 // page_top - the distance to the top of the page for the visible region
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
467 // page_height - the height of the visible region
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
468 function Drawable_is_visible(page_top, page_height) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
469 var elem_top = get_elem_xy(this.elem)[1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
470 var elem_height = this.elem.height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
471 if (typeof (elem_height) != 'number') elem_height = 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
472 return ((elem_top + elem_height) >= page_top && elem_top <= (page_top + page_height));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
473 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
474
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
475 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
476 // draw_on_screen
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
477 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
478 // Checks each drawable object and draws those on screen.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
479 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
480 function draw_on_screen() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
481 var found = false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
482 var page_top = get_scroll_xy()[1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
483 var page_height = get_page_size()[1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
484 for (var i = 0; i < drawable_list.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
485 var drawable = drawable_list[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
486 if (drawable.is_visible(page_top, page_height)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
487 drawable.task.run();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
488 drawable_list.splice(i--, 1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
489 found = true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
490 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
491 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
492 return found;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
493 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
494
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
495 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
496 // process_draw_tasks
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
497 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
498 // Called on a delay to process the next avaliable
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
499 // draw task.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
500 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
501 function process_draw_tasks() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
502 var delay = draw_delay;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
503 draw_timer = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
504 if (drawable_list.length == 0) return; //no more tasks
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
505 if (draw_on_screen()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
506 delay = stop_delay; //give the user a chance to scroll
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
507 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
508 //get next task
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
509 var drawable = drawable_list.shift();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
510 drawable.task.run();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
511 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
512 //allow UI updates between tasks
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
513 draw_timer = window.setTimeout("process_draw_tasks()", draw_delay);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
514 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
515
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
516 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
517 // delayed_process_draw_tasks
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
518 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
519 // Call process_draw_tasks after a short delay.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
520 // The delay serves to group multiple redundant events.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
521 // Should be set as event handler for onscroll and onresize.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
522 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
523 function delayed_process_draw_tasks() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
524 //reset the timer
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
525 if (drawable_list.length > 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
526 if (draw_timer != null) clearTimeout(draw_timer);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
527 draw_timer = window.setTimeout("process_draw_tasks()", user_delay);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
528 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
529 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
530
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
531 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
532 // add_draw_task
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
533 //
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
534 // Add a drawing task to be called immediately if it is
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
535 // visible, or to be called on a delay to reduce stuttering
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
536 // effect on the web browser.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
537 function add_draw_task(elem, task) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
538 var page_top = get_scroll_xy()[1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
539 var page_height = get_page_size()[1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
540 drawable = new Drawable(elem, task);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
541 if (drawable.is_visible(page_top, page_height)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
542 task.run();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
543 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
544 drawable_list.push(drawable);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
545 //reset timer
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
546 if (draw_timer != null) clearTimeout(draw_timer);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
547 draw_timer = window.setTimeout("process_draw_tasks()", user_delay);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
548 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
549 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
550
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
551 /* END INCLUDED FILE "delay_draw.js" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
552
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
553
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
554
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
555 /* START INCLUDED FILE "motif_logo.js" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
556 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
557 // start Alphabet object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
558 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
559 function Alphabet(alphabet, bg) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
560 //variable prototype
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
561 this.freqs = new Array();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
562 this.alphabet = new Array();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
563 this.letter_count = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
564 //method prototype
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
565 this.get_ic = Alphabet_get_ic;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
566 this.get_size = Alphabet_get_size;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
567 this.get_index = Alphabet_get_index;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
568 this.get_letter = Alphabet_get_letter;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
569 this.get_colour = Alphabet_get_colour;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
570 this.get_bg_freq = Alphabet_get_bg_freq;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
571 this.is_nucleotide = Alphabet_is_nucleotide;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
572 this.is_ambig = Alphabet_is_ambig;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
573 this.toString = Alphabet_to_string;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
574 //construct
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
575 var is_letter = /^\w$/;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
576 var is_prob = /^((1(\.0+)?)|(0(\.\d+)?))$/;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
577 for (var pos = 0; pos < alphabet.length; pos++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
578 var letter = alphabet.charAt(pos);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
579 if (is_letter.test(letter)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
580 this.alphabet[this.letter_count] = letter.toUpperCase();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
581 this.freqs[this.letter_count] = -1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
582 this.letter_count++;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
583 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
584 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
585 if (!(bg === undefined)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
586 var parts = bg.split(/\s+/);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
587 for (var i = 0, pos = 0; (i + 1) < parts.length; i += 2) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
588 var letter = parts[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
589 var freq = parts[i+1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
590 if (is_letter.test(letter) && is_prob.test(freq)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
591 letter = letter.toUpperCase(); //find the letter it matches
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
592 for (;pos < this.letter_count; pos++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
593 if (this.alphabet[pos] == letter) break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
594 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
595 if (pos >= this.letter_count) throw "NOT_IN_ALPHABET";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
596 this.freqs[pos] = (+freq);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
597 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
598 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
599 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
600 //assume uniform background
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
601 var freq = 1.0 / this.letter_count;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
602 for (var pos = 0; pos < this.letter_count; pos++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
603 this.freqs[pos] = freq;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
604 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
605 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
606 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
607
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
608
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
609 function Alphabet_get_ic() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
610 if (this.is_nucleotide()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
611 return 2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
612 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
613 return Math.log(20) / Math.LN2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
614 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
615 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
616
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
617 function Alphabet_get_size() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
618 return this.letter_count;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
619 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
620
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
621 function Alphabet_get_letter(alph_index) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
622 if (alph_index < 0 || alph_index >= this.letter_count) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
623 throw "BAD_ALPHABET_INDEX";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
624 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
625 return this.alphabet[alph_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
626 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
627
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
628 function Alphabet_get_bg_freq(alph_index) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
629 if (alph_index < 0 || alph_index >= this.letter_count) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
630 throw "BAD_ALPHABET_INDEX";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
631 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
632 if (this.freqs[alph_index] == -1) throw "BG_FREQ_NOT_SET";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
633 return this.freqs[alph_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
634 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
635
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
636 function Alphabet_get_colour(alph_index) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
637 var red = "rgb(204,0,0)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
638 var blue = "rgb(0,0,204)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
639 var orange = "rgb(255,179,0)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
640 var green = "rgb(0,128,0)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
641 var yellow = "rgb(255,255,0)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
642 var purple = "rgb(204,0,204)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
643 var magenta = "rgb(255,0,255)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
644 var pink = "rgb(255,204,204)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
645 var turquoise = "rgb(51,230,204)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
646 if (alph_index < 0 || alph_index >= this.letter_count) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
647 throw "BAD_ALPHABET_INDEX";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
648 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
649 if (this.is_nucleotide()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
650 switch (this.alphabet[alph_index]) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
651 case "A":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
652 return red;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
653 case "C":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
654 return blue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
655 case "G":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
656 return orange;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
657 case "T":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
658 return green;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
659 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
660 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
661 switch (this.alphabet[alph_index]) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
662 case "A":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
663 case "C":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
664 case "F":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
665 case "I":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
666 case "L":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
667 case "V":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
668 case "W":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
669 case "M":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
670 return blue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
671 case "N":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
672 case "Q":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
673 case "S":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
674 case "T":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
675 return green;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
676 case "D":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
677 case "E":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
678 return magenta;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
679 case "K":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
680 case "R":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
681 return red;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
682 case "H":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
683 return pink;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
684 case "G":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
685 return orange;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
686 case "P":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
687 return yellow;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
688 case "Y":
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
689 return turquoise;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
690 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
691 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
692 return "black";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
693 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
694
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
695 function Alphabet_is_ambig(alph_index) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
696 if (alph_index < 0 || alph_index >= this.letter_count) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
697 throw "BAD_ALPHABET_INDEX";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
698 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
699 if (this.is_nucleotide()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
700 return ("ACGT".indexOf(this.alphabet[alph_index]) == -1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
701 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
702 return ("ACDEFGHIKLMNPQRSTVWY".indexOf(this.alphabet[alph_index]) == -1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
703 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
704 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
705
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
706 function Alphabet_get_index(letter) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
707 for (i = 0; i < this.letter_count; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
708 if (this.alphabet[i] == letter.toUpperCase()) return i;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
709 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
710 throw "UNKNOWN_LETTER";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
711 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
712
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
713 function Alphabet_is_nucleotide() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
714 //TODO basic method, make better
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
715 if (this.letter_count < 20) return true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
716 return false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
717 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
718
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
719 function Alphabet_to_string() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
720 return (this.is_nucleotide() ? "Nucleotide" : "Protein") + " Alphabet " + (this.alphabet.join(""));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
721 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
722
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
723 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
724 // end Alphabet object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
725 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
726
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
727 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
728 // start Symbol object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
729 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
730 function Symbol(alph_index, scale, alphabet) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
731 //variable prototype
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
732 this.symbol = alphabet.get_letter(alph_index);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
733 this.scale = scale;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
734 this.colour = alphabet.get_colour(alph_index);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
735 //function prototype
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
736 this.get_symbol = Symbol_get_symbol;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
737 this.get_scale = Symbol_get_scale;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
738 this.get_colour = Symbol_get_colour;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
739 this.toString = Symbol_to_string;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
740 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
741
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
742 function Symbol_get_symbol() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
743 return this.symbol;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
744 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
745
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
746 function Symbol_get_scale() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
747 return this.scale;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
748 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
749
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
750 function Symbol_get_colour() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
751 return this.colour;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
752 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
753
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
754 function Symbol_to_string() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
755 return this.symbol + " " + (Math.round(this.scale*1000)/10) + "%";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
756 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
757
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
758 function compare_symbol(sym1, sym2) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
759 if (sym1.get_scale() < sym2.get_scale()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
760 return -1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
761 } else if (sym1.get_scale() > sym2.get_scale()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
762 return 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
763 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
764 return 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
765 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
766 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
767 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
768 // end Symbol object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
769 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
770
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
771 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
772 // start Pspm object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
773 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
774 function Pspm(pspm, name, ltrim, rtrim, nsites, evalue) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
775 if (ltrim === undefined) ltrim = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
776 if (rtrim === undefined) rtrim = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
777 if (nsites === undefined) nsites = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
778 if (evalue === undefined) evalue = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
779 //variable prototype
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
780 this.alph_length = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
781 this.motif_length = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
782 this.pspm = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
783 this.name = (typeof name == "string" ? name : "");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
784 this.nsites = nsites;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
785 this.evalue = evalue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
786 this.ltrim = ltrim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
787 this.rtrim = rtrim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
788 //function prototype
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
789 this.copy = Pspm_copy;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
790 this.reverse_complement = Pspm_reverse_complement;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
791 this.get_stack = Pspm_get_stack;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
792 this.get_stack_ic = Pspm_get_stack_ic;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
793 this.get_motif_length = Pspm_get_motif_length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
794 this.get_alph_length = Pspm_get_alph_length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
795 this.get_left_trim = Pspm_get_left_trim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
796 this.get_right_trim = Pspm_get_right_trim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
797 this.as_pspm = Pspm_as_pspm;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
798 this.as_pssm = Pspm_as_pssm;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
799 this.toString = Pspm_to_string;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
800 //construct
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
801 if (typeof pspm == "string") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
802 var pspm_header = /letter-probability matrix:\s+alength=\s+(\d+)\s+w=\s+(\d+)(\s+nsites=\s+(\S+))?(\s+E=\s+(\S+))?\s*/;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
803 var lines = pspm.split(/\n/);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
804 var read_pspm = false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
805 var line_num = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
806 var col_num = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
807 this.pspm = new Array();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
808 for (line_index in lines) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
809 //exclude inherited properties and undefined properties
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
810 if (!lines.hasOwnProperty(line_index) || lines[line_index] === undefined) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
811
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
812 var line = trim(lines[line_index]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
813 if (line == '') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
814 continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
815 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
816 if (!read_pspm) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
817 var header_match = pspm_header.exec(line);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
818 if (header_match != null) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
819 read_pspm = true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
820 this.alph_length = (+header_match[1]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
821 this.motif_length = (+header_match[2]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
822 if (header_match[4]) this.nsites = parseFloat(header_match[4]);//not always an integer
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
823 if (header_match[6]) this.evalue = parseFloat(header_match[6]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
824 this.pspm = new Array(this.motif_length);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
825 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
826 continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
827 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
828 if (line_num >= this.motif_length) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
829 throw "TOO_MANY_ROWS";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
830 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
831 this.pspm[line_num] = new Array(this.alph_length);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
832 col_num = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
833 var parts = line.split(/\s+/);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
834 for (part_index in parts) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
835 //exclude inherited properties and undefined properties
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
836 if (!parts.hasOwnProperty(part_index) || parts[part_index] === undefined) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
837
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
838 var prob = parts[part_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
839 if (col_num >= this.alph_length) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
840 throw "TOO_MANY_COLS";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
841 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
842 this.pspm[line_num][col_num] = (+prob);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
843 //check the probability is within bounds
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
844 if (this.pspm[line_num][col_num] > 1 || this.pspm[line_num][col_num] < 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
845 throw "NUM_NOT_PROB";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
846 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
847 col_num++;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
848 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
849 if (col_num != this.alph_length) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
850 throw "TOO_FEW_COLS";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
851 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
852 line_num++;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
853 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
854 if (line_num != this.motif_length) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
855 throw "TOO_FEW_ROWS";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
856 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
857 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
858 // assume pspm is a nested array
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
859 this.motif_length = pspm.length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
860 this.alpha_length = (pspm.length > 0 ? pspm[0].length : 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
861 this.pspm = new Array(this.motif_length);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
862 // copy pspm and check
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
863 for (var row = 0; row < this.motif_length; row++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
864 if (this.alpha_length != pspm[row].length) throw "COLUMN_MISMATCH";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
865 this.pspm[row] = new Array(this.alpha_length);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
866 var row_sum = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
867 for (var col = 0; col < this.alpha_length; col++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
868 row_sum += this.pspm[row][col];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
869 this.pspm[row][col] = 0 + pspm[row][col];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
870 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
871 var delta = 0.1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
872 if ((row_sum > 1 && (row_sum - 1) > delta) ||
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
873 (row_sum < 1 && (1 - row_sum) > delta)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
874 throw "INVALID_SUM";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
875 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
876 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
877 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
878 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
879
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
880 function Clone() {}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
881
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
882 function Pspm_copy() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
883 Clone.prototype = this;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
884 var clone = new Clone();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
885 //so far only a shallow copy, need to copy everything
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
886 clone.alph_length = (0+this.alph_length);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
887 clone.motif_length = (0+this.motif_length);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
888 clone.name = (""+this.name);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
889 clone.nsites = (0+this.nsites);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
890 clone.evalue = (0+this.evalue);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
891 clone.ltrim = (0+this.ltrim);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
892 clone.rtrim = (0+this.rtrim);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
893 clone.pspm = new Array(this.motif_length);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
894 for (row = 0; row < this.motif_length; row++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
895 clone.pspm[row] = new Array(this.alph_length);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
896 for (col = 0; col < this.alph_length; col++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
897 clone.pspm[row][col] = (0+this.pspm[row][col]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
898 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
899 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
900 return clone;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
901 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
902
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
903 function Pspm_reverse_complement(alphabet) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
904 if (this.alph_length != alphabet.get_size()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
905 throw "ALPHABET_MISMATCH";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
906 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
907 if (!alphabet.is_nucleotide()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
908 throw "NO_PROTEIN_RC";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
909 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
910 //reverse
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
911 var x = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
912 var y = this.motif_length-1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
913 while (x < y) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
914 var temp = this.pspm[x];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
915 this.pspm[x] = this.pspm[y];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
916 this.pspm[y] = temp;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
917 x++;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
918 y--;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
919 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
920 //complement
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
921 var a_index = alphabet.get_index("A");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
922 var c_index = alphabet.get_index("C");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
923 var g_index = alphabet.get_index("G");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
924 var t_index = alphabet.get_index("T");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
925 for (i = 0; i < this.motif_length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
926 var row = this.pspm[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
927 //swap A and T
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
928 var temp = row[a_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
929 row[a_index] = row[t_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
930 row[t_index] = temp;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
931 //swap C and G
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
932 temp = row[c_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
933 row[c_index] = row[g_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
934 row[g_index] = temp;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
935 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
936 //swap triming
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
937 var temp_trim = this.ltrim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
938 this.ltrim = this.rtrim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
939 this.rtrim = temp_trim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
940 //note that ambigs are ignored because they don't effect motifs
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
941 return this; //allow function chaining...
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
942 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
943
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
944 function Pspm_get_stack(position, alphabet) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
945 if (this.alph_length != alphabet.get_size()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
946 throw "ALPHABET_MISMATCH";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
947 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
948 var row = this.pspm[position];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
949 var stack_ic = this.get_stack_ic(position, alphabet);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
950 var alphabet_ic = alphabet.get_ic();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
951 var stack = new Array();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
952 for (i = 0; i < this.alph_length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
953 if (alphabet.is_ambig(i)) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
954 var sym = new Symbol(i, row[i]*stack_ic/alphabet_ic, alphabet);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
955 if (sym.get_scale() <= 0) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
956 stack.push(sym);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
957 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
958 stack.sort(compare_symbol);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
959 return stack;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
960 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
961
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
962 function Pspm_get_stack_ic(position, alphabet) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
963 if (this.alph_length != alphabet.get_size()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
964 throw "ALPHABET_MISMATCH";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
965 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
966 var row = this.pspm[position];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
967 var H = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
968 for (var i = 0; i < this.alph_length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
969 if (alphabet.is_ambig(i)) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
970 if (row[i] == 0) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
971 H -= (row[i] * (Math.log(row[i]) / Math.LN2));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
972 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
973 return alphabet.get_ic() - H;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
974 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
975
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
976 function Pspm_get_error(alphabet) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
977 var asize;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
978 if (this.nsites == 0) return 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
979 if (alphabet.is_nucleotide()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
980 asize = 4;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
981 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
982 asize = 20;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
983 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
984 return (asize-1) / (2 * Math.log(2)*this.nsites);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
985 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
986
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
987 function Pspm_get_motif_length() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
988 return this.motif_length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
989 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
990
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
991 function Pspm_get_alph_length() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
992 return this.alph_length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
993 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
994
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
995 function Pspm_get_left_trim() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
996 return this.ltrim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
997 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
998
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
999 function Pspm_get_right_trim() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1000 return this.rtrim;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1001 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1002
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1003 function Pspm_as_pspm() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1004 var out = "letter-probability matrix: alength= " + this.alph_length +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1005 " w= " + this.motif_length + " nsites= " + this.nsites +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1006 " E= " + this.evalue.toExponential() + "\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1007 for (var row = 0; row < this.motif_length; row++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1008 for (var col = 0; col < this.alph_length; col++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1009 if (col != 0) out += " ";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1010 out += this.pspm[row][col].toFixed(6);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1011 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1012 out += "\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1013 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1014 return out;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1015 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1016
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1017 function Pspm_as_pssm(alphabet, pseudo) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1018 if (typeof pseudo != "number") pseudo = 0.1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1019 var out = "log-odds matrix: alength= " + this.alph_length +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1020 " w= " + this.motif_length +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1021 " E= " + this.evalue.toExponential() + "\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1022 var log2 = Math.log(2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1023 var total = this.nsites + pseudo;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1024 for (var row = 0; row < this.motif_length; row++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1025 for (var col = 0; col < this.alph_length; col++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1026 if (col != 0) out += " ";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1027 var p = this.pspm[row][col];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1028 // to avoid log of zero we add a pseudo count
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1029 var bg = alphabet.get_bg_freq(col);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1030 var p2 = (p * this.nsites + bg * pseudo) / total;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1031 // now calculate the score
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1032 var score = -10000;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1033 if (p2 > 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1034 score = Math.round((Math.log(p2 / bg) / log2) * 100)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1035 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1036 out += score;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1037 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1038 out += "\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1039 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1040 return out;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1041 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1042
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1043 function Pspm_to_string() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1044 var str = "";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1045 for (row_index in this.pspm) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1046 //exclude inherited properties and undefined properties
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1047 if (!this.pspm.hasOwnProperty(row_index) || this.pspm[row_index] === undefined) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1048
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1049 var row = this.pspm[row_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1050 str += row.join("\t") + "\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1051 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1052 return str;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1053 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1054 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1055 // end Pspm object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1056 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1057
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1058 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1059 // start Logo object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1060 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1061 function Logo(alphabet, fine_text) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1062 this.alphabet = alphabet;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1063 this.fine_text = fine_text;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1064 this.pspm_list = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1065 this.pspm_column = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1066 this.rows = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1067 this.columns = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1068
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1069 //functions
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1070 this.add_pspm = Logo_add_pspm;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1071 this.get_columns = Logo_get_columns;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1072 this.get_rows = Logo_get_rows;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1073 this.get_pspm = Logo_get_pspm;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1074 this.get_offset = Logo_get_offset;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1075 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1076
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1077 function Logo_add_pspm(pspm, column) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1078 if (column === undefined) column = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1079 else if (column < 0) throw "COLUMN_OUT_OF_BOUNDS";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1080 this.pspm_list[this.rows] = pspm;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1081 this.pspm_column[this.rows] = column;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1082 this.rows++;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1083 var col = column + pspm.get_motif_length();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1084 if (col > this.columns) this.columns = col;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1085 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1086
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1087 function Logo_get_columns() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1088 return this.columns;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1089 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1090
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1091 function Logo_get_rows() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1092 return this.rows;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1093 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1094
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1095 function Logo_get_pspm(row_index) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1096 if (row_index < 0 || row_index >= this.rows) throw "INDEX_OUT_OF_BOUNDS";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1097 return this.pspm_list[row_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1098 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1099
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1100 function Logo_get_offset(row_index) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1101 if (row_index < 0 || row_index >= this.rows) throw "INDEX_OUT_OF_BOUNDS";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1102 return this.pspm_column[row_index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1103 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1104
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1105 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1106 // end Logo object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1107 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1108
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1109 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1110 // start RasterizedAlphabet
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1111 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1112
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1113 // Rasterize Alphabet
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1114 // 1) Measure width of text at default font for all symbols in alphabet
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1115 // 2) sort in width ascending
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1116 // 3) Drop the top and bottom 10% (designed to ignore outliers like 'W' and 'I')
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1117 // 4) Calculate the average as the maximum scaling factor (designed to stop I becoming a rectangular blob).
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1118 // 5) Assume scale of zero would result in width of zero, interpolate scale required to make perfect width font
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1119 // 6) Draw text onto temp canvas at calculated scale
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1120 // 7) Find bounds of drawn text
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1121 // 8) Paint on to another canvas at the desired height (but only scaling width to fit if larger).
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1122 function RasterizedAlphabet(alphabet, font, target_width) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1123 //variable prototypes
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1124 this.lookup = []; //a map of letter to index
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1125 this.rasters = []; //a list of rasters
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1126 this.dimensions = []; //a list of dimensions
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1127
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1128 //function prototypes
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1129 this.draw = RasterizedAlphabet_draw;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1130
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1131 //construct
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1132 var default_size = 60; // size of square to assume as the default width
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1133 var safety_pad = 20; // pixels to pad around so we don't miss the edges
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1134 // create a canvas to do our rasterizing on
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1135 var canvas = document.createElement("canvas");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1136 // assume the default font would fit in a canvas of 100 by 100
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1137 canvas.width = default_size + 2 * safety_pad;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1138 canvas.height = default_size + 2 * safety_pad;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1139 // check for canvas support before attempting anything
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1140 if (!canvas.getContext) throw "NO_CANVAS_SUPPORT";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1141 var ctx = canvas.getContext('2d');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1142 // check for html5 text drawing support
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1143 if (!supports_text(ctx)) throw "NO_CANVAS_TEXT_SUPPORT";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1144 // calculate the middle
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1145 var middle = Math.round(canvas.width / 2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1146 // calculate the baseline
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1147 var baseline = Math.round(canvas.height - safety_pad);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1148 // list of widths
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1149 var widths = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1150 var count = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1151 var letters = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1152 //now measure each letter in the alphabet
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1153 for (var i = 0; i < alphabet.get_size(); ++i) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1154 if (alphabet.is_ambig(i)) continue; //skip ambigs as they're never rendered
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1155 var letter = alphabet.get_letter(i);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1156 letters.push(letter);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1157 var pos = count++;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1158 this.lookup[letter] = pos;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1159 //clear the canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1160 canvas.width = canvas.width;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1161 // get the context and prepare to draw our width test
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1162 var ctx = canvas.getContext('2d');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1163 ctx.font = font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1164 ctx.fillStyle = alphabet.get_colour(i);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1165 ctx.textAlign = "center";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1166 ctx.translate(middle, baseline);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1167 // draw the test text
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1168 ctx.fillText(letter, 0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1169 //measure
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1170 var size = RasterizedAlphabet_measure(ctx, canvas.width, canvas.height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1171 if (size.width == 0) throw "INVISIBLE_LETTER"; //maybe the fill was white on white?
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1172 widths.push(size.width);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1173 this.dimensions[pos] = size;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1174 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1175 //sort the widths
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1176 widths.sort(function(a,b) {return a - b;});
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1177 //drop 10% of the items off each end
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1178 var tenpercent = Math.floor(widths.length / 10);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1179 for (var i = 0; i < tenpercent; ++i) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1180 widths.pop();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1181 widths.shift();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1182 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1183 //calculate average width
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1184 var avg_width = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1185 for (var i = 0; i < widths.length; ++i) avg_width += widths[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1186 avg_width /= widths.length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1187 // calculate scales
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1188 for (var i = 0; i < this.dimensions.length; ++i) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1189 var size = this.dimensions[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1190 // calculate scale
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1191 var scale = target_width / Math.max(avg_width, size.width);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1192 // estimate scaled height
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1193 var target_height = size.height * scale;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1194 // create an approprately sized canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1195 var raster = document.createElement("canvas");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1196 raster.width = target_width; // if it goes over the edge too bad...
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1197 raster.height = target_height + safety_pad * 2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1198 // calculate the middle
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1199 middle = Math.round(raster.width / 2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1200 // calculate the baseline
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1201 baseline = Math.round(raster.height - safety_pad);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1202 // get the context and prepare to draw the rasterized text
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1203 ctx = raster.getContext('2d');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1204 ctx.font = font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1205 ctx.fillStyle = alphabet.get_colour(i);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1206 ctx.textAlign = "center";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1207 ctx.translate(middle, baseline);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1208 ctx.save();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1209 ctx.scale(scale, scale);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1210 // draw the rasterized text
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1211 ctx.fillText(letters[i], 0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1212 ctx.restore();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1213 this.rasters[i] = raster;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1214 this.dimensions[i] = RasterizedAlphabet_measure(ctx, raster.width, raster.height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1215 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1216 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1217
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1218 function RasterizedAlphabet_measure(ctx, cwidth, cheight) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1219 var data = ctx.getImageData(0, 0, cwidth, cheight).data;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1220 var r = 0, c = 0;// r: row, c: column
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1221 var top_line = -1, bottom_line = -1, left_line = -1, right_line = -1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1222 var txt_width = 0, txt_height = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1223 // Find the top-most line with a non-white pixel
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1224 for (r = 0; r < cheight; r++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1225 for (c = 0; c < cwidth; c++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1226 if (data[r * cwidth * 4 + c * 4 + 3]) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1227 top_line = r;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1228 break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1229 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1230 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1231 if (top_line != -1) break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1232 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1233
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1234 //find the last line with a non-white pixel
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1235 if (top_line != -1) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1236 for (r = cheight-1; r >= top_line; r--) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1237 for(c = 0; c < cwidth; c++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1238 if(data[r * cwidth * 4 + c * 4 + 3]) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1239 bottom_line = r;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1240 break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1241 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1242 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1243 if (bottom_line != -1) break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1244 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1245 txt_height = bottom_line - top_line + 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1246 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1247
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1248 // Find the left-most line with a non-white pixel
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1249 for (c = 0; c < cwidth; c++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1250 for (r = 0; r < cheight; r++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1251 if (data[r * cwidth * 4 + c * 4 + 3]) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1252 left_line = c;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1253 break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1254 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1255 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1256 if (left_line != -1) break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1257 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1258
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1259 //find the right most line with a non-white pixel
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1260 if (left_line != -1) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1261 for (c = cwidth-1; c >= left_line; c--) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1262 for(r = 0; r < cheight; r++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1263 if(data[r * cwidth * 4 + c * 4 + 3]) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1264 right_line = c;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1265 break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1266 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1267 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1268 if (right_line != -1) break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1269 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1270 txt_width = right_line - left_line + 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1271 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1272
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1273 //return the bounds
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1274 return {bound_top: top_line, bound_bottom: bottom_line, bound_left: left_line, bound_right: right_line, width: txt_width, height: txt_height};
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1275 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1276
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1277 function RasterizedAlphabet_draw(ctx, letter, dx, dy, dWidth, dHeight) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1278 var index = this.lookup[letter];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1279 var raster = this.rasters[index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1280 var size = this.dimensions[index];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1281 ctx.drawImage(raster, 0, size.bound_top -1, raster.width, size.height+1, dx, dy, dWidth, dHeight);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1282 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1283
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1284 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1285 // end RasterizedAlphabet
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1286 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1287
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1288 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1289 // start LogoMetrics object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1290 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1291
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1292 function LogoMetrics(ctx, canvas_width, canvas_height, logo_columns, logo_rows, allow_space_for_names) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1293 if (allow_space_for_names === undefined) allow_space_for_names = false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1294 //variable prototypes
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1295 this.canvas_width = canvas_width;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1296 this.canvas_height = canvas_height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1297 this.scale_x = 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1298 this.scale_y = 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1299 this.pad_top = 5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1300 this.pad_left = 10;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1301 this.pad_right = 5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1302 this.pad_bottom = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1303 this.pad_middle = 20;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1304 this.name_height = 14;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1305 this.name_font = "bold " + this.name_height + "px Times, sans-serif";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1306 this.name_spacer = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1307 this.y_label = "bits"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1308 this.y_label_height = 12;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1309 this.y_label_font = "bold " + this.y_label_height + "px Helvetica, sans-serif";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1310 this.y_label_spacer = 3;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1311 this.y_num_height = 12;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1312 this.y_num_width = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1313 this.y_num_font = "bold " + this.y_num_height + "px Helvetica, sans-serif";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1314 this.y_tic_width = 5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1315 this.stack_pad_left = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1316 this.stack_font = "bold 25px Helvetica, sans-serif";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1317 this.stack_height = 90;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1318 this.stack_width = 26;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1319 this.stacks_pad_right = 5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1320 this.x_num_above = 2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1321 this.x_num_height = 12;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1322 this.x_num_width = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1323 this.x_num_font = "bold " + this.x_num_height + "px Helvetica, sans-serif";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1324 this.fine_txt_height = 6;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1325 this.fine_txt_above = 2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1326 this.fine_txt_font = "normal " + this.fine_txt_height + "px Helvetica, sans-serif";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1327 this.letter_metrics = new Array();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1328 this.summed_width = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1329 this.summed_height = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1330 //function prototypes
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1331 //none
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1332 //calculate the width of the y axis numbers
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1333 ctx.font = this.y_num_font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1334 for (var i = 0; i <= 2; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1335 this.y_num_width = Math.max(this.y_num_width, ctx.measureText("" + i).width);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1336 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1337 //calculate the width of the x axis numbers (but they are rotated so it becomes height)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1338 ctx.font = this.x_num_font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1339 for (var i = 1; i <= logo_columns; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1340 this.x_num_width = Math.max(this.x_num_width, ctx.measureText("" + i).width);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1341 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1342
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1343 //calculate how much vertical space we want to draw this
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1344 //first we add the padding at the top and bottom since that's always there
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1345 this.summed_height += this.pad_top + this.pad_bottom;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1346 //all except the last row have the same amount of space allocated to them
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1347 if (logo_rows > 1) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1348 var row_height = this.stack_height + this.pad_middle;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1349 if (allow_space_for_names) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1350 row_height += this.name_height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1351 //the label is allowed to overlap into the spacer
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1352 row_height += Math.max(this.y_num_height/2, this.name_spacer);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1353 //the label is allowed to overlap the space used by the other label
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1354 row_height += Math.max(this.y_num_height/2, this.x_num_height + this.x_num_above);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1355 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1356 row_height += this.y_num_height/2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1357 //the label is allowed to overlap the space used by the other label
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1358 row_height += Math.max(this.y_num_height/2, this.x_num_height + this.x_num_above);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1359 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1360 this.summed_height += row_height * (logo_rows - 1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1361 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1362 //the last row has the name and fine text below it but no padding
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1363 this.summed_height += this.stack_height + this.y_num_height/2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1364 if (allow_space_for_names) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1365 this.summed_height += this.fine_txt_height + this.fine_txt_above + this.name_height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1366 this.summed_height += Math.max(this.y_num_height/2, this.x_num_height + this.x_num_above + this.name_spacer);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1367 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1368 this.summed_height += Math.max(this.y_num_height/2, this.x_num_height + this.x_num_above + this.fine_txt_height + this.fine_txt_above);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1369 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1370
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1371 //calculate how much horizontal space we want to draw this
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1372 //first add the padding at the left and right since that's always there
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1373 this.summed_width += this.pad_left + this.pad_right;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1374 //add on the space for the y-axis label
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1375 this.summed_width += this.y_label_height + this.y_label_spacer;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1376 //add on the space for the y-axis
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1377 this.summed_width += this.y_num_width + this.y_tic_width;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1378 //add on the space for the stacks
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1379 this.summed_width += (this.stack_pad_left + this.stack_width) * logo_columns;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1380 //add on the padding after the stacks (an offset from the fine text)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1381 this.summed_width += this.stacks_pad_right;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1382
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1383 //calculate scaling factors
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1384 this.scale_y = this.canvas_height / this.summed_height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1385 this.scale_x = this.canvas_width / this.summed_width;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1386
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1387 //maintain aspect ratio
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1388 if (this.scale_y > this.scale_x) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1389 this.scale_y = this.scale_x;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1390 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1391 this.scale_x = this.scale_y;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1392 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1393
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1394
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1395 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1396
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1397 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1398 // end LogoMetrics object
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1399 //======================================================================
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1400
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1401
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1402 //found this trick at http://talideon.com/weblog/2005/02/detecting-broken-images-js.cfm
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1403 function image_ok(img) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1404 // During the onload event, IE correctly identifies any images that
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1405 // weren't downloaded as not complete. Others should too. Gecko-based
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1406 // browsers act like NS4 in that they report this incorrectly.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1407 if (!img.complete) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1408 return false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1409 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1410 // However, they do have two very useful properties: naturalWidth and
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1411 // naturalHeight. These give the true size of the image. If it failed
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1412 // to load, either of these should be zero.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1413 if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1414 return false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1415 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1416 // No other way of checking: assume it's ok.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1417 return true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1418 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1419
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1420 function supports_text(ctx) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1421 if (!ctx.fillText) return false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1422 if (!ctx.measureText) return false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1423 return true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1424 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1425
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1426 //draws the scale, returns the width
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1427 function draw_scale(ctx, metrics, alphabet_ic) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1428 var tic_height = metrics.stack_height / alphabet_ic;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1429 ctx.save();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1430 ctx.lineWidth = 1.5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1431 ctx.translate(metrics.y_label_height, metrics.y_num_height/2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1432 //draw the axis label
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1433 ctx.save();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1434 ctx.font = metrics.y_label_font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1435 ctx.translate(0, metrics.stack_height/2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1436 ctx.save();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1437 ctx.rotate(-(Math.PI / 2));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1438 ctx.textAlign = "center";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1439 ctx.fillText("bits", 0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1440 ctx.restore();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1441 ctx.restore();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1442
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1443 ctx.translate(metrics.y_label_spacer + metrics.y_num_width, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1444
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1445 //draw the axis tics
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1446 ctx.save();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1447 ctx.translate(0, metrics.stack_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1448 ctx.font = metrics.y_num_font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1449 ctx.textAlign = "right";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1450 ctx.textBaseline = "middle";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1451 for (var i = 0; i <= alphabet_ic; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1452 //draw the number
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1453 ctx.fillText("" + i, 0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1454 //draw the tic
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1455 ctx.beginPath();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1456 ctx.moveTo(0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1457 ctx.lineTo(metrics.y_tic_width, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1458 ctx.stroke();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1459 //prepare for next tic
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1460 ctx.translate(0, -tic_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1461 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1462 ctx.restore();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1463
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1464 ctx.translate(metrics.y_tic_width, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1465
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1466 ctx.beginPath();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1467 ctx.moveTo(0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1468 ctx.lineTo(0, metrics.stack_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1469 ctx.stroke();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1470
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1471 ctx.restore();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1472 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1473
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1474 function draw_stack_num(ctx, metrics, row_index) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1475 ctx.save();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1476 ctx.font = metrics.x_num_font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1477 ctx.translate(metrics.stack_width / 2, metrics.stack_height + metrics.x_num_above);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1478 ctx.save();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1479 ctx.rotate(-(Math.PI / 2));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1480 ctx.textBaseline = "middle"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1481 ctx.textAlign = "right"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1482 ctx.fillText("" + (row_index + 1), 0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1483 ctx.restore();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1484 ctx.restore();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1485 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1486
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1487 function draw_stack(ctx, metrics, symbols, raster) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1488 var preferred_pad = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1489 var sym_min = 5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1490
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1491 ctx.save();//1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1492 ctx.translate(0, metrics.stack_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1493 for (var i in symbols) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1494 //exclude inherited properties and undefined properties
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1495 if (!symbols.hasOwnProperty(i) || symbols[i] === undefined) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1496
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1497 var sym = symbols[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1498 var sym_height = metrics.stack_height * sym.get_scale();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1499
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1500 var pad = preferred_pad;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1501 if (sym_height - pad < sym_min) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1502 pad = Math.min(pad, Math.max(0, sym_height - sym_min));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1503 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1504 sym_height -= pad;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1505
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1506 //translate to the correct position
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1507 ctx.translate(0, -(pad/2 + sym_height));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1508 //draw
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1509 raster.draw(ctx, sym.get_symbol(), 0, 0, metrics.stack_width, sym_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1510 //translate past the padding
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1511 ctx.translate(0, -(pad/2));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1512 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1513 ctx.restore();//1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1514 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1515
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1516 //draws a stack of symbols
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1517 function draw_stack_old(ctx, metrics, symbols) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1518 var lpad = 2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1519 var sym_min = 5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1520 var pos = metrics.stack_height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1521 for (var i in symbols) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1522 //exclude inherited properties and undefined properties
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1523 if (!symbols.hasOwnProperty(i) || symbols[i] === undefined) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1524
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1525 var sym = symbols[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1526 var sym_height = metrics.stack_height*sym.get_scale();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1527 var letter = metrics.get_letter_metrics(sym.get_symbol());
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1528 //attempting to draw something smaller than a pixel causes display corruption
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1529 if (sym_height >= 1) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1530 //it's better to see the letter than to pad it
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1531 var pad = lpad;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1532 if (sym_height - pad < sym_min) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1533 pad = Math.min(pad, Math.max(0, sym_height - sym_min));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1534 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1535 //move to the correct drawing position
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1536 ctx.save();//s1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1537 ctx.translate(0, pos);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1538 //create a clipping rectangle to ensure the letter doesn't overlap when it's distorted
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1539 ctx.save();//s2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1540 //ctx.beginPath(); //disabled clipping because after the improvements in the text metrics it looks better without
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1541 //ctx.moveTo(-metrics.stack_width/2,0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1542 //ctx.lineTo(metrics.stack_width/2, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1543 //ctx.lineTo(metrics.stack_width/2, -sym_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1544 //ctx.lineTo(-metrics.stack_width/2, -sym_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1545 //ctx.lineTo(-metrics.stack_width/2,0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1546 //ctx.clip();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1547 //now draw
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1548 ctx.translate(0, -(pad/2));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1549 ctx.translate(0, -letter.get_descent(sym_height - pad));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1550 ctx.fillStyle = sym.get_colour();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1551 ctx.textAlign = "center";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1552 ctx.save();//s3
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1553 ctx.scale(letter.wscale, letter.get_hscale(sym_height - pad));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1554 ctx.fillText(sym.get_symbol(), 0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1555 ctx.restore();//s3
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1556
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1557 ctx.restore();//s2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1558 ctx.restore();//s1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1559 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1560
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1561 pos = pos - sym_height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1562 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1563 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1564
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1565 function draw_dashed_line(ctx, pattern, start, x1, y1, x2, y2) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1566 var x, y, len, i;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1567 var dx = x2 - x1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1568 var dy = y2 - y1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1569 var tlen = Math.pow(dx*dx + dy*dy, 0.5);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1570 var theta = Math.atan2(dy,dx);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1571 var mulx = Math.cos(theta);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1572 var muly = Math.sin(theta);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1573 var lx = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1574 var ly = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1575 for (i = 0; i < pattern; ++i) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1576 lx.push(pattern[i] * mulx);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1577 ly.push(pattern[i] * muly);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1578 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1579 i = start;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1580 x = x1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1581 y = y1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1582 len = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1583 ctx.beginPath();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1584 while (len + pattern[i] < tlen) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1585 ctx.moveTo(x, y);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1586 x += lx[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1587 y += ly[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1588 ctx.lineTo(x, y);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1589 len += pattern[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1590 i = (i + 1) % pattern.length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1591 x += lx[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1592 y += ly[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1593 len += pattern[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1594 i = (i + 1) % pattern.length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1595 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1596 if (len < tlen) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1597 ctx.moveTo(x, y);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1598 x += mulx * (tlen - len);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1599 y += muly * (tlen - len);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1600 ctx.lineTo(x, y);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1601 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1602 ctx.stroke();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1603 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1604
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1605 function draw_trim_background(ctx, metrics, pspm, offset) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1606 var lwidth = metrics.stack_width * pspm.get_left_trim();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1607 var rwidth = metrics.stack_width * pspm.get_right_trim();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1608 var mwidth = metrics.stack_width * pspm.get_motif_length();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1609 var rstart = mwidth - rwidth;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1610 ctx.save();//s8
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1611 ctx.translate(offset * metrics.stack_width, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1612 ctx.fillStyle = "rgb(240, 240, 240)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1613 if (pspm.get_left_trim() > 0) ctx.fillRect(0, 0, lwidth, metrics.stack_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1614 if (pspm.get_right_trim() > 0) ctx.fillRect(rstart, 0, rwidth, metrics.stack_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1615 ctx.fillStyle = "rgb(51, 51, 51)";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1616 if (pspm.get_left_trim() > 0) draw_dashed_line(ctx, [3], 0, lwidth-0.5, 0, lwidth-0.5, metrics.stack_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1617 if (pspm.get_right_trim() > 0) draw_dashed_line(ctx, [3], 0, rstart+0.5, 0, rstart+0.5, metrics.stack_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1618 ctx.restore();//s8
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1619 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1620
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1621 function draw_logo_on_canvas(logo, canvas, show_names, scale) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1622 var draw_name = (typeof show_names == "boolean" ? show_names : (logo.get_rows() > 1));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1623 var cwidth = canvas.width;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1624 var cheight = canvas.height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1625 //need a minimum 46 x 120 canvas to draw the font size checks on
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1626 if (canvas.width < 46) canvas.width = 46;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1627 if (canvas.height < 120) canvas.height = 120;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1628 var ctx = canvas.getContext('2d');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1629 //assume that the user wants the canvas scaled equally so calculate what the best width for this image should be
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1630 var metrics = new LogoMetrics(ctx, canvas.width, canvas.height, logo.get_columns(), logo.get_rows(), draw_name);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1631 ctx.save();//s1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1632 if (typeof scale == "number") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1633 //resize the canvas to fit the scaled logo
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1634 cwidth = metrics.summed_width * scale;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1635 cheight = metrics.summed_height * scale;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1636 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1637 if (cwidth == 0 && cheight == 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1638 throw "CANVAS_MUST_HAVE_DIMENSIONS";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1639 } else if (cwidth == 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1640 scale = cheight / metrics.summed_height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1641 cwidth = metrics.summed_width * scale;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1642 } else if (cheight == 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1643 scale = cwidth / metrics.summed_width;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1644 cheight = metrics.summed_height * scale;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1645 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1646 scale = Math.min(cwidth / metrics.summed_width, cheight / metrics.summed_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1647 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1648 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1649 var raster = new RasterizedAlphabet(logo.alphabet, metrics.stack_font, metrics.stack_width * scale * 2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1650 if (cwidth != canvas.width || cheight != canvas.height) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1651 canvas.width = cwidth;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1652 canvas.height = cheight;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1653 //as the canvas has been resized the context is now out of date
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1654 ctx = canvas.getContext('2d');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1655 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1656 ctx.scale(scale, scale);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1657 ctx.save();//s2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1658 ctx.save();//s7
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1659 //create margin
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1660 ctx.translate(metrics.pad_left, metrics.pad_top);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1661 for (var pspm_i = 0; pspm_i < logo.get_rows(); ++pspm_i) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1662 var pspm = logo.get_pspm(pspm_i);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1663 var offset = logo.get_offset(pspm_i);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1664 //optionally draw name if this isn't the last row or is the only row
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1665 if (draw_name && (logo.get_rows() == 1 || pspm_i != (logo.get_rows()-1))) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1666 ctx.save();//s4
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1667 ctx.translate(metrics.summed_width/2, metrics.name_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1668 ctx.font = metrics.name_font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1669 ctx.textAlign = "center";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1670 ctx.fillText(pspm.name, 0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1671 ctx.restore();//s4
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1672 ctx.translate(0, metrics.name_height + Math.min(0, metrics.name_spacer - metrics.y_num_height/2));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1673 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1674 //draw scale
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1675 draw_scale(ctx, metrics, logo.alphabet.get_ic());
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1676 ctx.save();//s5
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1677 //translate across past the scale
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1678 ctx.translate(metrics.y_label_height + metrics.y_label_spacer +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1679 metrics.y_num_width + metrics.y_tic_width, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1680 //draw the trimming background
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1681 if (pspm.get_left_trim() > 0 || pspm.get_right_trim() > 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1682 draw_trim_background(ctx, metrics, pspm, offset);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1683 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1684 //draw letters
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1685 ctx.translate(0, metrics.y_num_height / 2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1686 for (var col_index = 0; col_index < logo.get_columns(); col_index++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1687 ctx.translate(metrics.stack_pad_left,0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1688 if (col_index >= offset && col_index < (offset + pspm.get_motif_length())) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1689 var motif_position = col_index - offset;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1690 draw_stack_num(ctx, metrics, motif_position);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1691 draw_stack(ctx, metrics, pspm.get_stack(motif_position, logo.alphabet), raster);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1692 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1693 ctx.translate(metrics.stack_width, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1694 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1695 ctx.restore();//s5
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1696 ////optionally draw name if this is the last row but isn't the only row
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1697 if (draw_name && (logo.get_rows() != 1 && pspm_i == (logo.get_rows()-1))) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1698 //translate vertically past the stack and axis's
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1699 ctx.translate(0, metrics.y_num_height/2 + metrics.stack_height +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1700 Math.max(metrics.y_num_height/2, metrics.x_num_above + metrics.x_num_width + metrics.name_spacer));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1701
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1702 ctx.save();//s6
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1703 ctx.translate(metrics.summed_width/2, metrics.name_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1704 ctx.font = metrics.name_font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1705 ctx.textAlign = "center";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1706 ctx.fillText(pspm.name, 0, 0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1707 ctx.restore();//s6
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1708 ctx.translate(0, metrics.name_height);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1709 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1710 //translate vertically past the stack and axis's
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1711 ctx.translate(0, metrics.y_num_height/2 + metrics.stack_height + Math.max(metrics.y_num_height/2, metrics.x_num_above + metrics.x_num_width));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1712 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1713 //if not the last row then add middle padding
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1714 if (pspm_i != (logo.get_rows() -1)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1715 ctx.translate(0, metrics.pad_middle);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1716 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1717 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1718 ctx.restore();//s7
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1719 ctx.translate(metrics.summed_width - metrics.pad_right, metrics.summed_height - metrics.pad_bottom);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1720 ctx.font = metrics.fine_txt_font;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1721 ctx.textAlign = "right";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1722 ctx.fillText(logo.fine_text, 0,0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1723 ctx.restore();//s2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1724 ctx.restore();//s1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1725 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1726
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1727 function create_canvas(c_width, c_height, c_id, c_title, c_display) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1728 var canvas = document.createElement("canvas");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1729 //check for canvas support before attempting anything
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1730 if (!canvas.getContext) return null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1731 var ctx = canvas.getContext('2d');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1732 //check for html5 text drawing support
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1733 if (!supports_text(ctx)) return null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1734 //size the canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1735 canvas.width = c_width;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1736 canvas.height = c_height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1737 canvas.id = c_id;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1738 canvas.title = c_title;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1739 canvas.style.display = c_display;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1740 return canvas;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1741 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1742
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1743 function logo_1(alphabet, fine_text, pspm) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1744 var logo = new Logo(alphabet, fine_text);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1745 logo.add_pspm(pspm);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1746 return logo;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1747 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1748
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1749 function logo_2(alphabet, fine_text, target, query, query_offset) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1750 var logo = new Logo(alphabet, fine_text);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1751 if (query_offset < 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1752 logo.add_pspm(target, -query_offset);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1753 logo.add_pspm(query);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1754 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1755 logo.add_pspm(target);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1756 logo.add_pspm(query, query_offset);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1757 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1758 return logo;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1759 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1760
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1761 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1762 * Specifies an alternate source for an image.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1763 * If the image with the image_id specified has
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1764 * not loaded then a generated logo will be used
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1765 * to replace it.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1766 *
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1767 * Note that the image must either have dimensions
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1768 * or a scale must be set.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1769 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1770 function alternate_logo(logo, image_id, scale) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1771 var image = document.getElementById(image_id);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1772 if (!image) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1773 alert("Can't find specified image id (" + image_id + ")");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1774 return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1775 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1776 //if the image has loaded then there is no reason to use the canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1777 if (image_ok(image)) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1778 //the image has failed to load so replace it with a canvas if we can.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1779 var canvas = create_canvas(image.width, image.height, image_id, image.title, image.style.display);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1780 if (canvas == null) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1781 //draw the logo on the canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1782 draw_logo_on_canvas(logo, canvas, undefined, scale);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1783 //replace the image with the canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1784 image.parentNode.replaceChild(canvas, image);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1785 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1786
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1787 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1788 * Specifes that the element with the specified id
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1789 * should be replaced with a generated logo.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1790 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1791 function replace_logo(logo, replace_id, scale, title_txt, display_style) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1792 var element = document.getElementById(replace_id);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1793 if (!replace_id) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1794 alert("Can't find specified id (" + replace_id + ")");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1795 return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1796 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1797 //found the element!
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1798 var canvas = create_canvas(50, 120, replace_id, title_txt, display_style);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1799 if (canvas == null) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1800 //draw the logo on the canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1801 draw_logo_on_canvas(logo, canvas, undefined, scale);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1802 //replace the element with the canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1803 element.parentNode.replaceChild(canvas, element);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1804 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1805
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1806 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1807 * Fast string trimming implementation found at
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1808 * http://blog.stevenlevithan.com/archives/faster-trim-javascript
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1809 *
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1810 * Note that regex is good at removing leading space but
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1811 * bad at removing trailing space as it has to first go through
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1812 * the whole string.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1813 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1814 function trim (str) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1815 str = str.replace(/^\s\s*/, '');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1816 var ws = /\s/, i = str.length;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1817 while (ws.test(str.charAt(--i)));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1818 return str.slice(0, i + 1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1819 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1820 /* END INCLUDED FILE "motif_logo.js" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1821
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1822
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1823
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1824 /* START INCLUDED FILE "dreme-to-html.js" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1825 var expansion_lookup = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1826
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1827 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1828 * show_hidden
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1829 *
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1830 * Looks for specially named elements and switches to the shown view
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1831 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1832 function show_hidden(prefix) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1833 document.getElementById(prefix + '_activator').style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1834 document.getElementById(prefix + '_deactivator').style.display = 'block';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1835 document.getElementById(prefix + '_data').style.display = 'block';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1836 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1837 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1838 * hide_shown
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1839 *
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1840 * Looks for specially named elements and switches to the hidden view
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1841 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1842 function hide_shown(prefix) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1843 document.getElementById(prefix + '_activator').style.display = 'block';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1844 document.getElementById(prefix + '_deactivator').style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1845 document.getElementById(prefix + '_data').style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1846 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1847
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1848 function click_download_tab(tab) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1849 document.getElementById("download_tab_num").value = tab;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1850 for (var i = 1; i <= 3; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1851 document.getElementById('download_tab_'+i).className = "tab" + (i==tab ? " activeTab" : "");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1852 document.getElementById('download_pnl_'+i).style.display = (i==tab ? "block" : "none");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1853 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1854 document.getElementById('download_button').style.visibility = (tab==3 ? "visible" : "hidden");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1855 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1856
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1857
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1858 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1859 * searches child nodes in depth first order and returns the
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1860 * first it finds with the className specified.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1861 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1862 function find_child_element_by_class(node, className) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1863 var patt = new RegExp("\\b" + className + "\\b");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1864
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1865 if (node.nodeType == Node.ELEMENT_NODE &&
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1866 patt.test(node.className)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1867 return node;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1868 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1869 var result = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1870 for (var i = 0; i < node.childNodes.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1871 result = find_child_element_by_class(node.childNodes[i], className);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1872 if (result != null) break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1873 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1874 return result;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1875 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1876 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1877
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1878 function find_parent_element_by_class(node, className) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1879 var patt = new RegExp("\\b" + className + "\\b");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1880 if (node.nodeType == Node.ELEMENT_NODE &&
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1881 patt.test(node.className)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1882 return node;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1883 } else if (node.parentNode != null) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1884 return find_parent_element_by_class(node.parentNode, className);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1885 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1886 return null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1887 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1888
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1889 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1890 * expand
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1891 *
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1892 * Expand the extra data section for a motif.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1893 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1894 function expand(num) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1895 // get motif data
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1896 var motif_info = motif_seqs[num];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1897 var motif_id = motif_info[0];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1898 var seq = motif_info[1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1899 var rcseq = motif_info[2];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1900 var length = motif_info[3];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1901 var nsites = motif_info[4];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1902 var p_hits = motif_info[5];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1903 var n_hits = motif_info[6];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1904 var pvalue = motif_info[7];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1905 var evalue = motif_info[8];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1906 var uevalue = motif_info[9];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1907 var matches = motif_info[10];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1908 // find the location to insert the expanded motif data
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1909 var table = document.getElementById('dreme_motifs');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1910 var motif_row = document.getElementById('motif_row_' + num);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1911 var exp_row = table.insertRow(motif_row.rowIndex + 1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1912 exp_row.id = 'exp_row_' + num;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1913 var cell = exp_row.insertCell(0);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1914 cell.colSpan = 9;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1915 // create the DOM to insert
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1916 var exp = document.getElementById('expanded_motif').firstChild.cloneNode(true);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1917 // update fields
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1918 set_content_to_text(find_child_element_by_class(exp, 'name'), seq);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1919 set_content_to_text(find_child_element_by_class(exp, 'num'), num);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1920 var img = find_child_element_by_class(exp, 'img_nc');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1921 img.src = motif_id + "nc_" + seq + ".png";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1922 var imgrc = find_child_element_by_class(exp, 'img_rc');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1923 imgrc.src = motif_id + "rc_" + rcseq + ".png";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1924 // fill in the details
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1925 var details = find_child_element_by_class(exp, 'details');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1926 set_content_to_text(find_child_element_by_class(details, 'positives'), p_hits);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1927 set_content_to_text(find_child_element_by_class(details, 'negatives'), n_hits);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1928 set_content_to_text(find_child_element_by_class(details, 'pvalue'), pvalue);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1929 set_content_to_text(find_child_element_by_class(details, 'evalue'), evalue);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1930 set_content_to_text(find_child_element_by_class(details, 'uevalue'), uevalue);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1931
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1932 // fill in match table
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1933 var match_row = find_child_element_by_class(exp, 'match');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1934 var tbody = match_row.parentNode;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1935 for (var i = 0; i < matches.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1936 var match = matches[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1937 var cseq = match[0];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1938 var cpos = match[1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1939 var cneg = match[2];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1940 var cpval = match[3].toExponential(1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1941 var ceval = match[4].toExponential(1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1942 var row = match_row.cloneNode(true);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1943 var td_cseq = find_child_element_by_class(row, 'dnaseq');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1944 set_content_to_text(td_cseq, cseq);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1945 colour_dna_seq(td_cseq);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1946 set_content_to_text(find_child_element_by_class(row, 'positives'), cpos);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1947 set_content_to_text(find_child_element_by_class(row, 'negatives'), cneg);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1948 set_content_to_text(find_child_element_by_class(row, 'pvalue'), cpval);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1949 set_content_to_text(find_child_element_by_class(row, 'evalue'), ceval);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1950 tbody.appendChild(row);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1951 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1952 tbody.removeChild(match_row);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1953 // append the expanded information
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1954 cell.appendChild(exp);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1955 // hide the old row
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1956 motif_row.style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1957 update_headers();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1958 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1959
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1960 function expanded_num(elem) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1961 var exp = find_parent_element_by_class(elem, 'expanded_motif');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1962 var num = parseInt(nodes_text(text_nodes(find_child_element_by_class(exp, 'num'))));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1963 return num;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1964 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1965
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1966 function contract(contained_node) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1967 var table = document.getElementById('dreme_motifs');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1968 var num = expanded_num(contained_node);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1969 var motif_row = document.getElementById('motif_row_' + num);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1970 var exp_row = document.getElementById('exp_row_' + num);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1971
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1972 motif_row.style.display = 'table-row';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1973 table.deleteRow(exp_row.rowIndex);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1974 update_headers();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1975 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1976
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1977 function update_headers() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1978 var motif_row_patt = new RegExp("\\bmotif_row\\b");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1979 var motif_head_patt = new RegExp("\\bmotif_head\\b");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1980 var table = document.getElementById('dreme_motifs');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1981 var header = table.tHead.getElementsByTagName('tr')[0];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1982 header.style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1983 var trs = table.tBodies[0].getElementsByTagName('tr');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1984 var needHeader = true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1985 for (var i = 0; i < trs.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1986 var row = trs[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1987 if (row.style.display == 'none') continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1988 if (motif_row_patt.test(row.className)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1989 if (needHeader) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1990 var dupHeader = header.cloneNode(true);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1991 dupHeader.style.display = 'table-row';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1992 row.parentNode.insertBefore(dupHeader, row);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1993 needHeader = false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1994 i++;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1995 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1996 } else if (motif_head_patt.test(row.className)) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1997 table.deleteRow(row.rowIndex);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1998 i--;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1999 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2000 needHeader = true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2001 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2002 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2003 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2004
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2005 function set_content_to_text(ele, text) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2006 while(ele.hasChildNodes()) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2007 ele.removeChild(ele.firstChild);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2008 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2009 ele.appendChild(document.createTextNode(text));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2010 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2011
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2012 function both_setup(pos) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2013 // get the total number of motifs
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2014 var nmotifs = parseInt(document.getElementById('nmotifs').value, 10);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2015 // set the motif that we're submitting
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2016 document.getElementById('submit_motif').value = (pos == 0 ? 'all' : pos);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2017 document.getElementById('send_to_selector').style.display = (pos == 0 ? 'none' : 'block');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2018 document.getElementById('send_to_title_1').style.display = (pos == 0 ? 'none' : 'block');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2019 document.getElementById('send_to_title_2').style.display = (pos == 0 ? 'block' : 'none');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2020
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2021 if (pos != 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2022 // get the information for the position
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2023 var motif_seq = motif_seqs[pos];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2024 var motif_id = motif_seq[0];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2025 var seq = motif_seq[1];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2026 var rcseq = motif_seq[2];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2027 // set the motif number
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2028 // set the titles of both popups
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2029 set_content_to_text(document.getElementById('send_to_name'), seq);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2030 set_content_to_text(document.getElementById('download_name'), seq);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2031 // set the images
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2032 var nc_img = "" + motif_id + "nc_" + seq + ".png";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2033 var rc_img = "" + motif_id + "rc_" + rcseq + ".png";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2034 var img;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2035 img = document.getElementById('send_to_img');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2036 img.src = nc_img;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2037 img.style.display = "inline";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2038 img = document.getElementById('send_to_rcimg');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2039 img.src = rc_img;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2040 img.style.display = "inline";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2041 img = document.getElementById('download_img');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2042 img.src = nc_img;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2043 img.style.display = "inline";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2044 img = document.getElementById('download_rcimg');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2045 img.src = rc_img;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2046 img.style.display = "inline";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2047 // hide the canvas
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2048 document.getElementById('send_to_can').style.display = "none";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2049 document.getElementById('send_to_rccan').style.display = "none";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2050 document.getElementById('download_can').style.display = "none";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2051 document.getElementById('download_rccan').style.display = "none";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2052 // get some motif details
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2053 var pspm_text = document.getElementById("pspm"+ pos).value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2054 var pspm = new Pspm(pspm_text);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2055 var alpha = new Alphabet(document.getElementById("alphabet").value,
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2056 document.getElementById("bgfreq").value);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2057 document.getElementById('download_pspm').value = pspm.as_pspm();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2058 document.getElementById('download_pssm').value = pspm.as_pssm(alpha);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2059 // set the width and height defaults
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2060 document.getElementById('logo_width').value = pspm.get_motif_length();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2061 document.getElementById('logo_height').value = 7.5;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2062 // hide and show the arrows
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2063 var prevclass = (pos == 1 ? "navarrow inactive" : "navarrow");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2064 var nextclass = (pos == nmotifs ? "navarrow inactive" : "navarrow");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2065 document.getElementById('prev_arrow_1').className = prevclass;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2066 document.getElementById('prev_arrow_2').className = prevclass;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2067 document.getElementById('next_arrow_1').className = nextclass;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2068 document.getElementById('next_arrow_2').className = nextclass;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2069 set_content_to_text(document.getElementById('pop_num_1'), pos);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2070 set_content_to_text(document.getElementById('pop_num_2'), pos);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2071 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2072 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2073
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2074 function both_change(inc) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2075 var motif_num = parseInt(document.getElementById('submit_motif').value, 10);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2076 var nmotifs = parseInt(document.getElementById('nmotifs').value, 10);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2077 var orig = motif_num;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2078 motif_num += inc;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2079 if (motif_num > nmotifs) motif_num = nmotifs;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2080 else if (motif_num < 1) motif_num = 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2081 if (orig != motif_num) both_setup(motif_num);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2082 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2083
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2084 function both_hide() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2085 document.getElementById('grey_out_page').style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2086 document.getElementById('download').style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2087 document.getElementById('send_to').style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2088 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2089
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2090 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2091 * lookup the information on a motif and prepare the
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2092 * popup for sending it to another program
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2093 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2094 function send_to_popup(pos) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2095 both_setup(pos);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2096 var program = find_child_element_by_class(document.getElementById('programs'), 'selected').id;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2097 var task = highlight_submit_task(null, submit_programs[program]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2098 highlight_submit_program(program, submit_tasks[task]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2099 update_submit_text(task, program);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2100 // show the send to page
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2101 var grey_out = document.getElementById('grey_out_page');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2102 grey_out.style.display = 'block';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2103 var send_to_pop = document.getElementById('send_to');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2104 send_to_pop.style.display = 'block';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2105 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2106
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2107 function send_to_popup2(elem) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2108 send_to_popup(expanded_num(elem));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2109 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2110
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2111 function send_to_submit() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2112 var program = find_child_element_by_class(document.getElementById('programs'), 'selected').id;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2113 // set the hidden fields on the form
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2114 document.getElementById('submit_program').value = program;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2115 // send the form
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2116 document.getElementById('submit_form').submit();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2117 both_hide();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2118 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2119
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2120 function download_popup(pos) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2121 both_setup(pos);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2122 click_download_tab(document.getElementById("download_tab_num").value);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2123 document.getElementById('submit_program').value = "LOGO";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2124 // show the download page
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2125 var grey_out = document.getElementById('grey_out_page');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2126 grey_out.style.display = 'block';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2127 var download_pop = document.getElementById('download');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2128 download_pop.style.display = 'block';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2129 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2130
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2131 function download_popup2(elem) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2132 download_popup(expanded_num(elem));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2133 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2134
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2135 function download_submit() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2136 var format = document.getElementById('logo_format').value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2137 var orient = document.getElementById('logo_rc').value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2138 var ssc = document.getElementById('logo_ssc').value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2139 var width = document.getElementById('logo_width').value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2140 var height = document.getElementById('logo_height').value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2141 document.getElementById('submit_format').value = format;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2142 document.getElementById('submit_rc').value = orient;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2143 document.getElementById('submit_ssc').value = ssc;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2144 document.getElementById('submit_width').value = width;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2145 document.getElementById('submit_height').value = height;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2146 document.getElementById('submit_form').submit();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2147 both_hide();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2148 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2149
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2150 function FixLogoTask(num, rc) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2151 this.num = num;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2152 this.rc = rc;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2153 this.run = FixLogoTask_run;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2154 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2155
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2156 function FixLogoTask_run() {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2157 var pspm_text = document.getElementById("pspm" + this.num).value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2158 var alpha = new Alphabet("ACGT");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2159 var pspm = new Pspm(pspm_text);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2160 if (this.rc) pspm = pspm.reverse_complement(alpha);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2161 var imgid = "small_" + (this.rc ? "rc_" : "") + "logo_" + this.num;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2162
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2163 var image = document.getElementById(imgid);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2164
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2165 var canvas = create_canvas(pspm.get_motif_length() *15, 50, image.id,
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2166 image.title, image.style.display);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2167 if (canvas == null) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2168
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2169 var logo = logo_1(alpha, "DREME", pspm);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2170 draw_logo_on_canvas(logo, canvas);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2171 image.parentNode.replaceChild(canvas, image);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2172 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2173
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2174 function fix_popup_logo(image, canvasid, rc) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2175 var motif_num = parseInt(document.getElementById('submit_motif').value, 10);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2176 var pspm_text = document.getElementById("pspm" + motif_num).value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2177 var alpha = new Alphabet("ACGT");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2178 var pspm = new Pspm(pspm_text);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2179 if (rc) pspm = pspm.reverse_complement(alpha);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2180 image.style.display = "none";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2181 //check for canvas support before attempting anything
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2182 var canvas = document.getElementById(canvasid);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2183 if (!canvas.getContext) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2184 if (!supports_text(canvas.getContext('2d'))) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2185 canvas.height = 90;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2186 canvas.width = 170;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2187 canvas.style.display = "inline";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2188 var logo = logo_1(alpha, "DREME", pspm);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2189 draw_logo_on_canvas(logo, canvas, false);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2190 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2191
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2192 function fix_expanded_logo(image, rc) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2193 var motif_num = expanded_num(image);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2194 var pspm_text = document.getElementById("pspm" + motif_num).value;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2195 var alpha = new Alphabet("ACGT");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2196 var pspm = new Pspm(pspm_text);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2197 if (rc) pspm = pspm.reverse_complement(alpha);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2198 //check for canvas support before attempting anything
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2199 var canvas = document.createElement('canvas');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2200 if (!canvas.getContext) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2201 if (!supports_text(canvas.getContext('2d'))) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2202 canvas.height = 150;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2203 canvas.width = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2204 draw_logo_on_canvas(logo_1(alpha, "DREME", pspm), canvas, false);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2205 image.parentNode.replaceChild(canvas, image);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2206 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2207
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2208 function text_nodes(container) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2209 var textNodes = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2210 var stack = [container];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2211 // depth first search to maintain ordering when flattened
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2212 while (stack.length > 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2213 var node = stack.pop();
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2214 if (node.nodeType == Node.TEXT_NODE) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2215 textNodes.push(node);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2216 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2217 for (var i = node.childNodes.length-1; i >= 0; i--) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2218 stack.push(node.childNodes[i]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2219 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2220 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2221 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2222 return textNodes;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2223 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2224
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2225 function node_text(node) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2226 if (node === undefined) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2227 return '';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2228 } else if (node.textContent) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2229 return node.textContent;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2230 } else if (node.innerText) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2231 return node.innerText;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2232 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2233 return '';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2234 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2235 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2236
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2237 function nodes_text(nodes, separator) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2238 if (separator === undefined) separator = '';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2239 var text = '';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2240 if (nodes.length > 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2241 text += node_text(nodes[0]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2242 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2243 for (var i = 1; i < nodes.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2244 text += separator + node_text(nodes[i]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2245 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2246 return text;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2247 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2248
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2249 function colour_dna_seq(container) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2250 var textnodes = text_nodes(container);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2251 for (var i = 0; i < textnodes.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2252 var node = textnodes[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2253 container.replaceChild(create_dna_seq(node_text(node)), node);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2254 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2255 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2256
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2257 function create_dna_seq(seq) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2258 var out = document.createElement('span');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2259 var last = 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2260 for (var i = 0; i < seq.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2261 var letter = seq.charAt(i);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2262 if (letter == 'A' || letter == 'C' || letter == 'G' || letter == 'T') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2263 if (last < i) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2264 out.appendChild(document.createTextNode(seq.substring(last, i)));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2265 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2266 var coloured_letter = document.createElement('span');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2267 coloured_letter.className = "dna_" + letter;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2268 coloured_letter.appendChild(document.createTextNode(letter));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2269 out.appendChild(coloured_letter);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2270 last = i + 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2271 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2272 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2273 if (last < seq.length) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2274 out.appendChild(document.createTextNode(seq.substring(last)));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2275 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2276 return out;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2277 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2278
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2279 function sort_table(colEle, compare_function) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2280 //find the parent of colEle that is either a td or th
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2281 var cell = colEle;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2282 while (true) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2283 if (cell == null) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2284 if (cell.nodeType == Node.ELEMENT_NODE &&
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2285 (cell.tagName.toLowerCase() == "td" || cell.tagName.toLowerCase() == "th")) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2286 break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2287 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2288 cell = cell.parentNode;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2289 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2290 //find the parent of cell that is a tr
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2291 var row = cell;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2292 while (true) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2293 if (row == null) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2294 if (row.nodeType == Node.ELEMENT_NODE && row.tagName.toLowerCase() == "tr") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2295 break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2296 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2297 row = row.parentNode;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2298 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2299 //find the parent of row that is a table
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2300 var table = row;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2301 while (true) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2302 if (table == null) return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2303 if (table.nodeType == Node.ELEMENT_NODE && table.tagName.toLowerCase() == "table") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2304 break;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2305 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2306 table = table.parentNode;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2307 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2308 var column_index = cell.cellIndex;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2309 // do a bubble sort, because the tables are so small it doesn't matter
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2310 var change;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2311 var trs = table.tBodies[0].getElementsByTagName('tr');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2312 var already_sorted = true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2313 var reverse = false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2314 while (true) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2315 do {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2316 change = false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2317 for (var i = 0; i < trs.length -1; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2318 var v1 = nodes_text(text_nodes(trs[i].cells[column_index]));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2319 var v2 = nodes_text(text_nodes(trs[i+1].cells[column_index]));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2320 if (reverse) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2321 var tmp = v1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2322 v1 = v2;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2323 v2 = tmp;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2324 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2325 if (compare_function(v1, v2) > 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2326 exchange(trs[i], trs[i+1], table);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2327 change = true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2328 already_sorted = false;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2329 trs = table.tBodies[0].getElementsByTagName('tr');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2330 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2331 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2332 } while (change);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2333 if (reverse) break;// we've sorted twice so exit
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2334 if (!already_sorted) break;// sort did something so exit
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2335 // when it's sorted one way already then sort the opposite way
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2336 reverse = true;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2337 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2338 update_sort_arrows(row, column_index, reverse);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2339 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2340
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2341 function update_sort_arrows(row, column_index, reverse) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2342 var ascending = "\u25BC";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2343 var descending = "\u25B2";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2344 var dir = (reverse ? descending : ascending);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2345 for (var i = 0; i < row.cells.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2346 var arrow = find_child_element_by_class(row.cells[i], "sort_dir");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2347 if (arrow == null) continue;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2348 if (i == column_index) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2349 set_content_to_text(arrow, dir);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2350 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2351 set_content_to_text(arrow, "");
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2352 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2353 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2354 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2355
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2356 function exchange(oRowI, oRowJ, oTable) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2357 var i = oRowI.rowIndex;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2358 var j = oRowJ.rowIndex;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2359 if (i == j+1) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2360 oTable.tBodies[0].insertBefore(oRowI, oRowJ);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2361 } if (j == i+1) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2362 oTable.tBodies[0].insertBefore(oRowJ, oRowI);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2363 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2364 var tmpNode = oTable.tBodies[0].replaceChild(oRowI, oRowJ);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2365 if(typeof(oRowI) != "undefined") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2366 oTable.tBodies[0].insertBefore(tmpNode, oRowI);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2367 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2368 oTable.appendChild(tmpNode);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2369 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2370 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2371 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2372
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2373 function compare_numbers(v1, v2) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2374 var f1 = parseFloat(v1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2375 var f2 = parseFloat(v2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2376 if (f1 < f2) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2377 return -1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2378 } else if (f1 > f2) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2379 return 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2380 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2381 return 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2382 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2383 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2384
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2385 function compare_counts(v1, v2) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2386 var re = /(\d+)\/\d+/;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2387 var m1 = re.exec(v1);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2388 var m2 = re.exec(v2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2389 if (m1 == null && m2 == null) return 0;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2390 if (m1 == null) return -1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2391 if (m2 == null) return 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2392 return compare_numbers(m1[1], m2[1]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2393 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2394
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2395 function compare_strings(v1, v2) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2396 return v1.localeCompare(v2);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2397 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2398 /*
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2399 * help
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2400 *
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2401 * Moves around help pop-ups so they appear
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2402 * below an activator.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2403 */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2404 function help(activator, popup_id) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2405 if (help.popup === undefined) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2406 help.popup = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2407 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2408 if (help.activator === undefined) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2409 help.activator = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2410 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2411
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2412 if (typeof(activator) == 'undefined') { // no activator so hide
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2413 help.popup.style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2414 help.popup = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2415 return;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2416 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2417 var pop = document.getElementById(popup_id);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2418 if (pop == help.popup) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2419 if (activator == help.activator) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2420 //hide popup (as we've already shown it for the current help button)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2421 help.popup.style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2422 help.popup = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2423 return; // toggling complete!
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2424 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2425 } else if (help.popup != null) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2426 //activating different popup so hide current one
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2427 help.popup.style.display = 'none';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2428 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2429 help.popup = pop;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2430 help.activator = activator;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2431
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2432 //must make the popup visible to measure it or it has zero width
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2433 pop.style.display = 'block';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2434 var xy = get_elem_xy(activator);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2435 var padding = 10;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2436 var edge_padding = 15;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2437 var scroll_padding = 15;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2438
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2439 var pop_left = (xy[0] + (activator.offsetWidth / 2) - (pop.offsetWidth / 2));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2440 var pop_top = (xy[1] + activator.offsetHeight + padding);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2441
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2442 // ensure the box is not past the top or left of the page
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2443 if (pop_left < 0) pop_left = edge_padding;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2444 if (pop_top < 0) pop_top = edge_padding;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2445 // ensure the box does not cause horizontal scroll bars
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2446 var page_width = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2447 if (window.innerWidth) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2448 page_width = window.innerWidth;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2449 } else if (document.body) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2450 page_width = document.body.clientWidth;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2451 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2452 if (page_width) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2453 if (pop_left + pop.offsetWidth > page_width) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2454 pop_left = page_width - pop.offsetWidth - edge_padding - scroll_padding; //account for scrollbars
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2455 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2456 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2457
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2458 pop.style.left = pop_left + "px";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2459 pop.style.top = pop_top + "px";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2460 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2461
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2462 var submit_tasks = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2463 submit_tasks['search_motifs'] = ['TOMTOM'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2464 submit_tasks['search_sequences'] = ['FIMO'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2465 submit_tasks['rank_sequences'] = ['MAST'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2466 submit_tasks['predict_go'] = ['GOMO'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2467 submit_tasks['infer_tf'] = ['SPAMO'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2468 var submit_programs = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2469 submit_programs['TOMTOM'] = ['search_motifs'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2470 submit_programs['FIMO'] = ['search_sequences'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2471 submit_programs['MAST'] = ['rank_sequences'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2472 submit_programs['GOMO'] = ['predict_go'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2473 submit_programs['SPAMO'] = ['infer_tf'];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2474 var submit_descriptions = [];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2475 submit_descriptions['TOMTOM'] = "Find similar motifs in published " +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2476 "libraries or a library you supply.";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2477 submit_descriptions['FIMO'] = "Find motif occurences in sequence data.";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2478 submit_descriptions['MAST'] = "Rank sequences by affinity to groups " +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2479 "of motifs.";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2480 submit_descriptions['GOMO'] = "Identify possible roles (Gene Ontology " +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2481 "terms) for motifs.";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2482 submit_descriptions['SPAMO'] = "Find other motifs that are enriched at " +
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2483 "specific close spacings which might imply the existance of a complex.";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2484
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2485
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2486 function click_submit_task(ele) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2487 var task = ele.id;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2488 var program = highlight_submit_program(null, submit_tasks[task]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2489 highlight_submit_task(task, submit_programs[program]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2490 update_submit_text(task, program);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2491 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2492
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2493 function click_submit_program(ele) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2494 var program = ele.id;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2495 var task = highlight_submit_task(null, submit_programs[program]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2496 highlight_submit_program(program, submit_tasks[task]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2497 update_submit_text(task, program);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2498 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2499
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2500 function update_submit_text(task, program) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2501 var task_ele = document.getElementById(task);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2502 var program_ele = document.getElementById(program);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2503 set_content_to_text(document.getElementById('program_action'),
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2504 nodes_text(text_nodes(task_ele)));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2505 set_content_to_text(document.getElementById('program_name'),
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2506 nodes_text(text_nodes(program_ele)));
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2507 set_content_to_text(document.getElementById('program_desc'),
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2508 submit_descriptions[program]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2509 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2510
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2511 function highlight_submit_task(select, highlights) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2512 var tasks_ul = document.getElementById('tasks');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2513 var all_tasks = tasks_ul.getElementsByTagName('li');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2514 var li;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2515 var originally_selected = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2516 // deselect everything in the tasks list
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2517 for (var i = 0; i < all_tasks.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2518 li = all_tasks[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2519 if (li.className == "selected") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2520 originally_selected = li;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2521 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2522 li.className = "";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2523 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2524 // highlight everything in the highlights list
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2525 for (var i = 0; i < highlights.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2526 var li = document.getElementById(highlights[i]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2527 li.className = "active";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2528 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2529 // check if we're setting the selected item specifically
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2530 if (select != null) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2531 li = document.getElementById(select);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2532 li.className = "selected";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2533 return select;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2534 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2535 // if the originally selected item is allowed then keep it
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2536 // otherwise move to the first element of the highlight list
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2537 if (originally_selected != null &&
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2538 originally_selected.className == "active") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2539 originally_selected.className = "selected";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2540 return originally_selected.id;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2541 } else if (highlights.length > 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2542 li = document.getElementById(highlights[0]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2543 li.className = "selected";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2544 return highlights[0];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2545 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2546 return null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2547 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2548 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2549
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2550
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2551 function highlight_submit_program(select, highlights) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2552 var programs_ul = document.getElementById('programs');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2553 var all_programs = programs_ul.getElementsByTagName('li');
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2554 var li;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2555 var originally_selected = null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2556 // deselect everything in the programs list
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2557 for (var i = 0; i < all_programs.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2558 li = all_programs[i];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2559 if (li.className == "selected") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2560 originally_selected = li;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2561 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2562 li.className = "";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2563 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2564 // highlight everything in the highlights list
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2565 for (var i = 0; i < highlights.length; i++) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2566 var li = document.getElementById(highlights[i]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2567 li.className = "active";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2568 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2569 // check if we're setting the selected item specifically
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2570 if (select != null) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2571 li = document.getElementById(select);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2572 li.className = "selected";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2573 return select;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2574 } else {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2575 // if the originally selected item is allowed then keep it
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2576 // otherwise move to the first element of the highlight list
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2577 if (originally_selected != null &&
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2578 originally_selected.className == "active") {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2579 originally_selected.className = "selected";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2580 return originally_selected.id;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2581 } else if (highlights.length > 0) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2582 li = document.getElementById(highlights[0]);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2583 li.className = "selected";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2584 return highlights[0];
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2585 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2586 return null;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2587 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2588 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2589 /* END INCLUDED FILE "dreme-to-html.js" */
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2590
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2591 </script>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2592 </head>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2593 <body>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2594 <form id="submit_form" method="post" action="http://Sharplab-G4-1.local/meme/cgi-bin/meme_request.cgi" target="_blank">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2595 <!--+++++++++++++++START DATA+++++++++++++++-->
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2596 <input type="hidden" name="version" value="MEME version 4.7.0">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2597 <input type="hidden" name="alphabet" id="alphabet" value="ACGT">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2598 <input type="hidden" name="strands" value="+ -">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2599 <input type="hidden" name="bgsrc" value="dataset">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2600 <input type="hidden" name="bgfreq" id="bgfreq" value="A 0.243 C 0.270 G 0.243 T 0.243">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2601 <input type="hidden" name="name" value="test">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2602 <input type="hidden" name="nmotifs" id="nmotifs" value="0">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2603 <!--+++++++++++++++FINISHED DATA++++++++++++-->
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2604 <input type="hidden" name="program" id="submit_program" value="TOMTOM"><input type="hidden" name="motif" id="submit_motif" value="all"><input type="hidden" name="logoformat" id="submit_format" value="png"><input type="hidden" name="logorc" id="submit_rc" value="false"><input type="hidden" name="logossc" id="submit_ssc" value="false"><input type="hidden" name="logowidth" id="submit_width" value=""><input type="hidden" name="logoheight" id="submit_height" value="7.5">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2605 </form>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2606 <div class="pop_content" id="pop_motifs_name">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2607 <p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2608 The name of the motif uses the IUPAC codes for nucleotides which has
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2609 a different letter to represent each of the 15 possible combinations.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2610 </p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2611 <p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2612 The name is itself a representation of the motif though the position
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2613 weight matrix is not directly equalivant as it is generated from the
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2614 sites found that matched the letters given in the name.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2615 </p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2616 <p><a href="http://meme.nbcr.net/meme/doc/alphabets.html">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2617 Read more about the MEME suite's use of the IUPAC alphabets.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2618 </a></p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2619 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2620 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2621 <div class="pop_content" id="pop_motifs_logo">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2622 <p>The logo of the motif.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2623 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2624 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2625 <div class="pop_content" id="pop_motifs_rc_logo">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2626 <p>The logo of the reverse complement motif.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2627 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2628 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2629 <div class="pop_content" id="pop_motifs_evalue">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2630 <p>The E-value is the enrichment p-value times the number of candidate
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2631 motifs tested.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2632 <p>The enrichment p-value is calculated using the Fisher Exact Test for
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2633 enrichment of the motif in the positive sequences.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2634 <p>Note that the counts used in the Fisher Exact Test are made after
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2635 erasing sites that match previously found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2636 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2637 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2638 <div class="pop_content" id="pop_motifs_uevalue">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2639 <p>The E-value of the motif calculated without erasing the sites of
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2640 previously found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2641 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2642 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2643 <div class="pop_content" id="pop_more">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2644 <p>Show more information on the motif.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2645 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2646 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2647 <div class="pop_content" id="pop_submit">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2648 <p>Submit your motif to another MEME Suite program.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2649 <h5>Supported Programs</h5>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2650 <dl>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2651 <dt>Tomtom</dt>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2652 <dd>Tomtom is a tool for searching for similar known motifs.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2653 [<a href="http://meme.nbcr.net/meme/tomtom-intro.html">manual</a>]</dd>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2654 <dt>MAST</dt>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2655 <dd>MAST is a tool for searching biological sequence databases for
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2656 sequences that contain one or more of a group of known motifs.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2657 [<a href="http://meme.nbcr.net/meme/mast-intro.html">manual</a>]</dd>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2658 <dt>FIMO</dt>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2659 <dd>FIMO is a tool for searching biological sequence databases for
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2660 sequences that contain one or more known motifs.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2661 [<a href="http://meme.nbcr.net/meme/fimo-intro.html">manual</a>]</dd>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2662 <dt>GOMO</dt>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2663 <dd>GOMO is a tool for identifying possible roles (Gene Ontology
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2664 terms) for DNA binding motifs.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2665 [<a href="http://meme.nbcr.net/meme/gomo-intro.html">manual</a>]</dd>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2666 <dt>SpaMo</dt>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2667 <dd>SpaMo is a tool for inferring possible transcription factor
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2668 complexes by finding motifs with enriched spacings.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2669 [<a href="http://meme.nbcr.net/meme/spamo-intro.html">manual</a>]</dd>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2670 </dl>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2671 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2672 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2673 <div class="pop_content" id="pop_download">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2674 <p>Download your motif as a position weight matrix or a custom logo.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2675 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2676 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2677 <div class="pop_content" id="pop_motif_positives">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2678 <p># positive sequences matching the motif / # positive sequences.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2679 <p>Note these counts are made after erasing sites that match previously
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2680 found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2681 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2682 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2683 <div class="pop_content" id="pop_motif_negatives">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2684 <p># negative sequences matching the motif / # negative sequences.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2685 <p>Note these counts are made after erasing sites that match previously
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2686 found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2687 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2688 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2689 <div class="pop_content" id="pop_motif_pvalue">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2690 <p>The p-value of the Fisher Exact Test for enrichment of the motif in
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2691 the positive sequences.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2692 <p>Note that the counts used in the Fisher Exact Test are made after
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2693 erasing sites that match previously found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2694 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2695 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2696 <div class="pop_content" id="pop_motif_evalue">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2697 <p>The E-value is the motif p-value times the number of candidate motifs
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2698 tested.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2699 <p>Note that the p-value was calculated with counts made after
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2700 erasing sites that match previously found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2701 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2702 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2703 <div class="pop_content" id="pop_motif_uevalue">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2704 <p>The E-value of the motif calculated without erasing the sites of
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2705 previously found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2706 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2707 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2708 <div class="pop_content" id="pop_match_word">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2709 <p>All words matching the motif whose uncorrected p-value is less than
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2710 0.01.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2711 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2712 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2713 <div class="pop_content" id="pop_match_pos">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2714 <p># positive sequences with matches to the word / # positive sequences.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2715 <p>Note these counts are made after erasing sites that match previously
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2716 found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2717 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2718 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2719 <div class="pop_content" id="pop_match_neg">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2720 <p># negative sequences with matches to the word / # negative sequences.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2721 <p>Note these counts are made after erasing sites that match previously
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2722 found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2723 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2724 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2725 <div class="pop_content" id="pop_match_pval">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2726 <p>The p-value of the Fisher Exact Test for enrichment of the word in
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2727 the positive sequences.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2728 <p>Note that the counts used in the Fisher Exact Test are made after
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2729 erasing sites that match previously found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2730 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2731 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2732 <div class="pop_content" id="pop_match_eval">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2733 <p>The word p-value times the number of candidates tested.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2734 <p>Note that the p-value was calculated with counts made after
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2735 erasing sites that match previously found motifs.</p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2736 <div style="float:right; bottom:0px;">[<a href="javascript:help()">close</a> ]</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2737 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2738 <div id="expanded_motif" style="display:none"><div class="box expanded_motif" style="margin-bottom:5px;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2739 <div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2740 <div style="float:left"><h2 class="mainh" style="margin:0; padding:0;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2741 <span class="num"></span>.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2742 <span class="name"></span>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2743 </h2></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2744 <div style="float:right; "><div class="close" onclick="contract(this);" title="Show less information.">↥</div></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2745 <div style="clear:both"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2746 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2747 <div style="padding:0 5px;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2748 <div style="float:left;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2749 <img class="img_nc" onerror="fix_expanded_logo(this, false)"><img class="img_rc" onerror="fix_expanded_logo(this, true)">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2750 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2751 <div style="float:right; height:100px;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2752 <div onclick="send_to_popup2(this);" class="actionbutton" title="Submit this motif to another MEME Suite program.">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2753 <div style="float:left; margin-right:1em;">Submit</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2754 <div style="float:right">⇢</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2755 <div style="clear:both;"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2756 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2757 <div onclick="download_popup2(this);" class="actionbutton" title="Download this motif as a position weight matrix or a custom logo.">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2758 <div style="float:left; margin-right:1em;">Download</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2759 <div style="float:right">⟱</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2760 <div style="clear:both;"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2761 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2762 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2763 <div style="clear:both;"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2764 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2765 <h4>Details</h4>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2766 <table class="details">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2767 <thead><tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2768 <th>Positives <div class="help2" onclick="help(this,'pop_motif_positives')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2769 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2770 <th>Negatives <div class="help2" onclick="help(this,'pop_motif_negatives')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2771 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2772 <th>P-value <div class="help2" onclick="help(this,'pop_motif_pvalue')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2773 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2774 <th>E-value <div class="help2" onclick="help(this,'pop_motif_evalue')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2775 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2776 <th>Unerased E-value <div class="help2" onclick="help(this,'pop_motif_uevalue')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2777 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2778 </tr></thead>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2779 <tbody><tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2780 <td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2781 <span class="positives"></span>/3</td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2782 <td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2783 <span class="negatives"></span>/3</td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2784 <td class="pvalue"></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2785 <td class="evalue"></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2786 <td class="uevalue"></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2787 </tr></tbody>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2788 </table>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2789 <h4>Enriched Matching Words</h4>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2790 <table>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2791 <thead><tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2792 <th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2793 <a href="javascript:;" onclick="sort_table(this, compare_strings)"><span class="sort_dir"></span>Word</a> 
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2794 <div class="help2" onclick="help(this,'pop_match_word')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2795 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2796 <th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2797 <a href="javascript:;" onclick="sort_table(this, compare_counts)"><span class="sort_dir"></span>Positives</a> 
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2798 <div class="help2" onclick="help(this,'pop_match_pos')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2799 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2800 <th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2801 <a href="javascript:;" onclick="sort_table(this, compare_counts)"><span class="sort_dir"></span>Negatives</a> 
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2802 <div class="help2" onclick="help(this,'pop_match_neg')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2803 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2804 <th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2805 <a href="javascript:;" onclick="sort_table(this, compare_numbers)"><span class="sort_dir"></span>P-value</a> 
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2806 <div class="help2" onclick="help(this,'pop_match_pval')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2807 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2808 <th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2809 <a href="javascript:;" onclick="sort_table(this, compare_numbers)"><span class="sort_dir">▼</span>E-value</a> 
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2810 <div class="help2" onclick="help(this,'pop_match_eval')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2811 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2812 </tr></thead>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2813 <tbody><tr class="match">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2814 <td class="dnaseq"></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2815 <td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2816 <span class="positives"></span>/3</td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2817 <td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2818 <span class="negatives"></span>/3</td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2819 <td class="pvalue"></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2820 <td class="evalue"></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2821 </tr></tbody>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2822 </table>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2823 </div></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2824 <div id="grey_out_page" class="grey_background" style="display:none;"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2825 <div class="popup_wrapper"><div id="send_to" class="popup" style="top:-150px; display:none">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2826 <div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2827 <div style="float:left" id="send_to_title_1"><h2 class="mainh compact">Submit "<span id="send_to_name"></span>"</h2></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2828 <div style="float:left" id="send_to_title_2"><h2 class="mainh compact">Submit All Motifs</h2></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2829 <div style="float:right; "><div class="close" onclick="both_hide();">x</div></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2830 <div style="clear:both"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2831 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2832 <div style="padding:0 5px 5px 5px;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2833 <div id="send_to_selector" style="height:100px;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2834 <img id="send_to_img" height="90" style="max-width:170px;" onerror="fix_popup_logo(this, 'send_to_can', false)"><canvas id="send_to_can" width="10" height="100" style="display:none;"></canvas><img id="send_to_rcimg" height="90" style="max-width:170px;" onerror="fix_popup_logo(this, 'send_to_rccan', true);"><canvas id="send_to_rccan" width="10" height="100" style="display:none"></canvas><div style="float:right;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2835 <a id="prev_arrow_2" href="javascript:both_change(-1)" class="navarrow">⇧</a><div id="pop_num_2" class="navnum"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2836 <a id="next_arrow_2" href="javascript:both_change(1)" class="navarrow">⇩</a>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2837 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2838 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2839 <form>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2840 <div style="">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2841 <div style="float:left;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2842 <h4 class="compact">Select what you want to do</h4>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2843 <div class="programs_scroll"><ul id="tasks" class="programs">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2844 <li id="search_motifs" onclick="click_submit_task(this)" class="selected">Search Motifs</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2845 <li id="search_sequences" onclick="click_submit_task(this)">Search Sequences</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2846 <li id="rank_sequences" onclick="click_submit_task(this)">Rank Sequences</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2847 <li id="predict_go" onclick="click_submit_task(this)">Predict Gene Ontology terms</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2848 <li id="infer_tf" onclick="click_submit_task(this)">Infer TF Complexes</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2849 </ul></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2850 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2851 <div style="float:right;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2852 <h4 class="compact">Select a program</h4>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2853 <div class="programs_scroll"><ul id="programs" class="programs">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2854 <li id="TOMTOM" onclick="click_submit_program(this)" class="selected">Tomtom</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2855 <li id="FIMO" onclick="click_submit_program(this)">FIMO</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2856 <li id="MAST" onclick="click_submit_program(this)">MAST</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2857 <li id="GOMO" onclick="click_submit_program(this)">GOMO</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2858 <li id="SPAMO" onclick="click_submit_program(this)">SpaMo</li>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2859 </ul></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2860 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2861 <div style="font-weight:bold; display:inline-block; text-align:center; width:60px; height:100px; line-height:100px">Or</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2862 <div style="clear:both;"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2863 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2864 <h4>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2865 <span id="program_action">Search Motifs</span> with <span id="program_name">Tomtom</span>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2866 </h4>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2867 <p><span id="program_desc">Find similar motifs in published
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2868 libraries or a library you supply.</span></p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2869 <div style="margin-top:10px; height: 2em;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2870 <div style="float:left;"><input type="button" value="Send" onclick="javascript:send_to_submit()"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2871 <div style="float:right;"><input type="button" value="Cancel" onclick="javascript:both_hide()"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2872 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2873 </form>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2874 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2875 </div></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2876 <div class="popup_wrapper"><div id="download" class="popup" style="top:-150px; display:none">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2877 <div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2878 <div style="float:left"><h2 class="mainh" style="margin:0; padding:0;">Download "<span id="download_name"></span>"</h2></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2879 <div style="float:right; "><div class="close" onclick="both_hide();">x</div></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2880 <div style="clear:both"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2881 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2882 <div style="padding:0 5px 5px 5px;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2883 <div style="height:100px">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2884 <img id="download_img" height="90" style="max-width:170px;" onerror="fix_popup_logo(this, 'download_can', false)"><canvas id="download_can" width="10" height="100" style="display:none;"></canvas><img id="download_rcimg" height="90" style="max-width:170px;" onerror="fix_popup_logo(this, 'download_rccan', true)"><canvas id="download_rccan" width="10" height="100" style="display:none;"></canvas><div style="float:right;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2885 <a id="prev_arrow_1" href="javascript:both_change(-1)" class="navarrow">⇧</a><div id="pop_num_1" class="navnum"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2886 <a id="next_arrow_1" href="javascript:both_change(1)" class="navarrow">⇩</a>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2887 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2888 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2889 <form>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2890 <input type="hidden" id="download_tab_num" value="1"><div style="padding:5px 0;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2891 <div class="tabArea top">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2892 <a id="download_tab_1" href="javascript:click_download_tab(1)" class="tab activeTab">PSPM Format</a><a id="download_tab_2" href="javascript:click_download_tab(2)" class="tab">PSSM Format</a><a id="download_tab_3" href="javascript:click_download_tab(3)" class="tab">Logo</a>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2893 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2894 <div class="tabMain">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2895 <div id="download_pnl_1"><textarea id="download_pspm" style="width:99%" rows="10" readonly></textarea></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2896 <div id="download_pnl_2"><textarea id="download_pssm" style="width:99%" rows="10" readonly></textarea></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2897 <div id="download_pnl_3"><table>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2898 <tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2899 <td><label for="logo_format">Format:</label></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2900 <td><select id="logo_format"><option value="png">PNG (for web)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2901 <option value="eps">EPS (for publication)</option></select></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2902 </tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2903 <tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2904 <td><label for="logo_rc">Orientation:</label></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2905 <td><select id="logo_rc"><option value="false">Normal</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2906 <option value="true">Reverse Complement</option></select></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2907 </tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2908 <tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2909 <td><label for="logo_ssc">Small Sample Correction:</label></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2910 <td><select id="logo_ssc"><option value="false">Off</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2911 <option value="true">On</option></select></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2912 </tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2913 <tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2914 <td><label for="logo_width">Width:</label></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2915 <td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2916 <input type="text" id="logo_width" size="4"> cm
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2917 </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2918 </tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2919 <tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2920 <td><label for="logo_height">Height:</label></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2921 <td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2922 <input type="text" id="logo_height" size="4"> cm
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2923 </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2924 </tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2925 </table></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2926 <div style="margin-top:10px;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2927 <div style="float:left;"><input type="button" id="download_button" value="Download" style="visibility:hidden;" onclick="javascript:download_submit()"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2928 <div style="float:right;"><input type="button" value="Cancel" onclick="javascript:both_hide()"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2929 <div style="clear:both;"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2930 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2931 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2932 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2933 </form>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2934 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2935 </div></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2936 <a name="top"></a><div class="pad1">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2937 <h1><img src="http://Sharplab-G4-1.local/meme/doc/images/dreme_logo.png" alt="Discriminative Regular Expression Motif Elicitation (DREME)"></h1>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2938 <p class="spaced">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2939 For further information on how to interpret these results or to get a
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2940 copy of the MEME software please access
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2941 <a href="http://meme.nbcr.net/">http://meme.nbcr.net</a>.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2942 </p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2943 <p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2944 If you use DREME in your research please cite the following paper:<br><span class="citation">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2945 Timothy L. Bailey, "DREME: Motif discovery in transcription factor ChIP-seq data", <i>Bioinformatics</i>, <b>27</b>(12):1653-1659, 2011.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2946 </span></p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2947 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2948 <div class="pad2">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2949 <a class="jump" href="#description">Description</a>  |  <a class="jump" href="#motifs">Discovered motifs</a>  |  <a class="jump" href="#program">Program information</a>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2950 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2951 <a name="description"></a><table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#FFFFFF"><tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2952 <td><h2 class="mainh">Description</h2></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2953 <td align="right" valign="bottom">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2954 <a href="#motifs">Next</a> <a href="#top">Top</a>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2955 </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2956 </tr></table>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2957 <div class="box"><p>xxxx</p></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2958 <a name="motifs"></a><table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#FFFFFF"><tr>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2959 <td><h2 class="mainh">Discovered Motifs</h2></td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2960 <td align="right" valign="bottom">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2961 <a href="#description">Previous</a> <a href="#program">Next</a> <a href="#top">Top</a>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2962 </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2963 </tr></table>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2964 <div class="box">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2965 <p><b>Click on the ↧</b> under the <b>More</b> column to show more
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2966 information about the motif.<br><b>Click on the ⇢</b> under the <b>Submit</b> column to send the
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2967 motif to another MEME suite program. Eg. Tomtom<br><b>Click on the ⟱</b> under the <b>Download</b> column to get
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2968 the position weight matrix of a motif or to download the logo image with
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2969 your chosen options.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2970 </p>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2971 <table id="dreme_motifs" class="dreme_motifs">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2972 <thead><tr class="motif_head">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2973 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2974 <th>Motif <div class="help2" onclick="help(this,'pop_motifs_name')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2975 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2976 <th>Logo <div class="help2" onclick="help(this,'pop_motifs_logo')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2977 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2978 <th>RC Logo <div class="help2" onclick="help(this,'pop_motifs_rc_logo')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2979 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2980 <th>E-value <div class="help2" onclick="help(this,'pop_motifs_evalue')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2981 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2982 <th>Unerased E-value <div class="help2" onclick="help(this,'pop_motifs_uevalue')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2983 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2984 <th>More <div class="help2" onclick="help(this,'pop_more')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2985 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2986 <th>Submit <div class="help2" onclick="help(this,'pop_submit')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2987 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2988 <th>Download <div class="help2" onclick="help(this,'pop_download')">?</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2989 </th>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2990 </tr></thead>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2991 <tbody></tbody>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2992 <tfoot><tr class="rule">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2993 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2994 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2995 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2996 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2997 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2998 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2999 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3000 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3001 <td> </td>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3002 </tr></tfoot>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3003 </table>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3004 <div style="float:left"><div onclick="send_to_popup(0);" class="actionbutton" title="Submit all motifs to another program.">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3005 <div style="float:left; margin-right:1em;">Submit All</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3006 <div style="float:right">⇢</div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3007 <div style="clear:both;"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3008 </div></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3009 <div style="clear:both;"></div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3010 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3011 <a name="program"></a><div class="bar">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3012 <div style="text-align:right;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3013 <a href="#motifs">Previous</a> <a href="#top">Top</a>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3014 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3015 <div class="subsection">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3016 <a name="version"></a><h5>DREME version</h5>4.7.0 (Release date: Wed Sep 28 17:30:10 EST 2011)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3017 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3018 <div class="subsection">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3019 <a name="reference"></a><h5>Reference</h5>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3020 <span class="citation">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3021 Timothy L. Bailey, "DREME: Motif discovery in transcription factor ChIP-seq data", <i>Bioinformatics</i>, <b>27</b>(12):1653-1659, 2011.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3022 </span>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3023 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3024 <div class="subsection">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3025 <a name="command"></a><h5>Command line summary</h5>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3026 <textarea rows="1" style="width:100%;" readonly>dreme -p test.fa -desc xxxx</textarea><br>Result calculation took 0.01 seconds<br>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3027 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3028 <a href="javascript:show_hidden('model')" id="model_activator">show model parameters...</a><div class="subsection" id="model_data" style="display:none;">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3029 <h5>Model parameters</h5>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3030 <textarea style="width:100%;" rows="10" readonly>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3031 positives = name: "test", count: "3", file: "test.fa", last_mod_date: "Sat Dec 10 12:52:18 EST 2011"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3032 negatives = name: "shuffled positive sequences", count: "3", from: "shuffled"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3033 background = type: "dna", A: "0.243", C: "0.270", G: "0.243", T: "0.243", from: "dataset"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3034 stop = evalue: "0.05"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3035 ngen = 100
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3036 add_pv_thresh = 0.01
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3037 seed = 1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3038 host = SHARPLAB.MIT.EDU
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3039 when = Sun Dec 11 09:26:43 EST 2011
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3040 </textarea>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3041 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3042 <a href="javascript:hide_shown('model')" style="display:none;" id="model_deactivator">hide model parameters...</a>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3043 </div>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3044 </body>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3045 </html>