<?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");
//Title before frames_header
print '<title>ANISEED - DDD search</title>';

include("frames_header.php");
?>
<SCRIPT>
function enableField(){
    if(document.formulaire2.explev.checked==true){
        document.formulaire2.level.disabled=false;
	}else{
        document.formulaire2.level.disabled=true;
	}
}
</SCRIPT>



<?php
	
    if(isset($_POST["group"]))
	    $group=$_POST["group"];
	else
	    $group=2;
	if(isset($_POST["species"]))
	    $species=$_POST["species"];

?>
<div style="border-top:0px solid black;border-bottom:1px solid black;">
<font color="#D64242" size="+3"><b>D</font><font color="#D64242" size="3">igital</font> <font color="#D64242" size="+3">D</font><font color="#D64242" size="3">ifferential</font><font color="#D64242" size="+3">D</font><font color="#D64242" size="3">isplay</b></font>
<center>
</div>
<br>
This pages allows you to retrieve gene models with EST/cDNA clones
differentially expressed in the various sequenced cDNA libraries.
Select a species, and tick the libraries (pool A, pool B) to analyse.
Pool A corresponds to libraries you would like ESTs to be enriched
over pool B. By ticking all, you can retrieve all gene models
represented in a given EST pool.
<br>
<br>
<form name="formulaire2" action="DDD-result.php" method="post" target="_blank">

<?php
	$genelist="";
	if(isset($_POST["genelist"]))
		$genelist=$_POST["genelist"];
	if(strlen($genelist)>0)
		  print "<center><H2><font color=\"#FF6600\">Refine subset mode</font> <a href=\"DDD-search.php\" target=\"_self\"><img src=\"pictures/button-reset.jpg\" border=\"0\" align=\"middle\"></a> </H2></center>";

    print '<input name="genelist" type="hidden" value="'.$genelist.'">';
?>


            <table width="40%" border="0" cellspacing="0" cellpadding="0">
            
                <td align="left"><font color="#456898" size="2"><b>Species:</b></font></td>
                <td align="left"><strong>
                  <!--
				  <select name="species" onChange="javascript: self.location.href = 'DDD-search.php?species=' + this.options[this.selectedIndex].value;">
                  -->
				  <select name="species" onChange="javascript: document.formulaire2.target='_self'; document.formulaire2.action= 'DDD-search.php'; submit();">
                    <option></option>
					
					<?php
							$requete="Select \"NAME\" from \"SPECIES\" order by \"NAME\"";
							$stmt = pg_query($c,$requete);
							while($row=pg_fetch_array($stmt) ){
								$name=$row["NAME"];
								print "<option";
								if($species==$name)
								    print " selected";
								print ">$name</option>";
							}
		
					?>
					
                  </select>
                  </strong> </td>
              </tr>
              <tr> 
                <td height="30" align="right">&nbsp;
                </td>
                <td align="left">&nbsp;
				    
				</td>
              </tr>
            </table>



<table width="99%" border="1" cellspacing="0" cellpadding="1">

<?php
	print '<tr><td><font color="#456898" size="2"><b>Library type</b></td><td><font color="#456898" size="2"><b>Stage/Tissue</b></font></td><td><font color="#456898" size="2"><b>Library</b></font></td><td><font color="#456898" size="2"><b>Size</b></font></td>';
	//for($a=0;$a<$group;++$a){
		//print '<td><strong>Pool '.($a+1).'</strong></td>';
	//}
	print '<td><font color="#456898" size="2"><b>Pool A</b></font></td>';
	print '<td><font color="#456898" size="2"><b>Pool B</b></font></td>';
	print '</tr>';

	$requete="select * from \"LIBRARY\" where \"SPECIES\"='$species' order by \"ORDRE\" ASC";
    $stmt = pg_query($c,$requete);
	//$last="";
	while($row=pg_fetch_array($stmt)){

		if ($row["LIB_SIZE"]<100) //avoid to display very small library
			continue;

	    /*
	    $com=OCIResult($stmt,"COMMENTS");
		if($com!=$last)
			$last=$com;
		else
		    $com="&nbsp;";
		*/
		print "<tr align=\"left\"><td>&nbsp;<font color=\"#000000\" size=\"2\"><b>".$row["COMMENTS"]."</b></font></td><td>&nbsp;<font color=\"#000000\" size=\"-1\">".$row["TISSUE"]."</font></td><td>&nbsp;<font color=\"#000000\" size=\"-1\">".$row["TITLE"]."</font></td><td>&nbsp;<font color=\"#000000\" size=\"-1\">".$row["LIB_SIZE"]."</font></td>";
		for($a=0;$a<$group;++$a){
		    print '<td><input type="checkbox" value="'.$row["LIBRARY_ID"].'" name="group'.($a+1).'[]"></td>';
		}
		print '</tr>';
		
	}
	
?>
</table>
<input name="submit2" type="image" src="pictures/button-submit.jpg" onClick="submit">
</center>
<br><strong>Display:</strong>
<br><input name="sort" type="radio" value="1" checked>all
<br><input name="sort" type="radio" value="2">pool A > pool B
<br><input name="sort" type="radio" value="3">pool A < pool B 
<br><input type="checkbox" value="1" name="explev" onClick="javascript: self.enableField();">Display only genes whith a minimum differential expression of <select name="level" disabled><option>2</option><option>5</option><option>10</option><option>15</option><option>20</option><option>25</option><option>30</option><option>35</option><option>40</option><option>45</option><option>50</option></select> times.

</form>

<br>


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