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

?>
<h3><center>Edit a Molecular tool</center></h3><br>
<?
$molid=$_GET["id"];


$requete="SELECT * from \"MOLECULAR_TOOL\" where \"MOLECULAR_TOOL_ID\"='$molid'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);

$name=$row["NAME"];
$supplier=$row["SUPPLIER"];
$comments=$row["COMMENTS"];
$type=$row["TYPE"];
$regulation=$row["REGULATION"];
$gene=$row["ASSOCIATED_GENE_ID"];

$requete="SELECT \"SEQUENCE\" from \"SEQUENCE\" where \"MOL_ID\"='$molid'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);

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


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=="Overexpression Construct") $backcolor="#FAAFBA";

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

print "<form name=\"formu\" action=\"moltool-edit2.php\" method=\"POST\">";


print "<center>Name<br><input style=\"text-align:center;\" type=\"text\" name=\"name\" value=\"$name\" size=\"40\" ></center><br>";
print "<center>Comments/Description<br><input style=\"text-align:center;\" type=\"text\" name=\"comments\" value=\"$comments\" size=\"90\"></center><br>";

print "Type: ";
if ($type=="Antibody") $s_ant="selected";
if ($type=="Chemical inhibitor") $s_che="selected";
//if ($type=="Driver") $s_dri="selected";
if ($type=="Morpholino") $s_mor="selected";
if ($type=="mRNA") $s_mrn="selected";
//if ($type=="Pharmacological inhibitor") $s_pha="selected";
if ($type=="Overexpression Construct") $s_rep="selected";
if ($type=="RNAi") $s_rna="selected";

if ($type=="Other") $s_oth="selected";

print "<select name=\"type\">";
print "<option $s_ant>Antibody</option>";
print "<option $s_che>Chemical inhibitor</option>";
//print "<option $s_dri>Driver</option>";
print "<option $s_mor>Morpholino</option>";
print "<option $s_mrn>mRNA</option>";
//print "<option $s_pha>Pharmacological inhibitor</option>";
print "<option $s_rep>Overexpression Construct</option>";
print "<option $s_rna>RNAi</option>";
print "<option $s_oth>Other</option>";
print "</select><br>";


print "Supplier : <input type=\"text\" name=\"supplier\" value=\"$supplier\" size=\"40\"><br>";


if ($regulation=="loss of function") $s_loss="selected";
if ($regulation=="gain of function") $s_gain="selected";
print "Regulation : <select name=\"regulation\"><option $s_loss>loss of function</option><option $s_gain>gain of function</option></select><br><br>";

print "Associated Transcript (JGI, kyoto, Ensembl) : <input type=\"text\" name=\"gene\" value=\"$gene\" size=\"40\"><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");

print "<center>Sequence<br><textarea name=\"seq\" cols=\"80\" rows=\"2\">$seq</textarea></center>";
print "<input type=\"hidden\" name=\"id\" value=\"$molid\">";


$requete0="SELECT \"PUBMED_ID\" from \"REFERENCE\" where \"BIO_ID\"='$molid'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);
$pmid=$row0["PUBMED_ID"];

print "<br>Pubmed ID <input type=\"text\" size=\"15\" name=\"pmid\" value=\"$pmid\"><br>";



print "<center><input type=\"image\" src=\"pictures/button-cur-validate.gif\" onclick=\"submit;\"></center>";

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

print "<br>";




print "</form>";



include ("frames_footer.php");
?>