<html>
<head>
<title>ANISEED - Compare Expression pattern (Ciona intestinalis, Halocynthia roretzi)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="This page allows users to Halocynthia roretzi or Ciona intestinalis expression pattern. For more information, contact dauga@ibdm.univ-mrs.fr">
<meta name="keywords" content="In situ data, comparison, Ciona intestinalis expression data, Ciona intestinalis, Halocynthia roretzi, ascidian database, ciona intestinalis database.">
<meta name = "robots" content = "index, follow, all">
<META HTTP-EQUIV="Content-Language" CONTENT="EN">
<style type="text/css">
</style>
</head>

<?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/>.

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

include("navigation.php");

	
	//s mofif:   is clust2        checked & private
?>

<SCRIPT>
function ZoomIn() {
		for(a=0;a<document.images.length;++a){
			if(document.images[a].name=="pics")
				document.images[a].width+=20;
		}
}
function ZoomOut() {
		for(a=0;a<document.images.length;++a){
			if(document.images[a].name=="pics")
				document.images[a].width-=20;
		}
}
</SCRIPT>

<?php
///////////mode1 => wild type // mode2 => deregulation // mode3 => embryo manip///////////

	//variables pour le systeme page suiv/prec
	if( isset($_GET["option"]) ) $option= $_GET["option"];
	if( isset($_GET["offset"]) ) $offset= $_GET["offset"];
	if( isset($_GET["nbMAX"])  ) $nbMAX = $_GET["nbMAX"];
	
	if(! isset($option)) $option= 1;
	if(! isset($offset)) $offset= 0;
	if(! isset($nbMAX)) $nbMAX= 20;
	


	$target="";
	$mode="";
	$id="";

    if(isset($_GET["target"]))
		$target = $_GET["target"];
	if(isset($_GET["mode"]))
		$mode = $_GET["mode"];
	if(isset($_GET["id"]))
		$id = $_GET["id"];

    //titre/mode choisi
	if($mode==1){
        print "<font color=\"#D64242\" size=\"3\"><b>Expression pattern in a wild type context.</b></font><br><br>";
	}else if($mode==2){
	    print "<font color=\"#D64242\" size=\"3\"><b>Expression pattern in a deregulated molecule context.</b></font><br><br>";
	}else if($mode==3){
	    print "<font color=\"#D64242\" size=\"3\"><b>Expression in an embryo manipulation context.</b></font><br><br>";
	}else if($mode==4){
	    print "<font color=\"#D64242\" size=\"3\"><b>Similar expression pattern search.</b></font><br><br>";
	}
    print '<img src="pictures/zoom-in.gif" onClick="ZoomIn()" border="0"><img src="pictures/zoom-out.gif" onClick="ZoomOut()" border="0">';
	print "<br>To compare one of these in situ staining with the reference picture press the corresponding 'Compare' button. <br>";
	
	
	print "<TABLE CELLSPACING=\"0\" BORDER=\"0\" WIDTH=\"99%\">";
	

///////////////////////////////////////////////////////////////////////////////
for($a=0;$a<=1;++$a){   //astuce pour afficher l'image de reference: la premiere requete la retrouve (/$id) puis c'est la vraie recherche 

    if($a==1){
		if($mode==1){   //recherche des contextes Wild_type
			//$requete="SELECT UNIQUE A.IN_SITU_ID, A.WILD_TYPE, A.DEV_STAGE_ID, C.NAME AS DEV, A.SPECIES, A.IM_COMMENTS, B.TARGET_ID, B.NAME, C.DEV_PERCENT FROM CIONA_DESIGN.IN_SITU A, CIONA_DESIGN.TARGET B, CIONA_DESIGN.DEV_STAGE C WHERE (A.WILD_TYPE='y') AND (B.TARGET_ID=$target) AND (C.DEV_STAGE_ID=A.DEV_STAGE_ID) AND (A.IN_SITU_ID=B.IN_SITU_ID) ORDER BY A.SPECIES, C.DEV_PERCENT";
            $requete="SELECT distinct A.\"IN_SITU_ID\", A.\"WILD_TYPE\", A.\"DEV_STAGE_ID\", C.\"NAME\" AS \"DEV\", A.\"SPECIES\", A.\"IM_COMMENTS\", B.\"TARGET_ID\", B.\"NAME\", C.\"DEV_PERCENT\" FROM \"IN_SITU\" A, \"TARGET\" B, \"DEV_STAGE\" C WHERE (A.\"CHECKED\"='y') AND (A.\"PRIVATE\" = 'n') AND (A.\"WILD_TYPE\"='y') AND (B.\"TARGET_ID\"=$target) AND (C.\"DEV_STAGE_ID\"=A.\"DEV_STAGE_ID\") AND (A.\"IN_SITU_ID\"=B.\"IN_SITU_ID\") ORDER BY A.\"SPECIES\", C.\"DEV_PERCENT\"";
			
			$stmtT = pg_query($c,$requete);
		}else if($mode==2){   //recherche des deregulations
			//$requete="SELECT UNIQUE A.IN_SITU_ID, A.WILD_TYPE, A.DEV_STAGE_ID, C.NAME AS DEV, A.SPECIES, A.IM_COMMENTS, B.TARGET_ID, B.NAME, C.DEV_PERCENT FROM CIONA_DESIGN.IN_SITU A, CIONA_DESIGN.TARGET B, CIONA_DESIGN.DEV_STAGE C, CIONA_DESIGN.MUTANT D WHERE (A.WILD_TYPE='n') AND (B.TARGET_ID=$target) AND (C.DEV_STAGE_ID=A.DEV_STAGE_ID) AND (A.IN_SITU_ID=B.IN_SITU_ID) AND (A.IN_SITU_ID=D.IN_SITU_ID) ORDER BY A.SPECIES, C.DEV_PERCENT";
			$requete="SELECT distinct A.\"IN_SITU_ID\", A.\"WILD_TYPE\", A.\"DEV_STAGE_ID\", C.\"NAME\" AS \"DEV\", A.\"SPECIES\", A.\"IM_COMMENTS\", B.\"TARGET_ID\", B.\"NAME\", C.\"DEV_PERCENT\" FROM \"IN_SITU\" A, \"TARGET\" B, \"DEV_STAGE\" C, \"MUTANT\" D WHERE (A.\"CHECKED\"='y') AND (A.\"PRIVATE\" = 'n') AND (A.\"WILD_TYPE\"='n') AND (B.\"TARGET_ID\"=$target) AND (C.\"DEV_STAGE_ID\"=A.\"DEV_STAGE_ID\") AND (A.\"IN_SITU_ID\"=B.\"IN_SITU_ID\") AND (A.\"IN_SITU_ID\"=D.\"IN_SITU_ID\") ORDER BY A.\"SPECIES\", C.\"DEV_PERCENT\"";
			
			$stmtT = pg_query($c,$requete);
		}else if($mode==3){   //recherche des manip d'embryon
			//$requete="SELECT UNIQUE A.IN_SITU_ID, A.WILD_TYPE, A.DEV_STAGE_ID, C.NAME AS DEV, A.SPECIES, A.IM_COMMENTS, B.TARGET_ID, B.NAME, C.DEV_PERCENT FROM CIONA_DESIGN.IN_SITU A, CIONA_DESIGN.TARGET B, CIONA_DESIGN.DEV_STAGE C, CIONA_DESIGN.EMBRYO_MANIP D WHERE (A.WILD_TYPE='n') AND (B.TARGET_ID=$target) AND (C.DEV_STAGE_ID=A.DEV_STAGE_ID) AND (A.IN_SITU_ID=B.IN_SITU_ID) AND (A.IN_SITU_ID=D.IN_SITU_ID) ORDER BY A.SPECIES, C.DEV_PERCENT";
            $requete="SELECT distinct A.\"IN_SITU_ID\", A.\"WILD_TYPE\", A.\"DEV_STAGE_ID\", C.\"NAME\" AS \"DEV\", A.\"SPECIES\", A.\"IM_COMMENTS\", B.\"TARGET_ID\", B.\"NAME\", C.\"DEV_PERCENT\" FROM \"IN_SITU\" A, \"TARGET\" B, \"DEV_STAGE\" C, \"EMBRYO_MANIP\" D WHERE (A.\"CHECKED\"='y') AND (A.\"PRIVATE\" = 'n') AND (A.\"WILD_TYPE\"='n') AND (B.\"TARGET_ID\"=$target) AND (C.\"DEV_STAGE_ID\"=A.\"DEV_STAGE_ID\") AND (A.\"IN_SITU_ID\"=B.\"IN_SITU_ID\") AND (A.\"IN_SITU_ID\"=D.\"IN_SITU_ID\") ORDER BY A.\"SPECIES\", C.\"DEV_PERCENT\"";
			
			$stmtT = pg_query($c,$requete);
		}else if($mode==4){  //affiche les clusters d'images
          		/*
			$requete="select D.\"IN_SITU_ID_2\" as \"IN_SITU_ID\", D.\"DISTANCE\", A.\"WILD_TYPE\", A.\"DEV_STAGE_ID\", A.\"SPECIES\", A.\"IM_COMMENTS\", C.\"NAME\" AS \"DEV\", C.\"DEV_PERCENT\" FROM \"IN_SITU\" A, \"DEV_STAGE\" C, \"IN_SITU_CLUSTER2\" D WHERE (A.\"CHECKED\"='y') AND (A.\"PRIVATE\" = 'n') AND (D.\"IN_SITU_ID\"=$id) AND (C.\"DEV_STAGE_ID\"=A.\"DEV_STAGE_ID\") AND (A.\"IN_SITU_ID\"=D.\"IN_SITU_ID_2\") AND (D.\"TYPE\"='st')  order by D.\"DISTANCE\"";
			*/
			$requete="select D.\"IN_SITU_ID_2\" as \"IN_SITU_ID\", D.\"DISTANCE\", A.\"WILD_TYPE\", A.\"DEV_STAGE_ID\", A.\"SPECIES\", A.\"IM_COMMENTS\", C.\"NAME\" AS \"DEV\", C.\"DEV_PERCENT\" FROM \"IN_SITU\" A, \"DEV_STAGE\" C, \"IN_SITU_CLUSTER3\" D WHERE (A.\"CHECKED\"='y') AND (A.\"PRIVATE\" = 'n') AND (D.\"IN_SITU_ID\"=$id) AND (C.\"DEV_STAGE_ID\"=A.\"DEV_STAGE_ID\") AND (A.\"IN_SITU_ID\"=D.\"IN_SITU_ID_2\") AND (D.\"TYPE\"='st')  order by D.\"DISTANCE\"";

			$stmtT = pg_query($c,$requete);
		}
	}else{
        $requete = "SELECT A.\"DEV_STAGE_ID\", A.\"IN_SITU_ID\", A.\"WILD_TYPE\", A.\"IM_COMMENTS\", B.\"NAME\" AS \"DEV\", A.\"SPECIES\" FROM \"IN_SITU\" A, \"DEV_STAGE\" B WHERE (A.\"CHECKED\"='y') AND (A.\"PRIVATE\" = 'n') AND (A.\"IN_SITU_ID\" = $id) AND (A.\"DEV_STAGE_ID\"=B.\"DEV_STAGE_ID\")";
		$stmtT = pg_query($c,$requete);
	}
	

//print $requete;

if ($a==1) resultsBar($stmtT,$offset); //On met la resultBar que pour les entrees jaunes

		//print $requete;
		
		$count=0;
		while(  ($rowT=pg_fetch_array($stmtT)) && ($count < $offset+$nbMAX)  ){
		  if( ($count++ >= $offset)or($a!=1) ){
		    if( ($id==$rowT["IN_SITU_ID"])and($a==1) )
			    continue;
			
//		    ++$count;
			if($a==1){
			
				if($rowT["WILD_TYPE"]=='n'){$color='#CCCC99';}else{$color='#FFFFCC';}
			}else{  //la ref doit etre en rouge
			     $color='#990000';
				 $devini=$rowT["DEV_STAGE_ID"];
			}
			
		    print "<tr><td>";
			
			if( ($mode==4)and($a!=0) ){
			    print "<br><strong>Distance: ".$rowT["DISTANCE"]."</strong>";
			}
			
			
			//logo
			$requete = "SELECT C.\"LOGO\" FROM \"AUTHOR\" C, \"ENTRY_ORIGIN\" D where (D.\"BIO_ID\"=".$rowT["IN_SITU_ID"].") AND (D.\"AUTHOR_ID\"=C.\"AUTHOR_ID\")";
			$resultset = pg_query($c,$requete);

			$rowset=pg_fetch_array($resultset);
			
			


			//espece & stade de devt.
			print "<TABLE CELLSPACING=\"0\" BORDER=\"0\" bgcolor=\"$color\" WIDTH=\"100%\" style=\"color:black\"><TR>\n";

			print '<td><table width="100%" border="0" cellspacing="0" cellpadding="0" style="color:black">'
			  .'<tr>'
			  ."<td align=\"left\" >";
			  
			if(strlen($rowset["LOGO"])>0)
				print "<img align=\"absmiddle\" src=\"pictures/".$rowset["LOGO"]."\">&nbsp;&nbsp;";

			print "<a href=\"insitu.php?id=".$rowT["IN_SITU_ID"]."\"><img src=\"pictures/button-more.jpg\" border=\"1\"></a>";

			if($a==1){
				print "&nbsp;<a target=\"_blank\" href='insitu-compare.php?id1=$id&id2=".$rowT["IN_SITU_ID"]."'><img src=\"pictures/button-compare2.jpg\" border=1></a>";
			}else{
			    print "&nbsp;&nbsp;<font color=\"#FFFFFF\" size=\"2\"><b>Reference picture</b></font></strong>";
			}
			
			print '</td>';
			
			if( ($a==1)and($devini==$rowT["DEV_STAGE_ID"]) )  //repere le meme stade que la reference
			    print "<TD align=\"right\" valign=\"top\"><font color=\"#000000\" size=\"2\">".$rowT["SPECIES"]."</font>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#000000\">".$rowT["DEV"]."</font></strong></TD>\n";		
			else
			    print "<TD align=\"right\" valign=\"top\"><font color=\"#000000\" size=\"2\"><b>".$rowT["SPECIES"]."&nbsp;&nbsp;&nbsp;&nbsp;".$rowT["DEV"]."</b></font></TD>\n";		
			
			
			print '</tr></table></td></tr>';
			/*
			//picture
			$requete="SELECT PICTURE_ID FROM CIONA_DESIGN.PICTURE WHERE IN_SITU_ID = ".OCIResult($stmtT, "IN_SITU_ID")." AND CONTROL IS NULL";
			$stmtpic = OCIParse($connection, $requete);
			OCIExecute($stmtpic);
			print "<TR><TD>";
			while(OCIFetch($stmtpic)){
				$idpicture=OCIresult($stmtpic,"PICTURE_ID");
				echo "<a href=\"insitu.php?id=".OCIResult($stmtT, "IN_SITU_ID")."\"><img src=\"picture-mini.php?id=$idpicture\" border=1 width=\"100\" name=\"pics\" title=\"".str_replace("<br>"," ",OCIResult($stmtT, "IM_COMMENTS"))."\"></a> ";
		    }
			print "</TD></TR>\n";
			*/
			//picture
			$requete="SELECT \"PICTURE_ID\", \"PATH\" FROM \"PICTURE\" WHERE \"IN_SITU_ID\" = ".$rowT["IN_SITU_ID"]." and \"CONTROL\" IS NULL";
			$stmtpic = pg_query($c,$requete);
			print "<TR><TD><TABLE><tr align=\"top\"><td>";
			while($rowpic=pg_fetch_array($stmtpic)){
				$idpicture=$rowpic["PICTURE_ID"];
				if(strlen($rowpic["PATH"])>0)
					{
					if (!preg_match("/mix/",$rowpic["PATH"]))
			    		echo "<a href=\"insitu.php?id=$id\"><img src=\"picturesDB/".$rowpic["PATH"]."\" border=1 width=\"100\" name=\"pics\"></a> ";
					}
					/*echo "<a href=\"insitu.php?id=$id\"><img src=\"picturesDB/".$rowpic["PATH"]."\" border=1 width=\"100\" name=\"pics\"></a> ";*/

				else
					echo "<a href=\"insitu.php?id=".$rowT["IN_SITU_ID"]."\"><img src=\"picture-mini.php?id=$idpicture\" border=1 width=\"100\" name=\"pics\"></a> ";
			}
			print "</td><td width=\"45%\"><font size=\"-1\" color=\"#000000\">".(str_replace("<br>"," ",$rowT["IM_COMMENTS"]))."</font></td></tr>";
			print "</TABLE></TD></TR>\n";
			
			
			print "<TABLE CELLSPACING=\"0\" CELLPADDING=\"0\" BORDER=\"0\" bgcolor=\"$color\" WIDTH=\"100%\" style=\"color:black\">";
			//recherche des cibles
			$requete = "SELECT distinct B.\"SURE\", B.\"PART_OF\", A.\"MOL_ID\", A.\"NAME\", A.\"TYPE\", C.\"NAME\" AS \"REGION\", C.\"ANAT_ID\", C.\"DEV_STAGE_ID\" FROM \"MOL_ENTITY\" A, \"TARGET\" B, \"ANAT_ENTITY\" C where (B.\"IN_SITU_ID\"=".$rowT["IN_SITU_ID"].") AND (B.\"TARGET_ID\"=A.\"MOL_ID\") AND (B.\"REGION_ID\"=C.\"ANAT_ID\")";
			$resultset = pg_query($c,$requete);
			$str='';
			$str2='';
			$mol=null; $typemol=null;//sert a retrouver le gene correspondant
			while( $rowset=pg_fetch_array($resultset) ){
				if(substr_count (  $str, $rowset["NAME"] )==0){
				
					if( $rowset["TYPE"]=="clone" )
					    $str.="<a href=\"molecule-clone2.php?name=";
					else if( $rowset["TYPE"]=="clone_sequence" )
					    $str.="<a href=\"molecule-clone.php?name=";
					else if( $rowset["TYPE"]=="gene" )
					    $str.="<a href=\"molecule-gene.php?name=";
					else if( $rowset["TYPE"]=="construction" )
					    $str.="<a href=\"molecule-construction.php?name=";
					else
					    $str.="<a href=\"\" name=\"";
						
					$str.=$rowset["NAME"]."\">".$rowset["NAME"]."</a> - ";
				
					$mol[$rowset["MOL_ID"]]=$rowset["NAME"];
					$typemol[$rowset["MOL_ID"]]=$rowset["TYPE"];
				}
				
				//anotation sup sur les "stained anatomy part"
				$partof="";$sure="";
				if($rowset["PART_OF"]=="X") $partof="Part of ";  else $partof="";
				if($rowset["SURE"]=="X") $sure="?"; else $sure="";
					
				$str2.="<a href=\"short_hierarchy.php?region=".$rowset["ANAT_ID"]."&dev=".$rowset["DEV_STAGE_ID"]."\">$partof".$rowset["REGION"]."$sure</a> - ";
				//$str2.="<a href=\"short_hierarchy.php?region=".OCIResult($resultset,"ANAT_ID")."&dev=".OCIResult($resultset,"DEV_STAGE_ID")."\">".OCIResult($resultset, "REGION")."</a> - ";
			}

			print "<TR><TD><font color=\"#000000\" size=\"2\"><b>Stained molecule: - </b></font><font color=\"#000000\" size=\"2\">$str</font></TD>\n";

			
			//region
			print "<TD><font color=\"#000000\" size=\"2\"><b>Stained region: - </b></font><font color=\"#456898\" size=\"2\">$str2</font></TD></TR>\n";
	        
			
///////////////////////
            //recherche des genes correspondants aux cibles
			while (list($key, $value) = each($mol)) {
			      $count2=0;
			      $geneidlist="";
				  if( $typemol[$key]=="clone" ){
					  $requete="SELECT distinct \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"='$value'";
					  $resultset = pg_query($c,$requete);
					  while($rowset=pg_fetch_array($resultset)){
						   $geneidlist[$count2++]=$rowset["ANISEED_CLUSTER_ID"]; //+ieur genes poss si les est d'un meme clone correspondent a des modeles differents
					  }

//KYOTO
			  		$requete="select \"NAME\" from \"MOL_ENTITY\" where \"MOL_ID\"=(SELECT distinct \"ANISEED_KYOTO_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"='$value' and \"ANISEED_KYOTO_CLUSTER_ID\" is not null)";
				    	$resultset=pg_query($c,$requete);
					$row5bis=pg_fetch_array($resultset);
					$requete="select \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\" like '".$row5bis["NAME"].".%' and \"TYPE\" <> 'abstract'";
					$resultset=pg_query($c,$requete);						  
					while($row5=pg_fetch_array($resultset)){
						   $geneidlist[$count2++]=$row5["MOL_ID"];

					  }

					//ENSEMBL
					//$requete="SELECT \"TRANSCRIPT_ID\" from \"TRANSCRIPT\" where \"ABSTRACT_ID\" =(SELECT distinct \"ANISEED_ENSEMBL_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"='$value' and \"ANISEED_ENSEMBL_CLUSTER_ID\" is not null)";//LA VRAI REQUETE
					$requete="SELECT \"TRANSCRIPT_ID\" from \"TRANSCRIPT\" where \"ABSTRACT_ID\" in (SELECT distinct \"ANISEED_ENSEMBL_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_NAME\"='$value' and \"ANISEED_ENSEMBL_CLUSTER_ID\" is not null) limit 1";//MODIFIE TEMPORAIREMENT
					
					    	$resultset=pg_query($c,$requete);
						//print $requete;
						  
					while($row5=pg_fetch_array($resultset)){
						   $geneidlist[$count2++]=$row5["TRANSCRIPT_ID"]; //+ieur genes poss si les est d'un meme clone correspondent a des modeles differents

					  }


				  }
				  else if( $typemol[$key]=="clone_sequence" ){
					  $requete="SELECT \"ANISEED_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"=$key";
					  $resultset = pg_query($c,$requete);
					  while($rowset=pg_fetch_array($resultset)){
						   $geneidlist[$count2++]=$rowset["ANISEED_CLUSTER_ID"];
					  }

					//KYOTO
			  		$requete="select \"NAME\" from \"MOL_ENTITY\" where \"MOL_ID\"=(SELECT distinct \"ANISEED_KYOTO_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"='$key')";
				    	$resultset=pg_query($c,$requete);
					$row5bis=pg_fetch_array($resultset);
					$requete="select \"MOL_ID\" from \"MOL_ENTITY\" where \"NAME\" like '".$row5bis["NAME"].".%' and \"TYPE\" <> 'abstract'";
					$resultset=pg_query($c,$requete);						  
					while($row5=pg_fetch_array($resultset)){
						   $geneidlist[$count2++]=$row5["MOL_ID"];

					  }

					//ENSEMBL
					$requete="SELECT \"TRANSCRIPT_ID\" from \"TRANSCRIPT\" where \"ABSTRACT_ID\"=(
						SELECT distinct \"ANISEED_ENSEMBL_CLUSTER_ID\" from \"CLONE_SEQ\" where \"CLONE_SEQ_ID\"='$key')";
					    	$resultset=pg_query($c,$requete);
						
						  
					while($row5=pg_fetch_array($resultset)){
						   $geneidlist[$count2++]=$row5["TRANSCRIPT_ID"]; //+ieur genes poss si les est d'un meme clone correspondent a des modeles differents

					  }

				  }
				  else if( $typemol[$key]=="gene" ){
					  $geneidlist[$count2++]=$key;
				  }
				  
				  //recherche des noms possibles pour le gene correspondant
				  if(count($geneidlist)>1)
				      $geneidlist=array_unique($geneidlist);
				  for($ab=0; $ab<count($geneidlist); ++$ab){
					if(strlen($geneidlist[$ab])>0){
					  $requete="SELECT distinct A.\"NAME\", B.\"SYNO\", B.\"ORIGIN\" from \"GENE\" A, \"SYNO\" B where A.\"GENE_ID\"=B.\"GENE_ID\" and B.\"GENE_ID\"=".$geneidlist[$ab]."order by B.\"ORIGIN\" DESC";
					  $resultset = pg_query($c,$requete);
					  $syno=""; $aaa=0;
					  while($rowset=pg_fetch_array($resultset)){
					      $genename=$rowset["NAME"];
						  if($rowset["SYNO"]==$rowset["NAME"])
							  continue;
						  if(++$aaa>1)
							  $syno.=' <strong><font color="#000000">/</font></strong> ';
						  $syno.=$rowset["SYNO"];
						  if($rowset["ORIGIN"]=="user-JGI")
							  $syno.="*";
						  if( strlen($syno)-(($aaa-1)*48) > 100 ){
							  $syno.=" <strong><font color=\"#000000\">/</font></strong>...";
							  break;
						  }
					  }
						if($aaa==0){
							$requete="select \"DESCRIPTION\", \"EVALUE\" from \"BLAST\" where \"MOL_ID\"='".$geneidlist[$ab]."' and \"SCORE\"=(select max(\"SCORE\") from \"BLAST\" where \"MOL_ID\"='".$geneidlist[$ab]."')";
							//$requete2="select max(score), description, evalue from ciona_design.blast where mol_id=$id";
							
							$resultset = pg_query($c,$requete);
							if($rowset=pg_fetch_array($resultset)){
								$eval = $rowset["EVALUE"];
								if( $eval <= 1e-10)
									$syno.= "HIGHLY ";
								else if( ($eval >= 1e-4) and ($eval <= 1e-3) )
									$syno.= "WEAKLY ";
								if($eval <= 1e-3)
									$syno.= "SIMILAR TO ".$rowset["DESCRIPTION"]." (Eval: $eval)";
							}
						}
					  
					  print "<tr valign=\"top\"><td><div style=\"border-top:1px solid black;\"/><font size=\"-1\">Predicted gene for ".$value.": <a href=\"molecule-gene.php?name=".$genename."\">".$genename."</a></font></td><td><div style=\"border-top:1px solid black;\"/><font size=\"-1\">".$syno."</font></td></tr>";
					}
				  }
			}
//////////////////////////////////
			
			
			
			if($rowT["WILD_TYPE"]=='n'){
				//recherche des mutants
                $requete = "SELECT \"NAME\", \"BIO_ID\" FROM \"MUTANT\" where \"IN_SITU_ID\"=".$rowT["IN_SITU_ID"];
				$resultset = pg_query($c,$requete);
				$str='';
				$ab=0; $geneidlist="";//sert ensuite a retouver les noms des genes
				while( $rowset=pg_fetch_array($resultset) ){
				    $geneidlist[$ab++]=$rowset["BIO_ID"];
					$str.="<a href=\"molecule-gene.php?name=".$rowset["NAME"]."\">".$rowset["FULL_NAME"]." ".$rowset["NAME"]."</a> - ";
				}
				print "<TR valign=\"top\"><TD><hr color=\"#505F70\" size=\"1\"><font color=\"#000000\" size=\"2\"><b>Deregulated molecule: - </font><font color=\"#000000\" size=\"-1\">$str</font></TD>\n";
				
				//recherche des amputations
				$requete = "SELECT A.\"DEV_STAGE_ID\", A.\"ANAT_ID\", A.\"NAME\" FROM \"ANAT_ENTITY\" A, \"EMBRYO_MANIP\" B WHERE (B.\"IN_SITU_ID\"=".$rowT["IN_SITU_ID"].") AND (B.\"STRUCTURE_ID\"=A.\"ANAT_ID\")";
				$resultset = pg_query($c,$requete);
				$str='';
				while($rowset=pg_fetch_array($resultset) ){
					$str.="<a href=\"short_hierarchy.php?region=".$rowset["ANAT_ID"]."&dev=".$rowset["DEV_STAGE_ID"]."\">".$rowset["NAME"]."</a> - ";
				}
			    print "<TD><hr color=\"#505F70\" size=\"1\"><font color=\"#000000\" size=\"2\"><b>Embryo manipulation: - </b></font><font color=\"#000000\" size=\"-1\">$str</font></TD></TR>\n";
				
				
				//recherche des noms possibles pour le gene correspondant
				if(count($geneidlist)>1)
				    $geneidlist=array_unique($geneidlist);
				for($ab=0; $ab<count($geneidlist); ++$ab){
					if((isset($geneidlist[$ab]))and(strlen($geneidlist[$ab])>0)){
						  $requete="SELECT distinct A.\"NAME\", B.\"SYNO\", B.\"ORIGIN\" from \"GENE\" A, \"SYNO\" B where A.\"GENE_ID\"=B.\"GENE_ID\" and B.\"GENE_ID\"=".$geneidlist[$ab]."order by B.\"ORIGIN\" DESC";
						  $resultset = pg_query($c,$requete);
						  $syno=""; $aaa=0;
						  while($rowset=pg_fetch_array($resultset)){
						      $genename=$rowset["NAME"];
							  if($rowset["SYNO"]==$rowset["NAME"])
								  continue;
							  if(++$aaa>1)
								  $syno.=' <strong><font color="#990000">/</font></strong> ';
							  $syno.=$rowset["SYNO"];
							  if($rowset["ORIGIN"]=="user-JGI")
								  $syno.="*";
							  if( strlen($syno)-(($aaa-1)*48) > 100 ){
								  $syno.=" <strong><font color=\"#990000\">/</font></strong>...";
								  break;
							  }
						  }
							if($aaa==0){
								$requete="select \"DESCRIPTION\", \"EVALUE\" from \"BLAST\" where \"MOL_ID\"='".$geneidlist[$ab]."' and \"SCORE\"=(select max(\"SCORE\") from \"BLAST\" where \"MOL_ID\"='".$geneidlist[$ab]."')";
								//$requete2="select max(score), description, evalue from ciona_design.blast where mol_id=$id";
								$resultset = pg_query($c,$requete);
								if($rowset=pg_fetch_array($resultset)){
									$eval = $rowset["EVALUE"];
									if( $eval < 1e-10)
										$syno.= "HIGHLY ";
									else if( $eval > 1e-4) 
										$syno.= "WEAKLY ";
									$syno.= "SIMILAR TO ".$rowset["DESCRIPTION"]." (Eval: $eval)";
								}
							}
						  
						  if(strlen($syno)>0)
						      print "<tr valign=\"top\"><td><hr color=\"#505F70\" size=\"1\"><font size=\"-1\">Possible names for <a href=\"molecule-gene.php?name=".$genename."\">".$genename.": </a></font></td><td><hr color=\"#505F70\" size=\"1\"><font size=\"-1\">".$syno."</font></td></tr>"; }
				}
			    $geneidlist=null;
				
				
		    }
		    print "</table><br>";
		  }
		  
		}
}
//OCIFreeStatement($stmtT);

	
		print "</TD></TR></TABLE></center>\n";
		if($count==0){
			print "<br><br><center><h2><strong>No match</strong></h2></center><br><br>";
		}
		
		
	
	////////////////////////////////////////////////////////////////////////
	print '<center>';
print "<small><br>";
currentPageBar();
print "<br>";

	if($offset>0)
        echo '<input type="image" src="pictures/previous.jpg" onClick="javascript: self.location.href = \'compare.php?id='.$id.'&target='.$target.'&mode='.$mode.'&option='.$option.'&offset='.($offset-$nbMAX).'nbMAX='.$nbMAX.'\';">';
		//echo '<img src="pictures/previous.jpg" onClick="javascript:self.setbrowserprev(); submit();">';
	
	echo "&nbsp;&nbsp;&nbsp;";

navigationBarCompare();


	echo "&nbsp;&nbsp;&nbsp;";

	if( ($count%$nbMAX==0)&&($count>0)&&($count>$offset) )
	    echo '<input type="image" src="pictures/next