printDebugMessage('printGetParameters', 'Begin', 1); $paramList = $this->getParameters(); print "\n"; $this->printDebugMessage('printGetParameters', 'End', 1); } // Print details of a parameter function printGetParameterDetails($parameterId) { $this->printDebugMessage('printGetParameterDetails', 'Begin', 1); $paramDetail = $this->getParameterDetails($parameterId); print <<$paramDetail->name

$paramDetail->description

EOF ; if(isset($paramDetail->values)) { print "\n"; print "\n"; foreach($paramDetail->values->value as $val) { print "\n"; } print "
LabelValueDefault
$val->label$val->value"; if($val->defaultValue && $val->defaultValue == 'true') print 'default'; else print ' '; print "
\n"; } $this->printDebugMessage('printGetParameterDetails', 'Begin', 1); } // Label for an option, generated from the parameter details. function paramDetailToLabelStr($parameterId, $paramDetail) { $this->printDebugMessage('paramDetailToLabelStr', 'Begin', 1); $helpUrl = '?paramDetail=' . $parameterId; $retStr = '' . $paramDetail->name .': '; $this->printDebugMessage('paramDetailToLabelStr', 'End', 1); return $retStr; } // Generate HTML option tags for a parameter detail. function paramDetailToOptionStr($paramDetail) { $this->printDebugMessage('paramDetailToOptionStr', 'Begin', 1); $retStr = ''; if(isset($paramDetail->values)) { foreach($paramDetail->values->value as $val) { if($val->defaultValue && $val->defaultValue == 'true') { $retStr .= "\n"; } else { $retStr .= "\n"; } } } $this->printDebugMessage('paramDetailToOptionStr', 'End', 1); return $retStr; } // Generate HTML tags for a parameter detail. menu or text input. function paramDetailToStr($parameterId, $multi=FALSE) { $this->printDebugMessage('paramDetailToStr', 'Begin', 1); $paramDetail = $this->getParameterDetails($parameterId); $retStr = $this->paramDetailToLabelStr($parameterId, $paramDetail); if(isset($paramDetail->values)) { if($multi) { // Multi-select menu $retStr .= ''; } $retStr .= $this->paramDetailToOptionStr($paramDetail); $retStr .= ''; } else { // Input box $retStr .= ''; } $this->printDebugMessage('paramDetailToStr', 'End', 1); return $retStr; } // Output a submission form function printForm() { $this->printDebugMessage('printForm', 'Begin', 1); $stypeStr = $this->paramDetailToStr('stype'); $programStr = $this->paramDetailToStr('program'); $databaseStr = $this->paramDetailToStr('database', TRUE); $scoresStr = $this->paramDetailToStr('scores'); $alignmentsStr = $this->paramDetailToStr('alignments'); $expStr = $this->paramDetailToStr('exp'); print <<

E-mail:   Job title:

$stypeStr
Sequence:

$programStr $databaseStr

$scoresStr $alignmentsStr $expStr

EOF ; $this->printDebugMessage('printForm', 'End', 1); } // Submit a job to the service. function submitJob($options) { $this->printDebugMessage('submitJob', 'Begin', 1); $params = array(); foreach($options as $key => $val) { switch($key) { case 'stype': $params[$key] = $val; break; case 'sequence': $params[$key] = $val; break; case 'program': $params[$key] = $val; break; case 'database': $params[$key] = $val; break; case 'scores': $params[$key] = $val; break; case 'alignments': $params[$key] = $val; break; } } $jobId = $this->run( $options['email'], $options['title'], $params ); echo "

Job Id: $jobId

"; echo "

Please wait...

"; $this->printDebugMessage('submitJob', 'End', 1); return $this->genMetaRefresh($jobId); } // Get the status of a job. function printStatus($jobId) { $this->printDebugMessage('printStatus', 'Begin', 1); $retVal = ''; $status = $this->getStatus($jobId); echo "

Status for job $jobId: $status

\n"; if($status == 'FINISHED') { $this->printResultsSummary($jobId); } else { $retVal = $this->genMetaRefresh($jobId); } $this->printDebugMessage('printStatus', 'End', 1); return $retVal; } // Print details of available results for a job function printResultsSummary($jobId) { $this->printDebugMessage('printResultsSummary', 'Begin', 1); echo "

Results:

\n"; echo "\n"; $this->printDebugMessage('printResultsSummary', 'End', 1); } // Get a job result. function printResult($jobId, $resultType) { $this->printDebugMessage('printResult', 'Begin', 1); echo "

Result for job $jobId:

\n"; $resultTypeObjs = $this->getResultTypes($jobId); foreach($resultTypeObjs as $resultTypeObj) { if($resultTypeObj->identifier == $resultType) { $selResultTypeObj = $resultTypeObj; } } // Plain text if($selResultTypeObj->mediaType == 'text/plain') { $resultStr = $this->getResult($jobId, $resultType); echo "

$resultStr

\n"; } // Image, embed using img tag using service REST API for document elseif(strpos($selResultTypeObj->mediaType, 'image') === 0 && strpos($selResultTypeObj->mediaType, 'xml') == 0) { $resultUrl = 'http://www.ebi.ac.uk/Tools/services/rest/ncbiblast/result/'; $resultUrl .= $jobId . '/' . $resultType; echo ""; } // Other, embed in iframe using service REST API for document else { $resultUrl = 'http://www.ebi.ac.uk/Tools/services/rest/ncbiblast/result/'; $resultUrl .= $jobId . '/' . $resultType; echo ""; } $this->printDebugMessage('printResult', 'Begin', 1); } // Generate meta-refresh tag for a job. function genMetaRefresh($jobId) { $this->printDebugMessage('genMetaRefresh', 'Begin', 2); $statusUrl = "?jobId=$jobId"; $retVal = ""; $this->printDebugMessage('genMetaRefresh', 'Begin', 2); return $retVal; } } ?>

NCBI BLAST (REST)


PHP 5 is required for this page. This is PHP " . phpversion() . "

"; } else { // Map PHP errors to exceptions if(class_exists('ErrorException')) { function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler"); } try { // Grab input params $inputParams = array(); if(isset($_POST) && count($_POST) > 0) { $inputParams = $_POST; } elseif(isset($_GET) && count($_GET) > 0) { $inputParams = $_GET; } // Create an instance of the client. $client = new NcbiBlastWebClient(); // HTTP proxy config (modify for your local configuration). //$client->setHttpProxy('proxy.example.org', '8080'); // Debug if(array_key_exists('debug', $inputParams)) $client->debugLevel = 2; // Get a result if(array_key_exists('jobId', $inputParams) && array_key_exists('resultType', $inputParams)) { $client->printResult($inputParams['jobId'], $inputParams['resultType']); } // Get job status, and poll elseif(array_key_exists('jobId', $inputParams)) { $metaRefresh = $client->printStatus($inputParams['jobId']); } // Option/parameter details/help. elseif(array_key_exists('paramDetail', $inputParams)) { $client->printGetParameterDetails($inputParams['paramDetail']); } // Submit a job elseif(array_key_exists('stype', $inputParams)) { $metaRefresh = $client->submitJob($inputParams); } // Input form else { $client->printForm(); } } catch(Exception $ex) { echo '

Error: '; if($ex->getMessage() != '') echo $ex->getMessage(); else echo $ex; echo "

\n"; } } ?>

Powered by EMBL-EBI Web Services

NCBI BLAST (REST)