private function TaxonomyImporter::initTree
3.x TaxonomyImporter.inc | private TaxonomyImporter::initTree() |
Create the taxonomic tree in Chado.
If the tree already exists it will not be recreated.
Return value
Returns the phylotree object.
Throws
Exception
1 call to TaxonomyImporter::initTree()
- TaxonomyImporter::run in tripal_chado/
includes/ TripalImporter/ TaxonomyImporter.inc - Performs the import.
File
- tripal_chado/
includes/ TripalImporter/ TaxonomyImporter.inc, line 272
Class
Code
private function initTree() {
// Add the taxonomy tree record into the phylotree table. If the tree
// already exists then don't insert it again.
$tree_name = $site_name . 'Taxonomy Tree';
$phylotree = chado_select_record('phylotree', array('*'), array('name' => $tree_name));
if (count($phylotree) == 0) {
// Add the taxonomic tree.
$phylotree = array(
'name' => $site_name . 'Taxonomy Tree',
'description' => 'A phylogenetic tree based on taxonomic rank.',
'leaf_type' => 'taxonomy',
'tree_file' => '/dev/null',
'format' => 'taxonomy',
'no_load' => TRUE,
);
$errors = array();
$warnings = array();
$success = tripal_insert_phylotree($phylotree, $errors, $warnings);
if (!$success) {
throw new Exception("Cannot add the Taxonomy Tree record.");
}
$phylotree = (object) $phylotree;
}
else {
$phylotree = $phylotree[0];
}
return $phylotree;
}