<?

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

$gene=$_GET["clusterid"];
$clustid=$gene;

//// get gene models related to the gene give by clustid
$gm=(array) null;
$requete="select \"NAME\" from \"GENE\" where \"GENE_ID\" in (
SELECT \"GENE_MODEL_ID\" from \"GENE_CONCEPT\" where \"GENE_CLUSTER_ID\"='$clustid'
)";
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt)) $gm[count($gm)]=$row["NAME"];

//// agregation des modeles de genes

$agreg_gm="";
for ($i=0;$i<count($gm);$i++)
	{
	if (strlen($agreg_gm)==0) $agreg_gm=$gm[$i];
	else $agreg_gm.=":".$gm[$i];
	}



?>

  <link rel="stylesheet" type="text/css" media="screen" href="ongletv1.css" title="Version 1" />
<div id="header">
  <ul>
    <li><a href="gene-card.php?clusterid=<?print $clustid;?>">Gene Card</a></li>
    <li><a href="ESTcluster-gene.php?clusterid=<? print $clustid; ?>">ESTs cluster</a></li>
    <li><a href="est-expression-gene.php?clusterid=<?print $clustid; ?>">EST count</a></li>
    <li><a href="insitu-result.php?target=<?print $agreg_gm;?>&BOOLmut=3&BOOLmanip=2&MOLtype=2&Order=DEV_STAGE_ID">InSitu data</a></li>

  <li ><a href="gene-regulation-card.php?clusterid=<?print $clustid; ?>" >Regulation</a></li>
	<li ><a href="gene-function-card.php?clusterid=<?print $clustid; ?>">Function</a></li>
<li id="current"><a href="#">Regulatory Network</a></li>
    <li><a href="moltool-result-gene.php?clusterid=<?print $clustid;?>">Molecular tool</a></li>
    
	    <li><a href="bib-mol.php?clusterid=<? print $clustid; ?>&function=1&regulation=1&wild=1">Articles</a></li>

    <li><a href="#" style="color:white;">Export</a></li>
    

<!--<li><a href="#" style="color:white;">Microarray probe</a></li>-->
  </ul>
</div>
<!-- EOF Onglet -->
<br><br>


<?

$requete="
select \"GENE_CLUSTER_NAME\" as \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"='$gene'
UNION
SELECT \"GENE_CLUSTER_NAME_BLAST\" as \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME_BLAST\" where \"GENE_CLUSTER_ID\"='$gene'
";
$stmt=pg_query($c,$requete);
$gene_name="";
while ($row=pg_fetch_array($stmt)) if (strlen($gene_name)==0) $gene_name=$row["GENE_CLUSTER_NAME"]; else $gene_name.=" / ".$row["GENE_CLUSTER_NAME"];

print "<title>ANISEED V3 - Gene Regulatory Network for $gene_name</title>";


$requete="
select distinct \"ANAT_ID\" from \"ANAT_ENTITY\" where \"ANAT_ID\" in (
SELECT \"REG_ANAT\" from \"REG_EVIDENCE\" where \"GENE_X\"='$gene'
UNION
SELECT \"REG_ANAT\" from \"REG_EVIDENCE\" where \"GENE_Y\"='$gene'
)
";
$stmt=pg_query($c,$requete);
$NUM=pg_num_rows($stmt);

print "<center><br><br><font color=\"#D64242\" size=\"2\"><b>Gene Regulatory Networks in which $gene_name is implicated in</b></font><br></center><br><br>";
print "<center><font size=\"-1\"><b>$NUM results</b></font></center><br><br>";


print "<center><table width=\"80%\">";
print "<tr><td align=\"center\"><font color=\"#486898\" size=\"-1\"><b>Developmental Stage</b></font></td><td align=\"center\"><font color=\"#486898\" size=\"-1\"><b>Anatomical Territory</b></font></td><td><font color=\"#486898\" size=\"-1\"><b>Network</b></font></td><tr>";

$I=0;
while ($row=pg_fetch_array($stmt))
{
//print $row["ANAT_ID"]."<br>";

$anat=$row["ANAT_ID"];

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

$anat_name=$row0["NAME"];
$dev_id=$row0["DEV_STAGE_ID"];

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

$dev_name=$row0["NAME"];

//print "$anat_name at $dev_name <a target=\"blank\" href=\"view-net.php?clusterid=$gene&dev_stage=$dev_name&anat_name=$anat_name&h=500\">View</a><br>";
if ($I%2==0) $color="lightgray";
else $color="white";
print "<tr><td align=\"center\" style=\"background-color:$color;\"><font size=\"-1\">$dev_name</font></td><td align=\"center\"  style=\"background-color:$color;\"><font size=\"-1\"><a href=\"short_hierarchy.php?region=$anat&dev=$dev_id\">$anat_name</a></font></td><td align=\"center\" style=\"background-color:$color;\"><a target=\"blank\" href=\"view-net.php?clusterid=$gene&dev_stage=$dev_name&anat_name=$anat&h=500\"><font size=\"-1\">Show Network</font></a></td></tr>";


$I++;
}
print "</table>";
print "</center>";











include ("frames_footer.php");

?>