function tripal_pub_PMID_fetch
2.x tripal_pub.PMID.inc | tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null',
$retmod = 'null', $start = 0, $limit = 10, $args = array()) |
3.x tripal_chado.pub_importer_PMID.inc | tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null',
$retmod = 'null', $start = 0, $limit = 10, $args = array()) |
1.x PMID.inc | tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null',
$retmod = 'null', $start = 0, $limit = 10, $args = array()) |
Retreives from PubMed a set of publications from the previously initiated query.
Parameters
$query_key: The esearch QueryKey
$web_env: The esearch WebEnv
$rettype: The efetch return type
$retmod: The efetch return mode
$start: The start of the range to retrieve
$limit: The number of publications to retrieve
$args: Any additional arguments to add the efetch query URL
Return value
An array containing the total_records in the dataaset, the search string and an array of the publications that were retreived.
Related topics
1 call to tripal_pub_PMID_fetch()
- tripal_pub_remote_search_PMID in tripal_pub/
includes/ importers/ tripal_pub.PMID.inc - A hook for performing the search on the PubMed database.
File
- tripal_pub/
includes/ importers/ tripal_pub.PMID.inc, line 289 - This file provides support for importing and parsing of results from the NCBI PubMed database. The functions here are used by both the publication importer setup form and the publication importer.
Code
function tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null',
$retmod = 'null', $start = 0, $limit = 10, $args = array()) {
// repeat the search performed previously (using WebEnv & QueryKey) to retrieve
// the PMID's within the range specied. The PMIDs will be returned as a text list
$fetch_url = "http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?" .
"rettype=$rettype" .
"&retmode=$retmod" .
"&retstart=$start" .
"&retmax=$limit" .
"&db=Pubmed" .
"&query_key=$query_key" .
"&WebEnv=$web_env";
foreach ($args as $key => $value) {
if (is_array($value)) {
$fetch_url .= "&$key=";
foreach ($value as $item) {
$fetch_url .= "$item,";
}
$fetch_url = substr($fetch_url, 0, -1); // remove trailing comma
}
else {
$fetch_url .= "&$key=$value";
}
}
//dpm($fetch_url);
$rfh = fopen($fetch_url, "r");
if (!$rfh) {
drupal_set_message('ERROR: Could not perform PubMed query.', 'error');
tripal_report_error('tripal_pubmed', TRIPAL_ERROR, "Could not perform PubMed query: %fetch_url.",
array('%fetch_url' => $fetch_url));
return '';
}
$results = '';
if ($rfh) {
while (!feof($rfh)) {
$results .= fread($rfh, 255);
}
fclose($rfh);
}
return $results;
}