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())
1 call to tripal_pub_PMID_fetch()
tripal_pub_PMID_range in tripal_pub/includes/importers/PMID.inc

File

tripal_pub/includes/importers/PMID.inc, line 254
Tripal Pub PubMed Interface

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');
    watchdog('tpub_import', "Could not perform PubMed query: %fetch_url.", 
    array('%fetch_url' => $fetch_url), WATCHDOG_ERROR);
    return '';
  }
  $results = '';
  if ($rfh) {
    while (!feof($rfh)) {
      $results .= fread($rfh, 255);
    }
    fclose($rfh);
  }

  return $results;
}