<?php
/*
    ANISEED, NISEED System and Database
    Copyright (C) 2007 Olivier Tassy, Fabrice Daian, Patrick Lemaire

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
	//connection
	include("connection.php");
//Title before frames_header

    include("frames_header.php");
?>

  <link rel="stylesheet" type="text/css" media="screen" href="ongletv1.css" title="Version 1" />


<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
    if (! window.focus)
	    return true;

    var href;
    if (typeof(mylink) == 'string')
        href=mylink;
    else
        href=mylink.href;

    document.GO = window.open(href, windowname, 'width=600,height=200,scrollbars=yes,toolbar=no,resizable=yes');
    document.GO.focus();
	
	return false;
}
//-->
</SCRIPT>

<style type="text/css">
.tabulation
{
	padding-left :40px;
}

#cadreendo {
color: white;
background-color:black;
}

#cadremeso {
color: white;
background-color:green;
}
#cadreendo {
color: white;
background-color:blue;
}
#cadrecton {
color: white;
background-color:red;
}
#cadrectoe {
color: white;
background-color:gray;
}

#bordcleav {
border:1px solid black;
background-color:lightyellow;
color: black;
}

#bordgast {
border:1px solid black;
background-color:lightgreen;
color: black;
}

#bordneur {
border:1px solid black;
background-color:lightblue;
color: black;
}

#bordtail {
border:1px solid black;
background-color:lightgray;
color: black;
}

#bordlarva{
border:1px solid black;
background-color:white;
color: black;
}

#bordadult {
border:1px solid black;
background-color:lightcoral;
color: black;
}

#bordT {
border:1px solid black;
background-color:white;
}
#bordT2 {
border:2px solid red;
background-color:white;
color:black;
}

</style>

<?
$name=$_GET["name"];
?>

<?php


    
	
	$requete="select A.*, B.\"SPECIES\" from \"GENE\" A, \"MOL_ENTITY\" B where (A.\"NAME\"='$name')and(A.\"GENE_ID\"=B.\"MOL_ID\")";

//print $requete;

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

	if($row=pg_fetch_array($stmt)){
	
	    $id=$row["GENE_ID"];

	    $species=$row["SPECIES"];

	

	    $id=$row["GENE_ID"];
		$name=$row["NAME"];
?>
<title>ANISEED - Transcript model card: <?print $name;?></title>

<?
$clustid=$id;

if ($row["NAME"]{0}=="K") //KYOTO
{
//AJOUT POUR L'ABSTRACT de KYOTO

$qu="SELECT \"NAME\" from \"MOL_ENTITY\" where \"MOL_ID\"='$id'";
$st=pg_query($c,$qu);
$ro=pg_fetch_array($st);

$temp=explode(".",$ro["NAME"]);
$abstract=$temp[0].".".$temp[1].".".$temp[2];
$qu="SELECT \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$abstract' and \"TYPE\"='abstract'";
$st=pg_query($c,$qu);
$ro=pg_fetch_array($st);

	$clustid=$ro["MOL_ID"];
		//print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Corresponding cluster: </b></font></td><td>";
		//print "<a href=\"ESTcluster.php?name=".$ro["MOL_ID"]."\"><font color=\"#000000\" size=\"-1\">".$ro["MOL_ID"]."</font></a></td></tr>";
//FIN AJOUT
}

if ($row["NAME"]{0}=="E")
	{
	//POUR ENSEMBL

	$qu="SELECT \"ABSTRACT_ID\" from \"TRANSCRIPT\" where \"TRANSCRIPT_ID\"='$id'";
	$st=pg_query($c,$qu);
	$ro=pg_fetch_array($st);

 	$clustid=$ro["ABSTRACT_ID"];
//	print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Corresponding cluster: </b></font></td><td>";
//	print "<a href=\"ESTcluster.php?name=".$ro["ABSTRACT_ID"]."\"><font color=\"#000000\" size=\"-1\">".$ro["ABSTRACT_ID"]."</font></a></td></tr>";
	}



?>

<!-- Header pour l'onglet -->
<div id="header">
  <ul>
    <li id="current" ><a href="#">Transcript model card</a></li>
    <li><a href="molecule-sequence.php?id=<? print $id; ?>">Sequence</a></li>
    <li><a href="ESTcluster.php?name=<? print $clustid; ?>&base=<?print $id;?>">ESTs cluster</a></li>
    <li><a href="est-expression.php?name=<?print $clustid;?>&base=<? print $id; ?>&species=<?print $species;?>">EST count</a></li>
<!--    <li><a href="expression-curve.php?name=<? print $name;?>">Expression profile</a></li>-->
    <li><a href="insitu-result.php?target=<? print $name;?>&MOLtype=2&Order=DEV_STAGE_ID">InSitu data</a></li>
    <!--<li><a href="moltool.php?target=<? print $name; ?>">Molecular tool</a></li>-->
    <!--<li><a href="moltool-result.php?name=<? print $name; ?>">Molecular tool</a></li>-->
    <!--<li><a href="#" style="color:white;">Microarray probe</a></li>-->
    <li><a href="FLATexport-molecule-gene.php?name=<? print $name; ?>">Export</a></li>
  </ul>
</div>
<!-- EOF Onglet -->
<br><br>

<?



        


/////////// AJOUT pour la detection d'obsolete ////////////////

$requeteOBS="SELECT \"OBSOLETE\" from \"MOL_ENTITY\" where \"NAME\"='".$row["NAME"]."' and \"TYPE\"='gene'";
$stmtOBS=pg_query($c,$requeteOBS);
$rowOBS=pg_fetch_array($stmtOBS);

if ($rowOBS["OBSOLETE"]=='y') 
	{print '<br><br><font color="#AAAAAA" size="3"><b>'.$row["NAME"].' &nbsp (OBSOLETE: will be deleted soon) </b></font>';
	print "<center><br><b><i><font color=\"#D64262\">This Transcript model has : Only one exon, has a nucleotidic sequence which is less than 300 bp, is supported by no EST, and all its best blast hits are greater than 0.5</font></b></i></center><br><br>";
	}
else
	{
	print '<br><br><font color="#D64242" size="3"><b>'.$row["NAME"].'</b></font><br><br>';
	}


?>
This page gives access to the functional annotation (name, scaffold,
orthologues in mouse, human and drosophila, best blast hit in
Swissprot, interpro domains and Gene Ontology classification), The
other tabs give access to the sequence (nucleotide and aa),
associated ESTs, EST counts in the various sequenced libraries, in
situ data in WT and manipulated conditions, molecular tools
(morpholinos, full length Gateway clones), microarray probes (to be
implemented). The genomic annotations can be exported as a flat file
via the export tab.
<br><br>

<?

	    print "<u><font color=\"#456898\" size=\"3\"><b>Features</b></font></u><br>";
        print "<table border=\"0\" width=\"100%\"><tr valign=\"top\" align=\"left\"><td width=\"25%\"><font color=\"#656565\" size=\"-1\"><b>Transcript model ID: </b></font></td><td><font color=\"#656565\" size=\"-1\">".$row["NAME"]."</font></td></tr>";
        
		
	    $requete2="select \"SYNO\" from \"SYNO\" where \"GENE_ID\"=$id and \"ORIGIN\"='user-JGI'";
	    $stmt2 = pg_query($c,$requete2);
		
        print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Possible biological name</b> (manual annotation)*:</font> </td><td><font color=\"#656565\" size=\"-1\">";
		$a=0;
		while($row2=pg_fetch_array($stmt2)){
			   if($a++>0)
				    print ' <strong><font color="000000">/</font></strong> ';
		       print $row2["SYNO"];
		}
		print "</font></td></tr>";
	    //print "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
		
		
	    $requete2="select \"SYNO\" from \"SYNO\" where \"GENE_ID\"=$id and \"ORIGIN\"='phylogeny'";
	    $stmt2 = pg_query($c,$requete2);
		print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Possible biological name:</b></font></td><td><font color=\"#656565\" size=\"-1\">";
		$a=0;
		while($row2=pg_fetch_array($stmt2)){
		    //if(OCIresult($stmt2,"SYNO") != $name)
				if($a++>0)
				    print ' <strong><font color="000000">/</font></strong> ';
		        print $row2["SYNO"];

		}
		if($a==0){
			$requete2="select \"DESCRIPTION\", \"EVALUE\" from \"BLAST\" where \"MOL_ID\"=$id and \"SCORE\"=(select max(\"SCORE\") from \"BLAST\" where \"MOL_ID\"=$id)";
			//$requete2="select max(score), description, evalue from ciona_design.blast where mol_id=$id";
			$stmt2 = pg_query($c,$requete2);
			if($row2=pg_fetch_array($stmt2)){
			    $eval = $row2["EVALUE"];
			    if( $eval <= 1e-10)
				    print "HIGHLY ";
				else if( ($eval >= 1e-4) and ($eval <= 1e-3) )
				    print "WEAKLY ";
					
				if($eval <= 1e-3)
			        print "SIMILAR TO ".$row2["DESCRIPTION"]." (Eval: $eval)";
			}
		}
		
		print "</font></td></tr>";
	    print "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>";
	
	
	
	//EST clusters from M.GILCHRIST
		$queryEstCluster = "SELECT \"cluster_id\", \"cluster_name\", \"FL_score\", \"definition\" AS group_name,
				\"comment\" AS group_comment
			FROM \"EST_CLUSTER\" JOIN \"CC_TRANSCRIPT_ALIGNMENT\" USING(\"cluster_id\")
				JOIN \"GROUP_ALIGNMENT_CLUSTER\" USING(\"group_id\")
			WHERE \"transcript_id\"=$id;";
		$resultEstCluster = pg_query($c,$queryEstCluster);
		if($arrayEstCluster=pg_fetch_array($resultEstCluster))
		{
			$idEstCluster = $arrayEstCluster["cluster_id"];
			$nameEstCluster = $arrayEstCluster["cluster_name"];
			$nameEstClusterGroup = $arrayEstCluster["group_name"];
			$definitionEstClusterGroup = $arrayEstCluster["group_comment"];
			$scoreEstCluster = $arrayEstCluster["FL_score"];
			print("<tr valign=\"top\" align=\"left\">");
			print("<td colspan=\"2\"><font color=\"#656565\" size=\"-1\" style=\"font-weight: bold\">");
			print("<span title='N-terminal 200 aa of KH, > 90% identity, over > 100 aa, e-value < e-20'>Accuracy of initiator methionine prediction :</span></font>");
			print("</td>");
			print("</tr>");
			print("<tr>");
			print("<td>");
			print("</td>");
			print("<td>");
			print("<table style=\"font-size: small;color: #656565;\">");
			print("<tr>");
			print("<td>");
			print("5' end confirmed by presence of splice leader (SL) : ");
			if(preg_match("/SL/",$nameEstClusterGroup))
			{
				print("Yes");
			}
			else
			{
				print("No");
			}
			print("</td>");
			print("</tr>");
			print("<tr>");
			print("<td>");
			print("Comparison to 5' end of best matching EST cluster :");
			print("</td>");
			print("</tr>");
			print("<tr>");
			print("<td>");
			print("<span class='tabulation'>$definitionEstClusterGroup<a href=\"EstCluster_alignment.php?transcript_id=$id&cluster_id=$idEstCluster\" target=\"_blank\"> view alignment</a></span>");
			print("</td>");
			print("</tr>");
			print("<tr>");
			print("<td>");
			print("<span class='tabulation'>EST cluster full ORF confidence : $scoreEstCluster%</span>");
			print("</td>");
			print("</tr>");
			print("<tr>");
			print("<td>");
			print("<span class='tabulation'><a href=\"EstCluster_sequence.php?cluster_id=$idEstCluster\" target=\"_blank\">View EST cluster consensus sequence</a></span>");
			print("</td>");
			print("</tr>");
			print("<tr>");
			print("<td>");
			print("<span class='tabulation'><a href=\"\">Go to EST cluster page</a></span>");
			print("<br />");
			print("<br />");
			print("</td>");
			print("</tr>");
			print("</table>");
		}
		print("</td></tr>");

	
	
/* Gestion du modele de gene */

$requete0="select \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\"=(
SELECT \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$name' and \"TYPE\"='gene')";
$stmt0=pg_query($c,$requete0);
print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Aniseed Gene model: </b></font></td>";
if(pg_num_rows($stmt0)==0)
{
	print "<td><font color=\"#656565\" size=\"-1\"><i>No match</i></font></td></tr>";
}
else
{
	//special display for first cluster
	$first = 0;
	while($row0=pg_fetch_array($stmt0))
	{
		$aniseed_gm=str_replace("cluster","aniseedV3_",$row0["GENE_CLUSTER_ID"]);
		if($first==0)
		{
			print "<td><font 	color=\"#656565\" size=\"-1\"><a href=\"gene-card.php?clusterid=".$row0["GENE_CLUSTER_ID"]."\">$aniseed_gm</a></font></td></tr>";
			$first = 1;
		}
		else
		{
			print "<td></td><td><font 	color=\"#656565\" size=\"-1\"><a href=\"gene-card.php?clusterid=".$row0["GENE_CLUSTER_ID"]."\">$aniseed_gm</a></font></td></tr>";
		}
	}
}	



/* ------------------------- */


		print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Description: </b></font></td><td><font color=\"#656565\" size=\"-1\">".$row["COMMENTS"]."</font></td></tr>";
		print "<tr valign=\"top\" align=\"left\"><td width=\"15%\"><font color=\"#656565\" size=\"-1\"><b>Species: </b></font></td><td><font color=\"#656565\" size=\"-1\">".$row["SPECIES"]."</font></td></tr>";
        print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Scaffold: </b></font></td><td><font color=\"#656565\" size=\"-1\">".$row["SCAFFOLD_ID"]."</font></td></tr>";
		print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Chr. number: </b></font></td><td><font color=\"#656565\" size=\"-1\">".$row["CHR_NUM"]."</font></td></tr>";
		print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Strand: </b></font></td><td><font color=\"#656565\" size=\"-1\">".$row["STRAND"]."</font></td></tr>";
/*
if ($row["NAME"]{0}=="H") //Halocynthia gene model
{
print "ici";
		print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Corresponding cluster: </b></font></td><td>";
		print "<a href=\"ESTcluster.php?name=".$id."\"><font color=\"#000000\" size=\"-1\">".$id."</font></a></td></tr>";

}	
else if ($row["NAME"]{0}=="c") //JGI
{
		print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Corresponding cluster: </b></font></td><td>";
		print "<a href=\"ESTcluster.php?name=".$id."\"><font color=\"#000000\" size=\"-1\">".$id."</font></a></td></tr>";

}
else
{		
if ($row["NAME"]{0}=="K") //KYOTO
{
//AJOUT POUR L'ABSTRACT de KYOTO

$qu="SELECT \"NAME\" from \"MOL_ENTITY\" where \"MOL_ID\"='$id'";
$st=pg_query($c,$qu);
$ro=pg_fetch_array($st);

$temp=explode(".",$ro["NAME"]);
$abstract=$temp[0].".".$temp[1].".".$temp[2];
$qu="SELECT \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$abstract' and \"TYPE\"='abstract'";
$st=pg_query($c,$qu);
$ro=pg_fetch_array($st);

		print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Corresponding cluster: </b></font></td><td>";
		print "<a href=\"ESTcluster.php?name=".$ro["MOL_ID"]."\"><font color=\"#000000\" size=\"-1\">".$ro["MOL_ID"]."</font></a></td></tr>";

//FIN AJOUT
}

else
	{
	//POUR ENSEMBL

	$qu="SELECT \"ABSTRACT_ID\" from \"TRANSCRIPT\" where \"TRANSCRIPT_ID\"='$id'";
	$st=pg_query($c,$qu);
	$ro=pg_fetch_array($st);

	print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Corresponding cluster: </b></font></td><td>";
	print "<a href=\"ESTcluster.php?name=".$ro["ABSTRACT_ID"]."\"><font color=\"#000000\" size=\"-1\">".$ro["ABSTRACT_ID"]."</font></a></td></tr>";
	}

}
*/

/*
//// ON A BASCULE CETTE SECTION SUR LA GENE CARD !!!


		print "<tr valign=\"top\" align=\"left\"><td><font color=\"#656565\" size=\"-1\"><b>Cis-regulatory regions: </b></font></td><td>";
	    $requete2="select a.\"NAME\",a.\"PROMOTER_ID\" from \"GENE_REGULATION\" b, \"PROMOTER\" a where a.\"PROMOTER_ID\"=b.\"PROMOTER_ID\" and b.\"GENE_ID\"=$id and a.\"PRIVATE\"='n' and a.\"CHECKED\"='y' and a.\"BASE_REG_ID\"=a.\"PROMOTER_ID\";";
		$stmt2 = pg_query($c,$requete2);
	if (pg_num_rows($stmt2)==0) print "<font color=\"#656565\" size=\"-1\">No cis regulatory region available</font></td>";	
        while($row2=pg_fetch_array($stmt2)){
				//print "<a href=\"molecule-promoter.php?name=".$row2["NAME"]."\"><font color=\"#000000\" size=\"-1\">".$row2["NAME"]."</font></a>&nbsp;&nbsp;&nbsp;&nbsp;";
			print "<a href=\"reg-region-view.php?id=".$row2["PROMOTER_ID"]."\"><font color=\"#000000\" size=\"-1\">".$row2["NAME"]."</font></a>&nbsp;&nbsp;&nbsp;&nbsp;";
		}
		print '</td></tr>';
*/		
		print "</table>";






print "<br><u><font color=\"#456898\" size=\"3\"><b>External links</b></font></u><br>";

				/* APPEL AU BROWSER ICI  */
		if($row["SPECIES"] == "Ciona intestinalis"){

if ($row["NAME"]{0}=="c")
{
print '<br><font color="#656565" size="2"><b>Go to the <a target="_BLANK" href="http://crfb.univ-mrs.fr/ciona-bin/gbrowse/intestinalis?name='.$name.'">ANISEED genome  browser</a><br>';
print "<br><a target=\"blank\" href=\"http://genome.jgi-psf.org/cgi-bin/dispGeneModel.v4?db=ciona4&id=".eregi_replace( "ci0100","",$name)."\"> <img src=\"pictures/jgi_logo.jpg\" width=\"50\" align=\"middle\" border=\"0\"> Get the JGI file</a>";
print "<br><a target=\"blank\" href=\"http://hoya.zool.kyoto-u.ac.jp/cgi-bin/gbrowse/ci/?name=".$name."\"> <img src=\"pictures/mini-ghost.jpg\" align=\"middle\" border=\"0\"> Go to the Ghost Genome Browser</a>";
}
else if ($row["NAME"]{0}=="E")
{
print '<br><font color="#656565" size="2"><b>Go to the<a target="_BLANK" href="http://crfb.univ-mrs.fr/ciona-bin/gbrowse/intestinalis?name='.$name.'">ANISEED genome  browser</a><br>';
print "<br><a target=\"blank\" href=\"http://www.ensembl.org/Ciona_intestinalis/transview?db=core;transcript=".$name."\"> <img src=\"pictures/e-bang.jpg\" align=\"middle\" border=\"0\"> Get the Ensembl file</a>";
/*print "<br><a target=\"blank\" href=\"http://hoya.zool.kyoto-u.ac.jp/cgi-bin/gbrowse/ci/?name=".$name."\"> <img src=\"pictures/mini-ghost.jpg\" align=\"middle\" border=\"0\"> Go to the Ghost Genome Browser</a>";*/
}
else if ($row["NAME"]{0}=="K")
{
print '<br><font color="#656565" size="2"><b>Go to the <a target="_BLANK" href="http://crfb.univ-mrs.fr/ciona-bin/gbrowse/intestinalis?name='.$name.'">ANISEED genome  browser </a><br>';
print '<br><font color="#656565" size="2"><b>Go to the <a target="_BLANK" href="http://hoya.zool.kyoto-u.ac.jp/cgi-bin/gbrowse/ci/?name='.$name.'">GHOST genome  browser</a><br>';
print "<br><a target=\"blank\" href=\"http://hoya.zool.kyoto-u.ac.jp/cgi-bin/fordetailg2005.cgi?name=".$name."&class=mRNA\"> <img src=\"pictures/mini-ghost.jpg\" align=\"middle\" border=\"0\"> Get the KyotoGrail File</a>";
}

print '</b></font>';

//TEST
/*
print "<br>";
print "<iframe src=\"http://crfb.univ-mrs.fr/ciona-bin/gbrowse_img/intestinalis?name=$name;embed=1;type=JGI_transcripts+kyotoGrail+EnsemblJGI2+CNSvsCDS+Conservation_profile\" width=\"100%\" height=\"250\"></iframe>";*/
/*
?>
<FRAMESET COLS="50%,*" FRAMEBORDER=yes BORDER=1 SCROLLING=no> 
<FRAME SRC="http://www.google.fr" SCROLLING=yes name="left"> 
<FRAME SRC="http://www.yahoo.fr" SCROLLING=yes NAME="right"> 

  <noframes>
    <body>
     Sorry! You need a frames-browser to view this site.
    </body>
  </noframes>

</FRAMESET> 
<?
*/
print "<br>";
print "<br>";



///////////

	        //print "<br><a target=\"blank\" href=\"http://hgwdev.cse.ucsc.edu/cgi-bin/hgc?g=jgiGene&i=".$name."\"> <img src=\"pictures/UCSC.jpg\" align=\"middle\" border=\"0\"> Get the UCSC file</a>";
		}
		/*print "<br><br><center><a href=\"molecule-phylogeny.php?name=$name&id=$id\"><img border=\"0\" src=\"pictures/button-phylogeny.jpg\"></a>   &nbsp;&nbsp;&nbsp;&nbsp;  <a href=\"molecule-sequence.php?id=$id\"><img border=\"0\" src=\"pictures/button-sequence.jpg\"></a> 
 &nbsp;&nbsp;&nbsp;&nbsp;  <a href=\"insitu-result.php?target=$name&MOLtype=2&Order=DEV_STAGE_ID\"><img border=\"0\" src=\"pictures/button-getPics.jpg\"></a>  &nbsp;&nbsp;&nbsp;&nbsp;  <a href=\"est-expression.php?name=$id&species=$species\"><img src=\"pictures/button-library.jpg\" border=\"0\"></a></center>";*/
		
		
///////////////////////////////////////////INTERPRO////////////////////////////////////////////
		$requete="select \"LENGTH\" from \"SEQUENCE\" where \"MOL_ID\"=$id";
		$stmt = pg_query($c,$requete);
		
		$row=pg_fetch_array($stmt);
		
		$length=$row["LENGTH"];


		$requete="select A.*, B.\"NAME\" from \"IP_DESCRIPTION\" A, \"INTERPRO\" B where A.\"MOL_ID\"='$id' and A.\"IP_ID\"=B.\"IP_ID\"";
	    $stmt = pg_query($c,$requete);
		
        $count=0;
		while($row=pg_fetch_array($stmt)){
		
		    $tab[$row["METHOD"]][$row["IP_ID"]]["location"]=$row["LOCATION"];
		    $tab[$row["METHOD"]][$row["IP_ID"]]["IPID"]=$row["IP_ID"];
			$tab[$row["METHOD"]][$row["IP_ID"]]["DBID"]=$row["DB_ID"];
			$tabname[$row["IP_ID"]]=$row["NAME"];
			
			++$count;
		}
		
		if($count>0){
		
			print "<br><br><u><font color=\"#456898\" size=\"3\"><b>InterproScan</b></u></font><br><br>";
			print "<center><table width=\"99%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
			
			foreach ($tab as $method => $dbid){			
			    print "<tr><td height=35  align=\"right\"><font color=\"#656565\" size=\"-1\"><b>".$method."</b></font>&nbsp;</td><td align=\"left\"><img src=\"picture-motifs.php?size=".($length/3)."&data=".addslashes(urlencode(serialize($tab[$method])))."\" border=0 USEMAP=#img_map ISMAP></td></tr>";
			    $a=0;
				foreach ($dbid as  $data){
				    
				    print "<map name=\"img_map$a\">";
				    print "</map>";
					
					print "<tr><td align=\"right\" valign=\"top\">&nbsp;-</td><td><font color=\"#656565\" size=\"-1\"><b>".++$a.".</b></font><font color=\"#656565\" size=\"-1\">".$tabname[$data["IPID"]]." </font>(<a target=\"_BLANK\" href=\"http://www.ebi.ac.uk/interpro/IEntry?ac=".$data["IPID"]."\"><font color=\"#000000\" size=\"-1\">".$data["IPID"]."</font></a>)";
				                                                                                                   
				    if($method=="HMMSmart")
					    print " - <a target=\"_BLANK\" href=\"http://smart.embl-heidelberg.de/smart/do_annotation.pl?BLAST=DUMMY&DOMAIN=&ACC=".$data["DBID"]."\"><font color=\"#656565\" size=\"-1\">".$data["DBID"]."</font></a>";
					else if($method=="BlastProDom")
					    print " - <a target=\"_BLANK\" href=\"http://prodes.toulouse.inra.fr/prodom/current/cgi-bin/request.pl?question=DBEN&query=".$data["DBID"]."\"><font color=\"#656565\" size=\"-1\">".$data["DBID"]."</font></a>";
					else if($method=="ProfileScan")
					    print " - <a target=\"_BLANK\" href=\"http://au.expasy.org/cgi-bin/prosite-search-ac?".$data["DBID"]."\"><font color=\"#656565\" size=\"-1\">".$data["DBID"]."</font></a>";
					else
					    print " - <font color=\"#656565\" size=\"-1\">".$data["DBID"]."</font>";
						
					print "<br><font size=\"-2\">Position/Score: </font><font size=\"-1\">".$data["location"]."</font>";
						
				    print "</td></tr>";
				}
			}
			
			print "</TABLE></center>";
		
		}
		//print "<br><img src=\"pictures/superFamilly.gif\" align=\"middle\"> <a target=\"blank\" href=\"http://supfam.mrc-lmb.cam.ac.uk/SUPERFAMILY/cgi-bin/gene.cgi?genome=ci&seqid=$name\">Domain prediction from Superfamilly</a><br>";
/////////////////////////////////////////////////EXPRESSION PROFILE/////////////////////////////////////////////////


$mol=$name;
function torevFate($fate)
{
if (trim($fate)=="C") return "CEN";
if (trim($fate)=="EN") return "endodermal strand";
if (trim($fate)=="EP") return "epidermis";
if (trim($fate)=="H") return "head endoderm";
if (trim($fate)=="ME") return "mesenchyme";
if (trim($fate)=="MU") return "muscle";
if (trim($fate)=="NE") return "neck";
if (trim($fate)=="NS") return "nervous system";
if (trim($fate)=="NP") return "neurohypophysis primordium";
if (trim($fate)=="NO") return "notochord";
if (trim($fate)=="P") return "palps";
if (trim($fate)=="S") return "sensory vesicle";
if (trim($fate)=="T") return "tail nerve cord";
if (trim($fate)=="TEN") return "TEN";
if (trim($fate)=="TLC") return "TLC";
if (trim($fate)=="TVC") return "TVC";
if (trim($fate)=="VI") return "visceral ganglion";
//return "V"; //On a une expression mais le FATE n'est pas defini
}
/*
//print "<center>";
print "<br><h2>Spatio temporal expression profile</h2>";

$molGLOB=$mol;

//Recuperation des destins presents dans la base de donnees
$fate=(array) null;
$requete="SELECT \"KEYWORDS\" from \"FATE_KW\"";
$stmt=pg_query($c,$requete);
$k=0;
while ($row=pg_fetch_array($stmt))
{
//$fate[count($fate)]=$row["KEYWORDS"];
$fate[$row["KEYWORDS"]]=$k++;
}

//Recuperation des stades de developpement
$dev=(array) null;
$requete="SELECT \"DEV_STAGE_ID\" from \"DEV_STAGE\" where \"SPECIES\"='Ciona intestinalis' order by \"DEV_PERCENT\"";
$stmt=pg_query($c,$requete);
$k=0;
while ($row=pg_fetch_array($stmt))
{
//$dev[count($dev)]=$row["DEV_STAGE_ID"];
$dev[$row["DEV_STAGE_ID"]]=$k++;
}


//Initialisation de la table
foreach($fate as $key => $val)
{
foreach ($dev as $key2 => $val2)
	{
	$table[$key][$key2]="0";
	}
}



//Recuperation du profil d'expression
$prof=(array) null;
$requete="SELECT A.* from \"ISH_CLUSTERING\" A,\"DEV_STAGE\" B where A.\"MOL_ID\"=(
select \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$mol'
) order by A.\"DEV_STAGE_ID\"";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0) {print "<br><center>No data for this gene</center><br>";}
while ($row=pg_fetch_array($stmt))
{
$dev=$row["DEV_STAGE_ID"];
$spot=$row["SPOT"];

$tmp=explode("@",$spot);
//print $spot;
$bool=false;
for ($i=0;$i<count($tmp);$i++)
{
if (trim($tmp[$i])=="R") foreach ($table as $key => $val) $table[$key][$dev]="R";
else if (trim($tmp[$i])=="V") foreach ($table as $key => $val) $table[$key][$dev]="V";
else if (trim($tmp[$i])=="U") foreach ($table as $key => $val) $table[$key][$dev]="U";
else  {
	if (!$bool) {
	foreach ($table as $key => $val) $table[$key][$dev]="RR";
	$bool=true;
	}

	$table[torevFate(trim($tmp[$i]))][$dev]=trim($tmp[$i]);
}

}

}






//display


print "<table id=\"bordT\">";
print "<tr>";
print "<tr>";
print "<td >&nbsp;</td>";
print "<td id=\"bordcleav\"><small><b>Egg</b></small></td>";
print "<td id=\"bordcleav\"><small><b>Zyg</b></small></td>";
print "<td id=\"bordcleav\"><small><b>2-c</b></small></td>";
print "<td id=\"bordcleav\"><small><b>4-c</b></small></td>";
print "<td id=\"bordcleav\"><small><b>8-c</b></small></td>";
print "<td id=\"bordcleav\"><small><b>16c</b></small></td>";
print "<td id=\"bordcleav\"><small><b>24c</b></small></td>";
print "<td id=\"bordcleav\"><small><b>e32</b></small></td>";
print "<td id=\"bordcleav\"><small><b>l32</b></small></td>";
print "<td id=\"bordcleav\"><small><b>44c</b></small></td>";
print "<td id=\"bordcleav\"><small><b>64c</b></small></td>";
print "<td id=\"bordcleav\"><small><b>76c</b></small></td>";
print "<td id=\"bordgast\"><small><b>eGa</b></small></td>";
print "<td id=\"bordgast\"><small><b>mGa</b></small></td>";
print "<td id=\"bordgast\"><small><b>lGa</b></small></td>";
print "<td id=\"bordneur\"><small><b>eNe</b></small></td>";
print "<td id=\"bordneur\"><small><b>mNe</b></small></td>";
print "<td id=\"bordneur\"><small><b>lNe</b></small></td>";
print "<td id=\"bordtail\"><small><b>iTb</b></small></td>";
print "<td id=\"bordtail\"><small><b>eTb</b></small></td>";
print "<td id=\"bordtail\"><small><b>mTb</b></small></td>";
print "<td id=\"bordtail\"><small><b>lTb</b></small></td>";
print "<td id=\"bordlarva\"><small><b>Tad</b></small></td>";
print "<td id=\"bordadult\"><small><b>Y.A</b></small></td>";

print "</tr>";
foreach ($table as $key => $val)
{
if ($key=="endodermal strand") print "<td><small><b><div id=\"cadreendo\">$key</div></b></small></td>";
if ($key=="head endoderm") print "<td><small><b><div id=\"cadreendo\">$key</div></b></small></td>";
if ($key=="mesenchyme") print "<td><small><b><div id=\"cadremeso\">$key</div></b></small></td>";
if ($key=="muscle") print "<td><small><b><div id=\"cadremeso\">$key</div></b></small></td>";
if ($key=="notochord") print "<td><small><b><div id=\"cadremeso\">$key</div></b></small></td>";
if ($key=="TLC") print "<td><small><b><div id=\"cadremeso\">$key</div></b></small></td>";
if ($key=="TVC") print "<td><small><b><div id=\"cadremeso\">$key</div></b></small></td>";
if ($key=="CEN") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="neck") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="nervous system") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="neurohypophysis primordium") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="palps") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="sensory vesicle") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="tail nerve cord") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="TEN") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="visceral ganglion") print "<td><small><b><div id=\"cadrecton\">$key</div></b></small></td>";
if ($key=="epidermis") print "<td><small><b><div id=\"cadrectoe\">$key</div></b></small></td>";
//print "<td><small><b>$key</b></small></td>";
//print "<small><b>$key</b></small>";
	foreach ($table[$key] as $key2 => $val2)
		{
		print "<td align=\"center\">";
		if ($table[$key][$key2]=="0") print '<img title="No data" src="gray.gif">';
		else if ($table[$key][$key2]=="R") print '<img title="No expression" src="no.gif">';
		else if ($table[$key][$key2]=="RR") print '<img title="No expression in this territory" src="no.gif">';
		else if ($table[$key][$key2]=="U") print '<img title="Expressed in whole embryo" src="yes.gif">';
		else print '<img title="Expressed in this territory" src="yes.gif">';
		print "</td>";
		}
//print "<br>";
print "</tr>";
}
print "</table>";

*/





//////////////////////////// GENE EXPRESSION CARD //////////////////////////////////////////////////////
/*	print "<br><br><u><font color=\"#456898\" size=\"3\"><b>Transcript Expression Card</b></font></u><br><br>";

?>

<?

//$gene="ci0100131814";
$gene=$name;
//$gene="ci0100133709";
//$gene="ci0100136326"; //gata
//$gene="ci0100140048"; //ets

$anat=(array) null;

if ($gene{0}=="c") //// JGI gene model
{
$requete="
select anat.\"ANAT_ID\",dev.\"NAME\" from \"ANAT_ENTITY\" anat, \"DEV_STAGE\" dev where anat.\"ANAT_ID\" in (
select \"REGION_ID\" from \"TARGET\" where \"TARGET_ID\" in (
select \"MOL_ID\" from \"MOL_ENTITY\" where \"MOL_ID\" in (
select \"CLONE_ID\" from \"CLONE\" where \"CLONE_NAME\" in (
select \"CLONE_NAME\" from \"CLONE_SEQ\" where \"ANISEED_CLUSTER_ID\"=(select \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$gene')
)
UNION
select \"CLONE_SEQ_ID\" from \"CLONE_SEQ\" where \"ANISEED_CLUSTER_ID\"=(select \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$gene')
UNION
SELECT \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$gene'
)
) and \"REGION_ID\" is not null and \"IN_SITU_ID\" in (
select \"IN_SITU_ID\" from \"IN_SITU\" where \"WILD_TYPE\"='y' and \"CHECKED\"='y' and \"PRIVATE\"='n'
)
) and anat.\"SPECIES\"='Ciona intestinalis' and anat.\"DEV_STAGE_ID\"=dev.\"DEV_STAGE_ID\" order by dev.\"DEV_PERCENT\"
";
}


if ($gene{0}=="K") //// KYOTOGRAIL
{

$tkyo=explode(".",$gene);
$kabstract=$tkyo[0].".".$tkyo[1].".".$tkyo[2];

$requete="
select anat.\"ANAT_ID\",dev.\"NAME\" from \"ANAT_ENTITY\" anat, \"DEV_STAGE\" dev where anat.\"ANAT_ID\" in (
select \"REGION_ID\" from \"TARGET\" where \"TARGET_ID\" in (
select \"MOL_ID\" from \"MOL_ENTITY\" where \"MOL_ID\" in (
select \"CLONE_ID\" from \"CLONE\" where \"CLONE_NAME\" in (
select \"CLONE_NAME\" from \"CLONE_SEQ\" where \"ANISEED_KYOTO_CLUSTER_ID\"=(select \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$kabstract' and \"TYPE\"='abstract')
)
UNION
select \"CLONE_SEQ_ID\" from \"CLONE_SEQ\" where \"ANISEED_KYOTO_CLUSTER_ID\"=(select \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$kabstract' and \"TYPE\"='abstract')
UNION
SELECT \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$gene'
)
) and \"REGION_ID\" is not null and \"IN_SITU_ID\" in (
select \"IN_SITU_ID\" from \"IN_SITU\" where \"WILD_TYPE\"='y' and \"CHECKED\"='y' and \"PRIVATE\"='n'
)
) and anat.\"SPECIES\"='Ciona intestinalis' and anat.\"DEV_STAGE_ID\"=dev.\"DEV_STAGE_ID\" order by dev.\"DEV_PERCENT\"
";

}


//

if ($gene{0}=="E") //// ENSEMBL
{
$requete="
select anat.\"ANAT_ID\",dev.\"NAME\" from \"ANAT_ENTITY\" anat, \"DEV_STAGE\" dev where anat.\"ANAT_ID\" in (
select \"REGION_ID\" from \"TARGET\" where \"TARGET_ID\" in (
select \"MOL_ID\" from \"MOL_ENTITY\" where \"MOL_ID\" in (
select \"CLONE_ID\" from \"CLONE\" where \"CLONE_NAME\" in (
select \"CLONE_NAME\" from \"CLONE_SEQ\" where \"ANISEED_ENSEMBL_CLUSTER_ID\"=(select \"ABSTRACT_ID\" from \"TRANSCRIPT\" where \"TRANSCRIPT_ID\"=(select \"GENE_ID\" from \"GENE\" where \"NAME\"='$gene'))
)
UNION
select \"CLONE_SEQ_ID\" from \"CLONE_SEQ\" where \"ANISEED_ENSEMBL_CLUSTER_ID\"=(select \"ABSTRACT_ID\" from \"TRANSCRIPT\" where \"TRANSCRIPT_ID\"=(select \"GENE_ID\" from \"GENE\" where \"NAME\"='$gene'))
UNION
SELECT \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\"='$gene'
)
) and \"REGION_ID\" is not null and \"IN_SITU_ID\" in (
select \"IN_SITU_ID\" from \"IN_SITU\" where \"WILD_TYPE\"='y' and \"CHECKED\"='y' and \"PRIVATE\"='n'
)
) and anat.\"SPECIES\"='Ciona intestinalis' and anat.\"DEV_STAGE_ID\"=dev.\"DEV_STAGE_ID\" order by dev.\"DEV_PERCENT\"
";
}

$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{
//print $row["NAME"]." ".$row["DEV_STAGE_ID"]."<br>";
//$anat[$row["ANAT_ID"]."@".$row["DEV_STAGE_ID"]]++;


////OBLIGER DE FAIRE UNE DETECTION DES NOEXPRESSION
$r="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='".$row["ANAT_ID"]."'";
$s=pg_query($c,$r);
$ro=pg_fetch_array($s);

if ($ro["NAME"]=="No expression") $anat[$row["NAME"]].="NOEXP@";
else if ($ro["NAME"]=="Whole embryo") $anat[$row["NAME"]].="WHOLE@";
else $anat[$row["NAME"]].=$row["ANAT_ID"]."@";

}

 //print_r($anat);


$anat2=(array) null;

foreach ($anat as $key => $val)
{

$tmp=explode("@",$val);

if ($tmp[0]=="NOEXP")
	{
	$anat2[$key]="NOEXP";
	}
else 
if ($tmp[0]=="WHOLE")
	{
	$anat2[$key]="WHOLE";
	}
else
	{
for ($i=0;$i<count($tmp)-1;$i++)
	{
	$requete="SELECT fate.\"KEYWORDS\",anat.\"NAME\" from \"FATE\" fate,\"ANAT_ENTITY\" anat where fate.\"ANAT_ID\"='".trim($tmp[$i])."' and anat.\"ANAT_ID\"=fate.\"ANAT_ID\"";
	$stmt=pg_query($c,$requete);
	while ($row=pg_fetch_array($stmt))
	{
	//
	//if ($row["NAME"]=="Whole embryo") {$anat2[$key]="WHOLE";break;}
	
	if (strlen($row["KEYWORDS"])==0) continue;

	$anat2[$key].=$row["KEYWORDS"]."@";
	}

	}
	}

}
// print "<hr>";

// print_r($anat2);

// print "<hr>";
///////////
//LE TABLEAU ANAT2 contient les correspondances DEVSTAGE<=>FATE pour le gene $gene
///////////
$anat=$anat2;

if (count($anat)!=0)
{



$requete="SELECT \"NAME\" from \"DEV_STAGE\" where \"SPECIES\"='Ciona intestinalis' order by \"DEV_PERCENT\"";
$stmt=pg_query($c,$requete);



print "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
print "<tr>
<td>&nbsp;</td>
<td id=\"header0\" align=\"center\" valign=\"top\"><img src=\"es.gif\"></td>

<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"he.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"me.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"mu.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"noto.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"tlc.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"tvc.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"cen.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"ne.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"ns.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"np.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"palps.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"sv.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"tnc.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"ten.gif\"></td>
<td id=\"header0\"  align=\"center\" valign=\"top\"><img src=\"vg.gif\"></td>
<td id=\"headerlast\"  align=\"center\" valign=\"top\"><img src=\"ep.gif\"></td>




</tr>";

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

$stade=$row["NAME"];
$tabfate=$anat[$row["NAME"]];
print "<tr>";

// print $row["NAME"]." => ".$anat[$row["NAME"]]."<br>";

$tmp=explode("@",$tabfate);

/////ENCHAINEMENT DES FATE POUR L'AFFICHAGE
if (trim($tmp[0])=="WHOLE") print "
<td id=\"casefirst\">$stade</td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"case\"><img src='yes2.gif'></td>
<td id=\"caselast\"><img src='yes2.gif'></td>";
else if (trim($tmp[0])=="NOEXP") print "
<td id=\"casefirst\">$stade</td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"case\"><img src='no2.gif'></td>
<td id=\"caselast\"><img src='no2.gif'></td>";
else if (count($tmp)-1==0) print "
<td id=\"casefirst\">$stade</td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"case\"><img src='gray2.gif'></td>
<td id=\"caselast\"><img src='gray2.gif'></td>";
else 
	{
	//print $stade."\t";print_r($tmp);print "<br>";
	print "<td id=\"casefirst\">".$stade."</td>";
	if (in_array("endodermal strand",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("head endoderm",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("mesenchyme",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("muscle",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("notochord",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("TLC",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("TVC",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("CEN",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("neck",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("nervous system",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("neurohypophysis primordium",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("palps",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("sensory vesicle",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("tail nerve cord",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("TEN",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("visceral ganglion",$tmp)) print "<td id=\"case\"><img src='yes2.gif'></td>"; else print "<td id=\"case\"><img src='no2.gif'></td>";
	if (in_array("epidermis",$tmp)) print "<td id=\"caselast\"><img src='yes2.gif'></td>"; else print "<td id=\"caselast\"><img src='no2.gif'></td>";

	}

print "</tr>";
}


print "<tr>
<td>&nbsp;</td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=endodermal%20strand\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=head%20endoderm\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=mesenchyme\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=muscle\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=notochord\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=TLC\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=TVC\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=CEN\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=neck\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=nervous%20system\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=neurohypophysis%20primordium\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=palps\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=sensory%20vesicle\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=tail nerve cord\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=TEN\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"case\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=visceral%20ganglion\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>
<td id=\"caselast\" align=\"center\"><a href=\"show-curves.php?name=$name&fate=epidermis\" target=\"_blank\"><font size=\"-5\"><b>Show</b></font></a></td>

</tr>";


print "</table>
<br>
<img src=\"no2.gif\"> No expression in this territory &nbsp;&nbsp;<img src=\"yes2.gif\"> Expression in this territory &nbsp;&nbsp; <img src=\"gray2.gif\"> No data<br>
</center>";


//print "<br><br>";
//print "<center><font color=\"#D64242\" size=\"2\"><b>Blast this expression profile card against the database with STEP-BLAST (beta)</center></b></font><br>";
//print "<center><a href=\"stepblast2.php?mol1=$name\"><b>STEP-BLAST</b></a></center>";


}

else
{
   print "<br></center><center><font color=\"#D64242\" size=\"3\"><b>No Data</b></font></center><br>";

}



*/
/////////////////////////////////////////////////ORTHOLOG/////////////////////////////////////////////////
	print "<br><br><u><font color=\"#456898\" size=\"3\"><b>Ortholog prediction (In paranoid applied to
mouse, human and drosophila)</b></font></u><br><br>";	
	   
	 $requete="select * from \"PHYLOGENY\" where \"MOL_ID\"=$id and \"ORTHOLOG\" is not NULL order by \"SPECIES\", \"ORTHOLOG\", \"SCORE2\" desc";
    	$stmt = pg_query($c,$requete);

if (pg_num_rows($stmt)>0)
	{
	

        print "<center><table width=\"99%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	    print "<tr align=\"center\" valign=\"middle\"><td><font color=\"#456898\" size=\"2\"><b>Ortholog name*</font></td><td><font color=\"#456898\" size=\"2\"><b>ID</b></font></td><td><font color=\"#456898\" size=\"2\"><b>Score</b></font></td><td width=\"30%\"><font color=\"#456898\" size=\"2\"><b>Protein familly*</b></font></td><td><font color=\"#456898\" size=\"2\"><b>Species</b></font></td></tr>";
	}

	$count=0;
    	while($row=pg_fetch_array($stmt)){
		    ++$count;
			if($row["DB"]=="ensembl"){
			    if($row["SPECIES"]=='Drosophila melanogaster')
		            print "<tr align=\"center\" valign=\"middle\"><td><a target=\"blank\" href=\"http://www.ensembl.org/Drosophila_melanogaster/protview?peptide=".$row["ID"]."\"><font color=\"#000000\" size=\"-1\">".$row["ORTHOLOG"]."</font></a></td><td><font color=\"#656565\" size=\"-1\">".$row["ID"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SCORE2"]."%</font></td><td><font color=\"#656565\" size=\"-1\">".$row["FAMILLY"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SPECIES"]."</font></td></tr>";
			    else if($row["SPECIES"]=='Homo sapiens')
				    print "<tr align=\"center\" valign=\"middle\"><td><a target=\"blank\" href=\"http://www.ensembl.org/Homo_sapiens/protview?peptide=".$row["ID"]."\"><font color=\"#000000\" size=\"-1\">".$row["ORTHOLOG"]."</font></a></td><td><font color=\"#656565\" size=\"-1\">".$row["ID"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SCORE2"]."%</font></td><td><font color=\"#656565\" size=\"-1\">".$row["FAMILLY"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SPECIES"]."</font></td></tr>";
			    else if($row["SPECIES"]=='Mus musculus')
				    print "<tr align=\"center\" valign=\"middle\"><td><a target=\"blank\" href=\"http://www.ensembl.org/Mus_musculus/protview?peptide=".$row["ID"]."\"><font color=\"#000000\" size=\"-1\">".$row["ORTHOLOG"]."</font></a></td><td><font color=\"#656565\" size=\"-1\">".$row["ID"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SCORE2"]."%</font></td><td><font color=\"#656565\" size=\"-1\">".$row["FAMILLY"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SPECIES"]."</font></td></tr>";
			    else if($row["SPECIES"]=='Danio rerio')
				    print "<tr align=\"center\" valign=\"middle\"><td><a target=\"blank\" href=\"http://www.ensembl.org/Danio_rerio/protview?peptide=".$row["ID"]."\"><font color=\"#000000\" size=\"-1\">".$row["ORTHOLOG"]."</font></a></td><td><font color=\"#656565\" size=\"-1\">".$row["ID"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SCORE2"]."%</font></td><td><font color=\"#656565\" size=\"-1\">".$row["FAMILLY"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SPECIES"]."</font></td></tr>";			    
			    else
				    print "<tr align=\"center\" valign=\"middle\"><td><font color=\"#000000\" size=\"-1\">".$row["ORTHOLOG"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["ID"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SCORE2"]."%</font></td><td><font color=\"#656565\" size=\"-1\">".$row["FAMILLY"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SPECIES"]."</font></td></tr>";
			    print '<tr valign="top"><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td></tr>';
			}else
			    print "<tr valign=\"top\" align=\"center\"><td><font color=\"#000000\" size=\"-1\">".$row["ORTHOLOG"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["ID"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SCORE2"]."%</font></td><td><font color=\"#656565\" size=\"-1\">".$row["FAMILLY"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SPECIES"]."</font></td></tr>";
		}
		if($count==0){
 		    print "</center><center><font color=\"#D64242\" size=\"3\"><b>No match</b></font></center>";
		}else{
		    print "</table></center>";
			print "*annotations from <a target=\"blank\" href=\"http://www.ensembl.org/\">Ensembl</a>";
		}
	
	
//////////////////////////////////////////Best BLAST hits///////////////////////////////////////////

		print "<br><br><u><font color=\"#456898\" size=\"3\"><b>Best blast hits in Swissprot</b></u></font></strong><br><br>";

        $requete="select \"SCORE\", \"PROTEIN\", \"EVALUE\", \"BLOCKS\", \"DESCRIPTION\", \"ID\" from \"BLAST\" where \"MOL_ID\"=$id and \"DESCRIPTION\" is not NULL order by \"SCORE\" DESC";        	
		$stmt = pg_query($c,$requete);

if (pg_num_rows($stmt))
{
        print "<center><table width=\"99%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	    print "<tr align=\"center\" valign=\"middle\"><td><font color=\"#456898\" size=\"2\"><b>Protein name</b></font></td><td><font color=\"#456898\" size=\"2\"><b>ID%</b></font></td><td><font color=\"#456898\" size=\"2\"><b>Score</b></font></td><td><font color=\"#456898\" size=\"2\"><b>Evalue</b></font></td><td><font color=\"#456898\" size=\"2\"><b>HSP</b></font></td><td><font color=\"#456898\" size=\"2\"><b>Description</b></font></td></tr>";

}


		$count=0;
    	while($row=pg_fetch_array($stmt)){
		    ++$count;
			print "<tr align=\"center\"><td><a target=\"_BLANK\" href=\"http://us.expasy.org/cgi-bin/niceprot.pl?".$row["PROTEIN"]."\"><font color=\"#000000\" size=\"-1\">".$row["PROTEIN"]."</font></a></td><td><font color=\"#656565\" size=\"-1\">".$row["ID"]."%</font></td><td><font color=\"#656565\" size=\"-1\">".$row["SCORE"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row["EVALUE"]."</font></td><td><a href=\"molecule-hsp.php?gene=".$id."&mol=".$row["PROTEIN"]."\"><font color=\"#000000\" size=\"-1\">".$row["BLOCKS"]."</font></a></td><td><font size=\"-1\">".$row["DESCRIPTION"]."&nbsp;</font></td></tr>";
		    print '<tr valign="top"><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td></tr>';
		}
		if($count==0){
		    print "</center><center><font color=\"#D64242\" size=\"3\"><b>No match</b></font></center>";
		}else{
		    print "</table></center>";
			print "PSI-Blast - Swissprot database";
		}
        

////////////////////////////////////////////////GO//////////////////////////////////////////////////
	    //$requete2="select B.species_origin, A.go_id, A.go_term, A.go_type, A.definition from ciona_design.go A, ciona_design.go_description B where (B.mol_id=$id) and (B.go_id=A.go_id) order by A.go_type, go_id";

	    print "<br><br><u><font color=\"#456898\" size=\"3\"><b>Gene Ontology</b></u></font><br><br>";
		$requete2="select B.\"SPECIES_ORIGIN\", A.\"GO_ID\", A.\"GO_TERM\", A.\"GO_TYPE\" from \"GO\" A, \"GO_DESCRIPTION\" B where (B.\"MOL_ID\"=$id) and (B.\"GO_ID\"=A.\"GO_ID\") order by A.\"GO_TYPE\", \"GO_ID\"";
	    $stmt2 = pg_query($c,$requete2);
if (pg_num_rows($stmt2)>0)
	{
	


        print "<center><table width=\"99%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";

		print '<tr align="center" valign="middle"><td><font color="#456898" size="2"><b>GO ID</b></font></td><td><font color="#456898" size="2"><b>Origin</b></font></td><td><font color="#456898" size="2"><b>Type</b></font></td><td><font color="#456898" size="2"><b>Term</b></font></td></tr>';
	 }

		$count=0;
		while($row2=pg_fetch_array($stmt2)){
		    ++$count;
				print "<tr align=\"center\"><td><font color=\"#656565\" size=\"-1\">".$row2["GO_ID"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row2["SPECIES_ORIGIN"]."</font></td><td><font color=\"#656565\" size=\"-1\">".$row2["GO_TYPE"]."</font></td><td><a href=\"GO-definition.php?id=".$row2["GO_ID"]."\" onClick=\"return self.popup(this, 'Definition')\"><font color=\"#000000\" size=\"-1\">".$row2["GO_TERM"]."</font></a></td></tr>";
		        print '<tr valign="top"><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td><td><hr size="1"></td></tr>';
		}
		print "</TABLE></center>";
		if($count==0)
		    print "<font color=\"#D64242\" size=\"3\"><b>No match</b></font></center>";
		else
		    print "infered from ortholog prediction, best blast hits and interpro";
		/*else{
			print "<br><center>";
			print "<a href=\"GO-cluster.php?name=$name&mode=pr&id=$id\"><img border=\"1\" src=\"pictures/button-process.jpg\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
			print "<a href=\"GO-cluster.php?name=$name&mode=fu&id=$id\"><img border=\"1\" src=\"pictures/button-function.jpg\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
			print "<a href=\"GO-cluster.php?name=$name&mode=lo&id=$id\"><img border=\"1\" src=\"pictures/button-localisation.jpg\"></a>";
			print "</center>";
        }*/




print "<br><br><br>*includes JGI user annotations";
//print "<br><br><a href=\"XMLexport-molecule-gene.php?name=$name\">Display entry in XML format</a><br>";
print "<br><br>";
//	print "<a href=\"FLATexport-molecule-gene.php?name=$name\">Display entry in raw text format</a><br>";




	}else{ print "<br><br><center><font color=\"#D64242\" size=\"3\"><b>No match</b></font></center><br><br>"; }

	
	

	
?>
<script type="text/javascript" src="wz_tooltip.js"></script>

<?php
   	include("frames_footer.php");
?> 