function chado_assign_phylogeny_tree_indices
3.x tripal_chado.phylotree.api.inc | chado_assign_phylogeny_tree_indices(&$tree, &$index = 1) |
Iterates through the tree and sets the left and right indicies.
Parameters
$tree: The tree array.
$index: This parameters is not used when the function is first called. It is used for recursive calls.
Related topics
4 calls to chado_assign_phylogeny_tree_indices()
- chado_phylogeny_import_tree_file in tripal_chado/
api/ modules/ tripal_chado.phylotree.api.inc - Imports a tree file.
- TaxonomyImporter::importRecord in tripal_chado/
includes/ TripalImporter/ TaxonomyImporter.inc - Imports an organism from the NCBI taxonomy DB by its taxonomy ID
- TaxonomyImporter::rebuildTree in tripal_chado/
includes/ TripalImporter/ TaxonomyImporter.inc - Iterates through all existing organisms and rebuilds the taxonomy tree.
- tripal_assign_phylogeny_tree_indices in tripal_chado/
api/ modules/ tripal_chado.module.DEPRECATED.api.inc - Iterates through the tree and sets the left and right indicies.
File
- tripal_chado/
api/ modules/ tripal_chado.phylotree.api.inc, line 563 - Provides API functions specificially for managing phylogenetic and taxonomic tree records in Chado.
Code
function chado_assign_phylogeny_tree_indices(&$tree, &$index = 1) {
// Assign a left and right index to each node. The child node must
// have a right and left index less than that of it's parents. We
// increment the index by 100 to give space for new nodes that might
// be added later.
if (array_key_exists('name', $tree)) {
$tree['left_index'] = $index += 100;
if (array_key_exists('is_leaf', $tree)) {
$tree['right_index'] = $index += 100;
}
}
if (array_key_exists('branch_set', $tree)) {
foreach ($tree['branch_set'] as $key => $node) {
chado_assign_phylogeny_tree_indices($tree['branch_set'][$key], $index);
$tree['right_index'] = $index += 100;
}
}
}