我想创建一个从不同数组获取输入以生成搜索的URL。我想要检索的数据来自NCBI。您可以在下面找到我编写的代码。但我无法让它发挥作用;我被卡住了。提前谢谢。
<blink>
</blink>
$eutils = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils";
$db = "gene";
$gene_symbols = array("A20","HBB","ABO");
$species = array("homo sapiens", "Escherichia coli","Saccharomyces cerevisiae")
;
$links = array();
foreach ($gene_symbols as $key => $GS){
$SP = $species[$key];
$query = "$GS AND $SP [orgn] AND alive";
$esearch = "$eutils/esearch.fcgi?db=$db&retmode=xml&retmax=10&sort=relevance&term=";
echo $esearch;
$links[] = get($esearch.$query); }
foreach($links as $lk){
xml = simplexml_load_file($lk) or die("feed not loading"); }
var_dump(xml);
答案 0 :(得分:0)
$eutils = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi";
$databank = "gene";
$gene_symbols = array("A20","HBB","ABO");
$species = array("homo sapiens", "Escherichia coli","Saccharomyces cerevisiae");
foreach($gene_symbols as $value => $GS){
$Species = $species[$value];
$esearch = "$GS%AND%alive[prop]%AND+$Species[orgn]";
$esearch_test = "$eutils?db=$databank&retmode=xml&retmax=10&sort=relevance&term=$esearch";
$result = file_get_contents($esearch_test);
echo "Query: " . $esearch_test. "<br \>\n";
echo "Result: " . $result . "<br \>\n";
$xml = simplexml_load_string($result);
echo "Count:<br \>\n";
echo $xml->Count;
$C = $xml->Count;
echo $C;
}