From 9fc2d56c0736b6186052b90483a833a81af4622d Mon Sep 17 00:00:00 2001 From: miles Date: Tue, 23 Apr 2013 23:03:24 +0000 Subject: [PATCH] View Ontology Changes: - 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 | 64 +++++++++++------------ 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/Personnel/miles/Web Page/viewOntology.php b/Personnel/miles/Web Page/viewOntology.php index 39d2b91..3fd52c6 100644 --- a/Personnel/miles/Web Page/viewOntology.php +++ b/Personnel/miles/Web Page/viewOntology.php @@ -17,7 +17,7 @@ Note: The colors have no relevance to the data, they simply serve to distinguish
- +
@@ -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 "

No ontologies were selected!

"; @@ -207,17 +212,17 @@ echo "

No ontologies were selected!

"; ?> -
+
Your browser does not support the canvas element.
- +
- +
@@ -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 = ; + //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((-topOffset-15)/cellSize); -var maxCols = Math.floor((-leftOffset-300)/cellSize); //NOTE the -300 accounts for the key +var maxRows = Math.floor((-topOffset-15)/cellSize)+1; +var maxCols = Math.floor((-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:",-250,topOffset+cellSize); @@ -375,15 +378,10 @@ function drawKey() { ontMap.fillStyle = color; ontMap.fillText(legalOntologies[i],-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; (jtopOffset)) { //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(); } - -- 2.34.1