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 = '')

Add Database Reference

Related topics

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

File

tripal_cv/includes/obo_loader.inc, line 1064
Tripal Ontology Loader

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,
  );
  $options = array('statement_name' => 'sel_dbxref_idac');
  $result = tripal_core_chado_select('dbxref', array('dbxref_id'), $values, $options);
  if (count($result) == 0) {
    $ins_values = array(
      'db_id' => $db_id,
      'accession' => $accession,
      'version' => $version,
      'description' => $description,
    );
    $ins_options = array(
      'statement_name' => 'ins_dbxref_idacvede',
      'return_record' => FALSE
    );
    $result = tripal_core_chado_insert('dbxref', $ins_values, $ins_options);
    if (!$result) {
      tripal_cv_obo_quiterror("Failed to insert the dbxref record $accession");
      return FALSE;
    }
    $result = tripal_core_chado_select('dbxref', array('dbxref_id'), $values, $options);
  }
  return $result[0];
}