我正在尝试从 PubMed 的 Eutils 生成的 XML 输出中构建一个 ID 数组。
这是 GitHub 上的代码。下面是具体的子程序。
解决这个问题的最佳方法是什么?
getUID($query);
sub getUID {
# First, build the Eutils query
my $utils = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils'; # Base URL for searches
my $db = 'pubmed'; # Default to PubMed database; this may be changed.
my $retmax = 10; # Get 10 results from Eutils
my $esearch = $utils . '/esearch.fcgi?db=' . $db . '&retmax=' . $retmax . '&term=';
my $esearch_result = get( $esearch . $query ); # Downloads the XML
# Second, extract the UIDs
$esearch_result =~ m(<Id>*</Id>);
print $esearch_result; # This should return a list of ID's (numbers), but doesn't.
}
以下是 PubMed XML 结果的样子:
<?xml version="1.0" ?>
<!DOCTYPE eSearchResult PUBLIC "-//NLM//DTD eSearchResult, 11 May 2002//EN" "http://www.ncbi.nlm.nih.gov/entrez/query/DTD/eSearch_020511.dtd">
<eSearchResult><Count>2768671</Count><RetMax>10</RetMax><RetStart>0</RetStart><IdList>
<Id>23682407</Id>
<Id>23682406</Id>
<Id>23682388</Id>
<Id>23682359</Id>
<Id>23682336</Id>
<Id>23682331</Id>
<Id>23682325</Id>
<Id>23682320</Id>
<Id>23682315</Id>
<Id>23682311</Id>
</IdList><TranslationSet><Translation> <From>cancer</From> <To>"neoplasms"[MeSH Terms] OR "neoplasms"[All Fields] OR "cancer"[All Fields]</To> </Translation></TranslationSet><TranslationStack> <TermSet> <Term>"neoplasms"[MeSH Terms]</Term> <Field>MeSH Terms</Field> <Count>2430901</Count> <Explode>Y</Explode> </TermSet> <TermSet> <Term>"neoplasms"[All Fields]</Term> <Field>All Fields</Field> <Count>1920766</Count> <Explode>Y</Explode> </TermSet> <OP>OR</OP> <TermSet> <Term>"cancer"[All Fields]</Term> <Field>All Fields</Field> <Count>1192293</Count> <Explode>Y</Explode> </TermSet> <OP>OR</OP> <OP>GROUP</OP> </TranslationStack><QueryTranslation>"neoplasms"[MeSH Terms] OR "neoplasms"[All Fields] OR "cancer"[All Fields]</QueryTranslation></eSearchResult>