function tripal_pub_PMID_parse_publication_type

2.x tripal_pub.PMID.inc tripal_pub_PMID_parse_publication_type($xml, &$pub)
3.x tripal_chado.pub_importer_PMID.inc tripal_pub_PMID_parse_publication_type($xml, &$pub)
1.x PMID.inc tripal_pub_PMID_parse_publication_type($xml, &$pub)

Parses the section from the XML returned from PubMed that contains information about a publication

A full list of publication types can be found here: http://www.nlm.nih.gov/mesh/pubtypes.html.

The Tripal Pub ontology doesn't yet have terms for all of the publication types so we store the value in the 'publication_type' term.

Parameters

$xml: The XML to parse

$pub: The publication object to which additional details will be added

1 call to tripal_pub_PMID_parse_publication_type()
tripal_pub_PMID_parse_article in tripal_chado/includes/loaders/tripal_chado.pub_importer_PMID.inc
Parses the section from the XML returned from PubMed that contains information about an article.

File

tripal_chado/includes/loaders/tripal_chado.pub_importer_PMID.inc, line 600
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_parse_publication_type($xml, &$pub) {

  while ($xml->read()) {
    $element = $xml->name;

    if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'PublicationTypeList') {
      // we've reached the </PublicationTypeList> element so we're done.
      return;
    }
    if ($xml->nodeType == XMLReader::ELEMENT) {
      switch ($element) {
        case 'PublicationType':
          $xml->read();
          $value = $xml->value;

          $identifiers = array(
            'name' => $value,
            'cv_id' => array(
              'name' => 'tripal_pub',
            )
          );
          $options = array('case_insensitive_columns' => array('name'));
          $pub_cvterm = chado_get_cvterm($identifiers, $options);
          if (!$pub_cvterm) {
            // see if this we can find the name using a synonym
            $identifiers = array(
              'synonym' => array(
                'name' => $value,
                'cv_name' => 'tripal_pub'
              )
            );
            $pub_cvterm = chado_get_cvterm($identifiers, $options);
            if (!$pub_cvterm) {
              tripal_report_error('tripal_pubmed', TRIPAL_ERROR, 
              'Cannot find a valid vocabulary term for the publication type: "%term".', 
              array('%term' => $value));
            }
          }
          else {
            $pub['Publication Type'][] = $pub_cvterm->name;
          }
          break;
        default:
          break;
      }
    }
  }
}