File uploaded successfully! Now proceed to choose other options
";
}
//when the user enters gene ids into the textarea
else if (isset($_POST['gene'])) {
$gene = $_POST['gene'];
$geneArray=explode("\n",$gene);
$count = count($geneArray);
if($count > 0 && trim($geneArray[$count-1]) == ""){
unset($geneArray[$count -1]);
}
}
}
//db Config values
$dbHost = "floret.cgrb.oregonstate.local";
$dbUser = "planteome_php";
$dbPwd = "planteome_php-pw";
//global variables to hold the list of species values. This is passed to download.php for downloading protein sequence in fasta format
$specieslist="";
$geneids="";
//global variables to hold the list of results. This is passed to download.php for downloading the results as a text file.
$pairSearchResult = "";
$superClusterSearchResult = "";
$showFastaDownloadLink = true;
$showDataDownloadLink = true;
$sep="~";
//function that fetches all results from the db
function mysql_fetch_all($query, $conn) {
$result = mysql_query($query, $conn);
if (!$result) {
echo "DB Error, could not find cluster id
";
echo "MySQL Error: " . mysql_error() . "
";
}
$rows = array();
while($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
return $rows;
}
//function that builds query from the geneArray
function buildQueryFromGeneArray($query,$geneArray){
for($i=0;$i<=count($geneArray)-1;){
if(trim($geneArray[$i]) != ""){
$query = $query . " gene LIKE '%".trim($geneArray[$i])."%'";
}
$i++;
if($i!=count($geneArray) && trim($geneArray[$i]) != ""){
$query = $query. " OR ";
}
}
return $query;
}
?>
Upload a .txt file containing the list of gene ids. Make sure the file contains only one gene id per line
or
Enter gene id(s) in the textarea below. Make sure you enter only one gene id per line.
";
echo "MySQL Error: " . mysql_error(). "
";
}
$num = mysql_num_rows($query2Result);
if($num > 0) {
if($showFastaDownloadLink){
echo "Click here to download all results as a FASTA file
";
//this link has to be shown only one. so set the variable $showFastaDownloadLink to false after first time;
$showFastaDownloadLink = false;
}
if($showDataDownloadLink){
echo "Click here to download all results as a text file
";
//this link has to be shown only one. so set the variable $showDataDownloadLink to false after first time;
$showDataDownloadLink = false;
}
}
if($i==0){
echo "";
echo "Results for species-species pair search |
";
echo "";
echo "bit score | species | orthology score | gene | ";
echo "
";
}
$j=0;
while ($j <$num) {
$bit_score=mysql_result($query2Result,$j,"bit_score");
$species=mysql_result($query2Result,$j,"species");
$score=mysql_result($query2Result,$j,"score");
$gene_return=mysql_result($query2Result,$j,"gene");
$gene_return_url="$gene_return";
$specieslist= $specieslist == "" ? $species : $specieslist.','.$species;
$geneids = $geneids == "" ? $gene_return : $geneids.','.$gene_return;
if($score ==1) {$score = '1.00';}
echo "";
echo "$bit_score | ".str_replace('_',' ',$species)." | $score | $gene_return_url | ";
echo "
";
$j++;
$res = $clust_id.$sep.$bit_score.$sep.$species.$sep.$score.$sep.$gene_return;
if($pairSearchResult != "")
$pairSearchResult=$pairSearchResult.",".$res;
else
$pairSearchResult=$res;
}
}
echo "
";
mysql_close();
}
}
if(isset($super)) {
$connection = mysql_connect($dbHost,$dbUser,$dbPwd);
mysql_select_db("inparanoid_data_eucalyptus");
if(isset($geneArray)){
$query1 = "select super_id from super_clust where ";
$query1 = buildQueryFromGeneArray($query1,$geneArray);
}
$rowArray = mysql_fetch_all($query1,$connection);
for($i=0;$i<=count($rowArray)-1;$i++){
$row = $rowArray[$i];
$super_id = $row["super_id"];
$query2 = "select * from super_clust where super_id = '$super_id'";
$query2Result = mysql_query($query2);
if (!$query2Result) {
echo "DB Error, could not find cluster
";
echo "MySQL Error: " . mysql_error(). "
";
}
$num = mysql_num_rows($query2Result);
if($num > 0) {
if($showFastaDownloadLink){
echo "Click here to download all results as a FASTA file
";
//this link has to be shown only one. so set the variable $showFastaDownloadLink to false after first time;
$showFastaDownloadLink = false;
}
if($showDataDownloadLink){
echo "Click here to download all results as a text file
";
//this link has to be shown only one. so set the variable $showDataDownloadLink to false after first time;
$showDataDownloadLink = false;
}
}
if($i==0){
echo "";
echo "Results from supercluster search |
";
echo "";
echo "supercluster id | species | gene | ";
echo "
";
}
$j = 0;
while ($j < $num) {
$super_id_result=mysql_result($query2Result,$j,"super_id");
$species=mysql_result($query2Result,$j,"species");
$gene_result=mysql_result($query2Result,$j,"gene");
$gene_result_url="$gene_result";
$specieslist= $specieslist == "" ? $species : $specieslist.','.$species;
$geneids = $geneids == "" ? $gene_result : $geneids.','.$gene_result;
echo "";
echo "$super_id_result | ".str_replace('_',' ',$species)." | $gene_result_url | ";
echo "
";
$j++;
$res = $super_id_result.$sep.$species.$sep.$gene_result;
if($superClusterSearchResult != "")
$superClusterSearchResult=$superClusterSearchResult.",".$res;
else
$superClusterSearchResult=$res;
}
}
echo "
";
mysql_close();
}
//to be used for downloading protein sequence is fasta format
if(isset($geneArray)){
$genelist = implode(',', $geneArray);
}
?>