</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>
//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;
//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;
}
-
+ 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>";
?>
-<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>
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();
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;
canvas.addEventListener('mouseup', showInfo, false);
+
function drawKey() {
ontMap.fillStyle="#000000";
ontMap.fillText("Ontology Color Key:",<?php echo $width ?>-250,topOffset+cellSize);
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
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];
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];
}
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;
}
}
-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];
document.getElementById("topScrollDiv").scrollTop = row*cellSize;
drawMap();
}
-
</script>
</body>