Browse Source

Publishing (syncing) of records in Chado now working... no filters yet

Stephen Ficklin 9 years ago
parent
commit
e698d84256

+ 102 - 0
tripal/api/tripal.entities.api.inc

@@ -141,7 +141,90 @@ function tripal_create_bundle($namespace, $accession, $term_name, &$error = '')
 
   return TRUE;
 }
+/**
+ * Adds a field to an Entity bundle.
+ *
+ * @param $field_name
+ *   The name of the field.
+ * @param $field_info
+ *   An associative array containing the field information.  The following
+ *   key/value pairs are supported:
+ *     'field_type' : a valid field type.  May be any of the Drupal default
+ *       fields, one created by the tripal_chado module or another custom module.
+ *     'widget_type' : a valid widget type. May be any of the Drupal default
+ *       fields, one created by the tripal_chado module or another custom module.
+ *     'field_settings' : an array of settings that are appropriate for the
+ *       selected field type.
+ *     'widget_settings' : an array of settings that are appropriate for the
+ *       selected widget type.
+ *     'description' :  a default description for this field.
+ *     'label' : a label used as a header for this field.
+ *     'is_required' : indicates if the field is required in the edit form.
+ *     'cardinality' : indicates the number of values this field can support.
+ *       the default is 1 (meaning only one value). Use a value of
+ *       FIELD_CARDINALITY_UNLIMITED for unlimited number of values.
+ *     'default_value' : A default value for the field.
+ *     'format' : A string indicating the format for the field. Must be
+ *       specific to the field.
+ * @param $entity_type_name
+ *   The entity type name.
+ * @param $bundle_name
+ *   The bundle name.
+ *
+ */
+function tripal_add_bundle_field($field_name, $field_info, $entity_type_name, $bundle_name) {
+
+  $field = field_info_field($field_name);
+
+  // If the field exists and is attached to this bundle then just return,
+  // there is nothing left to do.
+  if ($field and array_key_exists('bundles', $field) and
+      array_key_exists($entity_type_name, $field['bundles']) and
+      in_array($bundle_name, $field['bundles'][$entity_type_name])) {
+        return;
+      }
 
+      // Allow other modules to alter the field information array.
+      drupal_alter('chado_field', $field_info);
+
+      $cardinality = 1;
+      if (array_key_exists('cardinality', $field_info) and is_numeric($field_info['cardinality'])) {
+        $cardinality = $field_info['cardinality'];
+      }
+
+      // If the field doesn't exist then create it.
+      if (!$field) {
+        $field = array(
+          'field_name' => $field_name,
+          'type' => $field_info['field_type'],
+          'cardinality' => $cardinality,
+          'locked' => FALSE,
+          'storage' => array(
+            'type' => 'field_chado_storage'
+          ),
+          'settings' => $field_info['field_settings'],
+        );
+        field_create_field($field);
+      }
+
+      // Attach the field to the bundle.
+      $field_instance = array(
+        'field_name' => $field_name,
+        'label' => $field_info['label'],
+        'description' => $field_info['description'],
+        'widget' => array(
+          'type' => $field_info['widget_type'],
+          'settings' => $field_info['widget_settings'],
+        ),
+        'entity_type' => $entity_type_name,
+        'required' => $field_info['is_required'],
+        'settings' => $field_info['field_settings'],
+        'bundle' => $bundle_name,
+        'default_value' => array_key_exists('default_value', $field_info) ? $field_info['default_value'] : '',
+        'format' => array_key_exists('format', $field_info) ? $field_info['format'] : '',
+      );
+      field_create_instance($field_instance);
+}
 /**
  * Allows a module to make changes to an entity object after creation.
  *
@@ -607,7 +690,26 @@ function hook_vocab_select_term_form(&$form, &$form_state) {
 function hook_vocab_select_term_form_validate($form, &$form_state) {
 
 }
+/**
+ * Provides a form for importing vocabularies and their terms.
+ *
+ * Tripal allows for vocabularies to be stored separately from the biological
+ * data. This hook allows the default term storage backend to provide an
+ * approprite form for importing ontologies (either in OBO or OWL format).
+ *
+ * @param $form
+ * @param $form_state
+ *
+ */
+function hook__vocab_import_form($form, &$form_state) {
+  return $form;
+}
+function hook__vocab_import_form_validate($form, &$form_state) {
 
+}
+function hook__vocab_import_form_submit($form, &$form_state) {
+
+}
 
 /**
  * Hook used by the default term storage backend to provide details for a term.

+ 11 - 9
tripal/includes/TripalEntityUIController.inc

@@ -245,7 +245,10 @@ function tripal_view_entity($entity, $view_mode = 'full') {
 
    // If the entity doesn't exist then create one.
    if (!$entity) {
-     $entity = entity_get_controller('TripalEntity')->create(array('bundle' => $bundle_name, 'term_id' => $term_id));
+     $entity = entity_get_controller('TripalEntity')->create(array(
+       'bundle' => $bundle_name,
+       'term_id' => $term_id
+     ));
      field_attach_form('TripalEntity', $entity, $form, $form_state);
 
      $form['add_button'] = array(
@@ -278,15 +281,14 @@ function tripal_view_entity($entity, $view_mode = 'full') {
    $form['#prefix'] = "<div id='$bundle_name-entity-form'>";
    $form['#suffix'] = "</div>";
    return $form;
-
  }
  /**
   * An Ajax callback for the tripal_entity_form.
   */
- function tripal_entity_form_ajax_callback($form, $form_state) {
-   // return the form so Drupal can update the content on the page
-   return $form;
- }
+function tripal_entity_form_ajax_callback($form, $form_state) {
+  // return the form so Drupal can update the content on the page
+  return $form;
+}
 
  /**
   * Implements hook_validate() for the tripal_entity_form.
@@ -295,9 +297,9 @@ function tripal_view_entity($entity, $view_mode = 'full') {
 
    if (array_key_exists('clicked_button', $form_state) and
        $form_state['clicked_button']['#name'] =='add_data') {
-         $entity = $form_state['TripalEntity'];
-         field_attach_form_validate('TripalEntity', $entity, $form, $form_state);
-       }
+     $entity = $form_state['TripalEntity'];
+     field_attach_form_validate('TripalEntity', $entity, $form, $form_state);
+   }
  }
 
 

+ 97 - 0
tripal/includes/tripal.admin.inc

@@ -1 +1,98 @@
 <?php
+
+/**
+ * Provides a form for importing vocabularies and their terms.
+ *
+ * Tripal allows for vocabularies to be stored separately from the biological
+ * data. By default, the Tripal Chado module uses Chado for both the data
+ * storage backend and for storing controlled vocabularies. This is a wrapper
+ * function that calls the hook_vocab_import_form() hook function that allows
+ * the term storage backend to provide an approprite import form.
+ *
+ * @param $form
+ * @param $form_state
+ *
+ */
+function tripal_vocabulary_import_form($form, &$form_state) {
+  // TODO: we need some sort of administrative interface that lets the user
+  // switch to the desired vocabulary type. For now, we'll just use the
+  // first one in the list.
+  $stores = module_invoke_all('vocab_storage_info');
+  if (is_array($stores) and count($stores) > 0) {
+    $keys = array_keys($stores);
+    $module = $stores[$keys[0]]['module'];
+    $function = $module . '_vocab_import_form';
+    if (function_exists($function)) {
+      $form = $function($form, $form_state);
+    }
+    else {
+      drupal_set_message("The function '$function' is not implemented. Cannot import vocabularies.", 'error');
+    }
+  }
+  else {
+    tripal_set_message('A storage backend is not enabled for managing
+          the vocabulary terms used to create content.  Please enable
+          a module that supports storage of vocabualary terms (e.g. tripal_chado)
+          and return to create new Tripal content types.', TRIPAL_NOTICE);
+  }
+  return $form;
+}
+
+/**
+ *
+ * @param $form
+ * @param $form_state
+ */
+function tripal_vocabulary_import_form_validate($form, &$form_state) {
+  // TODO: we need some sort of administrative interface that lets the user
+  // switch to the desired vocabulary type. For now, we'll just use the
+  // first one in the list.
+  $stores = module_invoke_all('vocab_storage_info');
+  if (is_array($stores) and count($stores) > 0) {
+    $keys = array_keys($stores);
+    $module = $stores[$keys[0]]['module'];
+    $function = $module . '_vocab_import_form_validate';
+    if (function_exists($function)) {
+      $form = $function($form, $form_state);
+    }
+    else {
+      drupal_set_message("The function '$function' is not implemented. Cannot import vocabularies.", 'error');
+    }
+  }
+  else {
+    tripal_set_message('A storage backend is not enabled for managing
+      the vocabulary terms used to create content.  Please enable
+      a module that supports storage of vocabualary terms (e.g. tripal_chado)
+      and return to create new Tripal content types.', TRIPAL_NOTICE);
+  }
+  return $form;
+}
+/**
+ *
+ * @param $form
+ * @param $form_state
+ */
+function tripal_vocabulary_import_form_submit($form, &$form_state) {
+  // TODO: we need some sort of administrative interface that lets the user
+  // switch to the desired vocabulary type. For now, we'll just use the
+  // first one in the list.
+  $stores = module_invoke_all('vocab_storage_info');
+  if (is_array($stores) and count($stores) > 0) {
+    $keys = array_keys($stores);
+    $module = $stores[$keys[0]]['module'];
+    $function = $module . '_vocab_import_form_submit';
+    if (function_exists($function)) {
+      $form = $function($form, $form_state);
+    }
+    else {
+      drupal_set_message("The function '$function' is not implemented. Cannot import vocabularies.", 'error');
+    }
+  }
+  else {
+    tripal_set_message('A storage backend is not enabled for managing
+      the vocabulary terms used to create content.  Please enable
+      a module that supports storage of vocabualary terms (e.g. tripal_chado)
+      and return to create new Tripal content types.', TRIPAL_NOTICE);
+  }
+  return $form;
+}

+ 25 - 1
tripal/tripal.module

@@ -105,11 +105,35 @@ function tripal_menu() {
 
   $items['admin/tripal/storage'] = array(
     'title' => 'Storage Backend',
-    'description' => t("Functionality related to data storage and tools to interact with the storage backend."),
+    'description' => t("Tripal is designed so that it can store biological
+        data in any data storage back-end.  Tripal provides by default a
+        module for storing data in Chado.  All available storage backends
+        and their administrative tools are found here."),
     'weight' => 8,
     'access arguments' => array('administer tripal'),
   );
 
+  $items['admin/tripal/terms'] = array(
+    'title' => 'Vocabularies',
+    'description' => t("Vocabulary terms are essential to creating content
+        in Tripal. This allows data to be shared more easily with others
+        using technologies such as the semantic web and web services.
+        Before creating content you must have loaded vocabularies and their
+        terms."),
+    'weight' => 8,
+    'access arguments' => array('administer tripal'),
+  );
+  $items['admin/tripal/terms/import'] = array(
+    'title' => 'Import Vocabulary',
+    'description' => t("Import vocabularies and terms in OBO format."),
+    'access arguments' => array('administer tripal'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_vocabulary_import_form'),
+    'file' => 'includes/tripal.admin.inc',
+    'file path' => drupal_get_path('module', 'tripal'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+
   // Menu items for facilitating import of extension modules.
   $items['admin/tripal/extension'] = array(
     'title' => 'Extensions',

+ 0 - 79
tripal_chado/api/tripal_chado.api.inc

@@ -1,81 +1,2 @@
 <?php
 
-/**
- * Adds a field to an Entity bundle.
- *
- * @param $field_name
- *   The name of the field.
- * @param $field_info
- *   An associative array containing the field information.  The following
- *   key/value pairs are supported:
- *     'field_type' : a valid field type.  May be any of the Drupal default
- *       fields, one created by the tripal_chado module or another custom module.
- *     'widget_type' : a valid widget type. May be any of the Drupal default
- *       fields, one created by the tripal_chado module or another custom module.
- *     'field_settings' : an array of settings that are appropriate for the
- *       selected field type.
- *     'widget_settings' : an array of settings that are appropriate for the
- *       selected widget type.
- *     'description' :  a default description for this field.
- *     'label' : a label used as a header for this field.
- *     'is_required' : indicates if the field is required in the edit form.
- *     'cardinality' : indicates the number of values this field can support.
- *       the default is 1 (meaning only one value). Use a value of
- *       FIELD_CARDINALITY_UNLIMITED for unlimited number of values.
- * @param $entity_type_name
- *   The entity type name.
- * @param $bundle_name
- *   The bundle name.
- *
- */
-function tripal_add_bundle_field($field_name, $field_info, $entity_type_name, $bundle_name) {
-
-  $field = field_info_field($field_name);
-
-  // If the field exists and is attached to this bundle then just return,
-  // there is nothing left to do.
-  if ($field and array_key_exists('bundles', $field) and
-      array_key_exists($entity_type_name, $field['bundles']) and
-      in_array($bundle_name, $field['bundles'][$entity_type_name])) {
-    return;
-  }
-
-  // Allow other modules to alter the field information array.
-  drupal_alter('chado_field', $field_info);
-
-  $cardinality = 1;
-  if (array_key_exists('cardinality', $field_info) and is_numeric($field_info['cardinality'])) {
-    $cardinality = $field_info['cardinality'];
-  }
-
-  // If the field doesn't exist then create it.
-  if (!$field) {
-    $field = array(
-      'field_name' => $field_name,
-      'type' => $field_info['field_type'],
-      'cardinality' => $cardinality,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage'
-      ),
-      'settings' => $field_info['field_settings'],
-    );
-    field_create_field($field);
-  }
-
-  // Attach the field to the bundle.
-  $field_instance = array(
-    'field_name' => $field_name,
-    'label' => $field_info['label'],
-    'description' => $field_info['description'],
-    'widget' => array(
-      'type' => $field_info['widget_type'],
-      'settings' => $field_info['widget_settings'],
-    ),
-    'entity_type' => $entity_type_name,
-    'required' => $field_info['is_required'],
-    'settings' => $field_info['field_settings'],
-    'bundle' => $bundle_name,
-  );
-  field_create_instance($field_instance);
-}

+ 8 - 5
tripal_chado/includes/loaders/tripal_chado.fasta_loader.inc

@@ -342,7 +342,10 @@ function tripal_feature_fasta_load_form_submit($form, &$form_state) {
   );
 
   $fname = preg_replace("/.*\/(.*)/", "$1", $dfile);
-  tripal_add_job("Import FASTA file: $fname", 'tripal_chado', 'tripal_chado_load_fasta', $args, $user->uid);
+  $includes = array(
+    module_load_include('inc', 'tripal_chado', 'includes/loaders/tripal_chado.fasta_loader'),
+  );
+  tripal_add_job("Import FASTA file: $fname", 'tripal_chado', 'tripal_feature_load_fasta', $args, $user->uid, 10, $includes);
 }
 
 /**
@@ -596,7 +599,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type, $re_name, $re_un
         print "Current feature: " . $seq['uname'] . ".\n";
       }
 
-      tripal_chado_load_fasta_feature($fh, $seq['name'], $seq['uname'], $db_id, $seq['accession'], $seq['subject'], $rel_type, $parent_type, $analysis_id, $organism_id, $cvterm, $source, $method, $re_name, $match_type, $parentcvterm, $relcvterm, $seq['seq_start'], $seq['seq_end']);
+      tripal_feature_load_fasta_feature($fh, $seq['name'], $seq['uname'], $db_id, $seq['accession'], $seq['subject'], $rel_type, $parent_type, $analysis_id, $organism_id, $cvterm, $source, $method, $re_name, $match_type, $parentcvterm, $relcvterm, $seq['seq_start'], $seq['seq_end']);
     }
     tripal_set_job_progress($job, 100);
     fclose($fh);
@@ -613,7 +616,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type, $re_name, $re_un
 }
 
 /**
- * A helper function for tripal_chado_load_fasta() to load a single feature
+ * A helper function for tripal_feature_load_fasta() to load a single feature
  *
  * @ingroup fasta_loader
  */
@@ -707,7 +710,7 @@ function tripal_feature_load_fasta_feature($fh, $name, $uname, $db_id, $accessio
     }
 
     // Add the residues for this feature
-    tripal_chado_load_fasta_residues($fh, $feature->feature_id, $seq_start, $seq_end);
+    tripal_feature_load_fasta_residues($fh, $feature->feature_id, $seq_start, $seq_end);
   }
 
   // if we don't have a feature and the user wants to do an update then fail
@@ -791,7 +794,7 @@ function tripal_feature_load_fasta_feature($fh, $name, $uname, $db_id, $accessio
   }
 
   // Update the residues for this feature
-  tripal_chado_load_fasta_residues($fh, $feature->feature_id, $seq_start, $seq_end);
+  tripal_feature_load_fasta_residues($fh, $feature->feature_id, $seq_start, $seq_end);
 
   // add in the analysis link
   if ($analysis_id) {

+ 22 - 19
tripal_chado/includes/loaders/tripal_chado.gff_loader.inc

@@ -302,8 +302,11 @@ function tripal_feature_gff3_load_form_submit($form, &$form_state) {
     $type = 'delete features';
   }
   $fname = preg_replace("/.*\/(.*)/", "$1", $gff_file);
+  $includes = array(
+    module_load_include('inc', 'tripal_chado', 'includes/loaders/tripal_chado.gff_loader'),
+  );
   tripal_add_job("$type GFF3 file: $fname", 'tripal_chado',
-    'tripal_chado_load_gff3', $args, $user->uid);
+    'tripal_feature_load_gff3', $args, $user->uid, 10, $includes);
 
   return '';
 }
@@ -513,7 +516,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
           // we're done because this is a delete operation so break out of the loop.
           break;
         }
-        tripal_chado_load_gff3_fasta($fh, $interval, $num_read, $intv_read, $line_num, $filesize, $job);
+        tripal_feature_load_gff3_fasta($fh, $interval, $num_read, $intv_read, $line_num, $filesize, $job);
         continue;
       }
       // if the ##sequence-region line is present then we want to add a new feature
@@ -522,7 +525,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
         $rstart = $region_matches[2];
         $rend = $region_matches[3];
         if ($landmark_type) {
-          tripal_chado_load_gff3_feature($organism, $analysis_id, $landmark_cvterm, $rid,
+          tripal_feature_load_gff3_feature($organism, $analysis_id, $landmark_cvterm, $rid,
             $rid, '', 'f', 'f', 1, 0);
         }
         continue;
@@ -805,7 +808,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
       if ($update or $refresh or $add_only) {
 
         // Add/update the feature.
-        $feature = tripal_chado_load_gff3_feature($feature_organism, $analysis_id, $cvterm,
+        $feature = tripal_feature_load_gff3_feature($feature_organism, $analysis_id, $cvterm,
           $attr_uniquename, $attr_name, $residues, $attr_is_analysis,
           $attr_is_obsolete, $add_only, $score);
 
@@ -832,58 +835,58 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
           // add/update the featureloc if the landmark and the ID are not the same
           // if they are the same then this entry in the GFF is probably a landmark identifier
           if (strcmp($landmark, $attr_uniquename) !=0 ) {
-            tripal_chado_load_gff3_featureloc($feature, $organism,
+            tripal_feature_load_gff3_featureloc($feature, $organism,
               $landmark, $fmin, $fmax, $strand, $phase, $attr_fmin_partial,
               $attr_fmax_partial, $attr_residue_info, $attr_locgroup);
           }
 
           // add any aliases for this feature
           if (array_key_exists('Alias', $tags)) {
-            tripal_chado_load_gff3_alias($feature, $tags['Alias']);
+            tripal_feature_load_gff3_alias($feature, $tags['Alias']);
           }
           // add any dbxrefs for this feature
           if (array_key_exists('Dbxref', $tags)) {
-            tripal_chado_load_gff3_dbxref($feature, $tags['Dbxref']);
+            tripal_feature_load_gff3_dbxref($feature, $tags['Dbxref']);
           }
           // add any ontology terms for this feature
           if (array_key_exists('Ontology_term', $tags)) {
-            tripal_chado_load_gff3_ontology($feature, $tags['Ontology_term']);
+            tripal_feature_load_gff3_ontology($feature, $tags['Ontology_term']);
           }
           // add parent relationships
           if (array_key_exists('Parent', $tags)) {
-            tripal_chado_load_gff3_parents($feature, $cvterm, $tags['Parent'],
+            tripal_feature_load_gff3_parents($feature, $cvterm, $tags['Parent'],
               $feature_organism->organism_id, $strand, $phase, $fmin, $fmax);
           }
 
           // add target relationships
           if (array_key_exists('Target', $tags)) {
-            tripal_chado_load_gff3_target($feature, $tags, $target_organism_id, $target_type, $create_target, $attr_locgroup);
+            tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $target_type, $create_target, $attr_locgroup);
           }
           // add gap information.  This goes in simply as a property
           if (array_key_exists('Gap', $tags)) {
             foreach ($tags['Gap'] as $value) {
-              tripal_chado_load_gff3_property($feature, 'Gap', $value);
+              tripal_feature_load_gff3_property($feature, 'Gap', $value);
             }
           }
           // add notes. This goes in simply as a property
           if (array_key_exists('Note', $tags)) {
             foreach ($tags['Note'] as $value) {
-                tripal_chado_load_gff3_property($feature, 'Note', $value);
+                tripal_feature_load_gff3_property($feature, 'Note', $value);
             }
           }
           // add the Derives_from relationship (e.g. polycistronic genes).
           if (array_key_exists('Derives_from', $tags)) {
-            tripal_chado_load_gff3_derives_from($feature, $cvterm, $tags['Derives_from'][0],
+            tripal_feature_load_gff3_derives_from($feature, $cvterm, $tags['Derives_from'][0],
               $feature_organism, $fmin, $fmax);
           }
           // add in the GFF3_source dbxref so that GBrowse can find the feature using the source column
           $source_ref = array('GFF_source:' . $source);
-          tripal_chado_load_gff3_dbxref($feature, $source_ref);
+          tripal_feature_load_gff3_dbxref($feature, $source_ref);
           // add any additional attributes
           if ($attr_others) {
             foreach ($attr_others as $tag_name => $values) {
               foreach ($values as $value) {
-                tripal_chado_load_gff3_property($feature, $tag_name, $value);
+                tripal_feature_load_gff3_property($feature, $tag_name, $value);
               }
             }
           }
@@ -948,15 +951,15 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
             }
 
             // Add the new protein record.
-            $feature = tripal_chado_load_gff3_feature($organism, $analysis_id,
+            $feature = tripal_feature_load_gff3_feature($organism, $analysis_id,
               $protein_cvterm, $uname, $name, '', 'f', 'f', 1, 0);
             // Add the derives_from relationship.
             $cvterm = tripal_get_cvterm(array('cvterm_id' => $result->cvterm_id));
-            tripal_chado_load_gff3_derives_from($feature, $cvterm,
+            tripal_feature_load_gff3_derives_from($feature, $cvterm,
               $result->uniquename, $organism, $pfmin, $pfmax);
             // Add the featureloc record. Set the start of the protein to
             // be the start of the coding sequence minus the phase.
-            tripal_chado_load_gff3_featureloc($feature, $organism, $landmark,
+            tripal_feature_load_gff3_featureloc($feature, $organism, $landmark,
               $pfmin, $pfmax, $strand, '', 'f', 'f', '', 0);
           }
         }
@@ -2211,7 +2214,7 @@ function tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $
 
     // we want to add a featureloc record that uses the target feature as the srcfeature (landmark)
     // and the landmark as the feature.
-    tripal_chado_load_gff3_featureloc($feature, $organism, $target_feature, $target_fmin,
+    tripal_feature_load_gff3_featureloc($feature, $organism, $target_feature, $target_fmin,
       $target_fmax, $target_strand, $phase, $attr_fmin_partial, $attr_fmax_partial, $attr_residue_info,
       $attr_locgroup, $t_type_id, $t_organism_id, $create_target, TRUE);
   }

+ 5 - 9
tripal_chado/includes/loaders/tripal_chado.obo_loader.inc

@@ -43,17 +43,12 @@ function tripal_cv_obo_form($form, &$form_state) {
     $obo_id = array_key_exists('obo_id', $form_state['values']) ? $form_state['values']['obo_id'] : '';
   }
 
-  $form['instructions'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'instructions',
-    '#collapsible' => TRUE,
-    '#collapsed' => FALSE,
-  );
+
   $form['instructions']['info'] = array(
     '#type' => 'item',
     '#markup' => t('This page allows you to load vocabularies and ontologies
       that are in OBO format. Once loaded, the terms from these
-      vocabularies can be used to categorize data in the database.
+      vocabularies can be used to create content.
       You may use the form below to either reload a vocabulary that is already
       loaded (as when new updates to that vocabulary are available) or load a new
       vocabulary.'),
@@ -82,6 +77,7 @@ function tripal_cv_obo_form($form, &$form_state) {
       'callback' => 'tripal_cv_obo_form_ajax_callback',
       'wrapper' => 'obo-existing-fieldset',
     ),
+    '#description' => t('Select a vocabulary to import.')
   );
 
   // If the user has selected an OBO ID then get the form elements for
@@ -142,12 +138,12 @@ function tripal_cv_obo_form($form, &$form_state) {
         must be accessible to the web server on which this Drupal instance is running.'),
       '#default_value' => $uobo_file,
     );
-    $form['obo_existing']['update_obo_details']= array(
+    $form['obo_existing']['update_obo_details'] = array(
       '#type' => 'submit',
       '#value' => 'Update Ontology Details',
       '#name' => 'update_obo_details'
     );
-    $form['obo_existing']['update_load_obo']= array(
+    $form['obo_existing']['update_load_obo'] = array(
       '#type' => 'submit',
       '#value' => 'Load Vocabulary',
       '#name' => 'update_load_obo'

+ 33 - 4
tripal_chado/includes/tripal_chado.entity.inc

@@ -29,12 +29,16 @@ function tripal_chado_entity_create(&$entity, $type) {
 /**
  * Implements hook_entity_presave().
  */
-function tripal_chado_entity_presave($entity, $type) { }
+function tripal_chado_entity_presave($entity, $type) {
+
+}
 
 /**
  * Implements hook_entity_postsave().
  */
-function tripal_chado_entity_postsave($entity, $type) { }
+function tripal_chado_entity_postsave($entity, $type) {
+
+}
 
 /**
  * Implements hook_entity_load().
@@ -156,10 +160,35 @@ function tripal_chado_tripal_default_title_format($entity, $available_tokens) {
   $term = entity_load('TripalTerm', array('id' => $entity->term_id));
   $term = reset($term);
 
+  // Load the bundle
+  $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
+  $bundle_id = $bundle->id;
+  $table = tripal_get_bundle_variable('chado_table', $bundle_id);
+  $column = tripal_get_bundle_variable('chado_column', $bundle_id);
+  $cvterm_id = tripal_get_bundle_variable('chado_cvterm_id', $bundle_id);
+
   // For organism titles  we want the genus and species with no comma separation.
-  if ($term->name == 'organism') {
+  if ($table == 'organism') {
+    $format[] = array(
+      'format' => '[organism__genus] [organism__species]',
+      'weight' => -5
+    );
+  }
+  if ($table == 'analysis') {
+    $format[] = array(
+      'format' => '[analysis__name]',
+      'weight' => -5
+    );
+  }
+  if ($table == 'feature') {
+    $format[] = array(
+      'format' => '[feature__name]',
+      'weight' => -5
+    );
+  }
+  if ($table == 'stock') {
     $format[] = array(
-      'format' => '[organism__genus]-[organism__species]',
+      'format' => '[stock__name]',
       'weight' => -5
     );
   }

+ 22 - 0
tripal_chado/includes/tripal_chado.term_storage.inc

@@ -62,6 +62,28 @@ function tripal_chado_vocab_get_term($namespace, $accession) {
     'cvterm'     => $cvterm,
   );
 }
+
+/**
+ * Implements hook_vocab_import_form();
+ */
+function tripal_chado_vocab_import_form($form, &$form_state) {
+  module_load_include('inc', 'tripal_chado', 'includes/loaders/tripal_chado.obo_loader');
+  return tripal_cv_obo_form($form, $form_state);
+}
+/**
+ * Implements hook_vocab_import_form_validate();
+ */
+function tripal_chado_vocab_import_form_validate($form, &$form_state) {
+  module_load_include('inc', 'tripal_chado', 'includes/loaders/tripal_chado.obo_loader');
+  return tripal_cv_obo_form_validate($form, $form_state);
+}
+/**
+ * Implements hook_vocab_import_form_submit();
+ */
+function tripal_chado_vocab_import_form_submit($form, &$form_state) {
+  module_load_include('inc', 'tripal_chado', 'includes/loaders/tripal_chado.obo_loader');
+  return tripal_cv_obo_form_submit($form, $form_state);
+}
 /**
  * Implements hook_vocab_select_term_form().
  */

+ 35 - 12
tripal_chado/tripal_chado.module

@@ -132,6 +132,19 @@ function tripal_chado_menu() {
     'file path' => drupal_get_path('module', 'tripal_chado'),
     'weight' => -99
   );
+  $items['admin/tripal/storage/chado/publish'] = array(
+    'title' => 'Publish',
+    'description' => t('Publish data that is present in Chado but which does
+        not yet have a page on this site for viewing. In Tripal v2.0 or
+        earlier this was refered to as "syncing".'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_chado_publish_form'),
+    'type' => MENU_NORMAL_ITEM,
+    'access arguments' => array('administer tripal'),
+    'file' => 'includes/tripal_chado.publish.inc',
+    'file path' => drupal_get_path('module', 'tripal_chado'),
+    'weight' => -99
+  );
 
   //////////////////////////////////////////////////////////////////////////////
   //                       Materialized Views
@@ -312,16 +325,6 @@ function tripal_chado_menu() {
     'type' => MENU_NORMAL_ITEM,
     'weight' => 6
   );
-  $items['admin/tripal/storage/chado/loaders/obo_loader'] = array(
-    'title' => 'OBO File Loader',
-    'description' => 'Load an ontology in OBO format into chado as a controlled vocabulary.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_cv_obo_form'),
-    'access arguments' => array('administer controlled vocabularies'),
-    'file' => 'includes/loaders/tripal_chado.obo_loader.inc',
-    'file path' => drupal_get_path('module', 'tripal_chado'),
-    'type' => MENU_NORMAL_ITEM,
-  );
   $items['admin/tripal/storage/chado/loaders/fasta_loader'] = array(
     'title' => 'FASTA file Loader',
     'description' => 'Load sequences from a multi-FASTA file into Chado',
@@ -991,7 +994,7 @@ function tripal_chado_add_bundle_base_fields($entity_type_name, $bundle_name, $b
     }
 
     // If we don't have a field type then we don't need to create a field.
-    if (!$field_info['field_type']) {
+    if (!$field_info['field_type']) { http://www.phytozome.net/citrus.php
       // If we don't have a field type but it is required and doesn't have
       // a default value then we are in trouble.
       if ($field_info['is_required'] and !array_key_exists('default', $details)) {
@@ -1066,6 +1069,7 @@ function tripal_chado_get_table_column_field_default($table_name, $schema, $colu
       $field['widget_type'] = 'text_textarea';
       $field['field_settings']['max_length'] = 17179869184;
       $field['field_settings']['text_processing'] = 1;
+      $field['format'] = filter_default_format();
       break;
     case 'blob':
       // not sure how to support a blob field.
@@ -1189,13 +1193,32 @@ function tripal_chado_get_table_column_field_default($table_name, $schema, $colu
     $field['field_settings']['semantic_web']['type'] = 'SoftwareApplication';
     $field['field_settings']['semantic_web']['ns'] = 'schema';
     $field['field_settings']['semantic_web']['nsurl'] = 'https://schema.org/';
+    $field['description'] = 'The program name (e.g. blastx, blastp, sim4, genscan. If the analysis was not derived from a software package then provide a very brief description of the pipeline, workflow or method.';
+    $field['label'] = 'Program, Pipeline, Workflow or Method Name.';
   }
   elseif ($field['field_settings']['chado_table'] == 'analysis' and $field['field_settings']['chado_column'] == 'sourceuri') {
     $field['field_type'] = 'text';
     $field['widget_type'] = 'text_textfield';
     $field['field_settings']['text_processing'] = 0;
+    $field['label'] = 'Source URL';
+    $field['description'] = 'The URL where the original source data was derived.  Ideally, this should link to the page where more information about the source data can be found.';
+  }
+  elseif ($field['field_settings']['chado_table'] == 'analysis' and $field['field_settings']['chado_column'] == 'sourcename') {
+    $field['label'] = 'Source Name';
+    $field['description'] = 'The name of the source data. This could be a file name, data set or a small description for how the data was collected. For long descriptions use the larger description field.';
+  }
+  elseif ($field['field_settings']['chado_table'] == 'analysis' and $field['field_settings']['chado_column'] == 'sourceversion') {
+    $field['label'] = 'Source Version';
+    $field['description'] = 'If hte source data set has a version include it here.';
+  }
+  elseif ($field['field_settings']['chado_table'] == 'analysis' and $field['field_settings']['chado_column'] == 'algorithm') {
+    $field['label'] = 'Source Version';
+    $field['description'] = 'The name of the algorithm used to produce the dataset if different from the program.';
+  }
+  elseif ($field['field_settings']['chado_table'] == 'analysis' and $field['field_settings']['chado_column'] == 'programversion') {
+    $field['label'] = 'Program Version';
+    $field['description'] = 'The version of the program used to perform this analysis. (e.g. TBLASTX 2.0MP-WashU [09-Nov-2000]. Enter "n/a" if no version is available or applicable.';
   }
-
   return $field;
 }