function tripal_cv_get_cvterm_by_synonym

2.x tripal_cv.DEPRECATED.inc tripal_cv_get_cvterm_by_synonym($synonym, $cv_id = NULL, $cv_name = 'tripal')
3.x tripal_cv.DEPRECATED.inc tripal_cv_get_cvterm_by_synonym($synonym, $cv_id = NULL, $cv_name = 'tripal')
1.x tripal_cv.api.inc tripal_cv_get_cvterm_by_synonym($synonym, $cv_id = NULL, $cv_name = 'tripal')

Retrieve a chado cvterm object with a given name

Parameters

$synonym: the synonym of the term

$cv_id: the cv_id of the term you are looking for

$cv_name: the name of the CV

Return value

cvterm object

Related topics

2 calls to tripal_cv_get_cvterm_by_synonym()
tripal_pub_add_publication in tripal_pub/api/tripal_pub.api.inc
Adds a new publication to the Chado, along with all properties and database cross-references. If the publication does not already exist in Chado then it is added. If it does exist nothing is done. If the $update parameter is TRUE then theā€¦
tripal_pub_PMID_parse_publication_type in tripal_pub/includes/importers/PMID.inc

File

tripal_cv/api/tripal_cv.api.inc, line 290
Controlled Vocabulary API

Code

function tripal_cv_get_cvterm_by_synonym($synonym, $cv_id = NULL, $cv_name = 'tripal') {

  // first find the CVTerm synonym
  $values = array(
    'synonym' => $synonym,
  );
  $statement = "sel_cvtermsynonym_sy";
  if ($cv_id) {
    $values['cvterm_id'] = array('cv_id' => $cv_id);
    $statement = "sel_cvtermsynonym_sycv";
  }
  if ($cv_name) {
    $values['cvterm_id'] = array('cv_id' => array('name' => $cv_name));
    $statement = "sel_cvtermsynonym_sycv";
  }
  $options = array(
    'statement_name' => $statement,
    'case_insensitive_columns' => array('name')
  );
  $synonym = tripal_core_chado_select('cvtermsynonym', array('cvterm_id'), $values, $options);

  // if the synonym doens't exist or more than one record is returned then return false
  if (count($synonym) == 0) {
    return FALSE;
  }
  if (count($synonym) > 1) {
    return FALSE;
  }

  // get the cvterm
  $values = array('cvterm_id' => $synonym[0]->cvterm_id);
  $options = array('statement_name' => 'sel_cvterm_id');
  $cvterm = tripal_core_chado_select('cvterm', array('*'), $values, $options);
  return $cvterm[0];
}