FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Can anyone explain why I have this error?





kk_loke86
I am runniing a php page to extract data from data file (basically about 15MB), and the php page show me the following error.

Fatal error: Maximum execution time of 30 seconds exceeded in D:\wamp\www\Testing\feature_table_extraction.php

Can anyone tell me what this mean and how to solve it. Thanks for your kindness.
rvec
meaning the script was trying to execute the commands in it for 30 seconds and because of a setting in your php.ini it stopped working there.

You shouldn't set this setting too high (above 1min is high) because if you have some error in your script which would take it to execute forever and eat all your ram apache will just kill it, after the time set in your php.ini .

If you show us your script we can try to figure out if the error is because of an error in your script or just the big file.
AftershockVibe
Unless you're doing some crazy statistical analysis then reading a 15MB file shouldn't take that long.
Like rvec said, post your code and we'll see if we can find an error which is slowing it down or causing an infinite loop.

On the other hand, if you are doing some kind of crazy statistical analysis, I'd suggest you separate it into different operational segments and do each separately. Not only will this overcome the timeout but will let you know exactly where your script is taking the time.
kk_loke86
I am trying to extract many data from a raw text data file. This is basically what the format look like:

Code:
ID   1433A_HORVU             Reviewed;         262 AA.
AC   P29305;
DT   01-DEC-1992, integrated into UniProtKB/Swiss-Prot.
DT   01-DEC-1992, sequence version 1.
DT   26-FEB-2008, entry version 39.
DE   14-3-3-like protein A (14-3-3A).
OS   Hordeum vulgare (Barley).
OC   Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta;
OC   Spermatophyta; Magnoliophyta; Liliopsida; Poales; Poaceae; BEP clade;
OC   Pooideae; Triticeae; Hordeum.
OX   NCBI_TaxID=4513;
RN   [1]
RP   NUCLEOTIDE SEQUENCE [MRNA].
RC   STRAIN=cv. Pallas; TISSUE=Leaf;
RX   MEDLINE=93258422; PubMed=1302634;
RA   Brandt J.M., Thordal-Christensen H., Vad K., Gregersen P.L.,
RA   Collinge D.B.;
RT   "A pathogen-induced gene of barley encodes a protein showing high
RT   similarity to a protein kinase regulator.";
RL   Plant J. 2:815-820(1992).
CC   -!- INDUCTION: In response to penetration attempts of powdery mildew
CC       fungi.
CC   -!- SIMILARITY: Belongs to the 14-3-3 family.
CC   -----------------------------------------------------------------------
CC   Copyrighted by the UniProt Consortium, see http://     www.uniprot.org/terms
CC   Distributed under the Creative Commons Attribution-NoDerivs License
CC   -----------------------------------------------------------------------
DR   EMBL; X62388; CAA44259.1; -; mRNA.
DR   PIR; S18911; S18911.
DR   HSSP; P93343; 1O9E.
DR   SMR; P29305; 4-240.
DR   Gramene; P29305; -.
DR   InterPro; IPR000308; 14-3-3.
DR   Gene3D; G3DSA:1.20.190.20; 14-3-3; 1.
DR   PANTHER; PTHR18860; 14-3-3; 1.
DR   Pfam; PF00244; 14-3-3; 1.
DR   PIRSF; PIRSF000868; 14-3-3; 1.
DR   PRINTS; PR00305; 1433ZETA.
DR   ProDom; PD000600; 14-3-3; 1.
DR   SMART; SM00101; 14_3_3; 1.
DR   PROSITE; PS00796; 1433_1; 1.
DR   PROSITE; PS00797; 1433_2; 1.
PE   2: Evidence at transcript level;
FT   CHAIN         1    262       14-3-3-like protein A.
FT                                /FTId=PRO_0000058678.
SQ   SEQUENCE   262 AA;  29352 MW;  DAE722EA5D416DAA CRC64;
     MSTAEATREE NVYMAKLAEQ AERYEEMVEF MEKVAKTADV GELTVEERNL LSVAYKNVIG
     ARRASWRIIS SIEQKEESRG NEAYVASIKE YRTRIETELS KICDGILKLL DSHLVPSATA
     AESKVFYLKM KGDYHRYLAE FKAGAERKEA AENTLVAYKS AQDIALADLP TTHPIRLGLA
     LNFSVFYYEI LNSPDRACNL AKQAFDEAIA ELDSLGEESY KDSTLIMQLL RDNLTLWTSD
     NAEEGGDEIK EAASKPEGEG HS
//     
ID   1433A_SOYBN             Reviewed;         257 AA.
AC   Q96450;
DT   15-JUL-1998, integrated into UniProtKB/Swiss-Prot.
DT   01-FEB-1997, sequence version 1.
DT   26-FEB-2008, entry version 38.
DE   14-3-3-like protein A (SGF14A).
GN   Name=GF14A;
OS   Glycine max (Soybean).
OC   Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta;
OC   Spermatophyta; Magnoliophyta; eudicotyledons; core eudicotyledons;
OC   rosids; eurosids I; Fabales; Fabaceae; Papilionoideae; Phaseoleae;
OC   Glycine.
OX   NCBI_TaxID=3847;
RN   [1]
RP   NUCLEOTIDE SEQUENCE [MRNA].
RC   STRAIN=cv. Williams;
RA   Ryu G.R., Yoo C.M., Jeong H.J., Hong J.C.;
RL   Submitted (SEP-1996) to the EMBL/GenBank/DDBJ databases.
CC   -!- SIMILARITY: Belongs to the 14-3-3 family.
CC   -----------------------------------------------------------------------
CC   Copyrighted by the UniProt Consortium, see http://     www.uniprot.org/terms
CC   Distributed under the Creative Commons Attribution-NoDerivs License
CC   -----------------------------------------------------------------------
DR   EMBL; U70533; AAB09580.1; -; mRNA.
DR   PIR; T08840; T08840.
DR   UniGene; Gma.31571; -.
DR   HSSP; P93343; 1O9E.
DR   SMR; Q96450; 4-238.
DR   InterPro; IPR000308; 14-3-3.
DR   Gene3D; G3DSA:1.20.190.20; 14-3-3; 1.
DR   PANTHER; PTHR18860; 14-3-3; 1.
DR   Pfam; PF00244; 14-3-3; 1.
DR   PIRSF; PIRSF000868; 14-3-3; 1.
DR   PRINTS; PR00305; 1433ZETA.
DR   ProDom; PD000600; 14-3-3; 1.
DR   SMART; SM00101; 14_3_3; 1.
DR   PROSITE; PS00796; 1433_1; 1.
DR   PROSITE; PS00797; 1433_2; 1.
PE   2: Evidence at transcript level;
FT   CHAIN         1    257       14-3-3-like protein A.
FT                                /FTId=PRO_0000058701.
SQ   SEQUENCE   257 AA;  29049 MW;  76DB93EC9828F430 CRC64;
     MSDSSREENV YMAKLADEAE RYEEMVEFME KVAKTVEVEE LTVEERNLLS VAYKNVIGAR
     RASWRIISSI EQKEESRGNE DHVAIIKEYR GKIEAELSKI CDGILNLLES NLIPSAASPE
     SKVFYLKMKG DYHRYLAEFK TGAERKEAAE STLLAYKSAQ DIALADLAPT HPIRLGLALN
     FSVFYYEILN SPDRACNLAK QAFDEAISEL DTLGEESYKD STLIMQLLRD NLTLWTSDIT
     DIAGDEIKET SKQQPGE
//
kk_loke86
This is the coding for some extraction

Code:

<html>
   <head>
      <title>Testing</title>
   </head>

   <body>
   <?php
      $i=0;
      mysql_connect("localhost", "kkloke86_root", "protein") or die (mysql_error());
      mysql_select_db("protein2") or die (mysql_error());

      $filename="sample.dat";
      $lines = file($filename);
      foreach ($lines as $line){

         $fields=explode("   ", $line);

    if($fields[0]=="ID"){
            echo $i.")"."<br />";
            $prot_fnme="";                                 
            $prot_name="";
            $keyword="";
            $comment="";
            $prot_seq="";
            $ec_num="";
            $lineage="";
            $descrpt="";

            if(preg_match("/([0-9]+) AA/",$line,$matches)){
               $size=$matches[1];
            }   
            echo $prot_seq;
         }
 
         if($fields[0]=="DE"){
            $line=str_replace("DE","",$line);
            $firstnme=explode("(",$line);
            if($prot_fnme==""){
              $firstnme=explode(",",$firstnme[0]);
              $prot_fnme=$firstnme[0];
            }
            $prot_name=$prot_name.$fields[1];
            if(preg_match("/[0-9]+.[0-9]+.[0-9]+.[0-9]+/",$fields[1],$matches)){
               $ec_num=$matches[0];
            }
         }

         if($fields[0]=="CC"){
            $line=str_replace("CC","",$line);
            $comment=$comment.$line;
         }

         if($fields[0]=="OC"){
            $lineage=$lineage.$fields[1];
         }
         
         if($fields[0]=="GN"){
            $gene_name=$fields[1];
         }

         if($fields[0]=="FT"){
            $newline=str_ireplace("FT ","",$line);
            $newline=trim($newline);
            $newline=str_ireplace("  "," ",$newline);
            $newline=str_ireplace("  "," ",$newline);
            $newline=str_ireplace("  "," ",$newline);
            $newline=str_ireplace("  "," ",$newline);
            $newline=str_ireplace("  "," ",$newline);
            $array=explode(" ", $newline, 4);         
            if($array[1]==""){
              $descrpt=$descrpt.$array[0];
            }else{
              $strand=$array[0];
              $num1=$array[1];
              $num2=$array[2];
              $descrpt=$array[3];
            }
              echo "[strand]= ".$strand." [num1]= ".$num1." [num2]= ".$num2." [DE]=".$descrpt;
         }

         if($fields[0]=="KW"){
            $keyword=$keyword.$fields[1];
         }

         if($fields[0]=="OX"){
            if(preg_match("/[0-9]+/",$fields[1],$matches)){
               $ncbi_id=$matches[0];
            }
         }
       
    if($fields[0]=="OS"){
            $origins=$fields[1];
         }

         if($fields[0]=="SQ"){
            if(preg_match("/([0-9]+) MW/",$line,$matches)){
               $weight=$matches[1];
            }
         }

         if($fields[0]==""){
            $prot_seq=$prot_seq." ".trim($fields[1]);
         }
         
         if($fields[0]=="//"){
            print "<br />*********<br />";

            $sql = "INSERT INTO prot_info(name,size,mw,gene_name,ec_num,keyword,ncbi_taxon,description) " . "VALUES('$prot_fnme','$size','$weight','$gene_name','$ec_num','$keyword','$ncbi_id','$prot_name')";
            mysql_query($sql) or die (mysql_error());

            $sql = "INSERT INTO sequence(protein) "."VALUES('$prot_seq')";
            mysql_query($sql) or die (mysql_error());

            $sql="SELECT * FROM taxonomy WHERE ncbi_taxon='".$ncbi_id."'";
            $resultset=mysql_query($sql) or die(mysql_error());
            $row_num=mysql_num_rows($resultset);
            $row=mysql_fetch_assoc($resultset);
            extract($row);
            if($row_num!=1){
            $sql = "INSERT INTO taxonomy(ncbi_taxon,org_source,lineage) "."VALUES('$ncbi_id','$origins','$lineage')";
            mysql_query($sql) or die (mysql_error());
            }

            echo $prot_fnme."[NAME]";
            echo $prot_name."[DE]";         
            echo $size."[SIZE]";
            echo $weight."[MW]";
            echo $gene_name."[GN]";
            echo $keyword."[KW]";
            $comment2=str_ireplace("-----------------------------------------------------------------------","",$comment);
            $comment2=str_ireplace("Copyrighted by the UniProt Consortium, see http://     www.uniprot.org/terms","",$comment2);
            $comment2=str_ireplace("Distributed under the Creative Commons Attribution-NoDerivs License","",$comment2);
            $temp_cc=explode("-!-",$comment2);
            foreach($temp_cc as $temp_cc[$key]){
            $each_cc=explode(":",$temp_cc[$key]);
            if($each_cc[0] != ""){
                  echo $each_cc[0]." = ".$each_cc[1]."[CC]";
                }
             
            }
            echo $origins."[OS]";
            echo $lineage."[TAXON]";
            echo $ncbi_id."[NCBI_ID]";
            echo $ec_num."[EC_NUM]";
            echo $prot_seq."[SQ]";
            print "<br /><br />";
            $i++;

         }
                   
      }
   ?>
   </body>
</html>



kk_loke86
Code:

<html>
   <head>
      <title>Testing</title>
   </head>

   <body>
   <?php
      $i=0;
      mysql_connect("localhost", "kkloke86_root", "aminoacid") or die (mysql_error());
      mysql_select_db("protein2") or die (mysql_error());

      $filename="sample.dat";
      $lines = file($filename);
      foreach ($lines as $line){
         $fields=explode("   ", $line);

         if($fields[0]=="ID"){
           $db_name="";
           $db_ac_num="";
           $i++;
         }

         if($fields[0]=="DR"){
            echo "Record ".$i."<br /><br />";
 
            $text=explode(";",$fields[1]);
            $sql="SELECT db_id, db_name AS name FROM external_db WHERE db_name='$text[0]'";
            $resultset=mysql_query($sql) or die(mysql_error());
            $row_num=mysql_num_rows($resultset);
            $row=mysql_fetch_assoc($resultset);
            extract($row);
            print_r($row);
            echo $row_num;
            if($row_num==1){

               if($db_name==$text[0]){           
                  $db_ac_num=$db_ac_num.";".$text[1];
                  $sql="UPDATE prot_db SET acc_num = '".$db_ac_num."' WHERE db_id='".$db_id."' AND id='".$i."'";
                  mysql_query($sql) or die(mysql_error());
                  echo $db_ac_num;
               } else if($db_name!=""){         
                  $db_name=$text[0];
                  $db_ac_num=$text[1];

                  $sql="INSERT INTO prot_db(id,db_id,acc_num) "."VALUES('".$i."','".$db_id."','".$db_ac_num."')";
                  mysql_query($sql) or die(mysql_error());

                  echo $db_ac_num;
               } else{
                  $db_name=$text[0];
                  $db_ac_num=$text[1];
       
                  $sql="INSERT INTO prot_db(id,db_id,acc_num) "."VALUES('".$i."','".$db_id."','".$db_ac_num."')";
                  mysql_query($sql) or die(mysql_error());

               }
            }
                                 
         }


     




      }
   ?>
   </body>
</html>


kk_loke86
Code:

<html>
   <head>
      <title>Testing</title>
   </head>

   <body>
   <?php
      $i=0;
      mysql_connect("localhost", "kkloke86_root", "subunit") or die (mysql_error());
      mysql_select_db("protein2") or die (mysql_error());

      $filename="sample.dat";
      $lines = file($filename);
      foreach ($lines as $line){

         $fields=explode("   ", $line);

      if($fields[0]=="ID"){
           $db_name="";
           $db_ac_num="";
           $i++;
         }

      if($fields[0]=="FT"){
            $newline=str_ireplace("FT ","",$line);
            $newline=trim($newline);
            $newline=str_ireplace("  "," ",$newline);
            $newline=str_ireplace("  "," ",$newline);
            $newline=str_ireplace("  "," ",$newline);
            $newline=str_ireplace("  "," ",$newline);
            $newline=str_ireplace("  "," ",$newline);
            $array=explode(" ", $newline, 4);         
            if($array[1]==""){
              $descrpt=$descrpt.$array[0];
            }else{
              $strand=$array[0];
              $num1=$array[1];
              $num2=$array[2];
              $descrpt=$array[3];
            }

            $sql="SELECT * FROM feat_cat WHERE category='".$strand."'";
            $resultset=mysql_query($sql) or die(mysql_error());
            $row_num=mysql_num_rows($resultset);
            $row=mysql_fetch_assoc($resultset);
            extract($row);
            if($row_num==0){
              $sql="INSERT INTO feat_cat(category) "."VALUES('$strand')";
              mysql_query($sql) or die (mysql_error());

              $sql="SELECT * FROM feat_cat WHERE category='".$strand."'";
              $resultset=mysql_query($sql) or die(mysql_error());
              $row_num=mysql_num_rows($resultset);
              $row=mysql_fetch_assoc($resultset);
              extract($row);

              $sql="SELECT * FROM feature WHERE id='".$i."' AND strand_str='".$num1."' AND strand_end='".$num2."'";
              $resultset2=mysql_query($sql) or die(mysql_error());
              $row_num2=mysql_num_rows($resultset2);
              $row2=mysql_fetch_assoc($resultset2);
              extract($row2);
              print_r($row2);
              if($row_num2==0){
                $sql="INSERT INTO feature(id,feat_cat_id,strand_str,strand_end,description) VALUES('".$i."','".$feat_cat_id."','".$num1."','".$num2."','".$descrpt."')";
                mysql_query($sql) or die (mysql_error());
              }else if($row_num2==1){
                $sql="UPDATE feature SET description='".$descrpt."' WHERE id='".$id."' AND strand_str='".$num1."' AND strand_end='".$num2."'";
                mysql_query($sql) or die (mysql_error());
              }

            }else if($row_num==1){

              $sql="SELECT * FROM feature WHERE id='".$i."' AND strand_str='".$num1."' AND strand_end='".$num2."'";
              $resultset2=mysql_query($sql) or die(mysql_error());
              $row_num2=mysql_num_rows($resultset2);
              $row2=mysql_fetch_assoc($resultset2);
              extract($row2);

              if($row_num2==0){
                $sql="INSERT INTO feature(id,feat_cat_id,strand_str,strand_end,description) VALUES('".$i."','".$feat_cat_id."','".$num1."','".$num2."','".$descrpt."')";
                mysql_query($sql) or die (mysql_error());
              }else if($row_num2==1){
                $sql="UPDATE feature SET description='".$descrpt."' WHERE id='".$id."' AND strand_str='".$num1."' AND strand_end='".$num2."'";
                mysql_query($sql) or die (mysql_error());
              }             
            }

              echo "[strand]= ".$strand." [num1]= ".$num1." [num2]= ".$num2." [DE]=".$descrpt;
         }

      }
   ?>
   </body>
</html>
kk_loke86
Code:

<html>
   <head>
      <title>Testing</title>
   </head>

   <body>
   <?php
      $i=0;
      mysql_connect("localhost", "kkloke86_root", "aminoacid") or die (mysql_error());
      mysql_select_db("protein2") or die (mysql_error());

      $filename="sample.dat";
      $lines = file($filename);
      foreach ($lines as $line){

         $fields=explode("   ", $line);

         if($fields[0]=="ID"){
           $comment="";
           $i++;
         }

         if($fields[0]=="CC"){
            $line=str_replace("CC","",$line);
            $comment=$comment.$line;
         }

         if($fields[0]=="//"){
            $comment2=str_ireplace("-----------------------------------------------------------------------","",$comment);
            $comment2=str_ireplace("Copyrighted by the UniProt Consortium, see http://     www.uniprot.org/terms","",$comment2);
            $comment2=str_ireplace("Distributed under the Creative Commons Attribution-NoDerivs License","",$comment2);
            $temp_cc=explode("-!-",$comment2);
            foreach($temp_cc as $temp_cc[$key]){
               $temp_cc[$key]=trim($temp_cc[$key]);
               $temp_cc[$key]=str_ireplace("  ","",$temp_cc[$key]);
               $temp_cc[$key]=str_ireplace("  ","",$temp_cc[$key]);
               $each_cc=explode(":",$temp_cc[$key]);
               if($each_cc[0] != ""){

                  $sql="SELECT * FROM prop_cat WHERE category='".$each_cc[0]."'";
                  $resultset=mysql_query($sql) or die(mysql_error());
                  $row_num=mysql_num_rows($resultset);
                  $row=mysql_fetch_assoc($resultset);
                  extract($row);

                  if($row_num==0 && $each_cc[0]!=""){
                    $sql="INSERT INTO prop_cat(category) VALUES('".$each_cc[0]."')";
                    mysql_query($sql) or die (mysql_error());         

                    $sql="SELECT * FROM prop_cat WHERE category='".$each_cc[0]."'";
                    $resultset=mysql_query($sql) or die(mysql_error());
                    $row_num=mysql_num_rows($resultset);
                    $row=mysql_fetch_assoc($resultset);
                    extract($row);

                    $sql="INSERT INTO properties(id,category_id,comment) VALUES('".$i."','".$category_id."','".$each_cc[1]."')";
                    mysql_query($sql) or die (mysql_error());

                  }else if($row_num==1){

                    $sql="INSERT INTO properties(id,category_id,comment) VALUES('".$i."','".$category_id."','".$each_cc[1]."')";
                    mysql_query($sql) or die (mysql_error());
                     
                  }
                  echo $each_cc[0]." = ".$each_cc[1]."[CC]";
               }
             
            }   
         }

      }
   ?>
   </body>
</html>
rvec
Please keep it all in one post.
And I hope someone is going to help you, but you'd have a better chance if you put it all in a zip file, put it on your space and give a link here.

Also post exactly what you want the script to do, so someone might even rewrite the script to something better.
AftershockVibe
First thing to do is see if it works on just one of the items. Strip out all but the first entry (remove everything after the first line from the file) so you only have everything up to the first line that begins "\\".

Secondly, you might want to edit out the passwords and usernames you've left in the code. You might want to delete your repetitions of posts too. Code appears to be the same at a quick glance.
Cool
Related topics
can anyone explain me what happens?
Can anyone explain delta-epsilon method?
Problem with Cache
Bleeping dialog
Simple Numerology Puzz
Pluto is no longer a planet
Evolution, the religion
Eventlog found Error...
anyone else ever get this?
FTP Timeing Out.
PHP Parse error on form handling - New to PHP
When Jesus was born...
Does anyone know why this is happening?
Why did the great ALEXANDER could not enter India?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.