function _chado_update_cvtermpath_root_loop
3.x tripal_chado.cv.api.inc | _chado_update_cvtermpath_root_loop($rootid, $cvid, &$roots) |
Duplicate of _fill_cvtermpath4root() stored procedure in Chado.
This function process a "branch" of the ontology. Initially, the "root" starts at the top of the tree. But, as the cvtermpath is populated the "root" becomes terms deeper in the tree.
Parameters
$rootid: The term ID from the cvterm table of Chado (i.e. cvterm.cvterm_id).
$cvid: The controlled vocabulary ID from the cv table of Chado (i.e. cv.cv_id).
Related topics
1 call to _chado_update_cvtermpath_root_loop()
- chado_update_cvtermpath in tripal_chado/
api/ modules/ tripal_chado.cv.api.inc - Duplicate of fill_cvtermpath() stored procedure in Chado.
File
- tripal_chado/
api/ modules/ tripal_chado.cv.api.inc, line 430 - Provides API functions specificially for managing controlled vocabulary records in Chado.
Code
function _chado_update_cvtermpath_root_loop($rootid, $cvid, &$roots) {
$ttype = db_query(
'SELECT cv.cvterm_id
FROM cvterm cv
WHERE cv.name = :isa
OR cv.name = :is_a
'
,
array(':isa' => "isa", ':is_a' => "is_a")
);
$result = $ttype->fetchObject();
$term_id = $rootid . '|' . $rootid . '|' . $cvid . '|' . $result->cvterm_id;
// If the child_id matches any other id in the array then we've hit a loop.
foreach ($roots as $element_id) {
if ($element_id == $term_id) {
return;
}
}
// Then add that new entry to the $tree_path.
$roots[] = $term_id;
// Descends through the branch starting at this "root" term.
$tree_path =[];
$matched_rows =[];
$possible_start_of_loop =[];
$depth = 0;
_chado_update_cvtermpath_loop($rootid, $rootid, $cvid, $result->cvterm_id, $depth,
0, $tree_path, FALSE, $matched_rows, $possible_start_of_loop, FALSE);
// Get's the children terms of this "root" term and then recursively calls
// this function making each child root.
$cterm = db_query(
'SELECT *
FROM cvterm_relationship
WHERE object_id = :rootid
',
[':rootid' $rootid]
);
while ($cterm_result = $cterm->fetchAssoc()) {
_chado_update_cvtermpath_root_loop($cterm_result['subject_id'], $cvid, $roots);
}
}