<html>
<head>
<title>ANISEED - Anatomical territory summary card (Ciona intestinalis or Halocynthia roretzi)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="You will find on this page different features concerning a Ciona anatomical territory. You will find lineage data, a short description, a link on FABA database, neighbour cells and biometry data.">
<meta name="keywords" content="Aniseed, Ciona intestinalis, Halocynthia roretzi, Ciona intestinalis database, anatomical territory, Ciona cells, biometry data, lineage data, FABA database.">
<meta name = "robots" content = "index, follow, all">
<META HTTP-EQUIV="Content-Language" CONTENT="EN">
<style type="text/css">
</style>
</head>

<?php
/*
    ANISEED, NISEED System and Database
    Copyright (C) 2007 Olivier Tassy, Fabrice Daian, Patrick Lemaire

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
//connection
include("connection.php");
include("frames_header.php");
?>

<script language="JavaScript">
function getValue(){

for(a=0; a< document.formu.length; a++){
        if(document.formu[a].checked==true){
obj=document.formu[a];
return obj.value;
    }

}
}
</script>



<form action="" method="get" name="formu">

<?php
	$region = $_GET["region"];

	$dev = $_GET["dev"];

if (strlen($dev)==0)
	{
	$requete="SELECT \"DEV_STAGE_ID\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$region'";
	$stmt=pg_query($c,$requete);
	$row=pg_fetch_array($stmt);
	$dev=$row["DEV_STAGE_ID"];
	}
	

$requete="SELECT \"SPECIES\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$region'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);
$species=$row["SPECIES"];






$requete="SELECT \"CHILD_OF\" from \"ANAT_ENTITY\" where \"CHILD_OF\"='$region'";
//print $requete;
$stmt=pg_query($c,$requete);
$ens_reg="";
while ($row=pg_fetch_array($stmt))
{
if (strlen($ens_reg)==0) $ens_reg=$row["CHILD_OF"];
else $ens_reg.=":".$row["CHILD_OF"];
}






?>

<link rel="stylesheet" type="text/css" media="screen" href="ongletv1.css" title="Version 1" />
<!-- Header pour l'onglet -->
<div id="header">
  <ul>
    <li><a onclick="this.href='anatomy.php?species=<?print $species;?>&dev=<?print $dev;?>&region='+self.getValue();" href="#">Anatomical dictionary</a></li>
    <li id="current" ><a href="#">Anatomical territory summary card</a></li>
    <li><a onclick="this.href='lineage.php?idanat='+self.getValue()" href="#">Lineage</a></li>
	<li><a onclick="this.href='insitu-result.php?BOOLanat=1&only=1&BOOLmut=3&BOOLmanip=2&idanat='+self.getValue()+':<?print $ens_reg;?>'" href="">Molecular Markers</a></li>
    <!--<li><a onclick="this.href='fates.php?idanat='+self.getValue()" href="#">Fate</a></li>-->
    
    <!--<li><a onclick="this.href='insitu-result.php?BOOLanat=1&xref=2&idanat='+self.getValue()+':'" href="#">InSitu data</a></li>-->

    <!--<li><a onclick="this.href='position.php?idanat='+self.getValue()" href="">Biometry</a></li>-->
    <!--<li><a onclick="this.href='induction.php?idanat='+self.getValue()" href="">Induction</a></li>-->


  </ul>
</div>
<!-- EOF Onglet -->
<br><br>



<?

	
	$requete= "SELECT \"NAME\", \"SPECIES\" FROM \"DEV_STAGE\" WHERE \"DEV_STAGE_ID\"= $dev";
    $stmt = pg_query($c,$requete);
    if( $row=pg_fetch_array($stmt)){
	
       //print "<br><br><font color=\"#D64242\" size=\"3\"><b>".$row["SPECIES"]."  (".$row["NAME"].") - short hierarchy</b></font></center><br><br>";
//print "<br><br><font color=\"#D64242\" size=\"3\"><b>Anatomical territory summary card</b></font></center><br>";
print "<br>";

print "<TABLE width=\"100%\" border=\"0\">";

 print "<tr>";
 print "<td><font color=\"#D64242\" size=\"3\"><b>Anatomical territory summary card</b></font></center></td>";
 print "<td><font color=\"#D64242\" size=\"2\"><b>Embryo view: </b></font></td>";
 print "</tr>";


print "<TR>";
print "<TD valign=\"top\" width=\"45%\">";

$requete0="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$region'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0); 
$anatname=$row0["NAME"];


 print "<br><br><font color=\"#D64242\" size=\"2\"><b>Anatomical territory name: &nbsp;&nbsp; <font color=\"#656565\"> $anatname</font></b></font><br>";
print "<font color=\"#D64242\" size=\"2\"><b>Species: &nbsp;&nbsp; <font color=\"#656565\">$species</font><b></font><br>";
 print "<font color=\"#D64242\" size=\"2\"><b>Developmental stage: &nbsp;&nbsp; <font color=\"#656565\">".$row["NAME"]."</font></b></font></center><br><br>";

print "<font color=\"#D64242\" size=\"2\"><b>Fate: &nbsp;&nbsp;</b></font>";
//////////// AFFICHAGE DES DESTINS ////////////////


$requete="SELECT \"KEYWORDS\" from \"FATE\" where \"ANAT_ID\"='$region'";
$stmt=pg_query($c,$requete);
$I=0;
while ($row=pg_fetch_array($stmt))
{
if ($I==0) print "<font size=\"-1\" color=\"#656565\"><b>".$row["KEYWORDS"]."</b></font>";
else  print "<font size=\"-1\" color=\"#656565\"><b> , ".$row["KEYWORDS"]."</b></font>";
$I++;
}


////////////////////////////////////////////////////
print "<br>";


////////////////////////////////////////////////////
//// QQ INFOS SUR LES LIGNAGES

print "<font color=\"#D64242\" size=\"2\"><b>Lineage, Mother territory:  &nbsp;&nbsp;<br></b></font>";

$requete="
select \"DEV_STAGE_ID\",\"ANAT_ID\" from \"ANAT_ENTITY\" where \"ANAT_ID\" in (
SELECT \"MOTHER_CELL\" from \"LINEAGE\" where \"DAUGHTER_CELL\"='$region')";
//print $requete;
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{

$devmoid=$row["DEV_STAGE_ID"];
$moid=$row["ANAT_ID"];

$requete0="SELECT \"NAME\" from \"DEV_STAGE\" where \"DEV_STAGE_ID\"='$devmoid'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);

$devmoname=$row0["NAME"];

$requete0="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$moid'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);

$moname=$row0["NAME"];

print "<font size=\"2\"><b><a href=\"embryo-short_hierarchy.php?region=$moid&dev=$devmoid\">".$moname." </a>($devmoname)</b></font><br>";

}
///////////////////


print "<font color=\"#D64242\" size=\"2\"><b>Lineage, Daughter territories:  &nbsp;&nbsp;<br></b></font>";
$requete="
select \"DEV_STAGE_ID\",\"ANAT_ID\" from \"ANAT_ENTITY\" where \"ANAT_ID\" in (
SELECT \"DAUGHTER_CELL\" from \"LINEAGE\" where \"MOTHER_CELL\"='$region')";
//print $requete;
$stmt=pg_query($c,$requete);

$I=0;
while ($row=pg_fetch_array($stmt))
{

$devdoid=$row["DEV_STAGE_ID"];
$doid=$row["ANAT_ID"];


$requete0="SELECT \"NAME\" from \"DEV_STAGE\" where \"DEV_STAGE_ID\"='$devdoid'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);

$devdoname=$row0["NAME"];

$requete0="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$doid'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);

$doname=$row0["NAME"];


if ($I==0) print "<font size=\"2\"><b><a href=\"embryo-short_hierarchy.php?region=$doid&dev=$devdoid&embryoid=".$_GET["embryoid"]."\">".$doname."</a> ($devdoname)</b></font><br>";
else print "<font size=\"2\"><b><a href=\"embryo-short_hierarchy.php?region=$doid&dev=$devdoid&embryoid=".$_GET["embryoid"]."\">".$doname."</a> ($devdoname)</b></font><br>";

$I++;
}



//// 




///////////////////////////////////////////////////





////// C'EST ICI QUE JE METS LA SHORT HIERARCHCHY //////

print "<br><font color=\"#D64242\" size=\"2\"><b>Short anatomical Hierarchy: </b></font><br>";
$count=0;

function select_recursif_descendant($conn,$start,$res)
{
global $dev;
global $count;
global $region;
/*ON ECRIT SA REQUETE*/

if ($start!='')
{
$requete="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"ANAT_ID\"= $start ";
//$res=select_recursif_descendant($conn,$row["CHILD_OF"],$res);
}
else return;

$stmt=pg_query($conn,$requete);
while ($row=pg_fetch_array($stmt))
	{
	$res=select_recursif_descendant($conn,$row["CHILD_OF"],$res);
        ++$count;
//print "ici";
	        for($a=0;$a<$count-1;++$a){
		        echo '&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
		    }
	
		    if( $row["TYPE"]=='cell' )
		        print "<img src=\"pictures/cell.gif\">";
		    else if($row["TYPE"]=='organism' )
		        print "<img src=\"pictures/tetard.gif\">";
		    else
		        print "<img src=\"pictures/region.gif\">";
			
		
		    if($row["ANAT_ID"]==$region){
	  	        echo '<A NAME="tag"><font size="-2" color="#FF9900"><strong>'.$row["NAME"]."</strong></font></A>"."<input name=\"region\" type=\"radio\" value=\"".$row["ANAT_ID"]."\" checked>";
		    }else{

echo "<font size=\"-2\"><b>".$row["NAME"]."</b></font>"."<input name=\"region\" type=\"radio\" value=\"".$row["ANAT_ID"]."\">";

//echo "<font size=\"-2\"><b><a href=\"short_hierarchy.php?region=".$row["ANAT_ID"]."&dev=".$row["DEV_STAGE_ID"]."\">".$row["NAME"]."</a></b></font>"."<!--<input name=\"region\" type=\"radio\" value=\"".$row["ANAT_ID"]."\">-->";
}
		
		
		    print '<br>';

	

	//$res=select_recursif_descendant($conn,$row["CHILD_OF"],$res);
	}
return $res;
}

$res=select_recursif_descendant($c,$region,$res);

function select_recursif_descendant_2($conn,$start,$res)
{
global $dev;
global $count;
global $level;
/*ON ECRIT SA REQUETE*/
//print "la";
if ($start!='')
{
$requete="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"CHILD_OF\"= $start ";
//$res=select_recursif_descendant_2($conn,$row["ANAT_ID"],$res);
//$level++;
}
else return;

$stmt=pg_query($conn,$requete);
while ($row=pg_fetch_array($stmt))
	{
	//$res=select_recursif_descendant_2($conn,$row["ANAT_ID"],$res);
	        for($a=0;$a<$count-1;++$a){
		        echo '&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
		    }
		    //echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			echo '&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
	        for($a=0;$a<$level-1;++$a){
		        if( $level>1 )
		            echo '&nbsp;&nbsp;<font color="#999999">|</font>&nbsp;&nbsp;';
		    }
			
		    if( $row["TYPE"]=='cell' )
		        print "&nbsp;|&nbsp;<img src=\"pictures/cell.gif\">";
		    else if( $row["TYPE"]=='organism' )
		        print "<img src=\"pictures/tetard.gif\">";
		    else
		        print "<img src=\"pictures/region.gif\">";
			
            echo "<font size=\"-2\"><b>".$row["NAME"]."</b></font>";
//echo "<font size=\"-2\"><b><a href=\"short_hierarchy.php?region=".$row["ANAT_ID"]."&dev=".$row["DEV_STAGE_ID"]."\">".$row["NAME"]."</a></b></font>";
		    print "<input name=\"region\" type=\"radio\" value=\"".$row["ANAT_ID"]."\"><br>";
			
	

	$res=select_recursif_descendant_2($conn,$row["ANAT_ID"],$res);
	}
return $res;
}

 $res=select_recursif_descendant_2($c,$region,$res);


//////////////////////////////////////////////////

print "</TD>";


print "<TD valign=\"top\" align=\"center\">";

//print "<font color=\"#D64242\" size=\"2\"><b>Embryo view: </b></font><br>";

///////////// AFFICHAGE DES EMBRYOS //////////////////////
$requete0="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$region'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);
print "<img name=\"embryo\" src=\"newtree.php?anat=$region\"><br>";
/////////////////////////////////////////////////////////////
print "</TD>";


print "</TR>";


print "</TABLE>";

print "<br><br>";
/*

print "<TABLE border=\"0\" width=\"100%\">";
print "<TR>";
print "<TD valign=\"top\">";
print "<font color=\"#D64242\" size=\"2\"><b>Short anatomical Hierarchy: </b></font>";
print "</td>";

print "<TD valign=\"top\">";
print "<font color=\"#D64242\" size=\"2\"><b>&nbsp;</b></font>";
print "</td>";

print "<tr>";
print "<tr>";
print "<TD valign=\"top\">";
*/

/*
$count=0;

function select_recursif_descendant($conn,$start,$res)
{
global $dev;
global $count;
global $region;


if ($start!='')
{
$requete="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"ANAT_ID\"= $start ";
//$res=select_recursif_descendant($conn,$row["CHILD_OF"],$res);
}
else return;

$stmt=pg_query($conn,$requete);
while ($row=pg_fetch_array($stmt))
	{
	$res=select_recursif_descendant($conn,$row["CHILD_OF"],$res);
        ++$count;
//print "ici";
	        for($a=0;$a<$count-1;++$a){
		        echo '&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
		    }
	
		    if( $row["TYPE"]=='cell' )
		        print "<img src=\"pictures/cell.gif\">";
		    else if($row["TYPE"]=='organism' )
		        print "<img src=\"pictures/tetard.gif\">";
		    else
		        print "<img src=\"pictures/region.gif\">";
			
		
		    if($row["ANAT_ID"]==$region){
	  	        echo '<A NAME="tag"><font size="-2" color="#FF9900"><strong>'.$row["NAME"]."</strong></font></A>"."<input name=\"region\" type=\"radio\" value=\"".$row["ANAT_ID"]."\" checked>";
		    }else{echo "<font size=\"-2\"><b>".$row["NAME"]."</b></font>"."<input name=\"region\" type=\"radio\" value=\"".$row["ANAT_ID"]."\">";}
		
		
		    print '<br>';

	

	//$res=select_recursif_descendant($conn,$row["CHILD_OF"],$res);
	}
return $res;
}

$res=select_recursif_descendant($c,$region,$res);

function select_recursif_descendant_2($conn,$start,$res)
{
global $dev;
global $count;
global $level;
//print "la";
if ($start!='')
{
$requete="SELECT * FROM \"ANAT_ENTITY\" WHERE  \"DEV_STAGE_ID\"= ".$dev." and  \"CHILD_OF\"= $start ";
//$res=select_recursif_descendant_2($conn,$row["ANAT_ID"],$res);
//$level++;
}
else return;

$stmt=pg_query($conn,$requete);
while ($row=pg_fetch_array($stmt))
	{
	//$res=select_recursif_descendant_2($conn,$row["ANAT_ID"],$res);
	        for($a=0;$a<$count-1;++$a){
		        echo '&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
		    }
		    //echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			echo '&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
	        for($a=0;$a<$level-1;++$a){
		        if( $level>1 )
		            echo '&nbsp;&nbsp;<font color="#999999">|</font>&nbsp;&nbsp;';
		    }
			
		    if( $row["TYPE"]=='cell' )
		        print "&nbsp;|&nbsp;<img src=\"pictures/cell.gif\">";
		    else if( $row["TYPE"]=='organism' )
		        print "<img src=\"pictures/tetard.gif\">";
		    else
		        print "<img src=\"pictures/region.gif\">";
			
            echo "<font size=\"-2\"><b>".$row["NAME"]."</b></font>";
		    print "<input name=\"region\" type=\"radio\" value=\"".$row["ANAT_ID"]."\"><br>";
			
	

	$res=select_recursif_descendant_2($conn,$row["ANAT_ID"],$res);
	}
return $res;
}

 $res=select_recursif_descendant_2($c,$region,$res);
*/


	/*
        print "</form>";



print "</TD>";

print "</TR>";
print "</TABLE>";
*/

//print "<hr>";

//////////////////////////////////////////////// AJOUT ///////////////////////////////////////////////////////



?>
<center>
</form>
<form name="formu0" action="" method="get" target="_blank">

<?
print "<input type=\"hidden\" name=\"region\" value=\"".$_GET["region"]."\">";
print "<input type=\"hidden\" name=\"dev\" value=\"$dev\">";

	print "<font color=\"486898\" size=\"-1\"><b>Choose an embryo to display its shapes properties</b></font><br><br>";
	print "<select name=\"embryoid\" size=\"3\" onChange=\"document.formu0.action='embryo-short_hierarchy.php?region=".$_GET["region"]."&dev=$dev&embryoooid='+this.options[this.selectedIndex].value; document.formu0.target='_self'; submit();\">";


	$requete="SELECT e.\"EMBRYO_ID\",e.\"NAME\" from \"EMBRYO\" e,\"DEV_STAGE\" d where e.\"DEV_STAGE_ID\"='$dev' and d.\"DEV_STAGE_ID\"=e.\"DEV_STAGE_ID\" order by d.\"DEV_PERCENT\"";
// 	print $requete."<br>";
	$stmt=pg_query($c,$requete);
	while ($row=pg_fetch_array($stmt))
	{
	
	print "<option value=\"".$row["EMBRYO_ID"]."\"";
	if ($row["EMBRYO_ID"]==$_GET["embryoid"]) print "selected";

	print ">";

	//print $row["NAME"];
	$name=$row["NAME"];
	$name=str_replace("@","_",$name);
	print "&nbsp;&nbsp;&nbsp;&nbsp;$name&nbsp;&nbsp;&nbsp;&nbsp;";




	print "</option>";
	}


	print "</select>";
	print "</form>";
print "<br>";


if (strlen($_GET["embryoid"])==0)
	{
	//default embryo;
	$requete="SELECT \"EMBRYO_ID\",\"NAME\" from \"EMBRYO\" where \"DEV_STAGE_ID\"='$dev'";
	$stmt=pg_query($c,$requete);
	$row=pg_fetch_array($stmt);



	$_GET["embryoid"]=$row["EMBRYO_ID"];
	$name=$row["NAME"];
	$name=str_replace("@","_",$name);
	}
else
	{
	$requete="SELECT \"NAME\" from \"EMBRYO\" where \"EMBRYO_ID\"='".$_GET["embryoid"]."'";
	$stmt=pg_query($c,$requete);
	$row=pg_fetch_array($stmt);
	$name=$row["NAME"];
	$name=str_replace("@","_",$name);
	}

	print "<font color=\"#686868\" size=\"-1\"><b>$name</b></font>";

	print "</center>";
	
print "<br><br>";

//////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////////


print "<TABLE width=\"100%\" border=\"0\">";
print "<TR>";
print "<TD valign=\"top\" align=\"left\" width=\"45%\">";

///// AFFICHAGE DU NEIGHBOR ////
print "<center><font color=\"#D64242\" size=\"2\"><b>Neighbour cells</b></font></center><br>";


$requete0="SELECT \"CELL_A\", \"CELL_B\", \"CONTACT\", \"DISTANCE\" FROM \"EMBRYO_NEIGHBOR\" where \"EMBRYO_ID\"='".$_GET["embryoid"]."' and ((\"CELL_A\"='$region') or (\"CELL_B\"='$region'))and(\"CONTACT\" >= '0')and(\"DISTANCE\" <= '5') order by \"CONTACT\" desc";
$stmt0=pg_query($c,$requete0);

if (pg_num_rows($stmt0)==0) 
	{
	print "<center><strong>No Data</strong></center>";
	}
else
	{
print '<table width="1000%" border="0" cellspacing="0" cellpadding="0">';

//print '<tr align="center" valign="middle"><td><font color="#456898" size="2"><b>Anatomical entity</b></font></td><td><font color="#456898" size="2"><b>Neighbour</b></font></td><td><font color="#456898" size="2"><b>Distance (&micro;)</b></font></td><td><font color="#456898" size="2"><b>Contact (&micro;&sup2;)</b></font></td></tr>';
print '<tr align="center" valign="middle"><td><font color="#456898" size="2"><b>Neighbour</b></font></td><td><font color="#456898" size="2"><b>Distance (&micro;)</b></font></td><td><font color="#456898" size="2"><b>Contact (&micro;&sup2;)</b></font></td></tr>';

	}
while ($row0=pg_fetch_array($stmt0))
{

$cella=$row0["CELL_A"];
$cellb=$row0["CELL_B"];
$contact=$row0["CONTACT"];
$distance=$row0["DISTANCE"];

///// AJOUT //////
if ($cella==$region) {$CELL=$cella;$NEI=$cellb;}
if ($cellb==$region) {$CELL=$cellb;$NEI=$cella;}


$requete1="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$NEI'";
$stmt1=pg_query($c,$requete1);
$row1=pg_fetch_array($stmt1);

$NEIM=$row1["NAME"];


/*
$requete1="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$cella'";
$stmt1=pg_query($c,$requete1);
$row1=pg_fetch_array($stmt1);

$cella=$row1["NAME"];


$requete1="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$cellb'";
$stmt1=pg_query($c,$requete1);
$row1=pg_fetch_array($stmt1);

$cellb=$row1["NAME"];
*/

//Affiche sans tooltip
//print "<tr><td style=\"border-bottom:1px solid black;\" align=\"center\"><font size=\"-1\"><b>$cella</b></font></td><td align=\"center\" style=\"border-bottom:1px solid black;\" ><font size=\"-1\"><b>$cellb</b></font></td><td  style=\"border-bottom:1px solid black;\"align=\"center\"><font size=\"-1\"><b>$distance</b></font></td><td  style=\"border-bottom:1px solid black;\"align=\"center\"><font size=\"-1\"><b>$contact</b></font></td></tr>";

//// Affiche avec tooltip
//print "<tr><td style=\"border-bottom:1px solid black;\" align=\"center\"><font size=\"-1\"><b><a href=\"short_hierarchy.php?region=$NEI&dev=$dev\"  onmouseover=\"return escape('<center><img src=newtree.php?anat=$NEI></center>');\"  >$NEIM</a></b></font></td><td  style=\"border-bottom:1px solid black;\"align=\"center\"><font size=\"-1\"><b>$distance</b></font></td><td  style=\"border-bottom:1px solid black;\"align=\"center\"><font size=\"-1\"><b>$contact</b></font></td></tr>";

//// Nouveau test
//print "<tr><td style=\"border-bottom:1px solid black;\" align=\"center\"><font size=\"-1\"><b><a href=\"short_hierarchy.php?region=$NEI&dev=$dev\"  onmouseover=\"embryo.src='newtree.php?anat=$NEI'\" onmouseout=\"embryo.src='newtree.php?anat=$region'\" >$NEIM</a></b></font></td><td  style=\"border-bottom:1px solid black;\"align=\"center\"><font size=\"-1\"><b>$distance</b></font></td><td  style=\"border-bottom:1px solid black;\"align=\"center\"><font size=\"-1\"><b>$contact</b></font></td></tr>";

//// Nouveau test Neig et region
 print "<tr><td style=\"border-bottom:1px solid black;\" align=\"center\"><font size=\"-1\"><b><a href=\"embryo-short_hierarchy.php?region=$NEI&dev=$dev&embryoid=".$_GET["embryoid"]."\"  onmouseover=\"embryo.src='combi_short.php?region=$region&nei=$NEI'\" onmouseout=\"embryo.src='newtree.php?anat=$region'\">$NEIM</a></b></font></td><td  style=\"border-bottom:1px solid black;\"align=\"center\"><font size=\"-1\"><b>$distance</b></font></td><td  style=\"border-bottom:1px solid black;\"align=\"center\"><font size=\"-1\"><b>$contact</b></font></td></tr>";






}

if (pg_num_rows($stmt0)!=0) print "</table>";
else print "&nbsp;";

////////////////////////////////

print "</TD>";

print "<TD width=\"49%\" valign=\"top\" align=\"center\">";

//////////// AFFICHAGE DE LA BIOMETRY //////////////

print "<font color=\"#D64242\" size=\"2\"><b>Biometry</b></font><br><br>";
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function select_recursif($c,$anat)
{
global $table;

$requete="SELECT \"ANAT_ID\",\"NAME\",\"TYPE\" from \"ANAT_ENTITY\" where \"CHILD_OF\"='$anat'";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0) {$table[count($table)]=$anat;return;}
while ($row=pg_fetch_array($stmt))
{
select_recursif($c,$row["ANAT_ID"]);
if ($row["TYPE"]=="cell") $table[count($table)]=$row["ANAT_ID"];
}
}
/////////////////////////////////////////////////////////////////////////////// biometry page///////////////////////////

$table=(array) null;
select_recursif($c,$region);

$ent=0;
$occ=0;
$sphe=0;
$elo=0;
$flat=0;
$sv=0;
$conv=0;
$vv=0;

$vol=0;
$surf=0;

/*
if (strlen($_GET["embryoid"])==0)
	{
*/
?>
<!--
<center>
<form name="formu" action="embryo-short_hierarchy.php" method="get" target="_blank">
-->
<?
/*
print "<input type=\"hidden\" name=\"region\" value=\"".$_GET["region"]."\">";
print "<input type=\"hidden\" name=\"dev\" value=\"$dev\">";

	print "<font color=\"486898\" size=\"-1\"><b>Choose an embryo to display its shapes properties</b></font><br>";
	print "<select name=\"embryoid\" size=\"3\" onChange=\"document.formu.action='embryo-short_hierarchy.php?region=".$_GET["region"]."&dev=$dev&embryoid='+this.options[this.selectedIndex].value; document.formu.target='_self'; submit();\">";


	$requete="SELECT e.\"EMBRYO_ID\",e.\"NAME\" from \"EMBRYO\" e,\"DEV_STAGE\" d where e.\"DEV_STAGE_ID\"='$dev' and d.\"DEV_STAGE_ID\"=e.\"DEV_STAGE_ID\" order by d.\"DEV_PERCENT\"";
// 	print $requete."<br>";
	$stmt=pg_query($c,$requete);
	while ($row=pg_fetch_array($stmt))
	{
	
	print "<option value=\"".$row["EMBRYO_ID"]."\"";
	if ($row["EMBRYO_ID"]==$_GET["embryoid"]) print "selected";

	print ">";

	//print $row["NAME"];
	$name=$row["NAME"];
	$name=str_replace("@","_",$name);
	print "&nbsp;&nbsp;&nbsp;&nbsp;$name&nbsp;&nbsp;&nbsp;&nbsp;";




	print "</option>";
	}


	print "</select>";
	print "</form>";
print "<br>";


if (strlen($_GET["embryoid"])==0)
	{
	//default embryo;
	$requete="SELECT \"EMBRYO_ID\",\"NAME\" from \"EMBRYO\" where \"DEV_STAGE_ID\"='$dev'";
	$stmt=pg_query($c,$requete);
	$row=pg_fetch_array($stmt);



	$_GET["embryoid"]=$row["EMBRYO_ID"];
	$name=$row["NAME"];
	$name=str_replace("@","_",$name);
	}
else
	{
	$requete="SELECT \"NAME\" from \"EMBRYO\" where \"EMBRYO_ID\"='".$_GET["embryoid"]."'";
	$stmt=pg_query($c,$requete);
	$row=pg_fetch_array($stmt);
	$name=$row["NAME"];
	$name=str_replace("@","_",$name);
	}

	print "<font color=\"#686868\" size=\"-1\"><b>$name</b></font>";

	print "</center>";
	
*/
$NOVOL=false;
$NOBIOM=false;

for ($i=0;$i<count($table);$i++)
{
$requete="SELECT \"SURFACE\",\"VOLUME\" from \"EMBRYO_BIOMETRY\" where \"CELL\"='".$table[$i]."' and \"EMBRYO_ID\"='".$_GET["embryoid"]."'";
// print $requete."<br>";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0) 
	{
	$NOVOL=true;
	print "<small><b>No Volume and Surface data associated to this embryo (<i>$name</i>)</b></small><br>";
	break;
	}

$row=pg_fetch_array($stmt);

$vol+=$row["VOLUME"];
$surf+=$row["SURFACE"];

}



for ($i=0;$i<count($table);$i++)
{
$requete="SELECT * from \"EMBRYO_BIOMETRY_SHAPE\" where \"CELL\"='".$table[$i]."' and \"EMBRYO_ID\"='".$_GET["embryoid"]."'";
// print $requete."<bR>";
$stmt=pg_query($c,$requete);

if (pg_num_rows($stmt)==0) 
	{
	$NOBIOM=true;
	print "<small><b>No Shape data associated to this embryo (<i>$name</i>)</b></small><br>";
	break;
	}

$row=pg_fetch_array($stmt);

$ent+=round($row["ENTROPY"]);
$occ+=round($row["OCCUPENCY"]);
$sphe+=round($row["SPHERICITY"]);
$elo+=round($row["ELONGATION"]);
$flat+=round($row["FLATNESS"]);
$sv+=round($row["SV"]);
$conv+=round($row["CONVEXITY"]);
$vv+=round($row["VV"]);

}



$ent/=(count($table));
$occ/=(count($table));
$sphe/=(count($table));
$elo/=(count($table));
$flat/=(count($table));
$sv/=(count($table));
$conv/=(count($table));
$vv/=(count($table));

$vol/=count($table);
$surf/=count($table);





	
if ($NOVOL==false)	print "<font color=\"#656565\" size=\"-1\">Volume: $vol &micro;3 &nbsp;&nbsp; Surface: $surf &micro;2 </font><br><br>";
if ($NOBIOM==false)
	{
	print "<table>";
	print "<tr><td><font color=\"#656565\" size=\"-1\">Entropy: </font></td><td>";
	for($l=0; $l<=$ent; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$ent); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$ent%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Squarness: </font></td><td>";
	for($l=0; $l<=$occ; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$occ); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$occ%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Sphericity: </font></td><td>";
	for($l=0; $l<=$sphe; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$sphe); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$sphe%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Elongation: </font></td><td>";
	for($l=0; $l<=$elo; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$elo); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$elo%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Flatness: </font></td><td>";
	for($l=0; $l<=$flat; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$flat); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$flat%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Convexity: </font></td><td>";
	for($l=0; $l<=$conv; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$conv); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$conv%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Surface/Volume: </font></td><td>";
	for($l=0; $l<=$sv; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$sv); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$sv%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Cell Volume/Embryo volume </font></td><td>";
	for($l=0; $l<=$vv; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$vv); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$vv%</font></td></tr>";

	print "</table>";
	}


////////////////////////////////////////////////////

print "</TD>";

print "</TR>";




//print "<TR><TD>&nbsp;</TD></TR>";


/*

print "<TR>";
print "<TD width=\"49%\" valign=\"top\" align=\"center\">";

//////////// AFFICHAGE DE LA BIOMETRY //////////////

print "<br><br>";
print "<font color=\"#D64242\" size=\"2\"><b>Biometry</b></font><br><br>";
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function select_recursif($c,$anat)
{
global $table;

$requete="SELECT \"ANAT_ID\",\"NAME\",\"TYPE\" from \"ANAT_ENTITY\" where \"CHILD_OF\"='$anat'";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0) {$table[count($table)]=$anat;return;}
while ($row=pg_fetch_array($stmt))
{
select_recursif($c,$row["ANAT_ID"]);
if ($row["TYPE"]=="cell") $table[count($table)]=$row["ANAT_ID"];
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////

$table=(array) null;
select_recursif($c,$region);

$ent=0;
$occ=0;
$sphe=0;
$elo=0;
$flat=0;
$sv=0;
$conv=0;
$vv=0;

$vol=0;
$surf=0;


for ($i=0;$i<count($table);$i++)
{
$requete="SELECT \"SURFACE\",\"VOLUME\" from \"BIOMETRY\" where \"CELL\"='".$table[$i]."'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);

$vol+=$row["VOLUME"];
$surf+=$row["SURFACE"];

}



for ($i=0;$i<count($table);$i++)
{
$requete="SELECT * from \"BIOMETRY_SHAPE\" where \"CELL\"='".$table[$i]."'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);

$ent+=$row["ENTROPY"];
$occ+=$row["OCCUPENCY"];
$sphe+=$row["SPHERICITY"];
$elo+=$row["ELONGATION"];
$flat+=$row["FLATNESS"];
$sv+=$row["SV"];
$conv+=$row["CONVEXITY"];
$vv+=$row["VV"];

}



$ent/=(count($table));
$occ/=(count($table));
$sphe/=(count($table));
$elo/=(count($table));
$flat/=(count($table));
$sv/=(count($table));
$conv/=(count($table));
$vv/=(count($table));

$vol/=count($table);
$surf/=count($table);



print "<table>";

	
	print "<font color=\"#656565\" size=\"-1\">Volume: $vol &micro;3 &nbsp;&nbsp; Surface: $surf &micro;2 </font><br><br>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Entropy: </font></td><td>";
	for($l=0; $l<=$ent; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$ent); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$ent%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Squarness: </font></td><td>";
	for($l=0; $l<=$occ; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$occ); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$occ%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Sphericity: </font></td><td>";
	for($l=0; $l<=$sphe; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$sphe); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$sphe%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Elongation: </font></td><td>";
	for($l=0; $l<=$elo; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$elo); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$elo%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Flatness: </font></td><td>";
	for($l=0; $l<=$flat; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$flat); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$flat%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Convexity: </font></td><td>";
	for($l=0; $l<=$conv; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$conv); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$conv%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Surface/Volume: </font></td><td>";
	for($l=0; $l<=$sv; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$sv); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$sv%</font></td></tr>";

	print "<tr><td><font color=\"#656565\" size=\"-1\">Cell Volume/Embryo volume </font></td><td>";
	for($l=0; $l<=$vv; ++$l) print '<img src="pictures/stat1.jpg">';
	for($l=0; $l<=(100-$vv); ++$l) print '<img src="pictures/stat0.jpg">';
	print "&nbsp;&nbsp;<font color=\"#656565\" size=\"-1\">$vv%</font></td></tr>";

print "</table>";


////////////////////////////////////////////////////

print "</TD>";
print "</TR>";

*/

print "</TABLE>";

















	
	}else{ print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>"; }
?>
<br>


<!--Rajout pour le tooltiptext -->
<script type="text/javascript" src="wz_tooltip.js"></script>


<?php
    include("frames_footer.php");
?>