<!-- display result of gene-search.php and permit to focus on a gene of interest -->
<html>
<head>
<title>ANISEED - Gene / Transcript result (Ciona intestinalis, Halocynthia roretzi)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="The result of a gene search by name or ID will be presented in a list of the gene model ID (ENSEMBL, JGI v1.0 or KYOTOGRAIL2005), the associated biological name and the specie. For more detail, contact aniseed@ibdm.univ-mrs.fr">
<meta name="keywords" content="Ciona intestinalis, Halocynthia roretzi, ascidian database, ciona intestinalis database, ciona intestinalis gene, functional annotation, transcript model, JGI, Kyotograil, ENSEMBL">
<meta name = "robots" content = "index, follow, all">
<META HTTP-EQUIV="Content-Language" CONTENT="EN">
<style type="text/css">
</style>
</head>

<?
/*
    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");

$name=$_GET["name"];
$name2=strtolower($name);
$species=$_GET["species"];
//print $name2;
////// On regarde si c'est un transcrit ici le type=gene c pour coller a la base
//$requete="SELECT gene.\"GENE_ID\",mol.\"SPECIES\" from \"GENE\" gene, \"MOL_ENTITY\" mol where gene.\"NAME\"='$name' OR gene.\"NAME\"='$name2' and mol.\"MOL_ID\"=gene.\"GENE_ID\" and mol.\"SPECIES\"='$species'";

$requete="select \"MOL_ID\" as \"GENE_ID\",\"SPECIES\",\"NAME\" from \"MOL_ENTITY\" where \"TYPE\"='gene' and (\"NAME\"='$name' or \"NAME\"='$name2') and \"SPECIES\"='$species' ";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)>0)
	{
	
	$row=pg_fetch_array($stmt);

	if ($row["SPECIES"]=='Halocynthia roretzi')
	{
	
	print '<font color="#D64242" size="3"><b>Matching records</b></font><br><br>';
	print '<table width="99%" border="0" cellspacing="0" cellpadding="0">';
	print '<tr align="center" valign="middle"><td><font color="#456898" size="2"><b>Transcript name</b></font></td><td><font color="#456898" size="2"><b>Species</b></font></td></tr>';
	print '<tr align="center" valign="middle"><td>&nbsp;</td><td>&nbsp;</td></tr>';
	print '<tr align="center" valign="middle">';
	print '<td><font color="#456898" size="2"><a href="molecule-gene.php?name='.$row["NAME"].'">'.$row["NAME"].'</a></font></td>';
	
	print '<td><font color="#456898" size="2">'.$species.'</font></td>';

	print '</tr>';

	print "</table>";
	
	include ("frames_footer.php");
	return;
	}


////////////////////////////////////////// COPY PASTE MOLECULE-RESULT ///////////////////////////////


	$requete0="SELECT \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_MODEL_ID\"='".$row["GENE_ID"]."'";
	$stmt0=pg_query($c,$requete0);
	$row0=pg_fetch_array($stmt0);

	if (strlen($row0["GENE_CLUSTER_ID"])==0)
	{
	print "<center><strong>No Gene are matching your query</strong></center>";
	print "<br><br>";
	print "<center>A transcript is matching your query : <a href=\"molecule-gene.php?name=$name\">$name</a></center>";
	
	include ("frames_footer.php");
	return;
	}


print '<font color="#D64242" size="3"><b>Matching records</b></font><br><br>';
print '<table width="99%" border="0" cellspacing="0" cellpadding="0">';
print '<tr align="center" valign="middle"><td><font color="#456898" size="2"><b>Aniseed Gene ID</b></font></td><td><font color="#456898" size="2"><b>Gene name</b></font></td><td><font color="#456898" size="2"><b>Species</b></font></td></tr>';
print '<tr align="center" valign="middle"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';



$clustid=$row0["GENE_CLUSTER_ID"];

$name_tmp="";
$requete1="SELECT \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"='$clustid'";
$stmt1=pg_query($c,$requete1);
while ($row1=pg_fetch_array($stmt1))
{
if (strlen($name_tmp)==0) $name_tmp=$row1["GENE_CLUSTER_NAME"];
else $name_tmp.="@".$row1["GENE_CLUSTER_NAME"];
}


$mg_tmp="";
$requete1="SELECT \"NAME\" from \"GENE\" where \"GENE_ID\" in (
select \"GENE_MODEL_ID\" from \"GENE_CONCEPT\" where \"GENE_CLUSTER_ID\"='$clustid'
)";
$stmt1=pg_query($c,$requete1);
while ($row1=pg_fetch_array($stmt1))
{
if (strlen($mg_tmp)==0) $mg_tmp=$row1["NAME"];
else $mg_tmp.="@".$row1["NAME"];
}



//print $clustid." => ".$name_tmp." => ".$mg_tmp."<bR>";
print '<tr align="center" valign="middle">';
print '<td><font color="#456898" size="2"><a href="gene-card.php?clusterid='.$clustid.'">'.(str_replace("cluster","aniseedV3_",$clustid)).'</a></font></td>';
print '<td>';
$one=explode("@",$name_tmp);
for ($i=0;$i<count($one);$i++)
	{
	print '<font color="#456898" size="2">'.$one[$i].'</font> / ';
	}
print '</td>';

print '<td><font color="#456898" size="2">Ciona intestinalis</font></td>';

print '</tr>';

print "</table>";

//////////////////////////////////////// FIN DU COPY PAST MOLECULE-RESULT ///////////////////////////

include ("frames_footer.php");
return;
	} ///////// ACCOLADE MOLECULE RESULT

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//// Recherche par ANISEED_GM


$requete="SELECT \"GENE_CLUSTER_ID\" from \"GENE_CONCEPT\" where \"GENE_CLUSTER_ID\"='".str_replace("aniseedV3_","cluster",$name)."'";
$stmt=pg_query($c,$requete);
if ($row=pg_fetch_array($stmt))
{

////////////////////////////////////////// COPY PASTE MOLECULE-RESULT ///////////////////////////////

print '<font color="#D64242" size="3"><b>Matching records</b></font><br><br>';
print '<table width="99%" border="0" cellspacing="0" cellpadding="0">';
print '<tr align="center" valign="middle"><td><font color="#456898" size="2"><b>Aniseed Gene ID</b></font></td><td><font color="#456898" size="2"><b>Gene name</b></font></td><td><font color="#456898" size="2"><b>Species</b></font></td></tr>';
print '<tr align="center" valign="middle"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';


$clustid=$row["GENE_CLUSTER_ID"];



$name_tmp="";
$requete1="SELECT \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"='$clustid'";
$stmt1=pg_query($c,$requete1);
while ($row1=pg_fetch_array($stmt1))
{
if (strlen($name_tmp)==0) $name_tmp=$row1["GENE_CLUSTER_NAME"];
else $name_tmp.="@".$row1["GENE_CLUSTER_NAME"];
}


$mg_tmp="";
$requete1="SELECT \"NAME\" from \"GENE\" where \"GENE_ID\" in (
select \"GENE_MODEL_ID\" from \"GENE_CONCEPT\" where \"GENE_CLUSTER_ID\"='$clustid'
)";
$stmt1=pg_query($c,$requete1);
while ($row1=pg_fetch_array($stmt1))
{
if (strlen($mg_tmp)==0) $mg_tmp=$row1["NAME"];
else $mg_tmp.="@".$row1["NAME"];
}



//print $clustid." => ".$name_tmp." => ".$mg_tmp."<bR>";
print '<tr align="center" valign="middle">';
print '<td><font color="#456898" size="2"><a href="gene-card.php?clusterid='.$clustid.'">'.(str_replace("cluster","aniseedV3_",$clustid)).'</a></font></td>';
print '<td>';
$one=explode("@",$name_tmp);
for ($i=0;$i<count($one);$i++)
	{
	print '<font color="#456898" size="2">'.$one[$i].'</font> / ';
	}
print '</td>';

print '<td><font color="#456898" size="2">Ciona intestinalis</font></td>';

print '</tr>';

print "</table>";

//////////////////////////////////////// FIN DU COPY PAST MOLECULE-RESULT ///////////////////////////




include ("frames_footer.php");
return;
}





//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$name=strtoupper($name);
$name2=$name;
$name=ereg_replace("[^a-zA-Z0-9]"," ",$name);
$name=ereg_replace("([a-zA-Z])([0-9])","\\1 \\2",$name);
$name=ereg_replace("([0-9])([a-zA-Z])","\\1 \\2",$name);
$name=ereg_replace(" +"," ",$name);
$name=ereg_replace("^ ","",$name);
$name=ereg_replace(" $","",$name);


$table=(array) null;
$requete="SELECT distinct gcn.\"GENE_CLUSTER_ID\" from \"GENE_CONCEPT_NAME\" gcn, \"GENE_CONCEPT\" gc where gcn.\"GENE_CLUSTER_UPPER_NAME\" like '%$name%' and gc.\"SPECIES\"='$species' and gc.\"GENE_CLUSTER_ID\"=gcn.\"GENE_CLUSTER_ID\" ";
$stmt=pg_query($c,$requete);
if (pg_num_rows($stmt)==0)
	{

//// On peut faire la recherche dans les BLAST

	$requete="SELECT distinct gcnb.\"GENE_CLUSTER_ID\" from \"GENE_CONCEPT_NAME_BLAST\" gcnb, \"GENE_CONCEPT\" gc where upper(gcnb.\"GENE_CLUSTER_NAME_BLAST\") like '%$name2%' and gc.\"SPECIES\"='$species' and gc.\"GENE_CLUSTER_ID\"=gcnb.\"GENE_CLUSTER_ID\"";
	$stmt=pg_query($c,$requete);
	
	if (pg_num_rows($stmt)==0)
		{
		print "<br><br><br><center><font size=\"2\"><b>No Match</b></font></center>";
		include ("frames_footer.php");
		return;
		}

	//////////////// NAME POUR GENE_CLUSTER_NAME_BLAST //////////////////
print "<center>";
print '<font color="#D64242" size="3"><b>Matchieng records</b></font><br><br>';
print '<table width="99%" border="0" cellspacing="0" cellpadding="0">';
print '<tr align="center" valign="middle"><td><font color="#456898" size="2"><b>Aniseed Gene ID</b></font></td><td><font color="#456898" size="2"><b>Gene name</b></font></td><td><font color="#456898" size="2"><b>Species</b></font></td></tr>';
print '<tr align="center" valign="middle"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';


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

$clustid=$row["GENE_CLUSTER_ID"];


$name_tmp="";
$requete0="SELECT \"GENE_CLUSTER_NAME_BLAST\" from \"GENE_CONCEPT_NAME_BLAST\" where \"GENE_CLUSTER_ID\"='$clustid'";
$stmt0=pg_query($c,$requete0);
while ($row0=pg_fetch_array($stmt0))
{
if (strlen($name_tmp)==0) $name_tmp=$row0["GENE_CLUSTER_NAME_BLAST"];
else $name_tmp.="@".$row0["GENE_CLUSTER_NAME_BLAST"];
}


$mg_tmp="";
$requete0="SELECT \"NAME\" from \"GENE\" where \"GENE_ID\" in (
select \"GENE_MODEL_ID\" from \"GENE_CONCEPT\" where \"GENE_CLUSTER_ID\"='$clustid'
)";
$stmt0=pg_query($c,$requete0);
while ($row0=pg_fetch_array($stmt0))
{
if (strlen($mg_tmp)==0) $mg_tmp=$row0["NAME"];
else $mg_tmp.="@".$row0["NAME"];
}



//print $clustid." => ".$name_tmp." => ".$mg_tmp."<bR>";
print '<tr align="center" valign="middle">';
print '<td><font color="#456898" size="2"><a href="gene-card.php?clusterid='.$clustid.'">'.(str_replace("cluster","aniseedV3_",$clustid)).'</a></font></td>';
print '<td>';
$one=explode("@",$name_tmp);
for ($i=0;$i<count($one);$i++)
	{
	print '<font color="#456898" size="2">'.$one[$i].'</font> / ';
	}
print '</td>';

print '<td><font color="#456898" size="2">Ciona intestinalis</font></td>';

print '</tr>';

}


print '</table>';
include ("frames_footer.php");
return;


	//////////////// FIN NAME POUR GENE_CLUSTER_NAME_BLAST //////////////////

	}



print '<font color="#D64242" size="3"><b>Matching records</b></font><br><br>';
print '<table width="99%" border="0" cellspacing="0" cellpadding="0">';
print '<tr align="center" valign="middle"><td><font color="#456898" size="2"><b>Aniseed Gene ID</b></font></td><td><font color="#456898" size="2"><b>Gene name</b></font></td><td><font color="#456898" size="2"><b>Species</b></font></td></tr>';
print '<tr align="center" valign="middle"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';


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

$clustid=$row["GENE_CLUSTER_ID"];


$name_tmp="";
$requete0="SELECT \"GENE_CLUSTER_NAME\" from \"GENE_CONCEPT_NAME\" where \"GENE_CLUSTER_ID\"='$clustid'";
$stmt0=pg_query($c,$requete0);
while ($row0=pg_fetch_array($stmt0))
{
if (strlen($name_tmp)==0) $name_tmp=$row0["GENE_CLUSTER_NAME"];
else $name_tmp.="@".$row0["GENE_CLUSTER_NAME"];
}


$mg_tmp="";
$requete0="SELECT \"NAME\" from \"GENE\" where \"GENE_ID\" in (
select \"GENE_MODEL_ID\" from \"GENE_CONCEPT\" where \"GENE_CLUSTER_ID\"='$clustid'
)";
$stmt0=pg_query($c,$requete0);
while ($row0=pg_fetch_array($stmt0))
{
if (strlen($mg_tmp)==0) $mg_tmp=$row0["NAME"];
else $mg_tmp.="@".$row0["NAME"];
}



//print $clustid." => ".$name_tmp." => ".$mg_tmp."<bR>";
print '<tr align="center" valign="middle">';
print '<td><font color="#456898" size="2"><a href="gene-card.php?clusterid='.$clustid.'">'.(str_replace("cluster","aniseedV3_",$clustid)).'</a></font></td>';
print '<td>';
$one=explode("@",$name_tmp);
for ($i=0;$i<count($one);$i++)
	{
	print '<font color="#456898" size="2">'.$one[$i].'</font> / ';
	}
print '</td>';

print '<td><font color="#456898" size="2">Ciona intestinalis</font></td>';

print '</tr>';

}


print '</table>';











include ("frames_footer.php");
?>