<?
include ("connection.php");
include ("frames_header.php");


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


$requete="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$anat'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);

$anat_name=$row["NAME"];

$requete="SELECT \"NAME\" from \"DEV_STAGE\" where \"DEV_STAGE_ID\"=(
select \"DEV_STAGE_ID\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$anat'
)";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt) or die (pg_last_error($c));

$dev_name=$row["NAME"];

print "<center><br><br><br><br><font color=\"#D64242\" size=\"2\"><b>Gene Regulatory Networks available for $anat_name at  $dev_name</b></font><br></center>";
print "<br>";

$requete="
select distinct \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\" in (
select distinct \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_CLUSTER_ID\" in (
SELECT \"GENE_X\" from \"REG_EVIDENCE\" where \"REG_ANAT\"='$anat'
UNION
SELECT \"GENE_Y\" from \"REG_EVIDENCE\" where \"REG_ANAT\"='$anat'
)
)
"
;

$stmt=pg_query($c,$requete);
print "<center>";


print "<b>".pg_num_rows($stmt)." results</b>";

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


while ($row=pg_fetch_array($stmt))
{

$clustid=$row["GENE_CLUSTER_ID"];

$requete0="SELECT \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"='$clustid'";
$stmt0=pg_query($c,$requete0);
$name="";
while ($row0=pg_fetch_array($stmt0))
{

if (strlen($name)==0) $name=$row0["GENE_CLUSTER_NAME"];
else $name.=" / ".$row0["GENE_CLUSTER_NAME"];


}

print "<font color=\"black\"><b>*</b></font> <b>$name  : </b>
<a target=\"blank\" href=\"view-net.php?clusterid=$clustid&dev_stage=$dev_name&anat_name=$anat&h=500\">View</a><br><br>";

//if (strlen($name)==0) print "$clustid  : <a href=\"view-net.php?clusterid=$clustid&dev_stage=$dev_name&anat_name=$anat_name&h=700\">View</a><br>";
//else
 
print "<center>";
print "<img src=\"imgNet2.php?clustid=$clustid&h=400&dev=$dev&anat=$anat\" USEMAP=\"#mymap0\" BORDER=\"0\" ><br>";
print "</center>";





}




include ("frames_footer.php");
?>