Entering edit mode
7.8 years ago
muraliniceguy97
•
0
I create a program to get the results from the blast using blast rest api. I success fully getting RID. When i passed RID into the url for getting result it show html output and also every 2 seconds page redirecting to the server. Visit this url you will find out my problem peerscientist.net. find out these images also http://prnt.sc/eb3l8q, http://prnt.sc/eb3mcz.
Here is the complete code.
class BlastAPI{
public function blastdata(){
$url = "https://blast.ncbi.nlm.nih.gov/Blast.cgi?CMD=Put&QUERY=SSWWAHVEMGPPDPILGVTEAYKRDTNSKK&PROGRAM=blastp&FILTER=L&DATABASE=nr&FORMAT_TYPE=XML";
$ncontent = $this->rid($url);
echo '
RID :'.$ncontent.'
';
$geturl = $this->geturl($ncontent);
echo $geturl;
$fulldata = $this->getfullData($geturl);
if($fulldata != ''){
echo '';
var_dump($fulldata);
echo '
';
}else{
echo "Code Once";
}
}
public function rid($url){
$surl = $url;
echo $surl;
//header('Content-type: text/html');
$content = file_get_contents($surl);
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHtml($content);
libxml_use_internal_errors(false);
$data = $doc->getElementById("rid");
$rid = $data->getAttribute('value');
return $rid;
}
public function geturl($rid){
$srid = $rid;
$mainurl = "https://blast.ncbi.nlm.nih.gov/Blast.cgi?CMD=Get&RID=$srid&FORMAT_OBJECT=SearchInfo";
return $mainurl;
}
public function getfullData($url){
$murl = $url;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $murl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$str = curl_exec($curl);
curl_close($curl);
return $str;
}
}
$nblast = new BlastAPI();
$nblast->blastdata();
Have you found an answer to this yet? I'm having the exact same problem in Java.