<html>
<head>
<title>ANISEED - Molecular tool card (Ciona intestinalis, Halocynthia roretzi)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="This page describes the Ciona molecular tool as the name of the tool, the supplier, the target gene, the in situ data linked to the tool, the type of regulation.">
<meta name="keywords" content="molecular tool, Ciona intestinalis, Halocynthia roretzi, ascidian database, ciona intestinalis database, Tassy, Lemaire, Daian, Sobral, Dauga.">
<meta name = "robots" content = "index, follow, all">
<META HTTP-EQUIV="Content-Language" CONTENT="EN">
<style type="text/css">
</style>
</head>


<?

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


$id=$_GET["id"];


$requete="SELECT \"NAME\",\"TYPE\",\"SUPPLIER\",\"COMMENTS\",\"REGULATION\",\"ASSOCIATED_GENE_ID\" from \"MOLECULAR_TOOL\" where \"MOLECULAR_TOOL_ID\"='$id'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);

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

$gene=$row["ASSOCIATED_GENE_ID"];

$ish=(array) null;
$requete="SELECT distinct \"IN_SITU_ID\",\"UP_DOWN\",\"BIO_ID\" from \"MUTANT\" where \"INHIBITOR_ID\"='$id' and \"IN_SITU_ID\" in (
select \"IN_SITU_ID\" from \"IN_SITU\" where \"PRIVATE\"='n' and \"CHECKED\"='y'
)";
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt)) 
	{

//AJOUT/////////
	$requete0="SELECT distinct \"TARGET_ID\" from \"TARGET\" where \"IN_SITU_ID\"='".$row["IN_SITU_ID"]."'";
	$stmt0=pg_query($c,$requete0);
	$row0=pg_fetch_array($stmt0);

	$ish[$row["IN_SITU_ID"]]=$row["UP_DOWN"]."@".$row0["TARGET_ID"];


//	$ish[$row["IN_SITU_ID"]]=$row["UP_DOWN"]."@".$row["BIO_ID"];
	}







$requete="select \"SEQUENCE\", \"LENGTH\", \"COMMENTS\", \"MOL_ID\" from \"SEQUENCE\" where \"MOL_ID\"=$id";
$stmt = pg_query($c,$requete);
if($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");
	
	$seq=ereg_replace("<br>","",$seq);
        $seq=ereg_replace("\n","",$seq);
	$seq = chunk_split($seq, 70, "\n");
	}



$requete="
select \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"=(
select \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\"=(
SELECT \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$gene')
)
UNION
select \"GENE_CLUSTER_NAME_BLAST\" as \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME_BLAST\" 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);
$GENENAME="";
while ($row=pg_fetch_array($stmt))
{
if (strlen($GENENAME)==0) $GENENAME=$row["GENE_CLUSTER_NAME"];
else $GENENAME.=" / ".$row["GENE_CLUSTER_NAME"];
}


$requete="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);
$row=pg_fetch_array($stmt);
$geneid=$row["GENE_CLUSTER_ID"];


////////////// AFFICHAGE ////////////



print '<font color="#D64242" size="3"><b>Molecular tool card for '.$name.'</b></font><br><br>';


print "<u><font color=\"#456898\" size=\"2\"><b>Features</b></font></u><br><br>";

print "<table border=\"0\" width=\"100%\">";
print "
<tr valign=\"top\" align=\"left\">
<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Name: </b></font></td><td><font color=\"#656565\" size=\"-1\">$name</font></td>
</tr>";

print "
<tr valign=\"top\" align=\"left\">
<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Targeted Gene: </b></font></td><td><font color=\"#656565\" size=\"-1\"><a href=\"gene-card.php?clusterid=$geneid\">$GENENAME</a></font></td>
</tr>";


print "
<tr valign=\"top\" align=\"left\">
<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Type: </b></font></td><td><font color=\"#656565\" size=\"-1\">$type</font></td>
</tr>";
print "
<tr valign=\"top\" align=\"left\">
<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Supplier: </b></font></td><td><font color=\"#656565\" size=\"-1\">$supplier</font></td>
</tr>";

print "
<tr valign=\"top\" align=\"left\">
<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Comments: </b></font></td><td><font color=\"#656565\" size=\"-1\">$comments</font></td>
</tr>";

print "
<tr valign=\"top\" align=\"left\">
<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Regulation: </b></font></td><td><font color=\"#656565\" size=\"-1\">$regulation</font></td>
</tr>";

print "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
print "
<tr valign=\"top\" align=\"left\">";
if (strlen($seq)!=0) print "<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Sequence: </b></font></td><td><font color=\"#656565\" size=\"-1\">".strtoupper($seq)."</font></td>";

else print "<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Sequence: </b></font></td><td><i><font size=\"-1\">No sequence</font></i></td>";

print "</tr>";


print "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";


print "
<tr valign=\"top\" align=\"left\">
<td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>InSitu experiments: </b></font></td><td><font color=\"#656565\" size=\"-1\">";
if (count($ish)>0)
{

$I=0;
foreach ($ish as $key => $val)
	{

	$tmp=explode("@",$val);
	$updown=$tmp[0];

	$updown=str_replace("regulated","regulation",$updown);

/*	$mol=$tmp[1];
	$requete="SELECT \"NAME\" from \"MOL_ENTITY\" where \"MOL_ID\"='$mol'";
	$stmt=pg_query($c,$requete);
	$row=pg_fetch_array($stmt);
	$deregmol=$row["NAME"];*/

	$mol=$tmp[1];
	/*$requete="
	select \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"=(
	select \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\" in (
	SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"='$mol'
	UNION
	SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"=(
	select \"CLONE_NAME\" from \"CLONE\" where \"CLONE_ID\"='$mol'
	)
	UNION
	select \"GENE_ID\" from \"GENE\" where \"GENE_ID\"='$mol'
	))

	UNION

	select \"GENE_CLUSTER_NAME_BLAST\" as \"GENE_CONCEPT_NAME\" from \"GENE_CONCEPT_NAME_BLAST\" where \"GENE_CLUSTER_ID\"=(
	select \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\" in (
	SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"='$mol'
	UNION
	SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"=(
	select \"CLONE_NAME\" from \"CLONE\" where \"CLONE_ID\"='$mol'
	)
	UNION
	select \"GENE_ID\" from \"GENE\" where \"GENE_ID\"='$mol'
	))
	";
	*/

	$requete="


	select \"GENE_CLUSTER_NAME\",\"GENE_CLUSTER_ID\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\" in 
	(
	select distinct \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\" in
		(
		select \"TRANSCRIPT_ID\" as \"ANISEED_CLUSTER_ID\" from \"TRANSCRIPT\" where \"ABSTRACT_ID\"=
			(
			select \"ANISEED_ENSEMBL_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"='$mol'
			)
		UNION 
		select \"TRANSCRIPT_ID\" from \"TRANSCRIPT\" where \"ABSTRACT_ID\" in (
		SELECT \"ANISEED_ENSEMBL_CLUSTER_ID\" as \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"=
			(
			select \"CLONE_NAME\" from \"CLONE\" where \"CLONE_ID\"='$mol'
			)
		)
		UNION
		SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"='$mol'
		UNION 
		SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"=( select \"CLONE_NAME\" from \"CLONE\" where \"CLONE_ID\"='$mol' ) UNION select \"GENE_ID\" as \"ANISEED_CLUSTER_ID\" from \"GENE\" where \"GENE_ID\"='$mol' 
		)
	)


	
	";

	
	$stmt=pg_query($c,$requete);
	$deregmol="";
	while ($row=pg_fetch_array($stmt))
	{
	$gc_id=$row["GENE_CLUSTER_ID"];
	if (strlen($deregmol)==0) $deregmol=$row["GENE_CLUSTER_NAME"];
	else $deregmol.="/".$row["GENE_CLUSTER_NAME"];
	}

	if (strlen($deregmol)==0)
	{
$requete="select distinct \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\" in
		(
		select \"TRANSCRIPT_ID\" as \"ANISEED_CLUSTER_ID\" from \"TRANSCRIPT\" where \"ABSTRACT_ID\"=
			(
			select \"ANISEED_ENSEMBL_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"='$mol'
			)
		UNION 
		select \"TRANSCRIPT_ID\" from \"TRANSCRIPT\" where \"ABSTRACT_ID\" in (
		SELECT \"ANISEED_ENSEMBL_CLUSTER_ID\" as \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"=
			(
			select \"CLONE_NAME\" from \"CLONE\" where \"CLONE_ID\"='$mol'
			)
		)
		UNION
		SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"='$mol'
		UNION 
		SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"=( select \"CLONE_NAME\" from \"CLONE\" where \"CLONE_ID\"='$mol' ) UNION select \"GENE_ID\" as \"ANISEED_CLUSTER_ID\" from \"GENE\" where \"GENE_ID\"='$mol' 
		)";
	$stmt=pg_query($c,$requete);
	$deregmol="";
	$row=pg_fetch_array($stmt);
	
	$deregmol=$row["GENE_CLUSTER_ID"];
	}

	//$deregmol_id=$deregmol;
	 $deregemol=str_replace("cluster","aniseedV3_",$gc_id);
	









	$requete="SELECT \"NAME\",\"SPECIES\" from \"DEV_STAGE\" where \"DEV_STAGE_ID\"=(
	select \"DEV_STAGE_ID\" from \"IN_SITU\" where \"IN_SITU_ID\"='$key'
	)";
	$stmt=pg_query($c,$requete);
	$row=pg_fetch_array($stmt);
	$dev=$row["NAME"];
	$species=$row["SPECIES"];


	print "<a href=\"insitu.php?id=$key\">View</a> ($updown of <b><i><a href=\"gene-card.php?clusterid=$gc_id\">$deregmol</a></i></b> at $dev for $species)<br> ";
	
	$I++;
	}
}
else print "<font size=\"-1\"><i>No InSitu experiments using this molecular tool have been entered in the database</i></font>";


print "</font></td><tr>";




print "</table>";









include ("frames_footer.php");

?>