00001 #include <stdio.h>
00002 #include "array.h"
00003 #include "html.h"
00004 #include "format.h"
00005 #include "sqvUtil.h"
00006 #include "sqvWeb.h"
00007
00008 void filterChrRegions(Array *regions, Chrdata_t **chromosomes)
00009 {
00010 Array tmpArr = arrayCreate(1, SRegion_t);
00011 SRegion_t *tmp, *tmp2;
00012 int i, j = 0;
00013
00014 for (i = 0; i < arrayMax(*regions); i++) {
00015 tmp = arrayp(*regions, i, SRegion_t);
00016 if (tmp->chromosome != -1 && tmp->instance != -1) {
00017 if (tmp->mend == -1) {
00018 tmp->mend = chrsize(tmp->chromosome);
00019 }
00020 if (tmp->end == -1) {
00021 tmp->end = chrsize(tmp->chromosome);
00022 }
00023 if (tmp->end > tmp->mend) {
00024 tmp->end = tmp->mend;
00025 }
00026 if (tmp->start < tmp->mstart) {
00027 tmp->start = tmp->mstart;
00028 }
00029
00030 tmp2 = arrayp(tmpArr, j, SRegion_t);
00031 tmp2->chromosome = tmp->chromosome;
00032 tmp2->instance = tmp->instance;
00033 tmp2->show = tmp->show;
00034 tmp2->start = tmp->start;
00035 tmp2->end = tmp->end;
00036 tmp2->mstart = tmp->mstart;
00037 tmp2->mend = tmp->mend;
00038
00039 (*chromosomes)[tmp->chromosome].instances++;
00040 j++;
00041 }
00042 }
00043
00044 for (i = 1; i <= 24; i++) {
00045 if ((*chromosomes)[i].show) {
00046 if ((*chromosomes)[i].instances == 0) {
00047 (*chromosomes)[i].show = 0;
00048 }
00049 }
00050 }
00051
00052 arraySort(tmpArr, (ARRAYORDERF) &SRegionCmp);
00053 arrayDestroy(*regions);
00054
00055 *regions = tmpArr;
00056 }
00057
00058
00059
00060 void web_printSingleLocusForm(char *web_url, char *web_pub_url)
00061 {
00062 puts ("<html>");
00063 puts ("<head>");
00064 puts ("<title>SeqViz: Single Locus Analysis</title>\n");
00065 html_printGenericStyleSheet (12);
00066 html_printAdditionalCSS(web_pub_url);
00067 html_linkjQuery(web_pub_url);
00068 puts ("</head>");
00069 puts ("<body>");
00070 puts ("<h1>SeqViz: Identification of all reads which align to one region</h1><br><br>");
00071 printf ("<form action=\"%s/seqViz_cgi\" method=\"get\">\n", web_url);
00072 puts ("<b>Data prefix:</b> ");
00073 puts ("<input type=\"text\" name=\"prefix\">");
00074 puts ("<br><br><br>");
00075 puts ("<b>Locus:</b> ");
00076 puts ("<input type=\"text\" name=\"location\">");
00077 puts ("Example: chr21:2449394-3499493");
00078 puts ("<br><br><br>");
00079 puts ("<b>Limit number of reads:</b> ");
00080 puts ("<input type=\"text\" name=\"readlim\">");
00081 puts ("<br><br><br>");
00082 puts ("<b>Minimum insert size:</b> ");
00083 puts ("<input type=\"text\" name=\"minspan\">");
00084 puts ("<br><br><br>");
00085 puts ("<input type=\"submit\" value=\"Submit\">");
00086 puts ("<input type=\"reset\" value=\"Reset\">");
00087 puts ("</form>");
00088 puts ("</body>");
00089 puts ("</html>");
00090 }
00091
00092 void web_printHTMLHead(Array regions, Chrdata_t *chromosomes, char *web_pub_url)
00093 {
00094 int i;
00095 SRegion_t *tmp;
00096
00097 puts ("<html>");
00098 puts ("<head>");
00099 puts ("<title>SeqViz - Single Location</title>");
00100 html_printGenericStyleSheet (10);
00101 html_printAdditionalCSS(web_pub_url);
00102 html_linkjQuery(web_pub_url);
00103
00104 tmp = arrayp(regions, 0, SRegion_t);
00105 if (tmp->chromosome >= 1 && tmp->chromosome <= 24) {
00106 puts ("<script type=\"text/javascript\">");
00107 puts ("$(function() {");
00108
00109 for (i = 0; i < arrayMax(regions); i++) {
00110 tmp = arrayp(regions, i, SRegion_t);
00111 web_printSliderJS (tmp);
00112 }
00113
00114 puts ("});");
00115
00116 puts ("</script>");
00117 }
00118 puts ("</head>");
00119 puts ("<body>");
00120 puts ("<div class=\"container\">");
00121 }
00122
00123
00124
00125 void web_printSliderJS (SRegion_t *region)
00126 {
00127 char *schrname;
00128 char *mchrname;
00129
00130 schrname = getSchrname (region->chromosome);
00131 mchrname = getMchrname (region->chromosome);
00132
00133 printf ("\t$(\"#slider-%s-%i\").slider({\n", schrname, region->instance);
00134 puts ("\t\trange: true,");
00135 printf ("\t\tmin: %i,\n", region->mstart);
00136 printf ("\t\tmax: %i,\n", region->mend);
00137 printf ("\t\tvalues: [%i, %i],\n", region->start, region->end);
00138 puts ("\t\tslide: function(event, ui) {");
00139 printf ("\t\t\t$(\"#%s-%i-start\").val(ui.values[0]);\n", schrname, region->instance);
00140 printf ("\t\t\t$(\"#%s-%i-end\").val(ui.values[1]);\n", schrname, region->instance);
00141 puts ("\t\t}");
00142 puts ("\t});");
00143 printf ("\t$(\"#%s-%i-start\").val($(\"#slider-%s-%i\").slider(\"values\", 0));\n", schrname, region->instance, schrname, region->instance);
00144 printf ("\t$(\"#%s-%i-end\").val($(\"#slider-%s-%i\").slider(\"values\", 1));\n\n", schrname, region->instance, schrname, region->instance);
00145
00146 printf ("\t$(\"#slider-%s-%i\").slider({\n", mchrname, region->instance);
00147 puts ("\t\trange: true,");
00148 printf ("\t\tmin: %i,\n", 0);
00149 printf ("\t\tmax: %i,\n", chrsize(region->chromosome));
00150 printf ("\t\tvalues: [%i, %i],\n", region->mstart, region->mend);
00151 puts ("\t\tslide: function(event, ui) {");
00152 printf ("\t\t\t$(\"#%s-%i-start\").val(ui.values[0]);\n", mchrname, region->instance);
00153 printf ("\t\t\t$(\"#%s-%i-end\").val(ui.values[1]);\n", mchrname, region->instance);
00154 puts ("\t\t}");
00155 puts ("\t});");
00156 printf ("\t$(\"#%s-%i-start\").val($(\"#slider-%s-%i\").slider(\"values\", 0));\n", mchrname, region->instance, mchrname, region->instance);
00157 printf ("\t$(\"#%s-%i-end\").val($(\"#slider-%s-%i\").slider(\"values\", 1));\n\n", mchrname, region->instance, mchrname, region->instance);
00158
00159 free (schrname);
00160 free (mchrname);
00161 }
00162
00163 void web_printPageHeader(char *prefix, char *location)
00164 {
00165 if (prefix[0] == '\0') {
00166 fprintf (stderr, "Invalid prefix\n");
00167 exit (1);
00168 }
00169 printf ("<h1>SeqViz - %s - %s</h1>\n", prefix, location);
00170 }
00171
00172
00173 void web_printSidebar (char *web_url,
00174 char *prefix,
00175 char *location,
00176 char *cirImgUrl,
00177 char *cirSvgUrl,
00178 Array regions,
00179 Chrdata_t *chromosomes,
00180 SVCfg_t *settings)
00181 {
00182 int i;
00183 char *chrname;
00184 char *schrname;
00185 Stringa url;
00186
00187
00188
00189
00190 putsn (1, "<div class=\"sidebar\">");
00191 putsn (2, "<div class=\"m_wrapper\">");
00192 putsn (3, "<div class=\"m_header\">Ideogram</div>");
00193 putsn (3, "<div class=\"m_bodyBlank\">");
00194 printf ("\t\t\t\t<form action=\"%s/seqViz_cgi\" method=\"get\">\n", web_url);
00195 putsn (5, "<table cellpadding=\"0\" cellspacing=\"0\">");
00196 putsn (6, "<tr>");
00197 putsn (7, "<td class=\"f_label\">Prefix</td>");
00198 putsn (7, "<td class=\"f_field\">");
00199 printf ("\t\t\t\t\t\t\t<input type=\"text\" name=\"prefix\" value=\"%s\" />\n", prefix);
00200 putsn (7, "</td>");
00201 putsn (6, "</tr>");
00202 putsn (6, "<tr>");
00203 putsn (7, "<td class=\"f_label\">Location</td>");
00204 putsn (7, "<td class=\"f_field\">");
00205 printf ("\t\t\t\t\t\t\t<input type=\"text\" name=\"location\" value=\"%s\" />\n", location);
00206 putsn (7, "</td>");
00207 putsn (6, "</tr>");
00208 putsn (6, "<tr>");
00209 putsn (7, "<td class=\"f_label\">Segmentation filter</td>");
00210 putsn (7, "<td class=\"f_field\">");
00211
00212 if (settings->rfilter.on) {
00213 putsn (8, "<span class=\"l_no\">Off <input type=\"radio\" name=\"rfilter\" value=\"0\" /></span>");
00214 putsn (8, "<span class=\"l_yes\"><input type=\"radio\" name=\"rfilter\" value=\"1\" checked=\"checked\" /> On</span>");
00215 }
00216 else {
00217 putsn (8, "<span class=\"l_no\">Off <input type=\"radio\" name=\"rfilter\" value=\"0\" checked=\"checked\" /></span>");
00218 putsn (8, "<span class=\"l_yes\"><input type=\"radio\" name=\"rfilter\" value=\"1\" /> On</span>");
00219 }
00220 putsn (7, "</td>");
00221 putsn (6, "</tr>");
00222
00223 if (settings->rfilter.on) {
00224 putsn (6, "<tr>");
00225 putsn (7, "<td class=\"f_cas\" colspan=\"2\">");
00226 putsn (8, "<fieldset>");
00227 putsn (9, "<legend>Filter params</legend>");
00228 putsn (9, "<table cellpading=\"0\" cellspacing=\"0\">");
00229 putsn (10, "<tr>");
00230 putsn (11, "<td class=\"f_label\">Threshold</td>");
00231 puts ("\t\t\t\t\t\t\t\t\t\t\t");
00232 printf ("<td class=\"f_field\"><input type=\"text\" name=\"rthold\" value=\"%i\" size=\"15\" /></td>\n", settings->rfilter.thold);
00233 putsn (10, "</tr>");
00234 putsn (10, "<tr>");
00235 putsn (11, "<td class=\"f_label\">Maxgap</td>");
00236 puts ("\t\t\t\t\t\t\t\t\t\t\t");
00237 printf ("<td class=\"f_field\"><input type=\"text\" name=\"rmaxgap\" value=\"%i\" size=\"15\" /></td>\n", settings->rfilter.maxgap);
00238 putsn (10, "</tr>");
00239 putsn (10, "<tr>");
00240 putsn (11, "<td class=\"f_label\">Minrun</td>");
00241 puts ("\t\t\t\t\t\t\t\t\t\t\t");
00242 printf ("<td class=\"f_field\"><input type=\"text\" name=\"rminrun\" value=\"%i\" size=\"15\" /></td>\n", settings->rfilter.minrun);
00243 putsn (10, "</tr>");
00244 putsn (10, "<tr>");
00245 putsn (11, "<td class=\"f_label\">Tars</td>");
00246 putsn (11, "<td class=\"f_field\">");
00247 if (settings->rfilter.showtars) {
00248 putsn (8, "<span class=\"l_no\">Hide <input type=\"radio\" name=\"rshowtars\" value=\"0\" /></span>");
00249 putsn (8, "<span class=\"l_yes\"><input type=\"radio\" name=\"rshowtars\" value=\"1\" checked=\"checked\" /> Show</span>");
00250 } else {
00251 putsn (8, "<span class=\"l_no\">Hide <input type=\"radio\" name=\"rshowtars\" value=\"0\" checked=\"checked\" /></span>");
00252 putsn (8, "<span class=\"l_yes\"><input type=\"radio\" name=\"rshowtars\" value=\"1\" /> Show</span>");
00253 }
00254 putsn (11, "</td>");
00255 putsn (10, "</tr>");
00256 putsn (9, "</table>");
00257 putsn (8, "</fieldset>");
00258 putsn (7, "</td>");
00259 putsn (6, "</tr>");
00260 }
00261
00262 putsn (6, "<tr>");
00263 putsn (7, "<td class=\"f_label\">Limit reads (0 for no limit)</td>");
00264 putsn (7, "<td class=\"f_field\">");
00265 printf ("\t\t\t\t\t\t\t\t<input type=\"text\" name=\"readlim\", value=\"%i\" />", settings->readlim);
00266 putsn (7, "</td>");
00267 putsn (6, "</tr>");
00268
00269 putsn (6, "<tr>");
00270 putsn (7, "<td class=\"f_label\">Min insert size</td>");
00271 putsn (7, "<td class=\"f_field\">");
00272 printf ("\t\t\t\t\t\t\t\t<input type=\"text\" name=\"minspan\", value=\"%i\" />", settings->minspan);
00273 putsn (7, "</td>");
00274 putsn (6, "</tr>");
00275
00276 putsn (6, "<tr>");
00277 putsn (7, "<td class=\"f_label\" colspan=\"2\">");
00278 if (settings->tracks.genes) {
00279 putsn (8, "<input type=\"hidden\" name=\"genes\" value=\"1\" />\n");
00280 if (settings->tracks.exons) {
00281 putsn (8, "<input type=\"hidden\" name=\"exons\" value=\"1\" />\n");
00282 }
00283 }
00284 if (settings->tracks.expr) {
00285 putsn (8, "<input type=\"hidden\" name=\"expr\" value=\"on\" />\n");
00286 }
00287
00288 web_printChrHidden (chromosomes, 8);
00289 web_printRegionHidden (regions, 8);
00290
00291 putsn (8, "<input type=\"submit\" value=\"Update\" />");
00292 putsn (7, "</td>");
00293 putsn (6, "</tr>");
00294
00295 putsn (6, "<tr>");
00296 putsn (7, "<td class=\"f_label\" colspan=\"2\">");
00297 printf ("\t\t\t\t\t\t\t\t<a href=\"%s\" target=\"_blank\">Download PNG</a><br />\n", cirImgUrl);
00298 printf ("\t\t\t\t\t\t\t\t<a href=\"%s\" target=\"_blank\">Download SVG</a>\n", cirSvgUrl);
00299 putsn (7, "</td>");
00300 putsn (6, "</tr>");
00301 putsn (5, "</table>");
00302 putsn (4, "</form>");
00303 putsn (3, "</div>");
00304 putsn (2, "</div>");
00305
00306
00307
00308
00309 putsn (2, "<div class=\"m_wrapper\">");
00310 putsn (3, "<div class=\"m_header\">Chromosomes</div>");
00311 putsn (3, "<div class=\"m_bodyBlank\">");
00312 printf ("\t\t\t\t<form action=\"%s/seqViz_cgi\" method=\"get\">\n", web_url);
00313 putsn (5, "<table cellpadding=\"0\" cellspacing=\"0\">");
00314 putsn (6, "<tr>");
00315 putsn (7, "<td>");
00316 printf ("\t\t\t\t\t\t\t<input type=\"hidden\" name=\"prefix\" value=\"%s\" />\n", prefix);
00317 printf ("\t\t\t\t\t\t\t<input type=\"hidden\" name=\"location\" value=\"%s\" />\n", location);
00318 putsn (8, "<table cellpadding=\"0\" cellspacing=\"0\">");
00319 for (i = 1; i < 13; i++) {
00320 chrname = getHchrname (i);
00321 url = stringCreate (50);
00322 schrname = getSchrname (i);
00323
00324 stringPrintf (url, "%s", url_makeBase (prefix, location));
00325 stringAppendf (url, "%s", url_makeChrs (chromosomes));
00326 if (!chromosomes[i].show) {
00327 stringAppendf (url, "&%s=on", chrname);
00328 }
00329 stringAppendf (url, "%s", url_makeRegions (regions, 0, 0));
00330 stringAppendf (url, "&%s-%i-show=on", schrname, chromosomes[i].instances+1);
00331 stringAppendf (url, "%s", url_makeOpts (settings));
00332
00333 putsn (9, "<tr>");
00334 putsn (10, "<td class=\"f_field\">");
00335 if (chromosomes[i].instances > 0) {
00336 if (chromosomes[i].show) {
00337 printf ("\t\t\t\t\t\t\t\t\t\t\t<input type=\"checkbox\" name=\"%s\" checked=\"checked\" />\n", chrname);
00338 }
00339 else {
00340 printf ("\t\t\t\t\t\t\t\t\t\t\t<input type=\"checkbox\" name=\"%s\" />\n", chrname);
00341 }
00342 }
00343 putsn (10, "</td>");
00344 putsn (10, "<td class=\"f_label\">");
00345 printf ("\t\t\t\t\t\t\t\t\t\t\t%s <a href=\"seqViz_cgi%s\" class=\"l_go\">+</a>\n", chrname, string(url));
00346 putsn (10, "</td>");
00347 putsn (9, "</tr>");
00348
00349 free (schrname);
00350 stringDestroy (url);
00351 free (chrname);
00352 }
00353
00354 putsn (8, "</table>");
00355 putsn (7, "</td>");
00356 putsn (7, "<td>");
00357 putsn (8, "<table cellpadding=\"0\" cellspacing=\"0\">");
00358 for (i = 13; i <= 24; i++) {
00359 chrname = getHchrname (i);
00360 url = stringCreate (50);
00361 schrname = getSchrname (i);
00362
00363 stringPrintf (url, "%s", url_makeBase (prefix, location));
00364 stringAppendf (url, "%s", url_makeChrs (chromosomes));
00365 if (!chromosomes[i].show) {
00366 stringAppendf (url, "&%s=on", chrname);
00367 }
00368 stringAppendf (url, "%s", url_makeRegions (regions, 0, 0));
00369 stringAppendf (url, "&%s-%i-show=on", schrname, chromosomes[i].instances+1);
00370 stringAppendf (url, "%s", url_makeOpts (settings));
00371
00372 putsn (9, "<tr>");
00373 putsn (10, "<td class=\"f_field\">");
00374 if (chromosomes[i].instances > 0) {
00375 if (chromosomes[i].show) {
00376 printf ("\t\t\t\t\t\t\t\t\t\t\t<input type=\"checkbox\" name=\"%s\" checked=\"checked\" />\n", chrname);
00377 }
00378 else {
00379 printf ("\t\t\t\t\t\t\t\t\t\t\t<input type=\"checkbox\" name=\"%s\" />\n", chrname);
00380 }
00381 }
00382 putsn (10, "</td>");
00383 putsn (10, "<td class=\"f_label\">");
00384 printf ("\t\t\t\t\t\t\t\t\t\t\t%s <a href=\"seqViz_cgi%s\" class=\"l_go\">+</a>\n", chrname, string(url));
00385 putsn (10, "</td>");
00386 putsn (9, "</tr>");
00387
00388 free (schrname);
00389 stringDestroy (url);
00390 free (chrname);
00391 }
00392 putsn (8, "</table>");
00393 putsn (7, "</td>");
00394 putsn (6, "</tr>");
00395 putsn (6, "<tr>");
00396 putsn (7, "<td class=\"f_field\" colspan=\"2\">");
00397 if (settings->tracks.genes) {
00398 putsn (8, "<input type=\"hidden\" name=\"genes\" value=\"1\" />\n");
00399 if (settings->tracks.exons) {
00400 putsn (8, "<input type=\"hidden\" name=\"exons\" value=\"1\" />\n");
00401 }
00402 }
00403 if (settings->tracks.expr) {
00404 putsn (8, "<input type=\"hidden\" name=\"expr\" value=\"on\" />\n");
00405 }
00406 if (settings->rfilter.on) {
00407 putsn (8, "<input type=\"hidden\" name=\"rfilter\" value=\"1\" />");
00408 if (settings->rfilter.thold)
00409 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"rthold\" value=\"%i\" />", settings->rfilter.thold);
00410 if (settings->rfilter.maxgap)
00411 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"rmaxgap\" value=\"%i\" />", settings->rfilter.maxgap);
00412 if (settings->rfilter.minrun)
00413 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"rminrun\" value=\"%i\" />", settings->rfilter.minrun);
00414 if (settings->rfilter.showtars)
00415 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"rshowtars\" value=\"%i\" />", settings->rfilter.showtars);
00416 }
00417 if (settings->readlim) {
00418 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"readlim\", value=\"%i\" />", settings->readlim);
00419 }
00420 if (settings->minspan) {
00421 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"minspan\", value=\"%i\" />", settings->minspan);
00422 }
00423
00424 web_printRegionHidden (regions, 8);
00425 putsn (8, "<input type=\"submit\" value=\"Update\">");
00426 putsn (7, "</td>");
00427 putsn (6, "</tr>");
00428 putsn (5, "</table>");
00429 putsn (4, "</form>");
00430 putsn (3, "</div>");
00431 putsn (2, "</div>");
00432 putsn (1, "</div>");
00433
00434 }
00435
00436 void web_printBody (char *web_url,
00437 char *prefix,
00438 char *location,
00439 Array regions,
00440 Chrdata_t *chromosomes,
00441 SVCfg_t *settings)
00442 {
00443 SRegion_t *tmp;
00444 char *schrname;
00445 char *mchrname;
00446 char *chrname;
00447 Stringa url;
00448 int i;
00449
00450 putsn (1, "<br class=\"clear\" />");
00451 printf ("\t<form action=\"%s/seqViz_cgi\" method=\"get\">\n", web_url);
00452 printf ("\t\t<input type=\"hidden\" name=\"prefix\" value=\"%s\" />\n", prefix);
00453 printf ("\t\t<input type=\"hidden\" name=\"location\" value=\"%s\" />\n", location);
00454
00455
00456
00457
00458 putsn (2, "<div class=\"m_wrapper\">");
00459 printf ("\t\t\t<div class=\"m_header\">Added regions <a href=\"seqViz_cgi?prefix=%s&location=%s%s\" class=\"l_warn\">- Remove all</a></div>\n",
00460 prefix, location, url_makeOpts (settings));
00461
00462 tmp = arrayp (regions, 0, SRegion_t);
00463 if (tmp->chromosome >= 1 && tmp->chromosome <= 24) {
00464
00465 for (i = 0; i < arrayMax (regions); i++) {
00466 tmp = arrayp (regions, i, SRegion_t);
00467 schrname = getSchrname (tmp->chromosome);
00468 mchrname = getMchrname (tmp->chromosome);
00469 chrname = getHchrname (tmp->chromosome);
00470 url = stringCreate (50);
00471
00472 putsn (3, "<div class=\"m_body\">");
00473 putsn (4, "<fieldset>");
00474 putsn (5, "<legend>");
00475 if (tmp->show) {
00476 printf ("\t\t\t\t\t\t<input type=\"checkbox\" name=\"%s-%i-show\" checked=\"checked\" />\n", schrname, tmp->instance);
00477 }
00478 else {
00479 printf ("\t\t\t\t\t\t<input type=\"checkbox\" name=\"%s-%i-show\" />\n", schrname, tmp->instance);
00480 }
00481 printf ("\t\t\t\t\t\t<label for=\"%s-%i-show\">%s</label>\n", schrname, tmp->instance, chrname);
00482 putsn (5, "</legend>");
00483 putsn (5, "<table cellpadding=\"0\" cellspacing=\"0\">");
00484 putsn (6, "<tr>");
00485 putsn (7, "<td rowspan=\"2\" class=\"f_label\">Zoomed Region</td>");
00486 putsn (7, "<td class=\"f_field\">");
00487 printf ("\t\t\t\t\t\t\t\t<label for=\"%s-%i-start\">Start:</label>\n", schrname, tmp->instance);
00488 printf ("\t\t\t\t\t\t\t\t<input type=\"text\" name=\"%s-%i-start\" id=\"%s-%i-start\" style=\"border:0; color:#f6931f; font-weight:bold;\" />\n",
00489 schrname, tmp->instance, schrname, tmp->instance);
00490 printf ("\t\t\t\t\t\t\t\t<label for=\"%s-%i-end\">End:</label>\n", schrname, tmp->instance);
00491 printf ("\t\t\t\t\t\t\t\t<input type=\"text\" name=\"%s-%i-end\" id=\"%s-%i-end\" style=\"border:0; color:#f6931f; font-weight:bold;\" />\n",
00492 schrname, tmp->instance, schrname, tmp->instance);
00493 putsn (7, "</td>");
00494 putsn (6, "</tr>");
00495 putsn (6, "<tr>");
00496 putsn (7, "<td class=\"f_field slide\">");
00497 putsn (8, "<br class=\"clear\" />");
00498 printf ("\t\t\t\t\t\t\t\t<div id=\"slider-%s-%i\"></div>\n", schrname, tmp->instance);
00499 putsn (8, "<br class=\"clear\" />");
00500 putsn (7, "</td>");
00501 putsn (6, "</tr>");
00502 putsn (6, "<tr>");
00503 putsn (7, "<td rowspan=\"2\" class=\"f_label\">Entire Chromosome</td>");
00504 putsn (7, "<td class=\"f_field\">");
00505 printf ("\t\t\t\t\t\t\t\t<label for=\"%s-%i-start\">Start:</label>\n", mchrname, tmp->instance);
00506 printf ("\t\t\t\t\t\t\t\t<input type=\"text\" name=\"%s-%i-start\" id=\"%s-%i-start\" style=\"border:0; color:#f6931f; font-weight:bold;\" />\n",
00507 mchrname, tmp->instance, mchrname, tmp->instance);
00508 printf ("\t\t\t\t\t\t\t\t<label for=\"%s-%i-end\">End:</label>\n", mchrname, tmp->instance);
00509 printf ("\t\t\t\t\t\t\t\t<input type=\"text\" name=\"%s-%i-end\" id=\"%s-%i-end\" style=\"border:0; color:#f6931f; font-weight:bold;\" />\n",
00510 mchrname, tmp->instance, mchrname, tmp->instance);
00511 putsn (7, "</td>");
00512 putsn (6, "</tr>");
00513 putsn (6, "<tr>");
00514 putsn (7, "<td class=\"f_field slide\">");
00515 putsn (8, "<br class=\"clear\" />");
00516 printf ("\t\t\t\t\t\t\t\t<div id=\"slider-%s-%i\"></div>\n", mchrname, tmp->instance);
00517 putsn (8, "<br class=\"clear\" />");
00518 putsn (7, "</td>");
00519 putsn (6, "</tr>");
00520 putsn (6, "<tr>");
00521 putsn (6, "<td class=\"f_label\">Options</td>");
00522 putsn (6, "<td class=\"f_field\">");
00523
00524 stringPrintf (url, "%s%s%s%s",
00525 url_makeBase (prefix, location),
00526 url_makeChrs (chromosomes),
00527 url_makeRegions (regions, tmp->chromosome, tmp->instance),
00528 url_makeOpts (settings));
00529
00530 printf ("<a href=\"seqViz_cgi%s\" class=\"l_warn\">- Remove</a> \n", string (url));
00531 putsn (7, "</td>");
00532 putsn (6, "</tr>");
00533 putsn (5, "</table>");
00534 putsn (4, "</fieldset>");
00535 putsn (3, "</div>");
00536
00537 free (chrname);
00538 free (schrname);
00539 free (mchrname);
00540 stringDestroy (url);
00541 }
00542 }
00543 putsn (3, "<div class=\"m_body\">");
00544
00545 web_printChrHidden (chromosomes, 4);
00546 if (settings->rfilter.on) {
00547 putsn (8, "<input type=\"hidden\" name=\"rfilter\" value=\"1\" />");
00548 if (settings->rfilter.thold)
00549 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"rthold\" value=\"%i\" />", settings->rfilter.thold);
00550 if (settings->rfilter.maxgap)
00551 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"rmaxgap\" value=\"%i\" />", settings->rfilter.maxgap);
00552 if (settings->rfilter.minrun)
00553 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"rminrun\" value=\"%i\" />", settings->rfilter.minrun);
00554 if (settings->rfilter.minrun)
00555 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"rminrun\" value=\"%i\" />", settings->rfilter.minrun);
00556 }
00557 if (settings->readlim) {
00558 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"readlim\", value=\"%i\" />", settings->readlim);
00559 }
00560 if (settings->minspan) {
00561 printf ("\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"minspan\", value=\"%i\" />", settings->minspan);
00562 }
00563 putsn (4, "<input type=\"submit\" value=\"Update\" />");
00564 putsn (3, "</div>");
00565 putsn (2, "</div>");
00566
00567
00568
00569
00570 putsn (2, "<div class=\"m_wrapper\">");
00571 putsn (3, "<div class=\"m_header\">Data Tracks</div>");
00572 putsn (3, "<div class=\"m_bodyBlank\">");
00573 putsn (4, "<table cellpadding=\"0\" cellspacing=\"0\">");
00574 putsn (5, "<tr>");
00575 if (settings->tracks.expr) {
00576 putsn (6, "<td class=\"f_field\"><input type=\"checkbox\" name=\"expr\" checked=\"checked\" /></td>");
00577 }
00578 else {
00579 putsn (6, "<td class=\"f_field\"><input type=\"checkbox\" name=\"expr\" /></td>");
00580 }
00581 putsn (6, "<td class=\"f_label\" colspan=\"2\"><label for=\"expr\">Gene Expression</label></td>");
00582 putsn (5, "</tr>");
00583 putsn (5, "<tr>");
00584 if (settings->tracks.genes) {
00585 putsn (6, "<td class=\"f_field\"><input type=\"checkbox\" name=\"genes\" checked=\"checked\" /></td>");
00586 putsn (6, "<td class=\"f_label\"><label for=\"genes\">Genes</label></td>");
00587 putsn (6, "<td class=\"f_label\">");
00588 if (settings->tracks.exons) {
00589 putsn (7, "<span class=\"l_no\">Hide exons <input type=\"radio\" name=\"exons\" value=\"0\" /></span>");
00590 putsn (7, "<span class=\"l_yes\"><input type=\"radio\" name=\"exons\" value=\"1\" checked=\"checked\" /> Show exons</span>");
00591 }
00592 else {
00593 putsn (7, "<span class=\"l_no\">Hide exons <input type=\"radio\" name=\"exons\" value=\"0\" checked=\"checked\" /></span>");
00594 putsn (7, "<span class=\"l_yes\"><input type=\"radio\" name=\"exons\" value=\"1\" /> Show exons</span>");
00595 }
00596 putsn (6, "</td>");
00597 }
00598 else {
00599 putsn (6, "<td class=\"f_field\"><input type=\"checkbox\" name=\"genes\" /></td>");
00600 putsn (6, "<td class=\"f_label\" colspan=\"2\"><label for=\"gexons\">Genes</label></td>");
00601 }
00602 putsn (5, "</tr>");
00603 putsn (5, "<tr>");
00604 putsn (6, "<td class=\"f_field\"><input type=\"checkbox\" name=\"isoforms\" disabled=\"disabled\" /></td>");
00605 putsn (6, "<td class=\"f_label\" colspan=\"2\">");
00606 putsn (7, "<fieldset>");
00607 putsn (8, "<legend>Isoforms</legend>");
00608 putsn (8, "<table cellspacing=\"0\" cellpadding=\"0\">");
00609 putsn (9, "<tr>");
00610 putsn (10, "<td class=\"f_field\">Coming Soon</td>");
00611 putsn (9, "</tr>");
00612 putsn (8, "</table>");
00613 putsn (7, "</fieldset>");
00614 putsn (6, "</td>");
00615 putsn (5, "</tr>");
00616 putsn (4, "</table>");
00617 putsn (3, "</div>");
00618 putsn (3, "<div class=\"m_body\">");
00619 putsn (4, "<input type=\"submit\" value=\"Update\" />");
00620 putsn (3, "</div>");
00621 putsn (2, "</div>");
00622 putsn (1, "</form>");
00623 puts ("</div>");
00624 puts ("</body>");
00625 puts ("</html>");
00626 }
00627
00628 void web_printChrHidden (Chrdata_t *chromosomes, int ntabs)
00629 {
00630 char *chrname;
00631 int i, j;
00632
00633 for (i = 1; i <= 24; i++) {
00634 if (chromosomes[i].show) {
00635 chrname = getHchrname (i);
00636
00637 for (j = 0; j < ntabs; j++) {
00638 printf ("\t");
00639 }
00640 printf ("<input type=\"hidden\" name=\"%s\" value=\"on\" />\n", chrname);
00641 free (chrname);
00642 }
00643 }
00644 }
00645
00646 void web_printRegionHidden (Array regions, int ntabs)
00647 {
00648 char *mchrname;
00649 char *schrname;
00650 Stringa tabs = stringCreate(ntabs+1);
00651 SRegion_t *tmp;
00652 int i, j;
00653
00654 stringPrintf (tabs, "");
00655
00656 for (j = 0; j < ntabs; j++) {
00657 stringAppendf (tabs, "\t");
00658 }
00659
00660 tmp = arrayp(regions, 0, SRegion_t);
00661 if (tmp->chromosome >= 1 && tmp->chromosome <= 24) {
00662 for (i = 0; i < arrayMax(regions); i++) {
00663 tmp = arrayp(regions, i, SRegion_t);
00664 mchrname = getMchrname (tmp->chromosome);
00665 schrname = getSchrname (tmp->chromosome);
00666
00667 if (tmp->show) {
00668 printf ("%s<input type=\"hidden\" name=\"%s-%i-show\" value=\"on\" />\n",
00669 string (tabs), schrname, tmp->instance);
00670 }
00671 printf ("%s<input type=\"hidden\" name=\"%s-%i-start\" value=\"%i\" />\n",
00672 string (tabs), schrname, tmp->instance, tmp->start);
00673 printf ("%s<input type=\"hidden\" name=\"%s-%i-end\" value=\"%i\" />\n",
00674 string (tabs), schrname, tmp->instance, tmp->end);
00675 printf ("%s<input type=\"hidden\" name=\"%s-%i-start\" value=\"%i\" />\n",
00676 string (tabs), mchrname, tmp->instance, tmp->mstart);
00677 printf ("%s<input type=\"hidden\" name=\"%s-%i-end\" value=\"%i\" />\n",
00678 string (tabs), mchrname, tmp->instance, tmp->mend);
00679
00680 free (mchrname);
00681 free (schrname);
00682 }
00683 }
00684
00685 stringDestroy (tabs);
00686 }
00687
00688 char *url_makeBase (char *prefix, char *location)
00689 {
00690 char *url = strappend (strdup ("?prefix="), prefix);
00691 char *loc = strappend (strdup ("&location="), location);
00692 url = strappend (url, loc);
00693
00694 free (loc);
00695 return url;
00696 }
00697
00698 char *url_makeOpts (SVCfg_t *settings)
00699 {
00700 Stringa url = stringCreate (50);
00701 char *u_url;
00702
00703 stringPrintf (url, "");
00704
00705 if (settings->tracks.expr) {
00706 stringAppendf (url, "&expr=on");
00707 }
00708 if (settings->tracks.genes) {
00709 stringAppendf (url, "&genes=on");
00710 if (settings->tracks.exons) {
00711 stringAppendf (url, "&exons=1");
00712 }
00713 }
00714 if (settings->rfilter.on) {
00715 stringAppendf (url, "&rfilter=1");
00716 if (settings->rfilter.thold)
00717 stringAppendf (url, "&rthold=%i", settings->rfilter.thold);
00718 if (settings->rfilter.maxgap)
00719 stringAppendf (url, "&rmaxgap=%i", settings->rfilter.maxgap);
00720 if (settings->rfilter.minrun)
00721 stringAppendf (url, "&rminrun=%i", settings->rfilter.minrun);
00722 if (settings->rfilter.showtars)
00723 stringAppendf (url, "&rshowtars=%i", settings->rfilter.showtars);
00724 }
00725 if (settings->readlim) {
00726 stringAppendf (url, "&readlim=%i", settings->readlim);
00727 }
00728 if (settings->minspan) {
00729 stringAppendf (url, "&minspan=%i", settings->minspan);
00730 }
00731
00732 u_url = strdup (string (url));
00733 stringDestroy (url);
00734
00735 return u_url;
00736 }
00737
00738 char *url_makeChrs (Chrdata_t *chromosomes)
00739 {
00740 Stringa buffer = stringCreate (50);
00741 char *chrname;
00742 char *url;
00743 int i;
00744
00745 stringPrintf (buffer, "");
00746
00747 for (i = 1; i <= 24; i++) {
00748 if (chromosomes[i].show) {
00749 chrname = getHchrname (i);
00750 stringAppendf (buffer, "&%s=on", chrname);
00751 free (chrname);
00752 }
00753 }
00754
00755 url = strdup (string (buffer));
00756 stringDestroy (buffer);
00757 return url;
00758 }
00759
00760 char *url_makeRegions (Array regions, int exchr, int exinst)
00761 {
00762 Stringa buffer = stringCreate (50);
00763 SRegion_t *tmp;
00764 char *schrname;
00765 char *mchrname;
00766 char *url;
00767 int i;
00768
00769 stringPrintf (buffer, "");
00770
00771 for (i = 0; i < arrayMax(regions); i++) {
00772 tmp = arrayp (regions, i, SRegion_t);
00773
00774 if (tmp->chromosome != exchr || tmp->instance != exinst) {
00775 schrname = getSchrname (tmp->chromosome);
00776 mchrname = getMchrname (tmp->chromosome);
00777
00778 if (tmp->show) {
00779 stringAppendf (buffer, "&%s-%i-show=on", schrname, tmp->instance);
00780 }
00781 stringAppendf (buffer, "&%s-%i-start=%i", schrname, tmp->instance, tmp->start);
00782 stringAppendf (buffer, "&%s-%i-end=%i", schrname, tmp->instance, tmp->end);
00783 stringAppendf (buffer, "&%s-%i-start=%i", mchrname, tmp->instance, tmp->mstart);
00784 stringAppendf (buffer, "&%s-%i-end=%i", mchrname, tmp->instance, tmp->mend);
00785
00786 free (schrname);
00787 free (mchrname);
00788 }
00789 }
00790
00791 url = strdup (string (buffer));
00792 stringDestroy (buffer);
00793 return url;
00794 }
00795
00796
00797
00798 void html_printAdditionalCSS(char *web_pub_url)
00799 {
00800 printf ("<link rel=\"stylesheet\" href=\"%s/css/style.css\" type=\"text/css\" media=\"all\" />\n", web_pub_url);
00801 }
00802
00803 void html_linkjQuery(char *web_pub_url)
00804 {
00805 printf ("<link rel=\"stylesheet\" href=\"%s/css/start/jquery-ui-1.7.2.custom.css\" type=\"text/css\" media=\"all\" />\n", web_pub_url);
00806 printf ("<script src=\"%s/js/jquery-1.3.2.min.js\" type=\"text/javascript\"></script>\n", web_pub_url);
00807 printf ("<script src=\"%s/js/jquery-ui-1.7.2.custom.min.js\" type=\"text/javascript\"></script>\n", web_pub_url);
00808 }