function tripal_cv_obo_add_dbxref

2.x tripal_cv.obo_loader.inc tripal_cv_obo_add_dbxref($db_id, $accession, $version = '', $description = '')
1.x obo_loader.inc tripal_cv_obo_add_dbxref($db_id, $accession, $version = '', $description = '')

Adds a database cross reference to a cvterm

Parameters

db_id: The database ID of the cross reference

accession: The cross reference's accession

$version: The version of the dbxref

$description: The description of the cross reference

Related topics

1 call to tripal_cv_obo_add_dbxref()
tripal_cv_obo_add_cvterm_dbxref in tripal_cv/includes/tripal_cv.obo_loader.inc
Adds a database reference to a cvterm

File

tripal_cv/includes/tripal_cv.obo_loader.inc, line 1401
Functions to aid in loading ontologies into the chado cv module

Code

function tripal_cv_obo_add_dbxref($db_id, $accession, $version = '', $description = '') {

  // check to see if the dbxref exists if not, add it
  $values = array(
    'db_id' => $db_id,
    'accession' => $accession,
  );
  $result = chado_select_record('dbxref', array('dbxref_id'), $values);
  if (count($result) == 0) {
    $ins_values = array(
      'db_id' => $db_id,
      'accession' => $accession,
      'version' => $version,
      'description' => $description,
    );
    $ins_options = array('return_record' => FALSE);
    $result = chado_insert_record('dbxref', $ins_values, $ins_options);
    if (!$result) {
      tripal_cv_obo_quiterror("Failed to insert the dbxref record $accession");
      return FALSE;
    }
    $result = chado_select_record('dbxref', array('dbxref_id'), $values);
  }
  return $result[0];
}