function chado_update_cvtermpath

3.x tripal_chado.cv.api.inc chado_update_cvtermpath($cv_id, $job_id = NULL)

Duplicate of fill_cvtermpath() stored procedure in Chado.

Identifies all of the root terms of the controlled vocabulary. These root terms are then processed by calling the _chado_update_cvtermpath_root_loop() function on each one.

Parameters

$cvid: The controlled vocabulary ID from the cv table of Chado (i.e. cv.cv_id).

$job_id:

Related topics

3 calls to chado_update_cvtermpath()
OBOImporter::postRun in tripal_chado/includes/TripalImporter/OBOImporter.inc
tripal_chado_update_7313 in tripal_chado/tripal_chado.install
Run the cvtermpath for the Tripal Pub and Contact ontologies.
tripal_update_cvtermpath in tripal_chado/api/modules/tripal_chado.module.DEPRECATED.api.inc
Duplicate of fill_cvtermpath() stored procedure in Chado.
1 string reference to 'chado_update_cvtermpath'
tripal_cv_cvtermpath_form_submit in tripal_chado/includes/tripal_chado.cv.inc
Cvterm path form submit

File

tripal_chado/api/modules/tripal_chado.cv.api.inc, line 385
Provides API functions specificially for managing controlled vocabulary records in Chado.

Code

function chado_update_cvtermpath($cv_id, $job_id = NULL) {
  // TODO: there's a function to determine the current Chado instance.
  // we should use that.
  $prev_db = chado_set_active('chado');
  try {
    $result = db_query('
      SELECT DISTINCT t.*
      FROM cvterm t
        LEFT JOIN cvterm_relationship r ON (t.cvterm_id = r.subject_id)
        INNER JOIN cvterm_relationship r2 ON (t.cvterm_id = r2.object_id)
      WHERE t.cv_id = :cvid AND r.subject_id is null', 
    array(':cvid' => $cv_id)
    );

    // Iterate through each root level term.
    $record = $result->fetchAll();
    $roots =[];

    foreach ($record as $item) {
      _chado_update_cvtermpath_root_loop($item->cvterm_id, $item->cv_id, $roots);
    }
  }
  catch (Exception $e) {
    // If there's an exception we have to set the database back. So, do that
    // and then rethrow the error.
    chado_set_active($prev_db);
    throw $e;
  }
  chado_set_active($prev_db);
}