function chado_get_semweb_term

3.x tripal_chado.semweb.api.inc chado_get_semweb_term($chado_table, $chado_column, $options = array())

Retrieves the term that maps to the given Chado table and field.

Parameters

$chado_table: The name of the Chado table.

$chado_column: The name of the Chado field.

$options: An associative array of one or more of the following keys: -return_object: Set to TRUE to return the cvterm object rather than the string version of the term.

Return value

Returns a string-based representation of the term (e.g. SO:0000704). If the 'return_object' options is provided then a cvterm object is returned. returns NULL if no term is mapped to the table and column.

Related topics

52 calls to chado_get_semweb_term()
chado_linker__contact::elementInfo in tripal_chado/includes/TripalFields/chado_linker__contact/chado_linker__contact.inc
chado_linker__contact::load in tripal_chado/includes/TripalFields/chado_linker__contact/chado_linker__contact.inc
chado_linker__contact::query in tripal_chado/includes/TripalFields/chado_linker__contact/chado_linker__contact.inc
chado_linker__contact::queryOrder in tripal_chado/includes/TripalFields/chado_linker__contact/chado_linker__contact.inc
chado_linker__contact_formatter::view in tripal_chado/includes/TripalFields/chado_linker__contact/chado_linker__contact_formatter.inc

... See full list

File

tripal_chado/api/tripal_chado.semweb.api.inc, line 200
Provides an application programming interface (API) for semantic web support.

Code

function chado_get_semweb_term($chado_table, $chado_column, $options = array()) {
  $cvterm_id = db_select('chado_semweb', 'CS')
    ->fields('CS', array('cvterm_id'))
    ->condition('chado_column', $chado_column)
    ->condition('chado_table', $chado_table)
    ->execute()
    ->fetchField();

  if ($cvterm_id) {
    $cvterm = chado_generate_var('cvterm', array('cvterm_id' => $cvterm_id));
    if (array_key_exists('return_object', $options)) {
      return $cvterm;
    }

    return chado_format_semweb_term($cvterm);
  }
}