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

$id=$_GET["id"];
$gene=$_GET["gene"];



print "<br><center><h3>Molecular tools for $gene</h3></center>";


$requete="SELECT * from \"MOLECULAR_TOOL\" where \"ASSOCIATED_GENE_ID\" in (select \"NAME\" from \"GENE\" where \"GENE_ID\" in (select \"GENE_MODEL_ID\" from \"GENE_CONCEPT\" where \"GENE_CLUSTER_ID\"= (select \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\"=(select \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$gene'))))";




$stmt=pg_query($c,$requete);

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


print "<form name=\"formu0\" action=\"moltool-create.php\" method=\"POST\" target=\"blank\">";
print "<input type=\"hidden\" name=\"gene\" value=\"$gene\">";
print "<center><input type=\"submit\" value=\"Create a new Molecular Tool associated to this gene\"></center>";
print "</form>";


print "<br>";

while ($row=pg_fetch_array($stmt))
{
$name=$row["NAME"];
$type=$row["TYPE"];
$supplier=$row["SUPPLIER"];
$comments=$row["COMMENTS"];
$regulation=$row["REGULATION"];

$molid=$row["MOLECULAR_TOOL_ID"];

if ($type=="Other") $backcolor="lightyellow";
if ($type=="Morpholino") $backcolor="#C6AEC7";
if ($type=="Antibody") $backcolor="#BDEDFF";
if ($type=="Chemical inhibitor") $backcolor="#48CCCD";
if ($type=="Pharmacological inhibitor") $backcolor="#ECE5B6";
if ($type=="Reporter gene") $backcolor="#FAAFBA";
if ($type=="mRNA") $backcolor="#FFFFFF";
if ($type=="Driver") $backcolor="#FFFFFF";
if ($type=="RNAi") $backcolor="#FFFFFF";

print "<center><div style=\"border:1px solid black;text-align:left;background-color:$backcolor;color:black;width:70%;padding:5px;\">";

print "<center><b><font color=\"#D64242\">$name</font></b></center>";
print "<center>$comments</center><br>";

print "Type: <b>$type</b><br>";

if (strlen($supplier)==0) print "Supplier : <i><font size=\"-1\">No data</font></i><br>"; else print "Supplier : <b>$supplier</b><br>";
if (strlen($regulation)==0) print "Regulation : <i><font size=\"-1\">No data</font></i><br>"; else print "Regulation : <b>$regulation</b><br>";

print "<br>";

$requete0="SELECT \"SEQUENCE\" from \"SEQUENCE\" where \"MOL_ID\"='$molid'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);

$lob = $row0["SEQUENCE"];
pg_query ($c, "begin");
$handle_lo = pg_lo_open($c,$lob,"r");
$seq=pg_lo_read($handle_lo);
pg_query($c,"end");

if (strlen($seq)==0) print "<center><u>Sequence</u><br><i><font size=\"-1\">No sequence has been entered for this tool</font></i></center>";
else print "<center><u>Sequence</u> <br><br><div style=\"width:60%;background-color:white;padding;5px;\"><font face=\"Courier New, Courier, mono\" size=\"3\">$seq</font></center><br>";


print "<hr>";
print "<center><a target=\"blank\" href=\"moltool-edit.php?id=$molid\"><img border=\"0\" src=\"pictures/button-cur-edit.gif\"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a target=\"blank\" href=\"moltool-delete.php?id=$molid\"><img border=\"0\" src=\"pictures/button-cur-delete.gif\"></a></center>";


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




}








include ("frames_footer.php");
?>