Browse Source

Added support for Phylogenetic Tree content type and visualization field

Stephen Ficklin 7 years ago
parent
commit
d9e87077f6

+ 3 - 3
tripal_chado/api/modules/tripal_chado.phylotree.api.inc

@@ -146,9 +146,9 @@ function tripal_validate_phylotree($val_type, &$options, &$errors, &$warnings) {
     if ($options['leaf_type'] == 'taxonomy') {
       $values = array(
         'cv_id' => array(
-           'name' => 'tripal_phylogeny'
+           'name' => 'EDAM'
         ),
-        'name' => 'taxonomy'
+        'name' => 'Species tree'
       );
       $type = chado_select_record('cvterm', array('cvterm_id'), $values);
     }
@@ -238,7 +238,7 @@ function tripal_validate_phylotree($val_type, &$options, &$errors, &$warnings) {
  *                   term 'polypeptide'.
  *     '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'
+ *     '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

+ 9 - 6
tripal_chado/includes/TripalFields/data__accession/data__accession.inc

@@ -68,12 +68,15 @@ class data__accession extends ChadoField {
     if ($record->$field_column) {
       $dbxref = $record->$field_column;
       $value = $dbxref->db_id->name . ':' . $dbxref->accession;
-      $entity->{$field_name}['und'][0] = array(
-        'value' => $dbxref->accession,
-        'chado-' . $field_table . '__' . $field_column => $record->$field_column->$field_column,
-        'db_id' => $dbxref->db_id->db_id,
-        'accession' => $dbxref->accession,
-      );
+      // Skip the local:null accession as it is just a placeholder.
+      if ($value != 'local:null') {
+        $entity->{$field_name}['und'][0] = array(
+          'value' => $dbxref->accession,
+          'chado-' . $field_table . '__' . $field_column => $record->$field_column->$field_column,
+          'db_id' => $dbxref->db_id->db_id,
+          'accession' => $dbxref->accession,
+        );
+      }
     }
   }
 

+ 105 - 0
tripal_chado/includes/TripalFields/operation__phylotree_vis/operation__phylotree_vis.inc

@@ -0,0 +1,105 @@
+<?php
+
+class operation__phylotree_vis extends ChadoField {
+
+  // The default lable for this field.
+  public static $default_label = 'Phylogenetic tree visualisation';
+
+  // The default description for this field.
+  public static $description = 'Rendering of a phylogenetic tree.';
+
+  // Provide a list of instance specific settings. These can be access within
+  // the instanceSettingsForm.  When the instanceSettingsForm is submitted
+  // then Drupal with automatically change these settings for the instnace.
+  // It is recommended to put settings at the instance level whenever possible.
+  // If you override this variable in a child class be sure to replicate the
+  // term_name, term_vocab, term_accession and term_fixed keys as these are
+  // required for all TripalFields.
+  public static $default_instance_settings  = array(
+    // The short name for the vocabulary (e.g. shcema, SO, GO, PATO, etc.).
+    'term_vocabulary' => 'operation',
+    // The name of the term.
+    'term_name' => 'Phylogenetic tree visualisation',
+    // The unique ID (i.e. accession) of the term.
+    'term_accession' => '0567',
+    // Set to TRUE if the site admin is allowed to change the term
+    // type. This will create form elements when editing the field instance
+    // to allow the site admin to change the term settings above.
+    'term_fixed' => FALSE,
+  );
+
+  // The default widget for this field.
+  public static $default_widget = 'operation__phylotree_vis_widget';
+
+  // The default formatter for this field.
+  public static $default_formatter = 'operation__phylotree_vis_formatter';
+
+
+  /**
+   * @see TripalField::validate()
+   */
+  public function validate($entity_type, $entity, $langcode, $items, &$errors) {
+
+    // If we don't have an entity then we don't want to validate.  The case
+    // where this could happen is when a user is editing the field settings
+    // and trying to set a default value. In that case there's no entity and
+    // we don't want to validate.  There will always be an entity for creation
+    // and update operations of a content type.
+    if (!$entity) {
+      return;
+    }
+    $settings = $this->field['settings'];
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->instance['settings']['chado_table'];
+    $field_column = $this->instance['settings']['chado_column'];
+
+  }
+
+  /**
+   * @see TripalField::load()
+   */
+  public function load($entity) {
+
+    $record = $entity->chado_record;
+    $settings = $this->instance['settings'];
+
+    $field_name = $this->field['field_name'];
+    $field_type = $this->field['type'];
+    $field_table = $this->instance['settings']['chado_table'];
+    $field_column = $this->instance['settings']['chado_column'];
+
+    // Get the terms for each of the keys for the 'values' property.
+    $label_term = 'operation:0567';
+
+    // Set some defaults for the empty record.
+    $entity->{$field_name}['und'][0]['value'] = array();
+
+    if ($record) {
+      $entity->{$field_name}['und'][0]['value'] = array(
+        'schema:url' => url('bio_data/' . $entity->id, array('absolute' => TRUE)),
+      );
+    }
+  }
+
+  /**
+   * @see TripalField::elementInfo()
+   */
+  public function elementInfo() {
+    $field_term = $this->getFieldTermID();
+
+    return array(
+      $field_term => array(
+        'operations' => array(),
+        'sortable' => FALSE,
+        'searchable' => FALSE,
+        'type' => 'string',
+        'elements' => array(
+          'schema:url' => array(
+            'searchabel' => FALSE,
+          ),
+        ),
+      )
+    );
+  }
+}

+ 42 - 0
tripal_chado/includes/TripalFields/operation__phylotree_vis/operation__phylotree_vis_formatter.inc

@@ -0,0 +1,42 @@
+<?php
+
+class operation__phylotree_vis_formatter extends ChadoFieldFormatter {
+
+  // The default lable for this field.
+  public static $default_label = 'Phylogenetic tree visualisation';
+
+  // The list of field types for which this formatter is appropriate.
+  public static $field_types = array('operation__phylotree_vis');
+
+  /**
+   * @see TripalFieldFormatter::view()
+   */
+  public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
+    if (count($items) > 0) {
+      $phylotree = $entity->chado_record;
+
+      $node = new stdClass();
+      $node->phylotree = $phylotree;
+
+      $phylotree = chado_expand_var($phylotree,'field','phylotree.comment');
+      module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.phylotree');
+      tripal_phylogeny_prepare_tree_viewer($phylotree);
+
+      if ($phylotree->has_nodes) {
+        $element[0]['comment'] = array(
+          '#type' => 'markup',
+          '#markup' => 'Click a species to view its species page.',
+        );
+        $ajax_loader = url(drupal_get_path('module', 'tripal') . '/theme/images/ajax-loader.gif');
+        $element[0]['phylogram'] = array(
+          '#type' => 'markup',
+          '#markup' => '
+            <div id="phylogram">
+              <img src="' . $ajax_loader . '" class="phylogram-ajax-loader"/>
+            </div>
+          '
+        );
+      }
+    }
+  }
+}

+ 11 - 0
tripal_chado/includes/TripalFields/operation__phylotree_vis/operation__phylotree_vis_widget.inc

@@ -0,0 +1,11 @@
+<?php
+
+class operation__phylotree_vis_widget extends ChadoFieldWidget {
+
+  // The default lable for this field.
+  public static $default_label = 'Phylogenetic tree visualisation';
+
+  // The list of field types for which this formatter is appropriate.
+  public static $field_types = array('operation__phylotree_vis');
+
+}

+ 1 - 2
tripal_chado/includes/TripalImporter/TaxonomyImporter.inc

@@ -268,9 +268,8 @@ class TaxonomyImporter extends TripalImporter {
       // Add the taxonomic tree.
       $phylotree = array(
         'name' =>  $site_name . 'Taxonomy Tree',
-        'description' => 'The taxonomic tree of species present on this site. Click a species name for more details.',
+        'description' => 'A phylogenetic tree based on taxonomic rank.',
         'leaf_type' => 'taxonomy',
-        'analysis_id' => $analysis->analysis_id,
         'tree_file' => '/dev/null',
         'format' => 'taxonomy',
         'no_load' => TRUE,

+ 45 - 14
tripal_chado/includes/setup/tripal_chado.setup.inc

@@ -240,8 +240,9 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'OBI', 'accession' => '0100026'));
-    if ($term)
-        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term) {
+      $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -262,8 +263,9 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'operation', 'accession' => '2945'));
-    if ($term)
-        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term) {
+      $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -284,8 +286,9 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'local', 'accession' => 'project'));
-    if ($term)
-        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term) {
+      $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -306,8 +309,9 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'data', 'accession' => '1274'));
-    if ($term)
-        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term) {
+      $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -339,8 +343,9 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'TPUB', 'accession' => '0000002'));
-    if ($term)
+    if ($term) {
         $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -381,8 +386,9 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'SO', 'accession' => '0000704'));
-    if ($term)
-        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term) {
+      $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -404,8 +410,9 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'SO', 'accession' => '0000234'));
-    if ($term)
-        $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if ($term) {
+      $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);
@@ -426,8 +433,32 @@ function tripal_chado_prepare_chado($job = NULL) {
       )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'sep', 'accession' => '00195'));
-    if ($term)
+    if ($term) {
         $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
+    if (!$term or !$bundle) {
+      if (!tripal_create_bundle($args, $error)) {
+        throw new Exception($error['!message']);
+      }
+    }
+    if ($report_progress) {
+      $job->setProgress(99);
+    }
+
+    // Create the 'Phylogenetic tree' entity type.
+    $error = '';
+    $args = array(
+      'vocabulary' => 'data',
+      'accession' => '0872',
+      'term_name' => 'Phylogenetic tree',
+      'storage_args' => array(
+        'data_table' => 'phylotree',
+      )
+    );
+    $term = tripal_load_term_entity(array('vocabulary' => 'data', 'accession' => '0872'));
+    if ($term) {
+      $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
     if (!$term or !$bundle) {
       if (!tripal_create_bundle($args, $error)) {
         throw new Exception($error['!message']);

+ 6 - 0
tripal_chado/includes/tripal_chado.entity.inc

@@ -211,6 +211,12 @@ function tripal_chado_tripal_default_title_format($bundle, $available_tokens) {
       'weight' => -5,
     );
   }
+  if ($table == 'phylotree') {
+    $format[] = array(
+      'format' => '[schema__name]',
+      'weight' => -5,
+    );
+  }
   return $format;
 }
 

+ 50 - 0
tripal_chado/includes/tripal_chado.fields.inc

@@ -433,6 +433,21 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
       ),
     );
   }
+
+  // Add field for viewing the phylogenetic tree.
+  if ($table_name == 'phylotree') {
+    $field_name = 'operation__phylotree_vis';
+    $field_type = 'operation__phylotree_vis';
+    $info[$field_name] = array(
+      'field_name' => $field_name,
+      'type' => $field_type,
+      'cardinality' => 1,
+      'locked' => FALSE,
+      'storage' => array(
+        'type' => 'field_chado_storage',
+      ),
+    );
+  }
 }
 
 /**
@@ -1526,6 +1541,40 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
       ),
     );
   }
+
+  // Phylotree Viewer
+  if (chado_table_exists('phylotree')) {
+    $field_name = 'operation__phylotree_vis';
+    $schema = chado_get_schema('phylotree');
+    $pkey = $schema['primary key'][0];
+    $info[$field_name] = array(
+      'field_name' => $field_name,
+      'entity_type' => $entity_type,
+      'bundle' => $bundle->name,
+      'label' => 'Tree View',
+      'description' => 'Rendering of a phylogenetic tree.',
+      'required' => FALSE,
+      'settings' => array(
+        'auto_attach' => FALSE,
+        'chado_table' => 'phylotree',
+        'chado_column' => 'type_id',
+        'base_table' => 'phylotree',
+      ),
+      'widget' => array(
+        'type' => 'operation__phylotree_vis_widget',
+        'settings' => array(
+          'display_label' => 0,
+        ),
+      ),
+      'display' => array(
+        'default' => array(
+          'label' => 'hidden',
+          'type' => 'operation__phylotree_vis_formatter',
+          'settings' => array(),
+        ),
+      ),
+    );
+  }
 }
 
 /**
@@ -2105,6 +2154,7 @@ function tripal_chado_bundle_instances_info_linker(&$info, $entity_type, $bundle
       ),
     );
   }
+
 }
 
 /**

+ 21 - 12
tripal_chado/includes/tripal_chado.phylotree.inc

@@ -24,19 +24,10 @@ function tripal_phylogeny_prepare_tree_viewer($phylotree) {
 
   // Don't show tick marks for the taxonomy tree.
   $skip_ticks = 0;
-  if ($phylotree->type_id->name == 'taxonomy') {
+  if ($phylotree->type_id->name == 'taxonomy' or $phylotree->type_id->name == 'Speces tree') {
     $skip_ticks = 1;
   }
 
-  // Get the tree options as set by the administrator.
-  $options = json_encode(array(
-    'phylogram_width' => variable_get('tripal_phylogeny_default_phylogram_width', 350),
-    'root_node_size' => variable_get('tripal_phylogeny_default_root_node_size', 3),
-    'interior_node_size' => variable_get('tripal_phylogeny_default_interior_node_size', 0),
-    'leaf_node_size' => variable_get('tripal_phylogeny_default_leaf_node_size', 6),
-    'skipTicks' => $skip_ticks,
-  ));
-
   // Get the node colors as set by the administrator.
   $colors = array();
   $color_defaults = variable_get("tripal_phylogeny_org_colors", array('1' => array('organism' => '', 'color' => '')));
@@ -51,7 +42,13 @@ function tripal_phylogeny_prepare_tree_viewer($phylotree) {
     'tripal_chado' => array(
       'phylotree_url' => url('phylotree/' . $phylotree->phylotree_id),
       'phylotree_theme_url' => url($module_path . '/theme'),
-      'tree_options' => $options,
+      'tree_options' => array(
+        'phylogram_width' => variable_get('tripal_phylogeny_default_phylogram_width', 350),
+        'root_node_size' => variable_get('tripal_phylogeny_default_root_node_size', 3),
+        'interior_node_size' => variable_get('tripal_phylogeny_default_interior_node_size', 0),
+        'leaf_node_size' => variable_get('tripal_phylogeny_default_leaf_node_size', 6),
+        'skipTicks' => $skip_ticks,
+      ),
       'org_colors' => $colors,
     ),
   ), 'setting');
@@ -168,7 +165,7 @@ function tripal_phylogeny_ajax_get_tree_json($phylotree_id) {
       );
 
       // If the nodes are taxonomic then set an equal distance
-      if ($phylotree->type_id->name == 'taxonomy') {
+      if ($phylotree->type_id->name == 'taxonomy' or $phylotree->type_id->name == 'Speces tree') {
         $node['length'] = 0.001;
       }
 
@@ -183,6 +180,10 @@ function tripal_phylogeny_ajax_get_tree_json($phylotree_id) {
         if (module_exists('tripal_phylogeny')) {
           $node['feature_nid'] = (int) $r->feature_nid;
         }
+        else {
+          $entity_id = chado_get_record_entity_by_table('feature', $r->feature_id);
+          $node['feature_eid'] = (int) $entity_id;
+        }
       }
       // Add in the organism fields when they are available via the
       // phylonode_organism table.
@@ -195,6 +196,10 @@ function tripal_phylogeny_ajax_get_tree_json($phylotree_id) {
         if (module_exists('tripal_phylogeny')) {
           $node['organism_nid'] = (int) $r->organism_nid;
         }
+        else {
+          $entity_id = chado_get_record_entity_by_table('organism', $r->organism_id);
+          $node['organism_eid'] = (int) $entity_id;
+        }
         // If the node does not have a name but is linked to an organism
         // then set the name to be that of the genus and species.
         if (!$r->name) {
@@ -212,6 +217,10 @@ function tripal_phylogeny_ajax_get_tree_json($phylotree_id) {
         if (module_exists('tripal_phylogeny')) {
           $node['fo_organism_nid'] = (int) $r->fo_organism_nid;
         }
+        else {
+          $entity_id = chado_get_record_entity_by_table('organism', $r->fo_organism_id);
+          $node['fo_organism_eid'] = (int) $entity_id;
+        }
       }
 
       // Add this node to the list, organized by ID.

+ 29 - 2
tripal_chado/includes/tripal_chado.semweb.inc

@@ -550,6 +550,33 @@ function tripal_chado_populate_vocab_EDAM() {
     'cv_name' => 'EDAM',
     'definition' => 'Apply analytical methods to existing data of a specific type.',
   ));
+  tripal_associate_chado_semweb_term('phylotree', 'analysis_id', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'data:0872',
+    'name' => 'Phylogenetic tree',
+    'cv_name' => 'EDAM',
+    'definition' => 'The raw data (not just an image) from which a phylogenetic tree is directly generated or plotted, such as topology, lengths (in time or in expected amounts of variance) and a confidence interval for each length.',
+  ));
+  $term = tripal_insert_cvterm(array(
+    'id' => 'data:3272',
+    'name' => 'Species tree',
+    'cv_name' => 'EDAM',
+    'definition' => 'A phylogenetic tree that reflects phylogeny of the taxa from which the characters (used in calculating the tree) were sampled.',
+  ));
+  $term = tripal_insert_cvterm(array(
+    'id' => 'data:3271',
+    'name' => 'Gene tree',
+    'cv_name' => 'EDAM',
+    'definition' => 'A phylogenetic tree that is an estimate of the character\'s phylogeny.',
+  ));
+  $term = tripal_insert_cvterm(array(
+    'id' => 'operation:0567',
+    'name' => 'Phylogenetic tree visualisation',
+    'cv_name' => 'EDAM',
+    'definition' => 'A phylogenetic tree that is an estimate of the character\'s phylogeny.',
+  ));
+
 }
 
 /**
@@ -1043,6 +1070,7 @@ function tripal_chado_populate_vocab_LOCAL() {
   ));
 
   // Add the terms used to identify nodes in the tree.
+  // DEPRECATED: use EDAM's data 'Species tree' term instead.
   tripal_insert_cvterm(array(
     'name' => 'taxonomy',
     'definition' => 'A term used to indicate if a phylotree is a taxonomic tree',
@@ -1051,7 +1079,6 @@ function tripal_chado_populate_vocab_LOCAL() {
     'db_name' => 'local'
   ));
 
-
   //--------------
   // Project Terms
   //--------------
@@ -1450,7 +1477,7 @@ function tripal_chado_populate_vocab_SWO() {
     'url' => 'http://theswo.sourceforge.net/',
     'urlprefix' => '',
   ));
-  tripal_insert_cv('swo','Software Ontology. An ontology representation of the NCBI organismal taxonomy.');
+  tripal_insert_cv('swo','Software Ontology.');
 
 
   $term = tripal_insert_cvterm(array(

+ 0 - 62
tripal_chado/includes/tripal_chado.taxonomy.inc

@@ -1,62 +0,0 @@
-<?php
-
-/**
- * Generates a page that contains the taxonomy view.
- */
-function tripal_phylogeny_taxonomy_view() {
-  $values = array(
-    'type_id' => array(
-      'name' => 'taxonomy',
-    ),
-  );
-
-  $message = t('Site administrators:  This page is meant to provide
-      a heirarchical taxonomic tree for all of the organism present
-      in this site.  This may not be useful if you only have a few
-      species. If so, you can turn off this page by disabling this page on
-      the site\'s <a href="@menu">Navigation Menu</a>.  Otherwise, to generate the taxonomy go to this site\'s
-      <a href="@taxloader">NCBI taxonomy loader</a> to import the taxonomy information from NCBI.
-      <br><br>Note: If you add new species to this site, you should rerun the
-        NCBI taxonomy loader to update the view</p>',
-      array(
-        '@menu' => url('admin/structure/menu/manage/navigation'),
-        '@taxloader' => url('admin/tripal/loaders/chado_taxonomy'
-      ))
-  );
-  $admin_message = tripal_set_message($message, TRIPAL_INFO, array('return_html' => TRUE));
-
-  $content['admin_message'] = array(
-    '#type' => 'markup',
-    '#markup' => t('This site has not yet prepared the taxonomy for viewing.') . $admin_message,
-  );
-
-  $phylotree = chado_generate_var('phylotree', $values);
-  if ($phylotree) {
-    $node = new stdClass();
-    $node->phylotree = $phylotree;
-
-    $phylotree = chado_expand_var($phylotree,'field','phylotree.comment');
-    module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.phylotree');
-    tripal_phylogeny_prepare_tree_viewer($phylotree);
-
-    if ($phylotree->type_id->name == "taxonomy" and $phylotree->has_nodes) {
-      $content['comment'] = array(
-        '#type' => 'markup',
-        '#markup' =>$phylotree->comment
-      );
-      $ajax_loader = url(drupal_get_path('module', 'tripal') . '/theme/images/ajax-loader.gif');
-      $content['phylogram'] = array(
-        '#type' => 'markup',
-        '#markup' => '
-          <div id="phylogram">
-            <img src="' . $ajax_loader . '" class="phylogram-ajax-loader"/>
-          </div>
-        '
-      );
-    }
-  }
-
-  return $content;
-}
-
-

+ 3 - 0
tripal_chado/theme/js/tripal_phylogeny.js

@@ -102,6 +102,9 @@
       if (!d.feature_id && d.organism_nid) {
         window.location.replace(baseurl + '/node/' + d.organism_nid);
       }
+      if (!d.feature_id && d.organism_eid) {
+        window.location.replace(baseurl + '/bio_data/' + d.organism_eid);
+      }
       // leaf node
     }
   };

+ 60 - 0
tripal_chado/tripal_chado.install

@@ -1330,3 +1330,63 @@ function tripal_chado_update_7319() {
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
 }
+
+/**
+ * Adding Phylogenetic Tree content type.
+ */
+function tripal_chado_update_7320() {
+    try {
+    // Associate the Analysis term with the analysis_id of the phylotree table.
+    $term = tripal_get_cvterm(array('id' => 'operation:2945'));
+    tripal_associate_chado_semweb_term('phylotree', 'analysis_id', $term);
+
+    $term = tripal_insert_cvterm(array(
+      'id' => 'data:0872',
+      'name' => 'Phylogenetic tree',
+      'cv_name' => 'EDAM',
+      'definition' => 'The raw data (not just an image) from which a phylogenetic tree is directly generated or plotted, such as topology, lengths (in time or in expected amounts of variance) and a confidence interval for each length.',
+    ));
+    $term = tripal_insert_cvterm(array(
+      'id' => 'data:3272',
+      'name' => 'Species tree',
+      'cv_name' => 'EDAM',
+      'definition' => 'A phylogenetic tree that reflects phylogeny of the taxa from which the characters (used in calculating the tree) were sampled.',
+    ));
+    $term = tripal_insert_cvterm(array(
+      'id' => 'data:3271',
+      'name' => 'Gene tree',
+      'cv_name' => 'EDAM',
+      'definition' => 'A phylogenetic tree that is an estimate of the character\'s phylogeny.',
+    ));
+    $term = tripal_insert_cvterm(array(
+      'id' => 'operation:0567',
+      'name' => 'Phylogenetic tree visualisation',
+      'cv_name' => 'EDAM',
+      'definition' => 'A phylogenetic tree that is an estimate of the character\'s phylogeny.',
+    ));
+
+    // Create the 'Phylogenetic tree' content type.
+    $error = '';
+    $args = array(
+      'vocabulary' => 'data',
+      'accession' => '0872',
+      'term_name' => 'Phylogenetic tree',
+      'storage_args' => array(
+        'data_table' => 'phylotree',
+      )
+    );
+    $term = tripal_load_term_entity(array('vocabulary' => 'data', 'accession' => '0872'));
+    if ($term) {
+      $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    }
+    if (!$term or !$bundle) {
+      if (!tripal_create_bundle($args, $error)) {
+        throw new Exception($error['!message']);
+      }
+    }
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: '. $error);
+  }
+}