<?php
if($_POST["type"] == "cluster") {
- echo "<form name=\"Branch\" method=\"post\" action=\"viewOntology.php\">\n";
- echo "<input type=\"submit\" value=\"View Ontology\">\n";
- echo "<input type=\"hidden\" name=\"param\" value=\"\">\n";
- echo "</form>\n";
+ echo "<form name=\"viewOntology\" method=\"post\" action=\"viewOntology.php\">\n";
+ echo "<p> Possible Ontologies: <br>";
+ echo "<input type=\"checkbox\" name=\"Anatomy\" value=\"Anatomy\">";
+ echo "Anatomy <br>";
+ echo "<input type=\"checkbox\" name=\"Growth\" value=\"Growth\">";
+ echo "Growth <br>";
+ echo "<input type=\"submit\" value=\"View Ontology\" onClick=process()>\n";
+ echo "<input type=\"hidden\" name=\"param\" value=\"null\">\n";
+ echo "<input type=\"hidden\" name=\"ontologies\" value=\"\">\n";
+ echo "</form>";
echo "<br> <br>\n";
$username="inparanoid-read-user";
echo str_replace("_", " ", $species) . " has " . $count . " genes in cluster " . $clusterIndex . ": <br> <br>\n";
- echo "<form name=\"Branch\" method=\"post\" action=\"viewOntology.php\">\n";
- echo "<input type=\"submit\" value=\"View Ontology\">\n";
- echo "<input type=\"hidden\" name=\"param\" value=\"\">\n";
- echo "</form>\n";
+ echo "<form name=\"viewOntology\" method=\"post\" action=\"viewOntology.php\">\n";
+ echo "<p> Possible Ontologies: <br>";
+ echo "<input type=\"checkbox\" name=\"Anatomy\" value=\"Anatomy\">";
+ echo "Anatomy <br>";
+ echo "<input type=\"checkbox\" name=\"Growth\" value=\"Growth\">";
+ echo "Growth <br>";
+ echo "<input type=\"submit\" value=\"View Ontology\" onClick=process()>\n";
+ echo "<input type=\"hidden\" name=\"param\" value=\"null\">\n";
+ echo "<input type=\"hidden\" name=\"ontologies\" value=\"\">\n";
+ echo "</form>";
echo "<br> <br>\n";
$genes="";
<script type="text/javascript">
if(<?php echo (($_POST["type"] == "cluster") || ($_POST["type"] == "box")) ?> == 1) {
- document.Branch.param.value = "<?php echo $genes ?>";
+ document.viewOntology.param.value = "<?php echo $genes ?>";
}
+
+function process() {
+ var ontologies = "null";
+ if(document.viewOntology.Anatomy.checked) ontologies = document.viewOntology.Anatomy.value;
+ if(document.viewOntology.Growth.checked) {
+ if(ontologies == "null") ontologies = document.viewOntology.Growth.value;
+ else ontologies = ontologies + "," + document.viewOntology.Growth.value;
+ }
+ document.viewOntology.ontologies.value = ontologies;
+}
+
+
+
+//2533488419
</script>
</body>
$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!";
+}
?>
<div id="Legend" style="float: right; height: 200px; width: 400px;">
Note: The colors have no relevance to the data, they simply serve to distinguish rows visually. <br> <br>
document.downloadImage.submit();
}
-
</script>
</body>