Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
View Ontology Changes:
authormiles <miles@localhost>
Tue, 23 Apr 2013 23:03:24 +0000 (23:03 +0000)
committermiles <miles@localhost>
Tue, 23 Apr 2013 23:03:24 +0000 (23:03 +0000)
        - many small bug fixes
        - solved the term cut-off problem
        - solved the gene cut-off problems

svn path=/; revision=467

Personnel/miles/Web Page/viewOntology.php

index 39d2b9111e8726540c07ccaa6cafa7f583db7c70..3fd52c62073a04ccbe6acc37862f26ad84b14b71 100644 (file)
@@ -17,7 +17,7 @@ Note: The colors have no relevance to the data, they simply serve to distinguish
 </form>
 
 <form name="jumpToGene">
-<input type="button" value="Find Gene:" onClick="getGeneLoc(); return false;"/>
+<input type="button" value="Find Gene in Set:" onClick="getGeneLoc(); return false;"/>
 <input type="text" name="gene" value = ""/>
 </form>
 
@@ -134,7 +134,7 @@ $ontologies = explode(",",$_POST["ontologies"]);
   //This all gets the list of terms for the x-axis
 
 
-  $query="select concat(acc, \"- \", name),term_type from (select distinct name, acc,term_type from (select term_id from gene_product left join association on association.gene_product_id=gene_product.id " . $logic . ") as mytable left join term on term_id=term.id " . $ontLogic . "order by acc) as secondTable";
+  $query="select concat(acc, \"- \", name),term_type from (select distinct name, acc,term_type from (select term_id from gene_product left join association on association.gene_product_id=gene_product.id " . $logic . ") as mytable left join term on term_id=term.id " . $ontLogic . "order by term_type,acc) as secondTable";
   $results=mysql_query($query);
 
   $i = 0;
@@ -148,9 +148,8 @@ $ontologies = explode(",",$_POST["ontologies"]);
   //new testing stuff with optimized queries
 
 
-  $query = "select full_name,term_id,concat(acc, \"- \", name),evnum from (select full_name,term_id,count(*) as evnum from gene_product left join association on association.gene_product_id=gene_product.id " . $logic . "group by full_name,term_id order by full_name,term_id) as temp left join term on term.id=term_id order by full_name,acc";
+  $query = "select full_name,term_id,concat(acc, \"- \", name),evnum,term_type from (select full_name,term_id,count(*) as evnum from gene_product left join association on association.gene_product_id=gene_product.id " . $logic . "group by full_name,term_id order by full_name,term_id) as temp left join term on term.id=term_id order by full_name,term_type,acc";
   $results=mysql_query($query);
-
   $t = 0;
   $g = -1;
   $cellData;
@@ -196,9 +195,15 @@ $ontologies = explode(",",$_POST["ontologies"]);
   }
 
 
-
+  echo sizeof($terms);
   $height = 800;
   $width = 1200;
+
+  $maxTermSize = 0;
+  for($i = 0; $i < sizeof($terms); $i ++) {
+    if(strlen($terms[$i][0]) > $maxTermSize) $maxTermSize = strlen($terms[$i][0]);
+  }
+
 } else {
 
 echo "<br> <br> <H1> No ontologies were selected! </H1>";
@@ -207,17 +212,17 @@ echo "<br> <br> <H1> No ontologies were selected! </H1>";
 ?>
 
 
-<div id="canvasDiv" style="overflow: hidden; float: left; height: <?php echo $height ?>px; width: <?php echo $width ?>px;">
+<div id="canvasDiv" style="overflow: hidden; float: left; height: <?php echo $height+10 ?>px; width: <?php echo $width ?>px;">
 <canvas id="myCanvas" width="1500" height="1000" style="border:1px solid #c3c3c3;">
 Your browser does not support the canvas element.
 </canvas> </div>
 
 <div id="topScrollDiv" style="overflow: auto; float: left; height: <?php echo ($height + 15) ?>px; width: 15px;" onscroll="drawMap();">
-<canvas id="nothing" width="1" height="<?php echo 210 + sizeof($finalGenes)*15 ?>"> </canvas>
+<canvas id="nothing" width="1" height="<?php echo $maxTermSize*5 + 30 + sizeof($finalGenes)*15 ?>"> </canvas>
 </div>
 
 <div id="sideScrollDiv" style="overflow: auto; float: left; height: 15px; width: <?php echo ($width + 15) ?>px;" onscroll="drawMap();">
-<canvas id="nothing" width="<?php echo 85 + sizeof($terms)*15 ?>" height="1"> </canvas>
+<canvas id="nothing2" width="<?php echo 386 + sizeof($terms)*15 ?>" height="1"> </canvas>
 </div>
 
 
@@ -285,10 +290,8 @@ var ontMap = canvas.getContext("2d");
 var startTerm = 0;
 
 //to find out what our top offset should be:
-var maxTermSize = 0;
-for(var i = 0; i < terms.length; i ++) {
-  if(terms[i][0].length > maxTermSize) maxTermSize = terms[i][0].length;
-}
+var maxTermSize = <?php echo $maxTermSize; ?>;
+
 //to create a method for coloring each ontology differently
 var ontCount;
 var ontologies = new Array();
@@ -322,16 +325,15 @@ function findIndex(element,array) {
   return -1;
 }
 
-
 var cellSize = 15; //NOTE if this is changed, the size of the topScrollDiv must also be changed by the same factor!
 
-maxTermSize = maxTermSize + (cellSize/5)*3; //This is to account for the legend row
+maxTermSize = maxTermSize + (cellSize/5); //This is to account for the legend row
 
-var topOffset = maxTermSize*5;//NOTE the *7 is just my own approximation: characters on average seem to be about 5 pixels wide at the current font size
+var topOffset = maxTermSize*5;
 var leftOffset = 85;
 
-var maxRows = Math.floor((<?php echo $height ?>-topOffset-15)/cellSize);
-var maxCols = Math.floor((<?php echo $width ?>-leftOffset-300)/cellSize); //NOTE the -300 accounts for the key
+var maxRows = Math.floor((<?php echo $height ?>-topOffset-15)/cellSize)+1;
+var maxCols = Math.floor((<?php echo $width ?>-leftOffset-300)/cellSize)+1; //NOTE the -300 accounts for the key
 
 var borderWidth = 1;
 
@@ -354,6 +356,7 @@ for(var i = 0; i < terms.length; i ++) {
 
 canvas.addEventListener('mouseup', showInfo, false);
 
+
 function drawKey() {
   ontMap.fillStyle="#000000";
   ontMap.fillText("Ontology Color Key:",<?php echo $width ?>-250,topOffset+cellSize);
@@ -375,15 +378,10 @@ function drawKey() {
     ontMap.fillStyle = color;
     ontMap.fillText(legalOntologies[i],<?php echo $width ?>-250,topOffset+cellSize*(2+i))
   }
-
-
-
-
 }
+
 var tempTerms = new Array();
 function drawTerms(startTerm) {
-
-
   //black for text
 
   //rotating the canvas for labeling the terms
@@ -395,7 +393,7 @@ function drawTerms(startTerm) {
   var t=startTerm
   var i=0;
   for (var j=startTerm; (j<termCount) && (t<=startTerm+maxCols); j++) {
-      if(isIn(terms[j][1],legalOntologies)) {
+      if(isIn(terms[j][1],legalOntologies) && checkBoxes[j]) {
        tempTerms[i] = terms[j];
        i++
        term=terms[j][0];
@@ -454,7 +452,7 @@ function drawMap(init) {
     ontMap.strokeStyle="#0000FF";
     var t=startXCell;
     for(var j=startXCell; (j<termCount) && ((t-startXCell)<=maxCols); j++) {
-      if(isIn(terms[j][1],legalOntologies)) {
+      if(isIn(terms[j][1],legalOntologies) && checkBoxes[j]) {
        var xCoord = leftOffset+(t-startXCell)*cellSize+5;
 
        var color = termColors[j];
@@ -468,7 +466,7 @@ function drawMap(init) {
        }
        ontMap.strokeRect(xCoord,topOffset-(cellSize*3),cellSize,cellSize);
 
-       for(var g=startYCell; (g<geneCount) && ((g-startYCell)<maxRows); g++) {
+       for(var g=startYCell; (g<geneCount) && ((g-startYCell)<=maxRows); g++) {
 
          if(cellData[g][j][0] == 0) ontMap.fillStyle= "#FFFFFF";
          else ontMap.fillStyle=color;
@@ -490,26 +488,25 @@ function drawMap(init) {
   }
 }
 
-drawMap(true);
-
 
+drawMap(true);
 
 function showInfo(event) {
-  var x = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft - canvas.offsetLeft;
-  var y = event.clientY + document.body.scrollTop + document.documentElement.scrollTop - canvas.offsetTop;
+  var x = event.clientX - canvas.offsetLeft;
+  var y = event.clientY - canvas.offsetTop;
 
   if((x<leftOffset) && (y>topOffset)) { //for getting genes
-    var index = Math.floor((y-topOffset)/cellSize) + Math.floor(scrolledTop/cellSize);
+    var index = Math.floor((y-topOffset)/cellSize);
     var gene = genes[index];
     getGeneInfo(gene);
   }
   if((y<(topOffset-cellSize*3)) && (x>leftOffset)) { //for getting terms
-    var index = Math.floor((x-leftOffset)/cellSize) + Math.floor(scrolledLeft/cellSize);
+    var index = Math.floor((x-leftOffset)/cellSize);
     var term = tempTerms[index][0].split("-")[0];
     getTermInfo(term);
   }
   if(y<(topOffset-cellSize*2) && y>(topOffset-cellSize*3) && x>leftOffset) { //for checkBoxes
-    var index = Math.floor((x-leftOffset-7)/cellSize) + Math.floor(scrolledLeft/cellSize); //NOTE the -7 is to account for funky mouse mapping.
+    var index = Math.floor((x-leftOffset-7)/cellSize); //NOTE the -7 is to account for funky mouse mapping.
     var term=tempTerms[index];
     var chIndex = findIndex(term,terms);
     checkBoxes[chIndex] = !checkBoxes[chIndex];
@@ -599,7 +596,6 @@ function getGeneLoc() {
   document.getElementById("topScrollDiv").scrollTop = row*cellSize;
   drawMap();
 }
-
 </script>
 
 </body>