Jump to content

ktsirig

Members
  • Posts

    49
  • Joined

  • Last visited

Everything posted by ktsirig

  1. Hi, thanks for your answer... My problem is that I have absolutely no idea how to do this, can you point me to some place?
  2. Hi, I have an input form for a user to submit some input and then this input is processed by a Perl script, which is called through the PHP index page... My problem is that this external script takes usually more than 2-3 minutes so there is a risk of the page to hang. How can I modify my PHP page to stay in index.php, but periodically refresh it so, when the perl command is done, it then outputs the results. Here is the index page (the refresh I wrote on top did not work. <?php $max_seqs = 1000; $page = $_SERVER['PHP_SELF']; $sec = "10"; header("Refresh: $sec; url=$page"); ?> <html> <head> <style> body { font-family: arial; color: #003965; font-size: 14px; } textarea { width: 620px; height: 120px; font-family: courier; } .whole { width: 1000px; border-collapse: collapse; margin-top:20px; margin-bottom:20px; text-align: center; background-color: #e8e8e8; font-size: 12px; } .browse_cell { background:#d8dada; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; padding: 3; border-spacing: 2; text-align: center; font-weight: bold; color:#424d5d; } .browse_cell_change1 { background:#BFBFF6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding: 2; } .browse_cell_change2 { background:#D9D9D9; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding: 2; border-spacing:4px; } .headcell { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; font-weight:bold; line-height: 15px; text-align: center; color: #000144; } </style> </head> <body> <?php if( isset ( $_POST['sequence'] )) #run part { function readSeqs($text) { if( !preg_match( '/^>/m', $text ) ) return readSeqs( ">\n$text" ); $seqs = array(); $text = preg_replace( '/[\n\r]+/', "\n", $text ); preg_match_all( '/^>([^\n]*)\n([^>]*)/ms', $text, $matches ); foreach( $matches[1] as $k=>$name1 ) { $seqs_number++; $seq = $matches[2][$k]; $name1 = trim($name1); $name=substr($name1, 0, 50); #keep only the first 40 characters (if the name is longer) $name=preg_replace('/\s+/', ' ', $name); $name=preg_replace('/[\|\s\/\\\%\*&\#\@\(\)\[\]\$\^\!]/', '_', $name); $seq = preg_replace( '/\s+/', '', $seq ); $seqs[] = array( 'name'=>$name, 'seq'=>$seq ); } return $seqs; } $uniq_number = uniqid(); $input_folder = './tmp_files/myfolder_'.$uniq_number; mkdir($input_folder); $input_file = $input_folder.'/'.'input_seqs'; $seqs = readSeqs($_POST['sequence']); $run_mode = $_POST['mode']; $signal=''; $phmms=''; if($_POST[sp_pred] == 'on') { $signal = $_POST['sp_pred']; } else { $signal = 'off'; } if($_POST['pfams'] == 'on') { $phmms = $_POST['pfams']; } else { $phmms = 'off'; } $seqs_number = count($seqs); $prior_info1 = $_POST['prior']; if (preg_match('/Example/', $prior_info1)) { $prior_info='--'; $prior_info_final='NO_INFO'; } else { $prior_info=$prior_info1; $prior_info_final=str_replace(';', 'A', $prior_info); } if( $seqs_number == 0 ) { echo "<em>You did not submit any sequences.</em>"; } elseif( $seqs_number > $max_seqs ) { echo "<em>You can input no more than $max_seqs sequences at a time.</em>"; } elseif ( $seqs_number > 1 and $seqs_number <= $max_seqs ) { $input = ''; foreach($seqs as $v) #create input file for run { $input.= ">".$v['name']."\n".$v['seq']."\n"; } #write each FASTA seq in input file file_put_contents( $input_file, $input ); #(if we will allow >1 proteins) #echo "perl Whole_Program.pl $input_folder $seqs_number $prior_info_final $run_mode $signal $phmms<br>"; exec ("perl Whole_Program.pl $input_folder $seqs_number $prior_info_final $run_mode $signal $phmms", $res_total, $ret); if($ret==0) { $text_file = $input_file.'.txt_res'; $zip_file = 'tmp_files/'.$uniq_number.'.tgz'; echo "<table class=\"whole\">\n"; echo "<tbody>\n"; echo "<tr><td class=\"headcell\" align=\"right\" colspan=\"7\"><br>Results<br><br></td></tr>\n"; echo "<tr>\n"; echo "<td width=\"14%\" class=\"browse_cell\">Entry</td>\n". "<td width=\"12%\" class=\"browse_cell\">Length</td>\n". "<td width=\"14%\" class=\"browse_cell\">Signal peptide</td>\n". "<td width=\"14%\" class=\"browse_cell\">β-score</td>\n". "<td width=\"38%\" class=\"browse_cell\">OMPdb family</td>\n". "<td width=\"14%\" class=\"browse_cell\">#TM</td>\n". "<td width=\"12%\" class=\"browse_cell\">Topology image</td>\n"; echo "</tr>\n"; foreach ($res_total as $line_entry) { $counter++; if ($counter % 2) {$colour_class="browse_cell_change1";} else {$colour_class="browse_cell_change2";} $all_data = preg_split("/\t/", $line_entry); $id=$all_data[0]; $seq_len=$all_data[1]; $signal=$all_data[2]; $score=$all_data[3]; $family_name=$all_data[4]; $family_number=$families_array[$family_name]; $tm_num=$all_data[5]; if($tm_num==0) {$tm_num='--';} $topo_img_link=$all_data[6]; echo "<tr>\n"; echo "<td width=\"14%\" align=\"left\" class=\"".$colour_class."\">".$id."</td>\n". "<td width=\"12%\" class=\"".$colour_class."\">".$seq_len."</td>\n". "<td width=\"14%\" class=\"".$colour_class."\">".$signal."</td>\n". "<td width=\"14%\" class=\"".$colour_class."\">".$score."</td>\n". "<td width=\"38%\" align=\"left\" class=\"".$colour_class."\">"; if($family_name == "--") { echo "$family_name</td>\n"; } else { echo "<a target=\"_blank\" href=\"http://www.ompdb.org/OMPdb/view_family.php?fam_id=".$family_number."\">". $family_name."</a></td>\n"; } echo "<td width=\"14%\" class=\"".$colour_class."\">".$tm_num."</td>\n"; if($topo_img_link=='--') { echo "<td width=\"12%\" class=\"".$colour_class."\">--</td>\n"; } else { echo "<td width=\"12%\" class=\"".$colour_class."\"><a target=\"_blank\" href=\"".$topo_img_link."\"> Download</a></td>\n"; } echo "</tr>\n"; } echo "</tbody></table>\n"; } else { echo "<br /><br />Program error!"; } } echo "<br /><a target=\"_blank\" href=\"".$text_file."\">Download</a> results in plain text format\n"; echo "<br /><a target=\"_blank\" href=\"".$zip_file."\">Download</a> all files related to this submission as a tarball\n"; echo "<br /><br /><a href=\"index.php\">Run again</a><br />"; } else #index initial page { echo "Please paste up one or more ". " - formatted sequences in the textarea below: <br /><br />\n"; echo "<form method=post name=\"seq_form\">". "<textarea name=\"sequence\"></textarea> <br /><br /> Select mode: <input type=\"radio\" name=\"mode\" value=\"1\" checked /> MSA-version (1 sequence) <input type=\"radio\" name=\"mode\" value=\"2\" /> Single-sequence version (up to $max_seqs sequences) <br /><br /> Run signal-peptide prediction using <a target=\"_blank\" href=\"http://www.compgen.org/tools/PRED-TAT/\">PRED-TAT</a>: <input type=\"checkbox\" name=\"sp_pred\" checked> <br /><br /> Use library in prediction: <input type=\"checkbox\" name=\"pfams\" checked> <br /><br /> Prior information (constrained prediction): <input type=\"text\" name=\"prior\" size=\"33\" style=\"color:#888;\" value=\"Example: I:1-15;M:20-25;O:30-30\" onfocus=\"inputFocus(this)\" onblur=\"inputBlur(this)\" /> <br /><br /> <input type=\"submit\" value=\"Run prediction\" /> <input type=\"reset\" value=\"Clear fields\" /> <input type=\"button\" value=\"Generate sample input\" onclick=\"example_fill();\"> </form>"; echo "<br /><hr>"; } ?> </body> </html>
  3. Hi, in my PHP webpage I specify 3 files, like: $first_file = $_POST["one"]; $second_file = $_POST["two"]; $third_file = $_POST["three"]; then I have a JS fuction, that in some points, needs to open each file and store the data of each file into a variable. My questions are 2: First, how do I save all data of each text file into a JS variable? Second, the part of the Js function which has these variables looks like this: series: [ { name: 'ONE', color: 'blue', data: [ HERE WE SHOULD PLACE ALL DATA FROM FILE 1 ] }, { name: 'TWO', color: 'yellow', data: [ HERE WE SHOULD PLACE ALL DATA FROM FILE 2 ] }, { name: 'THREE', color: 'red', data: [ HERE WE SHOULD PLACE ALL DATA FROM FILE 3 ] } ] Can you please help me, how I can put the data of each file into the correct place? I am new to JS and came across a helpful snipet of code, but I do not know how I can place my data inside the JS code so as to use them. Thanks a lot!
  4. Hi, I wanted to ask if there exist any ready-to-use scripts for creating interactive plots with JS. What I mean by interactive, is, for example, if you have a plot with 5 histogram bars, each of which could correspond to, let's say, the number of people in a school (say schools 1,2,3,4 and 5) , one could select, by ticking a checkbox on a list outside the plot, which of the bars (schools) would be visible in the plot and which not.
  5. Hi all! So, I have a website for a database which contains biological data (proteins). In this website, there is a text search page, where the user can specify one or more search terms in order to get data from the database. The user can enter up to 5 search terms in each of the available text boxes, as shown below <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Text search</title> <link rel="shortcut icon" type="image/x-icon" href="css/images/fav.ico"> <link rel ="stylesheet" href ="css/style.css"> <script type="text/javascript"> function setReadOnly(obj) { if(obj.value == "specific") { document.forms[0].mytext.style.backgroundColor = "#ffffff"; document.forms[0].mytext.readOnly = 0; document.forms[0].mytext.value = ""; } else { document.forms[0].mytext.style.backgroundColor = "#eeeeee"; document.forms[0].mytext.readOnly = 1; document.forms[0].mytext.value = "50.00"; } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } function prepareInputsForHints() { var inputs = document.getElementsByTagName("input"); for (var i=0; i<inputs.length; i++){ // test to see if the hint span exists first if (inputs[i].parentNode.getElementsByTagName("span")[0]) { // the span exists! on focus, show the hint inputs[i].onfocus = function () { this.parentNode.getElementsByTagName("span")[0].style.display = "inline"; } // when the cursor moves away from the field, hide the hint inputs[i].onblur = function () { this.parentNode.getElementsByTagName("span")[0].style.display = "none"; } } } // repeat the same tests as above for selects var selects = document.getElementsByTagName("select"); for (var k=0; k<selects.length; k++){ if (selects[k].parentNode.getElementsByTagName("span")[0]) { selects[k].onfocus = function () { this.parentNode.getElementsByTagName("span")[0].style.display = "inline"; } selects[k].onblur = function () { this.parentNode.getElementsByTagName("span")[0].style.display = "none"; } } } } addLoadEvent(prepareInputsForHints); </script> </head> <body> <div align="center"> <table class="whole"> <tbody> <tr> <td> <?php include 'css/header.html';?> </td> </tr> <tr> <td> <?php include 'css/navbar.php';?> </td> </tr> <form enctype="multipart/form-data" method="post" action="retrieve_text.php"> <tr> <td> <div align="center"> <p class="headcell"><br/>Text search</p> <dl> <dt> Protein Name/Description </dt> <dd> <input type="text" name="prot_name" size="35" /> <span class="hint">e.g. ompa_ecoli, transmembrane, porin, adhesion<span class="hint-pointer"> </span> </dd> <dt> Gene name </dt> <dd> <input type="text" name="prot_gene" size="35" /> <span class="hint">e.g. ompA, porB, oprF, PMSV_1498<span class="hint-pointer"> </span> </dd> <dt> Organism name </dt> <dd> <input type="text" name="org_name" size="35" /> <span class="hint">e.g. Escherichia coli, Vibrio sp. (strain Ex25)<span class="hint-pointer"> </span> </dd> <dt> Organism taxonomy </dt> <dd> <input type="text" name="taxid" size="35" /> <span class="hint">e.g. 595536, 1051646<span class="hint-pointer"> </span> </dd> <dt> Cross-references </dt> <dd> <input type="text" name="crossref" size="35" /> <span class="hint">e.g. F2HUT9, PF01389, IPR006665, 1A0S<span class="hint-pointer"> </span> </dd> <dt> Literature references (PMID) </dt> <dd> <input type="text" name="pmid" size="35" /> <span class="hint">e.g. 9294435, 17114266, 8759855<span class="hint-pointer"> </span> </dd> <dt> Signal peptide information </dt> <dd> <select name="signal"> <option value="ALL" selected>All available</option> <option value="Experimentally verified">Experimentally verified</option> <option value="Experimentally verified [by similarity]">Experimentally verified [by similarity]</option> <option value="Prediction methods">SignalP 4.0</option> <option value="No information">No information</option> </select> </dd> <dt> Perform search in </dt> <dd> <select name="family"> <option value="0" selected>All families</option> <?php require_once("css/connection.php"); $query = "SELECT families.families_id, families.families_name FROM families"; $result = mysql_query($query) or die("<br><br><br>Please contact the administrator of the website.<br><br><br><br><br><br><br><br></td></div></tr>"); while ($line = mysql_fetch_row($result)) {echo "<option value=".$line[0].">".$line[1]."</option>\n";} ?> </select> </dd> <dt> Combine search criteria using </dt> <dd> <input type="radio" name="operator" value="combined" checked /> AND <input type="radio" name="operator" value="separate" /> OR </dd> <dt> Incude protein fragments in the results </dt> <dd> <input type="checkbox" class="check" name="fragment" checked /> </dd> <dd> <input type="hidden" name="order" value="id" /> </dd> </dl> </div> </td> </tr> <tr> <td><br> <input type="submit" value="Perform search"> <input type="reset" value="Clear fields"> </td> </tr> </form> <tr><td><br/></td></tr> <tr> <td height="40" class="note"><u><b><i>Note</i></b></u> : </b> You can specify up to 5 search terms in each text field, provided that they are separated by a comma.</td> </tr> </tbody> </table> </div> </body> </html> The retrieve_text.php page gets the data submitted by the user and fetches the results. Also, if the user clicks on 1 or more of the checkboxes next to each record, the respective entries are downloaded as raw format archives. However, because in some cases there were more than 200 results I decided to implement pagination... I searched around and asked for help, and managed to get it as far as you see below. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Text search results</title> <link rel="shortcut icon" type="image/x-icon" href="css/images/fav.ico"> <link rel ="stylesheet" href ="css/style.css"> </head> <body> <div align="center"> <table class="whole"> <tbody> <!-- arxikos pinakas --> <tr> <td> <?php include 'css/header.html';?> </td> </tr> <tr> <td> <?php include 'css/navbar.php';?> </td> </tr> <tr> <td> <div align="center"> <table class="included"> <tbody> <?php session_start(); require_once("css/connection.php"); print "POST_ARRAY:";print_r($_POST);print "<br><br>"; print "SESSION_CHOICE_ARRAY:";print_r($_SESSION['choice']);print "<br><br>"; /*<--- Download raw entries in zip form BEGIN--->*/ if ($_POST['submit'] == 'Retrieve') { if($count_selected<1000) { $add = rand(); $ids_selected=array_keys($_SESSION['choice']); foreach ( $ids_selected as $entry_selected) { $file_fasta = 'FASTA_FILES/'.$entry_selected.'.fasta'; $file_fasta_all = "TEMP_FTP_FILES/".$add.".fasta"; $create_fasta = `cat $file_fasta >>$file_fasta_all`;chmod($file_fasta_all,0777); } $zip_fasta=`gzip $file_fasta_all`; $final_fasta=$file_fasta_all.'.gz'; $file_xml_all = "TEMP_FTP_FILES/".$add.".xml"; $start_xml='<?xml version="1.0" encoding="utf-8"?>'."\n"."<Entries>\n"; $fh = fopen($file_xml_all, 'w'); fwrite($fh,$start_xml); fclose($fh); foreach ( $ids_selected as $entry_selected) { $file_xml = 'XML_DOWN_FILES/'.$entry_selected.'.xml'; $holdcontents = file_get_contents($file_xml); $fh2 = fopen($file_xml_all, 'a'); fwrite($fh2,$holdcontents); } $end_xml = "</Entries>\n"; fwrite($fh2,$end_xml); fclose($fh2);chmod($file_xml_all,0777); $zip_xml=`gzip $file_xml_all`; $final_xml=$file_xml_all.'.gz'; foreach ( $ids_selected as $entry_selected) { $file_flat = 'FLAT_FILES/'.$entry_selected.'.flat'; $file_flat_all = "TEMP_FTP_FILES/".$add.".flat"; $create_flat = `cat $file_flat>>$file_flat_all`; chmod($file_flat_all,0777); } $zip_flat=`gzip $file_flat_all`; $final_flat=$file_flat_all.'.gz'; if(file_exists($final_fasta) && file_exists($final_flat) && file_exists($final_xml)) { echo "<tr><td class=\"headcell\">Download selected entries</td></tr>\n"; echo "<tr><td class=\"searches_cell\"><br>Select one of the following formats:</td></tr>\n"; echo "<tr><br><td>"; echo "<ul>". "<li><a href=\"".$final_fasta."\">FASTA format</a></li>". "<li><a href=\"".$final_flat."\">Text format</a></li>". "<li><a href=\"".$final_xml."\">XML format</a></li>". "</ul>". "</td></tr></table>\n"; } } else { echo "<div align=\"center\"><table>". "<tr><td><div align=\"center\">". "You selected ".$counter." entries for download, which is more than the allowed limit of 1000. <br>For large barch searches, please download and search the total database files from the <a target=_blank href = \"download.php\">download</a> page. ". "<p>Go <a href=\"javascript: window.history.go(-1);\">back</a> to selection list</p>"; exit; } echo "<p>Go <a href=\"javascript: window.history.go(-1);\">back</a> to selection list</p>"; exit; } /*<--- Download raw entries in zip form END --->*/ function cleanQuery($string) { if (get_magic_quotes_gpc()) // prevents duplicate backslashes { $string = stripslashes($string); } $string = mysql_real_escape_string($string); $trimmed = trim($string); $final=str_replace("%","\%",$trimmed); return $final; } $name=$gene=$organism=$taxonomy=$references=$transmembrane=""; $family=0; $coverage=0; $combination='combined'; $frag=''; if (isset($_REQUEST['prot_name'])) {$name = cleanQuery($_REQUEST['prot_name']);} if (isset($_REQUEST['prot_gene'])) {$gene = cleanQuery($_REQUEST['prot_gene']);} if (isset($_REQUEST['org_name'])) {$organism = cleanQuery($_REQUEST['org_name']);} if (isset($_REQUEST['taxid'])) {$taxonomy = cleanQuery($_REQUEST['taxid']);} if (isset($_REQUEST['crossref'])) {$references = cleanQuery($_REQUEST['crossref']);} if (isset($_REQUEST['pmid'])) {$references_pmid = cleanQuery($_REQUEST['pmid']);} if (isset($_REQUEST['operator'])) {$combination = $_REQUEST['operator'];} if (isset($_REQUEST['fragment'])) {$frag='Y';} if (isset($_REQUEST['family'])) {$family = $_REQUEST['family'];} if (isset($_REQUEST['signal'])) {$signal = $_REQUEST['signal'];} if ( !$name && !$gene && !$organism && !$taxonomy && !$references && !$references_pmid && $family==0 && $signal=="ALL") { echo "<div align=\"center\"><table>". "<tr><td><div align=\"center\">". "<br><br><br><br>No values in the text fields specified. ". "Please go <a href = \"text_search.php\">back</a> to text search page.<br><br><br><br><br><br><br><br></td></div></tr>"; exit; } else { $wclause = array(); if($name!="") { if(strstr($name, ',', true)) { $array_name = explode(",", $name); $count_name = count ($array_name); if ($count_name>5) {print "<br><br><br><br>You specified more than 5 terms in one or more text fields. Please go <a href = \"text_search.php\">back</a> to text search page and review your submission.<br><br><br><br><br><br><br><br>";} $all_name=''; foreach ($array_name as $value_name) { $value_name=trim($value_name); $all_name = $all_name."protein.protein_name LIKE '%".$value_name."%' OR "; } $final_name_addition = substr($all_name, 0, -4); // remove the ' OR ' in the end $wclause[]= $final_name_addition; } else { $wclause[]="protein.protein_name LIKE '%".$name."%' "; } } if($gene!="") { if(strstr($gene, ',', true)) { $array_genes = explode(",", $gene); $count_genes = count ($array_genes); if ($count_genes>5) {print "<br><br><br><br>You specified more than 5 terms in one or more text fields. Please go <a href = \"text_search.php\">back</a> to text search page and review your submission.<br><br><br><br><br><br><br><br>";} $all_genes=''; foreach ($array_genes as $value_genes) { $value_genes=trim($value_genes); $all_genes = $all_genes."protein.protein_gene LIKE '%".$value_genes."%' OR "; } $final_genes_addition = substr($all_genes, 0, -4); // remove the ' OR ' in the end $wclause[]= $final_genes_addition; } else { $wclause[]="protein.protein_gene LIKE '%".$gene."%' "; } } if($organism!="") { if(strstr($organism, ',', true)) { $array_organism = explode(",", $organism); $count_organism = count ($array_organism); if ($count_organism>5) {print "<br><br><br><br>You specified more than 5 terms in one or more text fields. Please go <a href = \"text_search.php\">back</a> to text search page and review your submission.<br><br><br><br><br><br><br><br>";} $all_organism=''; foreach ($array_organism as $value_organism) { $value_organism=trim($value_organism); $all_organism = $all_organism."protein.protein_organism LIKE '%".$value_organism."%' OR "; } $final_organism_addition = substr($all_organism, 0, -4); // remove the ' OR ' in the end $wclause[]= $final_organism_addition; } else { $wclause[]="protein.protein_organism LIKE '%".$organism."%' "; } } if($taxonomy!="") { if(strstr($taxonomy, ',', true)) { $array_taxonomy = explode(",", $taxonomy); $count_taxonomy = count ($array_taxonomy); if ($count_taxonomy>5) {print "<br><br><br><br>You specified more than 5 terms in one or more text fields. Please go <a href = \"text_search.php\">back</a> to text search page and review your submission.<br><br><br><br><br><br><br><br>";} $all_taxonomy=''; foreach ($array_taxonomy as $value_taxonomy) { $value_taxonomy=trim($value_taxonomy); $all_taxonomy = $all_taxonomy."protein.protein_ncbi ='".$value_taxonomy."' OR "; } $final_taxonomy_addition = substr($all_taxonomy, 0, -4); // remove the ' OR ' in the end $wclause[]= $final_taxonomy_addition; } else { $wclause[]="protein.protein_ncbi ='".$taxonomy."' "; } } if($references!="") { if(strstr($references, ',', true)) { $array_references = explode(",", $references); $count_references = count ($array_references); if ($count_references>5) {print "<br><br><br><br>You specified more than 5 terms in one or more text fields. Please go <a href = \"text_search.php\">back</a> to text search page and review your submission.<br><br><br><br><br><br><br><br>";} $all_references=''; foreach ($array_references as $value_references) { $value_references=trim($value_references); $all_references = $all_references."reference.reference_code ='".$value_references."' OR "; } $final_references_addition = substr($all_references, 0, -4); // remove the ' OR ' in the end $wclause[]= $final_references_addition; } else { $wclause[]="reference.reference_code ='".$references."' "; } } if($references_pmid!="") { if(strstr($references_pmid, ',', true)) { $array_references_pmid = explode(",", $references_pmid); $count_references_pmid = count ($array_references_pmid); if ($count_references_pmid>5) {print "<br><br><br><br>You specified more than 5 terms in one or more text fields. Please go <a href = \"text_search.php\">back</a> to text search page and review your submission.<br><br><br><br><br><br><br><br>";} $all_references_pmid=''; foreach ($array_references_pmid as $value_references_pmid) { $value_references_pmid=trim($value_references_pmid); $all_references_pmid = $all_references_pmid."families.families_pubmed LIKE '%".$value_references_pmid."%' OR "; } $final_references_pmid_addition = substr($all_references_pmid, 0, -4); // remove the ' OR ' in the end $wclause[]= $final_references_pmid_addition; } else { $wclause[]="families.families_pubmed LIKE '%".$references_pmid."%' "; } } if($family>0) { $wclause[]="protein.protein_families_id ='".$family."' "; } if($signal!="ALL" && $signal!="") { $wclause[]="protein.protein_sp_quality ='".$signal."' "; } if($frag == "N") { $wclause[]="protein.protein_isfragment ='".$frag."' "; } switch($combination) { case "combined": $wclause_sql = implode(" AND ", $wclause); break; case "separate": $wclause_sql = implode(" OR ", $wclause); break; } //if(isset($_POST['sql'])) //{ //$query_total = "SELECT DISTINCT protein.protein_id, protein.protein_name, ". // "protein.protein_seq_len, protein.protein_organism, protein_ncbi FROM protein ". // "LEFT JOIN protein_reference ON protein_reference.prot_ref_protein_id = protein.protein_id ". // "LEFT JOIN reference ON reference.reference_id = protein_reference.prot_ref_reference_id ". // "LEFT JOIN families ON protein.protein_families_id = families.families_id ". // "WHERE ".$_POST['sql']; //} //else //{ $query_total = "SELECT DISTINCT protein.protein_id, protein.protein_name, ". "protein.protein_seq_len, protein.protein_organism, protein_ncbi FROM protein ". "LEFT JOIN protein_reference ON protein_reference.prot_ref_protein_id = protein.protein_id ". "LEFT JOIN reference ON reference.reference_id = protein_reference.prot_ref_reference_id ". "LEFT JOIN families ON protein.protein_families_id = families.families_id ". "WHERE ".$wclause_sql; //} print "QUERY: $query_total<br>"; $text_result = mysql_query($query_total) or die("<br><br><br><br>Non-acceptable query. Please go <a href = \"text_search.php\">back</a> to text search page.<br><br><br><br><br><br><br><br></td></div></tr>"); $number_results = mysql_num_rows($text_result); if ($number_results==0) { echo "<tr><td colspan=\"5\"><br><br><br><br><i>No records matching your query were found<br><br><br><br><br><br><br><br><br><br></i></td></tr>\n"; } else { // number of rows to show per page $rowsperpage = 25; // find out total pages $totalpages = ceil($number_results / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $newpage = (int)$_GET['currentpage']; } else { // default page num $newpage = 1; } // end if // modify the requested page based on any pagination form buttons, set/clear any remembered session checkbox data $page = isset($_POST['page']) ? trim($_POST['page']) : false; if($page){ // values of <<, <, x, >, or >> switch($page){ case '<< First': $newpage = 1; break; case '< Previous': $newpage--; break; case 'Next >': $newpage++; break; case 'Last >>': $newpage = $totalpages; break; default: // not one of the symbols, should be a number $page = intval($page); if($page > 0){ $newpage = $page; } break; } // set or clear the state of the check boxes in $_SESSION['choice'] // $_SESSION['ids'] = array of ids on the page that submitted foreach($_SESSION['ids'] as $key){ if(isset($_POST['choice'][$key])){ $_SESSION['choice'][$key] = 1; } elseif (isset($_SESSION['choice'][$key])) { unset($_SESSION['choice'][$key]); } } header("location: {$_SERVER['SCRIPT_NAME']}?currentpage=$newpage"); // clear post data exit; } // if current page is greater than total pages... if ($newpage > $totalpages) { // set current page to last page $newpage = $totalpages; } // end if // if current page is less than first page... if ($newpage < 1) { // set current page to first page $newpage = 1; } // end if /****** build the pagination links ******/ // range of num links to show $range = 3; $links = ''; // if not on page 1, don't show back links if ($newpage > 1) { // show << link to go back to page 1 $links .= "<input type='submit' name='page' value='<< First'>"; // show < link to go back 1 page $links .= "<input type='submit' name='page' value='< Previous'>"; } // end if // loop to show links to range of pages around current page for ($x = ($newpage - $range); $x < (($newpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $newpage) { // 'highlight' it but don't make a link $links .= " [<b>$x</b>] "; // if not current page... } else { $links .= "<input type='submit' name='page' value='$x'>"; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($newpage != $totalpages) { // echo forward link for next page $links .= "<input type='submit' name='page' value='Next >'>"; // echo forward link for lastpage $links .= "<input type='submit' name='page' value='Last >>'>"; } // end if /****** end build pagination links ******/ /****** get the actual database content for the requested page ******/ // the offset of the list, based on current page $offset = ($newpage - 1) * $rowsperpage; /* LIMITED SQL QUERY */ $query_limited = $query_total." LIMIT $offset, $rowsperpage"; $result_limited = mysql_query($query_limited); echo "<form name=\"srs_form\" action='?currentpage=$newpage' method='post'>"; $counter_color=0; echo "<tr><td class=\"headcell\" colspan=\"6\">Text search results</td></tr><tr><td><br></td></tr>\n"; echo "<tr>\n"; echo "<td width=\"10%\" class=\"browse_cell\">Select entries</td>". "<td width=\"15%\" class=\"browse_cell\">View Entry</td>". "<td width=\"30%\" class=\"browse_cell\">Description</td>". "<td width=\"33%\" class=\"browse_cell\">Organism</td><td width=\"12%\" class=\"browse_cell\">Length</td>"; echo "</tr>\n"; $ids_this_page = array(); // a list of the checkbox id's on this page while ($list = mysql_fetch_assoc($result_limited)) { echo "<tr>\n"; $counter++; if ($counter % 2) {$colour_class="browse_cell_change1";} else {$colour_class="browse_cell_change2";} $code = $list['protein_id']; $name_cell = $list['protein_name']; $length_cell = $list['protein_seq_len']; $organism_cell = $list['protein_organism']; $taxonomy_cell = $list['protein_ncbi']; $checked = isset($_SESSION['choice'][$list['protein_id']]) ? " checked='checked'" : ''; $ids_this_page[] = $list['protein_id']; echo "<td width=\"10%\" class=".$colour_class."><input type='checkbox' name='choice[{$list['protein_id']}]' value=".$list['protein_id']."><br />"; echo "<td width=\"15%\" class=".$colour_class."_left><a href=\"entry.php?code=".$code."\">DBID: ".$code."</a>"; echo "<td width=\"30%\" class=".$colour_class."_left>".$name_cell."</td>\n"; echo "<td width=\"33%\" class=".$colour_class."_left><a href=\"retrieve_text.php?taxid=".$taxonomy_cell."\">".$organism_cell."</a>"; echo "<td width=\"12%\" class=".$colour_class.">".$length_cell."</td>\n"; echo "</tr>\n"; } $_SESSION['ids'] = $ids_this_page; $total_selected=count($_SESSION['choice']); echo "<tr><td><br><input type = \"submit\" value = \"Retrieve\"></td>"; echo "<td colspan='4'><br>".$links."<br/></td></tr>"; echo "<tr><td><input type=\"hidden\" name=\"sql\" value=\"".$wclause_sql."\"></td></tr>"; echo "</form>"; } } ?> </tbody> </table> </div> </td> </tr> </tbody> </table> </div> </body> </html> My problem is that, although the state of the selected entries is maintained as the user browses from page to page, this is NOT the case for the $wclause_sql part, which is actually the "WHERE" clause of the sql query. So I can only see the first page, and not the others... I used sessions in order to keep track which records are selected by the user, so as when the user finally hits 'Retrieve' he can get all the desired entries, but I cannot transfer the $wclause and therefore, in all other pages except page 1, the SQL query is empty, thus no entries are shown. What am I missing here?
  6. Hi I have a results page from a MySQL query and I have implemented pagination to present data in chunks of 25 per page in a table view (each row => 1 entry). My problem is that next to each data row, I have a selection checkbox, and if the user clicks on it, he can download the selected entries. This thing worked OK before I employed paginated view, when I presented all data in one page. Now, if I select e.g. 2 entries in page 1, then I jump to page 12 and select another 2 entries, if I click on the "Retrieve" button, I get only the last 2 entries (from the last page visited). How can I solve this problem? With JS? Can I use PHP only?
  7. Hi guys, well I'm trying to formulate pagination view of my results from a Mysql query in my database. The thing is that the query is not known beforehand, since the user of the database can enter several search terms in text fields of the webpage (text_search.php) and when he hits the "Submit" button, the new page (retrieve_text.php) looks about which text fields have been filled and appends the values in the mysql query like this: $text_query = ...... WHERE [user-defined conditions] Everything is OK until now. But I wanted to show the results more clear to the user, since it can have e.g 600 results so it's not so good to view them in a loooooooooong page. So I tried to paginate them. Now comes the problem: the first page looks Ok, and brings only 25 results, which I want to be the limit of results to show per page. BUT, when I click on the "Next button", I see nothing. The reason? In pages 2,3...N, the $text_query is empty since there are no values submitted through the $_POST variable..., So, in the 1st page, if I print the SQL query I have something like that: SELECT DISTINCT protein.protein_id, protein.protein_name FROM protein LEFT JOIN protein_reference ON protein_reference.prot_ref_protein_id = protein.protein_id LEFT JOIN reference ON reference.reference_id = protein_reference.prot_ref_reference_id LEFT JOIN families ON protein.protein_families_id = families.families_id WHERE protein.protein_name LIKE '%protein%' ORDER BY protein.protein_id LIMIT 0, 25 while in the 2nd page for example I get: SELECT DISTINCT protein.protein_id, protein.protein_name, protein.protein_seq_len, protein.protein_organism, protein_ncbi FROM protein LEFT JOIN protein_reference ON protein_reference.prot_ref_protein_id = protein.protein_id LEFT JOIN reference ON reference.reference_id = protein_reference.prot_ref_reference_id LEFT JOIN families ON protein.protein_families_id = families.families_id WHERE ORDER BY protein.protein_id LIMIT 25, 25 The reason is, as I wrote before, that the where clause in the sql statement is written on-the-fly so the sql search is dynamic and not static. If it was static, like SELECT * from protein WHERE name LIKE '%protein%'; things would be straight-forward. What can I do? Should/Could I somehow "send" the sql query from page to page? I suppose this is BAD practice, but I don't really know how to proceed...
  8. Hi! I want Apache Tomcat to be able to "see" my site... Whereas when I store a website folder under /srv/www/htdocs/ (for example /srv/www/htdocs/MYSITE) and change permissions it's visible immediately, when I do the same in /srv/www/tomcat5/base/webapps/ROOT/MYSITE , even if I make the folder have 777 permissions, i get the response: Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. Must I specify something for Apache tomcat to see this new folder? And where? In some configuration file maybe?
  9. Hello! I am executing an external command from a PHP script, using the exec function. Since this program can take more than 1-2 minutes to run, I thought I should use a "Loading page...please wait". What I need is to be able to get the process id from the external program that is being run and, when this finishes, I'll start outputting the results. Is there a way to do this?
  10. Hello all! I have 2 things that I want to show/hide using JS. <html> <head> <title>Hidden Div</title> <script language="JavaScript"> function showstuff(boxid){ document.getElementById(boxid).style.visibility="visible"; } function hidestuff(boxid){ document.getElementById(boxid).style.visibility="hidden"; }</script> </head> <body> <a href="#" onclick="showstuff('one'); hidestuff('two');">Show ONE</a> <a href="#" onclick="showstuff('two'); hidestuff('one');">Show TWO</a> <div id="one" style="display:none" >ONE.</div> <div id="two" style="display:none">TWO.</div> </body> </html> If I use it as it is I don't see anything! If I don't use style="display:none" inside the divs, I see them both initially and I can hide/show each one depending on which link I press. But the thing is that I need both divs to be hidden in the first place, and when I click on ONE, to show TWO, when I click on TWO to hide ONE and show TWO etc. Each time 1 div should be visible, depending on which link we press. The other must disappear.
  11. Hello, I have a php page that the user enters some data in a textarea, and then this data is fed into a command line program. When the execution of the command line programm finishes, the results are stored in an output file that is created. The "results" php page then reads this file and the user views the results. My problem is that sometimes (depending on the amount of data inserted and, subsequently the size of the output file created by the command-line programm), the php results page crushes, outputting error like: Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 846269 bytes) in /results.php on line 125 In this line of the script, I read the whole file into a string and then separate each result chunk by a separator (//) that the command line programm creates: $res_handle= fopen($output_file, "r"); $results = fread($res_handle, filesize($output_file)); fclose($res_handle); $separated_entries = explode ("//", $results); Then, foreach chunk, I output the results to the user. Is there something that I must configure in php so that it won't have memory problems? Or another way to slurp the total output file without exhausting the memory? thank you!
  12. Hello, I wanted to ask if you have a string like: $my_s='ASRGREGTGTR----REGREGRE+++RRRRRR....'; is there a way to count the length of the string, excluding non-word characters (+,- or .)? thank you
  13. Hello all! I wanted to ask if there is a way to specify certain width sizes for table cells in a table. The thing is that I have a table in one webpage that, if I leave the width of the TD cells unspecified, I usually end up with some cells being very wide because the text that is written inside them is very big and does not roll up automatically and other cells shrink and become very small in order for the total table not to lose its specified length. Can I set a specific width for the cell that gets filled with many words so that the contents of this cell will wrap and not extend so much? Thank you!
  14. Hello all, on the server machine I am working, there is for some unexplained reason both PHP4 and PHP5 installed. Actually, for PHP4, there is only the PHP4-core files as I saw in the administration panel. However, I have a script that has shown some errors when being executed via PHP4 but works ok when PHP5 takes over. My question is, is there a way to "tell" Apache that I want to use only PHP4? The weird thing is that there's only the php5_apache2 module installed, but when I write in a terminal : php -v , I get: PHP 4.3.10 (cli) (built: Apr 23 2005 04:10:27) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies and also, when I ran: which php , I get: /usr/bin/php but I can see that there is also /usr/bin/php5 there. And if I write: php5 -v , I get: PHP 5.0.3 (cgi) (built: Apr 23 2005 08:18:44) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies Is there something in the Apache configuration file that I must change so that Apache will use Php5 only? Thank you!
  15. Hello, I have a list of numbers that can be in format like: 8.8458e-119 1.06542e-52 2.68e-36 2.91405e-35 0.0190644 0.0205511 0.004 Is there something you can suggest me that I use to have some more "elegance" appearance, i.e: 8.84e-119 1.06e-52 2.68e-36 2.91e-35 0.019 0.02 0.004 ? Note that I have all these number formats and I want to use a command that could apply to all of them.
  16. Hello all! Is there a way to remove the last line in a text file? Or, alternatively, is there a way to read a text file until the penultimate line of the file? That is, if you have a file like: AAAA BBBB CCCC DDDD XXXXXXXX read all lines except the last one? In the previous example I need to hold only AAAA, BBBB , CCCC and DDDD. Thank you!
  17. Hello, I need to know if there is a way of preserving the exact format of data that is send through a textarea. The data is send via $_POST variable from the submit page, and is written in a file. However, when I see the output file, I get: MKKTAIAIAVALAGFATVAQAAPKDNTWYTGAKLGWSQYHDTGFINNNGPTHENQLGAGA FGGYQVNPYVGFEMGYDWLGRMPYKGSVENGAYKAQGVQLTAKLGYPITDDLDIYTRLGG MVWRADTKSNVYGKNHDTGVSPVFAGGVEYAITPEIATRLEYQWTNNIGDAHTIGTRPDN GMLSLGVSYRFGQGEAAPVVAPAPAPAPEVQTKHFTLKSDVLFNFNKATLKPEGQAALDQ LYSQLSNLDPKDGSVVVLGYTDRIGSDAYNQGLSERRAQSVVDYLISKGIPADKISARGM GESNPVTGNTCDNVKQRAALIDCLAPDRRVEIEVKGIKDVVTQPQA instead of MKKTAIAIAVALAGFATVAQAAPKDNTWYTGAKLGWSQYHDTGFINNNGPTHENQLGAGA FGGYQVNPYVGFEMGYDWLGRMPYKGSVENGAYKAQGVQLTAKLGYPITDDLDIYTRLGG MVWRADTKSNVYGKNHDTGVSPVFAGGVEYAITPEIATRLEYQWTNNIGDAHTIGTRPDN GMLSLGVSYRFGQGEAAPVVAPAPAPAPEVQTKHFTLKSDVLFNFNKATLKPEGQAALDQ LYSQLSNLDPKDGSVVVLGYTDRIGSDAYNQGLSERRAQSVVDYLISKGIPADKISARGM GESNPVTGNTCDNVKQRAALIDCLAPDRRVEIEVKGIKDVVTQPQA Should I add something in my php submit page in the textarea part or is it something I have to do with the data before I write it in the file? Thank you
  18. Hello, I have a page with a textbox that I want to have a message written inside it that will dissapear when the user clicks in the text box and writes something and it will show up again if the user clicks somewhere else but hasn't written anything inside the textbox. So I am using the onfocus event in order to write "Enter your email here" and the onfocus event in order to show the "Enter your email here" message inside the textbox if the user clicks somewhere else in the webpage but has left the textbox blank. If however the user has written, for example "jim@yahoo.com", I want this to remain in the textbox. What am I doing wrong? <html> <head> <script language="javascript" type="text/javascript"> function clearPassword() { document.getElementById('sample').setAttribute('class', 'empty'); document.getElementById('sample').value = ''; } function restorePassword() { var given_text= document.getElementById('sample').value; if (given_text='') { document.getElementById('sample').setAttribute('class', 'grayedOut'); document.getElementById('sample').value = 'Enter your email'; } else { document.getElementById('sample').setAttribute('class', 'empty'); document.getElementById('sample').value = given_text; } } </script> </head> <body> <form > <input id="sample" type="text" value="Enter your email" size="22" class="grayedOut" onfocus="javascript:clearPassword();" onblur="javascript:restorePassword();"/> <input id="new" type="text"/> </form> </body> </html>
  19. Thank you very much, It was on the manual... I saw it afterwards!
  20. Hello all I wanted to ask if there is a way of inserting some mathematics in an SQL select statement. What I am interested in is to select all rows from a table where 56<ID<67 for example. Thank you
  21. Hi, thanx to you all for your answers! But my question remains: will these data types you suggested be able to store numbers like -1235456.754 or 645E-45 or 23.6 without any problem? As I said before, I CAN'T know beforehand what kind of number will the user enter, how many integer digits will it have, how many decimal places or if it will be negative or positive... And I MUST store the number exactly as it will be provided.
  22. Hello all! I have a field in my Mysql db which can store various numeric types, like 123, -45.74423, 23e-56 etc, and for those numbers, I can't know if they will be float, integers, positive or negative or how many decimal digits they may have. My question is, should I use something like VARCHAR (100) as data type for this column? If, in a query, I want to select all numbers that are >50 for example, will the comparison work or there will be a problem because I would have stored the numbers as VARCHAR? Please advice!
  23. Hello all! I am very new to Java programming and have came up with my first problem: I have a file which has several lines, similar to: ATOM 1 N SER P 71 -47.333 0.941 8.834 1.00 52.56 N ATOM 2 CA THR P 71 -45.849 0.731 8.796 1.00 53.56 C ATOM 3 C TRY P 71 -45.191 1.608 7.714 1.00 51.61 C What I want to do is, while reading the text file, find all lines that begin with ATOM and store the 3 letters (in this example SER, THR, TRY) along with the numbers close to them (in this example -47.333, -45.849 and -45.191 respectively). Once the array is constructed, we need to find the lowest and the highest value of it and substract them. Could you point me out to some guidelines please? Thank you in advance!
  24. Hello all! I need to run a script periodically to get some updates, so I thought I should better place it under the cron jobs. I have 2 questions: a) This is rather silly maybe... If I schedule the script to be executed every Tuesday at 4pm for example, and the pc is turned off at that time, this means that the script will be not executed for this Tuesday and it will have to wait another week to be executed again? b) It is wise to set "root" user as the user for the specific program to make sure that it has all the necessary permissions to download my updates in any folder I specify in the script? I mean, if I set a plain, restricted user as the user that runs the script, I may face problem if the script saves its downloads in /usr/local/share for example, where the plain user normally does not have write access. Thank you
  25. Hello, I have a php page with a button which I want to use in order to send data to a jsp page. The code for the button in the php page is : echo "<td align=\"center\"><form method=\"post\" action=\"http://mysite.blabla.com/input.jsp\">". "<input class=\"formbutton\" type=\"submit\" value=\"Run program\"/>". "<input type=\"hidden\" name=\"formInput\" value=\">".$code."\n".$sequence."\"/>". "</form></td></tr>\n"; and I use the code above in order to fill data in the textarea in the jsp page. Tha code in the input.jsp page is: <td> <textarea class="small" name="formInput" ></textarea> </td> The problem is that I do not see any data being written in the textarea when I press the button... PS: Both $code and $sequence have values and I can see them if I print them in my php page...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.