From 14507faf8d9085515e8977d912e71340c76cf76b Mon Sep 17 00:00:00 2001 From: miles Date: Wed, 27 Mar 2013 20:43:57 +0000 Subject: [PATCH] View Ontology Changes: -namespace selection now fully functional, error messages updated and made relevant Info Choice Changes: -namespace selection support -minor javascript changes svn path=/; revision=452 --- Personnel/miles/Web Page/infoChoice.php | 44 ++++- Personnel/miles/Web Page/viewOntology.php | 198 ++++++++++++---------- 2 files changed, 146 insertions(+), 96 deletions(-) diff --git a/Personnel/miles/Web Page/infoChoice.php b/Personnel/miles/Web Page/infoChoice.php index c1a3d12..352ed8b 100644 --- a/Personnel/miles/Web Page/infoChoice.php +++ b/Personnel/miles/Web Page/infoChoice.php @@ -4,10 +4,16 @@ \n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "
\n"; + echo "

Possible Ontologies:
"; + echo ""; + echo "Anatomy
"; + echo ""; + echo "Growth
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

"; echo "

\n"; $username="inparanoid-read-user"; @@ -138,10 +144,16 @@ mysql_close($connection); echo str_replace("_", " ", $species) . " has " . $count . " genes in cluster " . $clusterIndex . ":

\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo "
\n"; + echo "
\n"; + echo "

Possible Ontologies:
"; + echo ""; + echo "Anatomy
"; + echo ""; + echo "Growth
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

"; echo "

\n"; $genes=""; @@ -166,8 +178,22 @@ mysql_close($connection); diff --git a/Personnel/miles/Web Page/viewOntology.php b/Personnel/miles/Web Page/viewOntology.php index c956fc4..cfbeb70 100644 --- a/Personnel/miles/Web Page/viewOntology.php +++ b/Personnel/miles/Web Page/viewOntology.php @@ -7,124 +7,149 @@ $genes; $geneProductIDs = ""; $terms = ""; +$ontologies; +if($_POST["ontologies"] != "null") { +$ontologies = explode(",",$_POST["ontologies"]); -//get rid of any of those messy .somethings after the gene ID -$tmp = explode(",",$_POST['param']); -for($i = 0; $i < sizeof($tmp); $i ++) { - $newTmp = explode(".",$tmp[$i]); - $tmp[$i] = $newTmp[0]; -} -$genes = $tmp; + for($i = 0; $i < sizeof($ontologies); $i++) { + if($ontologies[$i] == "Anatomy") $ontologies[$i] = "plant_anatomy"; + if($ontologies[$i] == "Growth") $ontologies[$i] = "plant_structure_development_stage"; + + } + + //get rid of any of those messy .somethings after the gene ID + $tmp = explode(",",$_POST['param']); + for($i = 0; $i < sizeof($tmp); $i ++) { + $newTmp = explode(".",$tmp[$i]); + $tmp[$i] = $newTmp[0]; + } + $genes = $tmp; -$username="po-read-user"; -$password="po-read-user_pw"; -$database="po_live"; -$url="floret.cgrb.oregonstate.edu:3306"; + $username="po-read-user"; + $password="po-read-user_pw"; + //$database="po_live"; + $database="po_live"; + $url="floret.cgrb.oregonstate.local:3306"; -$connection=mysql_connect($url,$username,$password); -mysql_select_db($database); + $connection=mysql_connect($url,$username,$password); + mysql_select_db($database); -$logic = "where gene_product.full_name='"; -for($i = 0; $i < sizeof($genes); $i++) { - $toAdd = $genes[$i] . "'"; - if($i + 1 < sizeof($genes)) { - $toAdd = $toAdd . " or gene_product.full_name='"; + $logic = "where gene_product.full_name='"; + for($i = 0; $i < sizeof($genes); $i++) { + $toAdd = $genes[$i] . "'"; + if($i + 1 < sizeof($genes)) { + $toAdd = $toAdd . " or gene_product.full_name='"; + } + $logic = $logic . $toAdd; } - $logic = $logic . $toAdd; -} -$query = "select full_name from gene_product " . $logic . " order by full_name"; -$results=mysql_query($query); -$i = 0; -$finalGenes = array(); -$row = mysql_fetch_row($results); -while($row != null) { - $finalGenes[$i] = $row[0]; + + + + $query = "select full_name from gene_product " . $logic . " order by full_name"; + + $results=mysql_query($query); + $i = 0; + $finalGenes = array(); $row = mysql_fetch_row($results); - $i ++; //NOTE - } + while($row != null) { + $finalGenes[$i] = $row[0]; + $row = mysql_fetch_row($results); + $i ++; //NOTE + } -$logic = "where gene_product.full_name='"; -for($i = 0; $i < sizeof($finalGenes); $i++) { - $toAdd = $finalGenes[$i] . "'"; - if($i + 1 < sizeof($finalGenes)) { - $toAdd = $toAdd . " or gene_product.full_name='"; + $logic = "where gene_product.full_name='"; + for($i = 0; $i < sizeof($finalGenes); $i++) { + $toAdd = $finalGenes[$i] . "'"; + if($i + 1 < sizeof($finalGenes)) { + $toAdd = $toAdd . " or gene_product.full_name='"; + } + $logic = $logic . $toAdd; } - $logic = $logic . $toAdd; -} -//This all gets the list of terms for the x-axis + $ontLogic = "where "; -$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 order by acc) as secondTable"; -$results=mysql_query($query); + for($i = 0; $i < sizeof($ontologies); $i++) { + $ontLogic = $ontLogic . "term_type='" . $ontologies[$i] . "' "; + if($i + 1 < sizeof($ontologies)) $ontLogic = $ontLogic . "or "; + }; + //This all gets the list of terms for the x-axis -$i = 0; -for($row = mysql_fetch_row($results); $row != null; $row = mysql_fetch_row($results)) { - $add = ""; - if($row[1]=="plant_anatomy") $add= " (A)"; - if($row[1]=="plant_structure_development_stage") $add= " (G)"; - $terms[$i][0] = $row[0]; - $terms[$i][1] = $add; - $i++; - } -//new testing stuff with optimized queries + $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"; + $results=mysql_query($query); + + $i = 0; + for($row = mysql_fetch_row($results); $row != null; $row = mysql_fetch_row($results)) { + $add = ""; + if($row[1]=="plant_anatomy") $add= " (A)"; + if($row[1]=="plant_structure_development_stage") $add= " (G)"; + $terms[$i][0] = $row[0]; + $terms[$i][1] = $add; + $i++; + } + //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"; -$results=mysql_query($query); -$t = 0; -$g = -1; -$cellData; -for($row = mysql_fetch_row($results); $row != null; $row = mysql_fetch_row($results)) { - if(($g == -1) || ($finalGenes[$g] != $row[0])) { - $g ++; + $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"; + $results=mysql_query($query); + + $t = 0; + $g = -1; + $cellData; + for($row = mysql_fetch_row($results); $row != null; $row = mysql_fetch_row($results)) { + if(($g == -1) || ($finalGenes[$g] != $row[0])) { + $g ++; + for($t = 0; $t < sizeof($terms); $t++) { + $cellData[$g][$t][0] = 0; + } + } for($t = 0; $t < sizeof($terms); $t++) { - $cellData[$g][$t][0] = 0; + if($row[2] == $terms[$t][0]) { + $cellData[$g][$t][0] = 1; + $cellData[$g][$t][1] = $row[3]; + } //TODO optimize this by using PO ID's instead of the entire term string } - } - for($t = 0; $t < sizeof($terms); $t++) { - if($row[2] == $terms[$t][0]) { - $cellData[$g][$t][0] = 1; - $cellData[$g][$t][1] = $row[3]; - } //TODO optimize this by using PO ID's instead of the entire term string - } -} + } -if(empty($cellData)) { -echo "These genes are not yet annotated in our database."; -} -else { - $semiFinalCellData; - for ($i = 0; $i < sizeof($cellData); $i ++) - { - for($j = 0; $j < sizeof($cellData[$i]); $j++) + if(empty($cellData)) { + echo "These genes are not yet annotated in our database."; + } + else { + $semiFinalCellData; + for ($i = 0; $i < sizeof($cellData); $i ++) { - $semiFinalCellData[$i][$j] = implode(",",$cellData[$i][$j]); + for($j = 0; $j < sizeof($cellData[$i]); $j++) + { + $semiFinalCellData[$i][$j] = implode(",",$cellData[$i][$j]); + } } - } - $finalCellData; - for ($i = 0; $i < sizeof($semiFinalCellData); $i ++) - { - $finalCellData[$i] = implode(";", $semiFinalCellData[$i]); + $finalCellData; + for ($i = 0; $i < sizeof($semiFinalCellData); $i ++) + { + $finalCellData[$i] = implode(";", $semiFinalCellData[$i]); + } + $printTerms; + for($i = 0; $i < sizeof($terms); $i ++) { + $printTerms[$i] = $terms[$i][0] . $terms[$i][1]; } - $printTerms; - for($i = 0; $i < sizeof($terms); $i ++) { - $printTerms[$i] = $terms[$i][0] . $terms[$i][1]; } -} -$height = 800; -$width = 1200; + $height = 800; + $width = 1200; +} else { + +echo "No ontologies were selected!"; +} ?>
Note: The colors have no relevance to the data, they simply serve to distinguish rows visually.

@@ -429,7 +454,6 @@ function downloadTabDem() { document.downloadImage.submit(); } - -- 2.34.1