|
@@ -3,7 +3,7 @@
|
|
|
/**
|
|
|
* @file
|
|
|
* Provides API functions specificially for managing phylogenetic and taxonomic
|
|
|
- * tree records in Chado.
|
|
|
+ * tree records in Chado.
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -11,8 +11,8 @@
|
|
|
* @ingroup tripal_chado_api
|
|
|
* @{
|
|
|
* Provides API functions specificially for managing phylogenetic and taxonomic
|
|
|
- * tree records in Chado. The API consists of functions for creation,
|
|
|
- * retrieval, update and deltion (CRUD) for phylogenetic tree records as
|
|
|
+ * tree records in Chado. The API consists of functions for creation,
|
|
|
+ * retrieval, update and deltion (CRUD) for phylogenetic tree records as
|
|
|
* well as importing of trees in the newick file format.
|
|
|
* @}
|
|
|
*/
|
|
@@ -85,10 +85,6 @@ function chado_validate_phylotree($val_type, &$options, &$errors, &$warnings) {
|
|
|
$errors['description'] = t('Please provide a description for this tree.');
|
|
|
return FALSE;
|
|
|
}
|
|
|
- if (!array_key_exists('tree_file', $options)) {
|
|
|
- $errors['tree_file'] = t('Please provide either the full path to the tree_file or a Drupal managed file ID number.');
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
if (!array_key_exists('format', $options) or !$options['format']) {
|
|
|
$errors['format'] = t('Please provide a file format for the tree file.');
|
|
|
return FALSE;
|
|
@@ -202,12 +198,30 @@ function chado_validate_phylotree($val_type, &$options, &$errors, &$warnings) {
|
|
|
),
|
|
|
);
|
|
|
$dbxref = chado_generate_var('dbxref', $values);
|
|
|
+
|
|
|
if (!$dbxref) {
|
|
|
- $errors['dbxref'] = t('The dbxref provided does not exist in the database: %dbxref.', array('%dbxref' => $dbxref));
|
|
|
- return FALSE;
|
|
|
+
|
|
|
+ $db = chado_generate_var('db', array( 'name' => $db_name));
|
|
|
+
|
|
|
+ if (!$db){
|
|
|
+ $errors['dbxref'] = t('
|
|
|
+ dbxref could not be created for db: %dbxref.', array('%dbxref' => $dbxref));
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ $dbxref = chado_insert_record('dbxref', $values);
|
|
|
+
|
|
|
+ if (!$dbxref){
|
|
|
+ $errors['dbxref'] = t('
|
|
|
+ dbxref could not be created for db: %dbxref.', array('%dbxref' => $dbxref));
|
|
|
+ return FALSE;
|
|
|
}
|
|
|
+ }
|
|
|
+ if (is_array($dbxref)){
|
|
|
+ $options['dbxref_id'] = $dbxref['dbxref_id'];
|
|
|
+ }else {
|
|
|
$options['dbxref_id'] = $dbxref->dbxref_id;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
// Make sure the tree name is unique.
|
|
|
if (array_key_exists('name', $options) and $options['name']) {
|
|
@@ -254,7 +268,7 @@ function chado_validate_phylotree($val_type, &$options, &$errors, &$warnings) {
|
|
|
* 'tree_file': The path of the file containing the phylogenetic tree to
|
|
|
* import or a Drupal managed_file numeric ID.
|
|
|
* 'format': The file format. Currently only 'newick is supported'.
|
|
|
- *
|
|
|
+ *
|
|
|
* Optional keys:
|
|
|
* 'dbxref': A database cross-reference of the form DB:ACCESSION.
|
|
|
* Where DB is the database name, which is already present
|
|
@@ -312,6 +326,7 @@ function chado_insert_phylotree(&$options, &$errors, &$warnings) {
|
|
|
'comment' => $options['description'],
|
|
|
'type_id' => $options['type_id'],
|
|
|
);
|
|
|
+
|
|
|
$phylotree = chado_insert_record('phylotree', $values);
|
|
|
if (!$phylotree) {
|
|
|
drupal_set_message(t('Unable to add phylotree.'), 'warning');
|
|
@@ -675,7 +690,7 @@ function chado_phylogeny_import_tree(&$tree, $phylotree, $options, $vocab = arra
|
|
|
if (!empty($tree['name']) and $tree['name'] != '') {
|
|
|
if (!$options['taxonomy']) {
|
|
|
|
|
|
- // This is a sequence-based tree. Try to match leaf nodes with
|
|
|
+ // This is a sequence-based tree. Try to match leaf nodes with
|
|
|
// features.
|
|
|
// First, Get the Name and uniquename for the feature.
|
|
|
$matches = array();
|
|
@@ -751,9 +766,9 @@ function chado_phylogeny_import_tree(&$tree, $phylotree, $options, $vocab = arra
|
|
|
/**
|
|
|
* Get the vocabulary terms used to describe nodes in the tree.
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @return
|
|
|
* Array of vocab info or FALSE on failure.
|
|
|
- *
|
|
|
+ *
|
|
|
* @ingroup tripal_phylotree_api
|
|
|
*/
|
|
|
function chado_phylogeny_get_node_types_vocab() {
|