Error: No job submitted.

"; footer(); exit; } if ($searchType == 'advanced') { $expect=(empty($_POST['expect'])) ? 10 : $_POST['expect']; $wordSize = (empty($_POST['wordSize'])) ? '' : $_POST['wordSize']; $targetSeqs = (empty($_POST['targetSeqs'])) ? '' : $_POST['targetSeqs']; $mmScore = (empty($_POST['mmScore'])) ? '' : $_POST['mmScore']; $matrix = (empty($_POST['matrix'])) ? '' : $_POST['matrix']; $gapCost = (empty($_POST['gapCost'])) ? '' : $_POST['gapCost']; $filter = (empty($_POST['filter'])) ? 'F' : $_POST['filter']; $softMask = (empty($_POST['softMask'])) ? 'F' : $_POST['softMask']; $lowerCaseMask = (empty($_POST['lowerCaseMask'])) ? 'F' : $_POST['lowerCaseMask']; $ungapAlign = (empty($_POST['ungapAlign'])) ? 'F' : $_POST['ungapAlign']; $alignmentView = (empty($_POST['outFmt'])) ? 0 : $_POST['outFmt']; $geneticCode = (empty($_POST['qCode'])) ? '' : $_POST['qCode']; $dbGeneticCode = (empty($_POST['dbCode'])) ? '' : $_POST['dbCode']; $otherParam = (empty($_POST['OTHER_ADVANCED'])) ? '' : $_POST['OTHER_ADVANCED']; if ($otherParam) { if (!preg_match("/^\s+$/", $otherParam) && !preg_match("/^\s*\-[A-Za-z]/", $otherParam)) { echo "Error: The other advanced options must start with \"-\""; exit; } } $advanceParam = "$expect!#%$wordSize!#%$targetSeqs!#%$mmScore!#%$matrix!#%$gapCost!#%$filter!#%$softMask!#%$lowerCaseMask!#%$ungapAlign!#%$alignmentView!#%$geneticCode!#%$dbGeneticCode!#%$otherParam"; }else { $advanceParam = ""; } if (!$alignmentView) { $alignmentView = 0; } if($blast_flag == 1) { $nlstr = chr(10); $crstr = chr(13); if($_FILES['queryfile']['name']) { $uploadfile = "$dataPath/$jobid.blastinput.txt"; if (move_uploaded_file($_FILES['queryfile']['tmp_name'], $uploadfile)) { }else { print "Couldn't upload the file. Here's some debugging info:\n"; print_r($_FILES); exit; } @ $fp = fopen($uploadfile, "r"); if(!$fp) { echo "

Error: couldn't open $uploadfile

"; exit; } $buffer = fread($fp, filesize($uploadfile)); fclose($fp); if(!preg_match("/>/", $buffer)) { echo "

Error: The uploading sequence file is not in fasta format. Please format your sequence file and upload again.


"; exit; }else{ if(!preg_match("/$nlstr/", $buffer)) { $buffer_mod = str_replace($crstr, $nlstr, $buffer); $buffer = $buffer_mod; } $i = 0; while(substr($buffer, $i, 1) != ">") { $i++; } $buffer = substr($buffer, $i); @ $fp = fopen($uploadfile, "w", 1); if(!$fp) { echo "

Error: ouldn't open $uploadfile

"; exit; } fwrite($fp, $buffer); fclose($fp); } }elseif($querySeq && !preg_match("/^\s+$/", $querySeq)) { @ $fp1=fopen("$dataPath/$jobid.blastinput.txt", "w",1); if (!$fp1) { echo "

Error: couldn't open $dataPath/$jobid.blastinput.txt

"; exit; } fwrite($fp1, $querySeq); fclose($fp1); }else { echo "

Error: please enter your query sequence or upload your fasta sequence file.


"; exit; } if(!$_FILES['blastagainstfile']['name'] && !$patientIDarray[0]) { echo "

Error: please choose database(s) or upload your fasta sequence file to blast against.


"; exit; } if($_FILES['blastagainstfile']['name']) { $uploadfile = "$dataPath/$jobid.blastagainst.txt"; if (move_uploaded_file($_FILES['blastagainstfile']['tmp_name'], $uploadfile)) { }else { print "Couldn't upload file. Here's some debugging info:\n"; print_r($_FILES); exit; } @ $fp = fopen($uploadfile, "r"); if(!$fp) { echo "

Error: ouldn't open $uploadfile

"; exit; } $buffer = fread($fp, filesize($uploadfile)); fclose($fp); if(!preg_match("/>/", $buffer)) { echo "

Error: The uploading sequence file to blast against is not in fasta format. Please format your sequence file and upload again.


"; exit; }else{ if(!preg_match("/$nlstr/", $buffer)) { $buffer_mod = str_replace($crstr, $nlstr, $buffer); $buffer = $buffer_mod; } $i = 0; while(substr($buffer, $i, 1) != ">") { $i++; } $buffer = substr($buffer, $i); @ $fp = fopen($uploadfile, "w", 1); if(!$fp) { echo "

Error: ouldn't open $uploadfile

"; exit; } fwrite($fp, $buffer); fclose($fp); } } } if($cutoffType == 'pct') { $criterion = $pct_cutoff; } if($cutoffType == 'blst') { $criterion = $blst_cutoff; } if(!$opt || $opt == 'wait') { $progressdot = "image/progressdot.png"; echo "

Your job is being processed "; for($i = 0; $i <= ($dot%6); $i++) { echo ""; } echo "

"; $dot += 1; echo "

Your job id is $jobid.

"; echo "

Please wait here to watch the progress of your job.

"; echo "

This page will update itself automatically until search is done.

"; } if(!$opt || $opt == 'wait') { echo ""; echo ""; } if($blast_flag == 1) { $blastagainst = ""; if ($program == "blastn" || $program == "tblastn" || $program == "tblastx") { $dbPath = "C:/inetpub/wwwroot/webclient/db/nucleotide"; }else { $dbPath = "C:/inetpub/wwwroot/webclient/db/protein"; } if($blastagainstfile) { $blastagainst = "$dataPath/$jobid.blastagainst.txt"; } if ($patientIDarray) { for ($i = 0; $i < sizeof($patientIDarray); $i++) { $blastagainst .= " $dbPath/$patientIDarray[$i]"; } } $blastpath = "C:/inetpub/wwwroot/webclient/blast/bin"; $basicParam = "$jobid\t$searchType\t$blastagainst\t$program\t$blastpath"; /*create child process to run perl script which do the blast search and write output data to apropriate files*/ /* For windows */ pclose(popen("start /b perl blast.pl \"$basicParam\" \"$advanceParam\"", "r")); } /* error log if there is error in BLAST */ $errFile = "$dataPath/$jobid.err"; /* parent process continue here to check child process done or not */ $filename = "$dataPath/$jobid.blaststring.txt"; if (file_exists($errFile) && filesize($errFile) > 0) { if(!$opt || $opt == 'wait') { echo ""; }else { echo "

There is error in executing BLAST. Following is the error message:

"; $fperr = fopen("$dataPath/$jobid.err", "r"); if(!$fperr) { echo "

$jobid.err error: $errors

"; exit; } while (!feof($fperr)) { $line = rtrim(fgets($fperr)); echo "$line
"; } fclose($fperr); } }elseif(file_exists($filename)) { if ($alignmentView) { echo ""; }else { if($blast_flag == 'Parse again') { $print_flag = 0; $cutoff_count = 0; @ $fpout=fopen("$dataPath/$jobid.par", "r"); if (!$fpout) { echo "

$jobid.par error: $phperrormsg

"; exit; } @ $fpout3 = fopen("$dataPath/$jobid.out.par", "w", 1); if(!$fpout3) { echo "

$jobid.out.par error: $errors

"; exit; } while (!feof($fpout)) { $fpout2_str = ''; $line = rtrim(fgets($fpout)); if (!$line) { continue; } list($page, $query_name, $match_name, $score, $identities, $percentage, $e_value, $link) = preg_split("/\t/", $line); if($cutoffType == 'pct') { $subject = $percentage; }else { $subject = $score; } if($subject >= $criterion) { fwrite($fpout3, "$page\t$query_name\t$match_name\t$score\t$identities\t$percentage\t$e_value\t$link\n"); $cutoff_count++; } } fclose ($fpout); fclose($fpout3); @ $fp = fopen("$dataPath/$jobid.blastcount.txt", "w", 1); if(!$fp) { echo "

error: $php_errormsg

"; exit; }else { fwrite($fp, "$cutoff_count\n"); } fclose($fp); } $filename = "$dataPath/$jobid.blastcount.txt"; while(!file_exists($filename)) {} if(!$opt || $opt == 'wait') { echo ""; }else { @ $fp = fopen("$dataPath/$jobid.blastcount.txt", "r"); if(!$fp) { echo "

error: $php_errormsg

"; exit; } if(!feof($fp)) { $cutoff_count = fgets($fp); } fclose($fp); @ $fp = fopen("$dataPath/$jobid.blaststring.txt", "r"); if(!$fp) { echo "

error: $php_errormsg

"; exit; } if(!feof($fp)) { $blastagainststring = rtrim(fgets($fp)); } fclose($fp); if($cutoff_count == 0) { echo "

No comparison meets cutoff criterion. Please change expect value to blast again.

"; }else { echo "

Inspect BLAST output
"; echo "

"; echo "

Filter current page by score:

"; echo "

   Show for each query sequence

"; echo "

Re-parse current blast results (please select cutoff criterion):

"; echo "

"; echo ""; echo ""; echo ""; echo ""; echo "
Similarity percentageCutoff %:
Blast scoreCutoff score: "; echo "

"; echo "
"; echo "
"; echo "

Retrieve and download subject sequences in FASTA format:

"; echo "

Check here to download All sequences... "; echo "OR select particular sequences of interest below

"; echo "

your selection of sequences to download

"; echo "

"; echo ""; echo ""; @ $fp = fopen("$dataPath/$jobid.download.txt", "w", 1) or die("Cannot open file: $jobid.download.txt"); if($blast_flag == 'Parse again' || ($opt == 'none' && !$filter_flag)) { @ $fpout3=fopen("$dataPath/$jobid.out.par", "r"); if(!$fpout3) { echo "

error: $php_errormsg

"; exit; } $i = 0; $queryName = $preQueryName = ""; while(!feof($fpout3)) { $row = fgets($fpout3); if (!$row) { continue; } $element = preg_split("/\t/", $row); $page = $element[0]; $queryName = $element[1]; $target_name = $element[7]; $var_target = $page."\t".$element[1]."\t".$element[2]; if(count($element) != 1) { if($queryName == $preQueryName) { $i++; }else { $i = 0; } if($i < 10) { echo ""; fwrite($fp, "$var_target\n"); } } $preQueryName = $queryName; } fclose($fpout3); } if($filter_flag == 'Filter') { @ $fpout3=fopen("$dataPath/$jobid.out.par", "r"); if(!$fpout3) { echo "

error: $php_errormsg

"; exit; } $i = 0; while(!feof($fpout3)) { $row = fgets($fpout3); if (!$row) { continue; } $element = preg_split("/\t/", $row); $page = $element[0]; $target_name = $element[7]; $var_target = $page."\t".$element[1]."\t".$element[2]; if(count($element) != 1) { if($filt_val != 0) { if($i == 0) { $query_name = $element[1]; echo ""; fwrite($fp, "$var_target\n"); $i++; }elseif($query_name == $element[1] && $i < $filt_val) { echo ""; fwrite($fp, "$var_target\n"); $i++; }elseif($query_name != $element[1]) { echo ""; $query_name = $element[1]; fwrite($fp, "$var_target\n"); $i=1; } }else { echo ""; fwrite($fp, "$var_target\n"); } } } fclose($fpout3); } fclose($fp); echo "
QuerySubjectScoreIdentities (Query length)PercentageExpect
$element[1]$target_name$element[3]$element[4]$element[5]$element[6]
$element[1]$target_name$element[3]$element[4]$element[5]$element[6]
$element[1]$target_name$element[3]$element[4]$element[5]$element[6]
$element[1]$target_name$element[3]$element[4]$element[5]$element[6]
$element[1]$target_name$element[3]$element[4]$element[5]$element[6]

"; echo "

Top"; } } } } ?>