Browse Source

Merge branch '7.x-3.x' into 7.x-2.x-ds

Stephen Ficklin 8 years ago
parent
commit
2f5203dd72
39 changed files with 290 additions and 418 deletions
  1. 1 2
      legacy/tripal_analysis/includes/tripal_analysis.delete.inc
  2. 1 1
      legacy/tripal_analysis/tripal_analysis.info
  3. 1 1
      legacy/tripal_contact/tripal_contact.info
  4. 1 1
      legacy/tripal_core/tripal_core.info
  5. 1 1
      legacy/tripal_cv/tripal_cv.info
  6. 1 1
      legacy/tripal_db/tripal_db.info
  7. 1 1
      legacy/tripal_example/tripal_example.info
  8. 1 1
      legacy/tripal_feature/tripal_feature.info
  9. 1 1
      legacy/tripal_featuremap/tripal_featuremap.info
  10. 1 1
      legacy/tripal_genetic/tripal_genetic.info
  11. 1 1
      legacy/tripal_library/tripal_library.info
  12. 1 1
      legacy/tripal_natural_diversity/tripal_natural_diversity.info
  13. 0 2
      legacy/tripal_organism/includes/tripal_organism.delete.inc
  14. 1 1
      legacy/tripal_organism/tripal_organism.info
  15. 1 1
      legacy/tripal_phenotype/tripal_phenotype.info
  16. 1 1
      legacy/tripal_phylogeny/tripal_phylogeny.info
  17. 1 1
      legacy/tripal_project/tripal_project.info
  18. 1 1
      legacy/tripal_pub/tripal_pub.info
  19. 1 1
      legacy/tripal_stock/tripal_stock.info
  20. 1 1
      legacy/tripal_views/tripal_views.info
  21. 3 0
      tripal/api/tripal.entities.api.inc
  22. 1 0
      tripal/includes/TripalFields/TripalField.inc
  23. 1 1
      tripal/tripal.info
  24. 0 1
      tripal/tripal.module
  25. 1 1
      tripal_bulk_loader/tripal_bulk_loader.info
  26. 2 1
      tripal_chado/api/modules/tripal_chado.cv.api.inc
  27. 1 1
      tripal_chado/api/tripal_chado.custom_tables.api.inc
  28. 2 81
      tripal_chado/api/tripal_chado.mviews.api.inc
  29. 17 6
      tripal_chado/api/tripal_chado.query.api.inc
  30. 4 12
      tripal_chado/api/tripal_chado.schema.api.inc
  31. 33 22
      tripal_chado/includes/loaders/tripal_chado.obo_loader.inc
  32. 53 47
      tripal_chado/includes/tripal_chado.fields.inc
  33. 80 149
      tripal_chado/includes/tripal_chado.semweb.inc
  34. 68 68
      tripal_chado/includes/tripal_chado.setup.inc
  35. 1 1
      tripal_chado/tripal_chado.info
  36. 1 2
      tripal_chado/tripal_chado.module
  37. 1 1
      tripal_chado_views/tripal_chado_views.info
  38. 1 1
      tripal_ds/tripal_ds.info
  39. 1 1
      tripal_ws/tripal_ws.info

+ 1 - 2
legacy/tripal_analysis/includes/tripal_analysis.delete.inc

@@ -88,7 +88,6 @@ function tripal_analysis_delete_analyses($analyses, $job = NULL) {
   // function which is not prefix with the schema, and an error occurs.
   // Therefore, we set the active database to chado to get around that
   // problem.
-//  $previous_db = chado_set_active('chado');
 
   // begin the transaction
   $transaction = db_transaction();
@@ -114,6 +113,6 @@ function tripal_analysis_delete_analyses($analyses, $job = NULL) {
     watchdog_exception('tripal_analysis', $e);
     return 0;
   }
-//  chado_set_active($previous_db);
+
   print "\nDone\n";
 }

+ 1 - 1
legacy/tripal_analysis/tripal_analysis.info

@@ -3,7 +3,7 @@ description = Supports the companalyses tables of Chado by providing pages for v
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 configure = admin/tripal/legacy/tripal_analysis/configuration
 
 dependencies[] = tripal_core

+ 1 - 1
legacy/tripal_contact/tripal_contact.info

@@ -3,7 +3,7 @@ description = Supports the contact tables of Chado by providing pages for viewin
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal_core
 dependencies[] = tripal_chado_views

+ 1 - 1
legacy/tripal_core/tripal_core.info

@@ -3,7 +3,7 @@ description = Provides support for all Tripal modules and includes the Tripal AP
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 configure = admin/tripal
 
 stylesheets[all][] = theme/css/tripal_core.css

+ 1 - 1
legacy/tripal_cv/tripal_cv.info

@@ -3,7 +3,7 @@ description = Supports the Controlled Vocabulary (CV) tables of Chado by providi
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 configure = admin/tripal/vocab
 
 dependencies[] = tripal_core

+ 1 - 1
legacy/tripal_db/tripal_db.info

@@ -3,7 +3,7 @@ description = Supports the database cross-reference tables of Chado by providing
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 configure = admin/tripal/legacy/tripal_db
 
 dependencies[] = tripal_core

+ 1 - 1
legacy/tripal_example/tripal_example.info

@@ -26,7 +26,7 @@ package = Tripal v2 Legacy Extensions
 ; Follow these instructions when specifying the version:
 ; https://drupal.org/node/1015226
 ;
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 ;
 ; Style-sheets containing CSS that should always be available for the

+ 1 - 1
legacy/tripal_feature/tripal_feature.info

@@ -3,7 +3,7 @@ description = Supports the sequence (feature) tables of Chado by providing pages
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 stylesheets[all][] = theme/css/tripal_feature.css
 scripts[]          = theme/js/tripal_feature.js

+ 1 - 1
legacy/tripal_featuremap/tripal_featuremap.info

@@ -3,7 +3,7 @@ description = Supports the map tables of Chado by providing pages for viewing an
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal_core
 dependencies[] = tripal_chado_views

+ 1 - 1
legacy/tripal_genetic/tripal_genetic.info

@@ -3,7 +3,7 @@ description = Supports the genetic tables of Chado by providing pages for viewin
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal_core
 dependencies[] = tripal_chado_views

+ 1 - 1
legacy/tripal_library/tripal_library.info

@@ -3,7 +3,7 @@ description = Supports the library tables of Chado by providing pages for viewin
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal_core
 dependencies[] = tripal_chado_views

+ 1 - 1
legacy/tripal_natural_diversity/tripal_natural_diversity.info

@@ -3,7 +3,7 @@ description = Supports the natural diversity (ND) tables of Chado by providing p
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal_core
 dependencies[] = tripal_chado_views

+ 0 - 2
legacy/tripal_organism/includes/tripal_organism.delete.inc

@@ -87,7 +87,6 @@ function tripal_organism_delete_organisms($organisms, $job = NULL) {
   // function which is not prefix with the schema, and an error occurs.
   // Therefore, we set the active database to chado to get around that
   // problem.
-//  $previous_db = chado_set_active('chado');
 
   // begin the transaction
   $transaction = db_transaction();
@@ -113,6 +112,5 @@ function tripal_organism_delete_organisms($organisms, $job = NULL) {
     watchdog_exception('tripal_organism', $e);
     return 0;
   }
-//  chado_set_active($previous_db);
   print "\nDone\n";
 }

+ 1 - 1
legacy/tripal_organism/tripal_organism.info

@@ -3,7 +3,7 @@ description = Supports the organism tables of Chado by providing pages for viewi
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 configure = admin/tripal/legacy/tripal_organism
 
 stylesheets[all][] = theme/css/tripal_organism.css

+ 1 - 1
legacy/tripal_phenotype/tripal_phenotype.info

@@ -3,7 +3,7 @@ description = Supports the phenotype tables of Chado by providing pages for view
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal_core
 dependencies[] = tripal_chado_views

+ 1 - 1
legacy/tripal_phylogeny/tripal_phylogeny.info

@@ -3,7 +3,7 @@ description = Supports the phylogeny tables of Chado by providing pages for view
 core = 7.x
 project = tripal_phylogeny
 package = Tripal Extensions
-version = 7.x-2.x
+version = 7.x-3.0-beta1
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_db

+ 1 - 1
legacy/tripal_project/tripal_project.info

@@ -3,7 +3,7 @@ description = Supports the project tables of Chado by providing pages for viewin
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 configure = admin/tripal/legacy/tripal_project
 
 dependencies[] = tripal_core

+ 1 - 1
legacy/tripal_pub/tripal_pub.info

@@ -3,7 +3,7 @@ description = Supports the pub (publication) tables of Chado by providing pages
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 stylesheets[all][] = theme/css/tripal_pub.css
 

+ 1 - 1
legacy/tripal_stock/tripal_stock.info

@@ -3,7 +3,7 @@ description = Supports the stock tables of Chado by providing pages for viewing,
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal_core
 dependencies[] = tripal_chado_views

+ 1 - 1
legacy/tripal_views/tripal_views.info

@@ -3,4 +3,4 @@ description = Deprecated-- no longer provides any functionality. See Tripal Chad
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1

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

@@ -284,6 +284,9 @@ function tripal_create_bundle($args, &$error = '') {
       foreach ($info as $field_name => $details) {
         $field_type = $details['type'];
 
+        // TODO: make sure the field term exits. If not then
+        // skip it.
+
         // If the field already exists then skip it.
         $field = field_info_field($details['field_name']);
         if ($field) {

+ 1 - 0
tripal/includes/TripalFields/TripalField.inc

@@ -111,6 +111,7 @@ class TripalField {
         $accession = $instance['settings']['term_accession'];
         $term = tripal_get_term_details($vocabulary, $accession);
         if (!$term) {
+          dpm(debug_backtrace());
           throw new Error(t('Cannot create TripalField of type "%term" as that
               term does not exist.', array('%term' => "$vocabulary:$accession")));
         }

+ 1 - 1
tripal/tripal.info

@@ -3,7 +3,7 @@ description = Tripal is an toolkit to facilitate construction of online genomic,
 core = 7.x
 project = tripal
 package = Tripal
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 configure = admin/tripal
 
 stylesheets[all][] = theme/css/tripal.css

+ 0 - 1
tripal/tripal.module

@@ -50,7 +50,6 @@ function tripal_views_api() {
 
 /**
  * Implements hook_init().
- * Used to set the search_path, create default content and set default variables.
  *
  * @ingroup tripal
  */

+ 1 - 1
tripal_bulk_loader/tripal_bulk_loader.info

@@ -3,7 +3,7 @@ description = Supports the construction of templates for customizable uploading
 core = 7.x
 project = tripal
 package = Tripal
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal_core
 dependencies[] = tripal_chado_views

+ 2 - 1
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -347,6 +347,8 @@ function tripal_update_cvtermpath($cv_id, $job_id = NULL) {
 
   print "\nUpdating cvtermpath for $cv->name...\n";
 
+  // We need to set the chado schema as active because some of the
+  // functions call other functions which would not be in scope.
   $previous = chado_set_active('chado');
   try {
     $sql = "SELECT * FROM fill_cvtermpath(:name)";
@@ -359,7 +361,6 @@ function tripal_update_cvtermpath($cv_id, $job_id = NULL) {
     tripal_report_error('tripal_chado', TRIPAL_ERROR, "Could not fill cvtermpath table: @error", array('@error' => $error));
     return FALSE;
   }
-
   return TRUE;
 }
 

+ 1 - 1
tripal_chado/api/tripal_chado.custom_tables.api.inc

@@ -122,7 +122,7 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_if_exist
  *
  * @ingroup tripal_custom_tables_api
  */
-function chado_create_custom_table($table, $schema, $skip_if_exists = 1, $mview_id = NULL) {
+function chado_create_custom_table($table, $schema, $skip_if_exists = TRUE, $mview_id = NULL) {
   global $databases;
   $created = 0;
   $recreated = 0;

+ 2 - 81
tripal_chado/api/tripal_chado.mviews.api.inc

@@ -14,83 +14,6 @@
  * @}
  */
 
-/**
- * Add a materialized view to the chado database to help speed data access. This
- * function supports the older style where postgres column specifications
- * are provided using the $mv_table, $mv_specs and $indexed variables. It also
- * supports the newer preferred method where the materialized view is described
- * using the Drupal Schema API array.
- *
- * @param $name
- *   The name of the materialized view.
- * @param $modulename
- *   The name of the module submitting the materialized view (e.g. 'tripal_library')
- * @param $mv_table
- *   The name of the table to add to chado. This is the table that can be queried.
- * @param $mv_specs
- *   The table definition
- * @param $indexed
- *   The columns that are to be indexed
- * @param $query
- *   The SQL query that loads the materialized view with data
- * @param $special_index
- *   currently not used
- * @param $comment
- *   A string containing a description of the materialized view
- *
- * @ingroup tripal_mviews_api
- *
-function tripal_add_legacy_mview($name, $modulename, $mv_table, $mv_specs, $indexed,
-  $query, $special_index, $comment =OR NULL) {
-
-  // Create a new record
-  $record = new stdClass();
-  $record->name = $name;
-  $record->modulename = $modulename;
-  $record->mv_table = $mv_table;
-  $record->mv_specs = $mv_specs;
-  $record->indexed = $indexed;
-  $record->query = $query;
-  $record->special_index = $special_index;
-  $record->comment = $comment;
-
-  // add the record to the tripal_mviews table and if successful
-  // create the new materialized view in the chado schema
-  if (drupal_write_record('tripal_mviews', $record)) {
-
-    // drop the table from chado if it exists
-    if (chado_table_exists($mv_table)) {
-      $sql = "DROP TABLE {$mv_table}";
-      chado_query($sql);
-    }
-
-    // now construct the indexes
-    $index = '';
-    if ($indexed) {
-      // add to the array of values
-      $vals = preg_split("/[\n,]+/", $indexed);
-      $index = '';
-      foreach ($vals as $field) {
-        $field = trim($field);
-        $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
-      }
-    }
-  }
-
-  // add the table to the database
-  $sql = "CREATE TABLE {$mv_table} ($mv_specs); $index";
-  $previous_db = chado_set_active('chado');  // use chado database
-  $results = db_query($sql);
-  chado_set_active($previous_db);  // now use drupal database
-  if ($results) {
-    drupal_set_message(t("Materialized view '%name' created", array('%name' => $name)));
-  }
-  else {
-    drupal_set_message(t("Failed to create the materialized view table: '%mv_table'", array('%mv_table' => $mv_table)), 'error');
-  }
-}
-*/
-
 /**
  * Add a materialized view to the chado database to help speed data access. This
  * function supports the older style where postgres column specifications
@@ -432,10 +355,8 @@ function tripal_populate_mview($mview_id) {
     // that may leave parts of the site unfunctional
     $transaction = db_transaction();
     try {
-      $previous_db = chado_set_active('chado');  // use chado database
-      $success = db_query("DELETE FROM {" . $mview->mv_table . "}");
-      $success = db_query("INSERT INTO {" . $mview->mv_table . "} ($mview->query)");
-      chado_set_active($previous_db);  // now use drupal database
+      $success = chado_query("DELETE FROM {" . $mview->mv_table . "}");
+      $success = chado_query("INSERT INTO {" . $mview->mv_table . "} ($mview->query)");
       // if success get the number of results and update the table record
       if ($success) {
         $sql = "SELECT count(*) as cnt FROM {" . $mview->mv_table . "}";

+ 17 - 6
tripal_chado/api/tripal_chado.query.api.inc

@@ -113,14 +113,18 @@ function chado_set_active($dbname = 'default') {
     $GLOBALS['chado_active_db'] = 'default';
   }
 
-  $previous_db = $active_db = $GLOBALS['chado_active_db'];
-  $search_path = 'public';
+  $previous_db = $GLOBALS['chado_active_db'];
+
 
   // Change only if 'chado' has been specified.
   if ($dbname == 'chado') {
     $active_db = 'chado';
     $search_path = 'chado,public';
   }
+  else {
+    $active_db = $dbname;
+    $search_path = 'public';
+  }
 
   $settings = array(
     'dbname'          => $dbname,
@@ -132,10 +136,10 @@ function chado_set_active($dbname = 'default') {
   // note: hooks can alter $active_db and $search_path.
   drupal_alter('chado_connection', $settings);
 
-  // set chado_active_db to remember active db
+  // Set chado_active_db to remember active db.
   $GLOBALS['chado_active_db'] = $active_db;
 
-  // set PostgreSQL search_path
+  // Set PostgreSQL search_path.
   db_query('SET search_path TO ' . $search_path);
 
   return $previous_db;
@@ -1633,8 +1637,15 @@ function chado_query($sql, $args = array()) {
     // must automaticaly have the chado schema set as active to find
     if (preg_match('/chado.featureloc/i', $sql) or preg_match('/chado.feature/i', $sql)) {
       $previous_db = chado_set_active('chado') ;
-      $results = db_query($sql, $args);
-      chado_set_active($previous_db);
+      try {
+        $results = db_query($sql, $args);
+        chado_set_active($previous_db);
+      }
+      catch (Exception $e) {
+        chado_set_active($previous_db);
+        throw $e;
+      }
+
     }
     // for all other tables we should have everything in scope so just run the query
     else {

+ 4 - 12
tripal_chado/api/tripal_chado.schema.api.inc

@@ -38,14 +38,10 @@
  */
 function chado_table_exists($table) {
   global $databases;
+
+  global $databases;
+
   $default_db = $databases['default']['default']['database'];
-  $cached_obj = cache_get('chado_tables', 'cache');
-  if ($cached_obj) {
-    $cached_tables = $cached_obj->data;
-    if (is_array($cached_tables) and array_key_exists($table, $cached_tables)) {
-      return $cached_tables[$table]['exists'];
-    }
-  }
 
   $sql = "
     SELECT 1
@@ -63,12 +59,8 @@ function chado_table_exists($table) {
   $results = db_query($sql, $args);
   $exists = $results->fetchObject();
   if (!$exists) {
-    $cached_tables[$table]['exists'] = FALSE;
-    cache_set('chado_tables', $cached_tables, 'cache', CACHE_TEMPORARY);
     return FALSE;
   }
-  $cached_tables[$table]['exists'] = TRUE;
-  cache_set('chado_tables', $cached_tables, 'cache', CACHE_TEMPORARY);
   return TRUE;
 }
 /**
@@ -438,7 +430,7 @@ function chado_get_version($exact = FALSE, $warn_if_unsupported = FALSE) {
 function chado_get_table_names($include_custom = NULL) {
 
   // first get the chado version that is installed
-  $v = $GLOBALS["chado_version"];
+  $v = array_key_exists('chado_version', $GLOBALS) ? $GLOBALS["chado_version"] : '';
 
   $tables = array();
   if ($v == '1.3') {

+ 33 - 22
tripal_chado/includes/loaders/tripal_chado.obo_loader.inc

@@ -634,9 +634,11 @@ function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
     $term = unserialize(base64_decode($typedef->stanza));
 
     // update the job status every interval
-    if ($jobid and $i % $interval == 0) {
+    if ($i % $interval == 0) {
       $complete = ($i / $count) * 33.33333333;
-      tripal_set_job_progress($jobid, intval($complete + 33.33333333));
+      if ($jobid) {
+        tripal_set_job_progress($jobid, intval($complete + 33.33333333));
+      }
       printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
     }
 
@@ -644,17 +646,19 @@ function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
 
     $i++;
   }
-    // set the final status
+
+  // Set the final status.
+  if ($count > 0) {
+    $complete = ($i / $count) * 33.33333333;
+  }
+  else {
+    $complete = 33.33333333;
+  }
   if ($jobid) {
-    if ($count > 0) {
-      $complete = ($i / $count) * 33.33333333;
-    }
-    else {
-      $complete = 33.33333333;
-    }
     tripal_set_job_progress($jobid, intval($complete + 33.33333333));
-    printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
   }
+  printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
+
   return 1;
 }
 
@@ -703,9 +707,11 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
     $term = unserialize(base64_decode($t->stanza));
 
     // update the job status every interval
-    if ($jobid and $i % $interval == 0) {
+    if ($i % $interval == 0) {
       $complete = ($i / $count) * 33.33333333;
-      tripal_set_job_progress($jobid, intval($complete + 66.666666));
+      if ($jobid) {
+        tripal_set_job_progress($jobid, intval($complete + 66.666666));
+      }
       printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
     }
 
@@ -718,16 +724,17 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
   }
 
   // set the final status
+  if ($count > 0) {
+    $complete = ($i / $count) * 33.33333333;
+  }
+  else {
+    $complete = 33.33333333;
+  }
   if ($jobid) {
-    if ($count > 0) {
-      $complete = ($i / $count) * 33.33333333;
-    }
-    else {
-      $complete = 33.33333333;
-    }
     tripal_set_job_progress($jobid, intval($complete + 66.666666));
-    printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
   }
+  printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
+
 
   return 1;
 }
@@ -1164,10 +1171,12 @@ function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
     $line = trim($line);
 
     // update the job status every 1% features
-    if ($jobid and $intv_read >= $interval) {
+    if ($intv_read >= $interval) {
       $percent = sprintf("%.2f", ($num_read / $filesize) * 100);
       print "Parsing Line $line_num (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\r";
-      tripal_set_job_progress($jobid, intval(($num_read / $filesize) * 33.33333333));
+      if ($jobid) {
+        tripal_set_job_progress($jobid, intval(($num_read / $filesize) * 33.33333333));
+      }
       $intv_read = 0;
     }
 
@@ -1252,7 +1261,9 @@ function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
     }
     $percent = sprintf("%.2f", ($num_read / $filesize) * 100);
     print "Parsing Line $line_num (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\r";
-    tripal_set_job_progress($jobid, intval(($num_read / $filesize) * 33.33333333));
+    if ($jobid) {
+      tripal_set_job_progress($jobid, intval(($num_read / $filesize) * 33.33333333));
+    }
   }
   return $default_db;
 }

+ 53 - 47
tripal_chado/includes/tripal_chado.fields.inc

@@ -347,6 +347,9 @@ function tripal_chado_bundle_create_fields_custom(&$info, $details, $entity_type
       'type' => 'image',
       'cardinality' => 1,
       'locked' => FALSE,
+      'storage' => array(
+        'type' => 'field_sql_storage',
+      ),
     );
   }
 }
@@ -397,20 +400,21 @@ function tripal_chado_bundle_create_fields_linker(&$info, $details, $entity_type
   }
 
   // EXPRESSION
-  $expression_table = $table_name . '_expression';
-  if (chado_table_exists($expression_table)) {
-    $field_name = 'go__gene_expression';
-    $field_type = 'go__gene_expression';
-    $info[$field_name] = array(
-      'field_name' => $field_name,
-      'type' => $field_type,
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-    );
-  }
+  // TODO: this should only show up on gene or mRNA bunldes, not every feature.
+//   $expression_table = $table_name . '_expression';
+//   if (chado_table_exists($expression_table)) {
+//     $field_name = 'go__gene_expression';
+//     $field_type = 'go__gene_expression';
+//     $info[$field_name] = array(
+//       'field_name' => $field_name,
+//       'type' => $field_type,
+//       'cardinality' => FIELD_CARDINALITY_UNLIMITED,
+//       'locked' => FALSE,
+//       'storage' => array(
+//         'type' => 'field_chado_storage',
+//       ),
+//     );
+//   }
 
   // FEATURELOC
   if ($table_name == 'feature') {
@@ -1283,39 +1287,41 @@ function tripal_chado_bundle_create_instances_linker(&$info, $entity_type, $bund
   }
 
   // EXPRESSION
-  $expression_table = $table_name . '_expression';
-  if (chado_table_exists($expression_table)) {
-    $field_name = 'go__gene_expression';
-    $schema = chado_get_schema($expression_table);
-    $pkey = $schema['primary key'][0];
-    $info[$field_name] = array(
-      'field_name' => $field_name,
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
-      'label' => 'Gene expression',
-      'description' => 'Information about the expression of this record.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-        'chado_table' => $expression_table,
-        'chado_column' => $pkey,
-        'base_table' => $table_name,
-      ),
-      'widget' => array(
-        'type' => 'go__gene_expression_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'go__gene_expression_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
+  // TODO: this should only show up on gene or mRNA and the GO must be
+  // laoded or this field will crash things.
+//   $expression_table = $table_name . '_expression';
+//   if (chado_table_exists($expression_table)) {
+//     $field_name = 'go__gene_expression';
+//     $schema = chado_get_schema($expression_table);
+//     $pkey = $schema['primary key'][0];
+//     $info[$field_name] = array(
+//       'field_name' => $field_name,
+//       'entity_type' => $entity_type,
+//       'bundle' => $bundle->name,
+//       'label' => 'Gene expression',
+//       'description' => 'Information about the expression of this record.',
+//       'required' => FALSE,
+//       'settings' => array(
+//         'auto_attach' => FALSE,
+//         'chado_table' => $expression_table,
+//         'chado_column' => $pkey,
+//         'base_table' => $table_name,
+//       ),
+//       'widget' => array(
+//         'type' => 'go__gene_expression_widget',
+//         'settings' => array(
+//           'display_label' => 1,
+//         ),
+//       ),
+//       'display' => array(
+//         'default' => array(
+//           'label' => 'above',
+//           'type' => 'go__gene_expression_formatter',
+//           'settings' => array(),
+//         ),
+//       ),
+//     );
+//   }
 
   // FEATURELOC
   if ($table_name == 'feature') {

+ 80 - 149
tripal_chado/includes/tripal_chado.semweb.inc

@@ -31,7 +31,6 @@ function tripal_chado_populate_chado_semweb_table() {
   tripal_chado_populate_vocab_SBO();
   tripal_chado_populate_vocab_SCHEMA();
   tripal_chado_populate_vocab_SIO();
-  tripal_chado_populate_vocab_SO();
   tripal_chado_populate_vocab_SWO();
   tripal_chado_populate_vocab_TAXRANK();
   tripal_chado_populate_vocab_TCONTACT();
@@ -45,14 +44,16 @@ function tripal_chado_populate_chado_semweb_table() {
  */
 function tripal_chado_populate_vocab_FOAF() {
 
-  tripal_insert_cv('foaf','Friend of a Friend');
   tripal_insert_db(array(
     'name' => 'foaf',
     'description' => 'Friend of a Friend',
     'url' => 'http://www.foaf-project.org/',
     'urlprefix' => 'http://xmlns.com/foaf/spec/#',
   ));
-  tripal_insert_cv('foaf','Friend of a Friend. A dictionary of people-related terms that can be used in structured data).');
+  tripal_insert_cv(
+    'foaf',
+    'Friend of a Friend. A dictionary of people-related terms that can be used in structured data).'
+  );
 }
 
 /**
@@ -65,7 +66,10 @@ function tripal_chado_populate_vocab_RDFS() {
     'url' => 'https://www.w3.org/TR/rdf-schema/',
     'urlprefix' => 'https://www.w3.org/TR/rdf-schema/#ch_',
   ));
-  tripal_insert_cv('rdfs','Resource Description Framework Schema');
+  tripal_insert_cv(
+    'rdfs',
+    'Resource Description Framework Schema'
+  );
 
   $name = tripal_insert_cvterm(array(
     'id' => 'rdfs:type',
@@ -90,7 +94,10 @@ function tripal_chado_populate_vocab_SCHEMA() {
     'url' => 'https://schema.org/',
     'urlprefix' => 'https://schema.org/{accession}',
   ));
-  tripal_insert_cv('schema','Schema.org. Schema.org is sponsored by Google, Microsoft, Yahoo and Yandex. The vocabularies are developed by an open community process.');
+  tripal_insert_cv(
+    'schema',
+    'Schema.org. Schema.org is sponsored by Google, Microsoft, Yahoo and Yandex. The vocabularies are developed by an open community process.'
+  );
 
 
   $term = tripal_insert_cvterm(array(
@@ -218,7 +225,10 @@ function tripal_chado_populate_vocab_EDAM() {
     'url' => 'http://edamontology.org/page',
     'urlprefix' => 'http://edamontology.org/{db}_{accession}',
   ));
-  tripal_insert_cv('data','Bioinformatics operations, data types, formats, identifiers and topics.');
+  tripal_insert_cv(
+    'data',
+    'Bioinformatics operations, data types, formats, identifiers and topics.'
+  );
 
 
   $term = tripal_insert_cvterm(array(
@@ -327,7 +337,10 @@ function tripal_chado_populate_vocab_ERO() {
     'url' => 'http://purl.bioontology.org/ontology/ERO',
     'urlprefix' => 'http://purl.bioontology.org/ontology/ERO/{db}:{accession}',
   ));
-  tripal_insert_cv('ero','The Eagle-I Research Resource Ontology models research resources such instruments. protocols, reagents, animal models and biospecimens. It has been developed in the context of the eagle-i project (http://eagle-i.net/).');
+  tripal_insert_cv(
+      'ero',
+      'The Eagle-I Research Resource Ontology models research resources such instruments. protocols, reagents, animal models and biospecimens. It has been developed in the context of the eagle-i project (http://eagle-i.net/).'
+  );
 
   $term = tripal_insert_cvterm(array(
     'id' => 'ERO:0001716',
@@ -347,7 +360,10 @@ function tripal_chado_populate_vocab_OBI() {
     'url' => 'http://obi-ontology.org/page/Main_Page',
     'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
   ));
-  tripal_insert_cv('obi','Ontology for Biomedical Investigation. The Ontology for Biomedical Investigations (OBI) is build in a collaborative, international effort and will serve as a resource for annotating biomedical investigations, including the study design, protocols and instrumentation used, the data generated and the types of analysis performed on the data. This ontology arose from the Functional Genomics Investigation Ontology (FuGO) and will contain both terms that are common to all biomedical investigations, including functional genomics investigations and those that are more domain specific.');
+  tripal_insert_cv(
+    'obi',
+    'Ontology for Biomedical Investigation. The Ontology for Biomedical Investigations (OBI) is build in a collaborative, international effort and will serve as a resource for annotating biomedical investigations, including the study design, protocols and instrumentation used, the data generated and the types of analysis performed on the data. This ontology arose from the Functional Genomics Investigation Ontology (FuGO) and will contain both terms that are common to all biomedical investigations, including functional genomics investigations and those that are more domain specific.'
+  );
 
   $term = tripal_insert_cvterm(array(
     'id' => 'OBI:0100026',
@@ -368,7 +384,10 @@ function tripal_chado_populate_vocab_OGI() {
     'url' => 'http://purl.bioontology.org/ontology/OGI',
     'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
   ));
-  tripal_insert_cv('obi','Ontology for Biomedical Investigation. The Ontology for Biomedical Investigations (OBI) is build in a collaborative, international effort and will serve as a resource for annotating biomedical investigations, including the study design, protocols and instrumentation used, the data generated and the types of analysis performed on the data. This ontology arose from the Functional Genomics Investigation Ontology (FuGO) and will contain both terms that are common to all biomedical investigations, including functional genomics investigations and those that are more domain specific.');
+  tripal_insert_cv(
+    'ogi',
+    'Ontology for Biomedical Investigation. The Ontology for Biomedical Investigations (OBI) is build in a collaborative, international effort and will serve as a resource for annotating biomedical investigations, including the study design, protocols and instrumentation used, the data generated and the types of analysis performed on the data. This ontology arose from the Functional Genomics Investigation Ontology (FuGO) and will contain both terms that are common to all biomedical investigations, including functional genomics investigations and those that are more domain specific.'
+  );
 
   $term = tripal_insert_cvterm(array(
     'id' => 'OGI:0000021',
@@ -389,14 +408,17 @@ function tripal_chado_populate_vocab_IAO() {
     'url' => 'https://github.com/information-artifact-ontology/IAO/',
     'urlprefix' => 'http://purl.obolibrary.org/obo/IAO_',
   ));
-  tripal_insert_cv('IAO','Information Artifact Ontology  is a new ' .
+  tripal_insert_cv(
+    'IAO',
+    'Information Artifact Ontology  is a new ' .
       'ontology of information entities, originally driven by work by the ' .
-      'OBI digital entity and realizable information entity branch.');
+      'OBI digital entity and realizable information entity branch.'
+  );
 
   $term = tripal_insert_cvterm(array(
     'id' => 'IAO:0000115',
     'name' => 'definition',
-    'cv_name' => 'iao',
+    'cv_name' => 'IAO',
     'definition' => 'The official OBI definition, explaining the meaning of ' .
       'a class or property. Shall be Aristotelian, formalized and normalized. ' .
       'Can be augmented with colloquial definitions.',
@@ -459,10 +481,6 @@ function tripal_chado_populate_vocab_LOCAL() {
     'tripal_phylogeny',
     'Terms used by the Tripal phylotree module for phylogenetic and taxonomic trees.'
   );
-  tripal_insert_cv(
-    'synonym_type',
-    'A local vocabulary that contains synonym types (e.g. exact, broad, narrow, related).'
-  );
   // Add cv for relationship types
   tripal_insert_cv(
     'feature_relationship',
@@ -727,7 +745,6 @@ function tripal_chado_populate_vocab_LOCAL() {
       'name' => $term,
       'definition' => '',
       'cv_name' => 'organism_property',
-      'is_relationship' => 0,
       'db_name' => 'local'
     );
     tripal_insert_cvterm($value, $options);
@@ -738,16 +755,13 @@ function tripal_chado_populate_vocab_LOCAL() {
   //---------------------
 
   // Add the terms used to identify nodes in the tree.
-  tripal_insert_cvterm(
-      array(
-        'name' => 'phylo_leaf',
-        'definition' => 'A leaf node in a phylogenetic tree.',
-        'cv_name' => 'tripal_phylogeny',
-        'is_relationship' => 0,
-        'db_name' => 'local'
-      ),
-      array('update_existing' => TRUE)
-  );
+  tripal_insert_cvterm(array(
+    'name' => 'phylo_leaf',
+    'definition' => 'A leaf node in a phylogenetic tree.',
+    'cv_name' => 'tripal_phylogeny',
+    'is_relationship' => 0,
+    'db_name' => 'local'
+  ));
   // Add the terms used to identify nodes in the tree.
   tripal_insert_cvterm(array(
     'name' => 'phylo_root',
@@ -775,36 +789,6 @@ function tripal_chado_populate_vocab_LOCAL() {
     'db_name' => 'local'
   ));
 
-  //---------------------
-  // Synonym Types Terms
-  //---------------------
-  tripal_insert_cvterm(array(
-    'name' => 'exact',
-    'definition' => 'An exact equivalent; interchangeable with the term name.',
-    'cv_name' => 'synonym_type',
-    'db_name' => 'local',
-  ), array('force_db_change' => TRUE));
-
-  tripal_insert_cvterm(array(
-    'name' => 'broad',
-    'definition' => 'The synonym is broader than the name.',
-    'cv_name' => 'synonym_type',
-    'db_name' => 'local',
-  ), array('force_db_change' => TRUE));
-  tripal_insert_cvterm(array(
-    'name' => 'narrow',
-    'definition' => 'The synonym is narrower or more precise than the name.',
-    'cv_name' => 'synonym_type',
-    'db_name' => 'local',
-  ), array('force_db_change' => TRUE));
-
-  tripal_insert_cvterm(array(
-    'name' => 'related',
-    'definition' => 'The synonym is related in some way.',
-    'cv_name' => 'synonym_type',
-    'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
-
 
   //--------------
   // Project Terms
@@ -817,7 +801,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'definition'  => 'Description of a project',
     'cv_name' => 'project_property',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
 
   //--------------
   // Natural Diversity Terms
@@ -828,21 +812,21 @@ function tripal_chado_populate_vocab_LOCAL() {
     'definition' => 'An experiment where genotypes of individuals are identified.',
     'cv_name' => 'nd_experiment_types',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
 
   tripal_insert_cvterm(array(
     'name' => 'Phenotyping',
     'definition' => 'An experiment where phenotypes of individuals are identified.',
     'cv_name' => 'nd_experiment_types',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
 
   tripal_insert_cvterm(array(
     'name' => 'Location',
     'definition' => 'The name of the location.',
     'cv_name' => 'nd_geolocation_property',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
 
 
   //--------------
@@ -857,7 +841,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'definition' => 'Description of a library',
     'cv_name' => 'library_property',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
 
   // add cvterms for the map unit types
   tripal_insert_cvterm(array(
@@ -866,42 +850,42 @@ function tripal_chado_populate_vocab_LOCAL() {
     'definition' => 'cDNA library',
     'cv_name' => 'library_type',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'id' => 'local:bac_library',
     'name' => 'bac_library',
     'definition' => 'Bacterial Artifical Chromsome (BAC) library',
     'cv_name' => 'library_type',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'id' => 'local:fosmid_library',
     'name' => 'fosmid_library',
     'definition' => 'Fosmid library',
     'cv_name' => 'library_type',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'id' => 'local:cosmid_library',
     'name' => 'cosmid_library',
     'definition' => 'Cosmid library',
     'cv_name' => 'library_type',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'id' => 'local:yac_library',
     'name' => 'yac_library',
     'definition' => 'Yeast Artificial Chromosome (YAC) library',
     'cv_name' => 'library_type',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'id' => 'local:genomic_library',
     'name' => 'genomic_library',
     'definition' => 'Genomic Library',
     'cv_name' => 'library_type',
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
 
   //--------------
   // Feature Map
@@ -913,35 +897,35 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'featuremap_units',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'bp',
     'definition' => 'Base pairs units',
     'cv_name' => 'featuremap_units',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'bin_unit',
     'definition' => 'The bin unit',
     'cv_name' => 'featuremap_units',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'marker_order',
     'definition' => 'Units simply to define marker order.',
     'cv_name' => 'featuremap_units',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'undefined',
     'definition' => 'A catch-all for an undefined unit type',
     'cv_name' => 'featuremap_units',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   // featurepos properties
   tripal_insert_cvterm(array(
     'name' => 'start',
@@ -949,14 +933,14 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'featurepos_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'stop',
     'definition' => 'The end coordinate for a map feature',
     'cv_name' => 'featurepos_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   // add cvterms for map properties
   tripal_insert_cvterm(array(
     'name' => 'Map Dbxref',
@@ -966,21 +950,21 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'featuremap_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'Map Type',
     'definition' => 'The type of Map (e.g. QTL, Physical, etc.)',
     'cv_name' => 'featuremap_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'Genome Group',
     'definition' => '',
     'cv_name' => 'featuremap_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'URL',
     'definition' => 'A univeral resource locator (URL) reference where the '
@@ -989,7 +973,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'featuremap_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'Population Type',
     'definition' => 'A brief description of the population type used to generate '
@@ -997,28 +981,28 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'featuremap_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'Population Size',
     'definition' => 'The size of the population used to construct the map.',
     'cv_name' => 'featuremap_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'Methods',
     'definition' => 'A brief description of the methods used to construct the map.',
     'cv_name' => 'featuremap_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
   tripal_insert_cvterm(array(
     'name' => 'Software',
     'definition' => 'The software used to construct the map.',
     'cv_name' => 'featuremap_property',
     'is_relationship' => 0,
     'db_name' => 'local'
-  ), array('force_db_change' => TRUE));
+  ));
 
 
   //--------------
@@ -1123,7 +1107,10 @@ function tripal_chado_populate_vocab_SBO() {
     'url' => 'http://www.ebi.ac.uk/sbo/main/',
     'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
   ));
-  tripal_insert_cv('sbo','Systems Biology.  Terms commonly used in Systems Biology, and in particular in computational modeling.');
+  tripal_insert_cv(
+    'sbo',
+    'Systems Biology.  Terms commonly used in Systems Biology, and in particular in computational modeling.'
+  );
 
   $dbxref = tripal_insert_cvterm(array(
     'id' => 'SBO:0000358',
@@ -1147,35 +1134,6 @@ function tripal_chado_populate_vocab_SBO() {
   ));
 }
 
-/**
- * Adds the Sequence Ontology
- */
-function tripal_chado_populate_vocab_SO() {
-  tripal_insert_db(array(
-    'name' => 'SO',
-    'description' => 'Sequence Ontology',
-    'url' => 'http://www.sequenceontology.org',
-    'urlprefix' => 'http://www.sequenceontology.org/browser/current_svn/term/{db}:{accession}',
-  ));
-  tripal_insert_cv('sequence','The Sequence Ontology.');
-
-  // Add the terms we need for default content types.  This needs to be
-  // done because the sequence ontology may not already be loaded but we
-  // still want to provide these default content types.
-  $term = tripal_insert_cvterm(array(
-    'id' => 'SO:0000704',
-    'name' => 'gene',
-    'cv_name' => 'sequence',
-    'definition' => 'A region (or regions) that includes all of the sequence elements necessary to encode a functional transcript. A gene may include regulatory regions, transcribed regions and/or other functional sequence regions. [SO:immuno_workshop]',
-  ));
-  $term = tripal_insert_cvterm(array(
-    'id' => 'SO:0000234',
-    'name' => 'mRNA',
-    'cv_name' => 'sequence',
-    'definition' => 'Messenger RNA is the intermediate molecule between DNA and protein. It includes UTR and coding sequences. It does not contain introns. [SO:ma]',
-  ));
-}
-
 /**
  * Adds the Software Ontology database and terms.
  */
@@ -1221,10 +1179,6 @@ function tripal_chado_populate_vocab_SWO() {
  * Adds the contact table mapping.
  */
 function tripal_chado_populate_vocab_TCONTACT() {
-  tripal_insert_db(array(
-    'name' => 'TContact',
-    'description' => 'The Tripal Contact controlled vocabulary.',
-  ));
 }
 
 /**
@@ -1232,10 +1186,8 @@ function tripal_chado_populate_vocab_TCONTACT() {
  */
 function tripal_chado_populate_vocab_TPUB() {
 
-  tripal_insert_db(array(
-    'name' => 'TPUB',
-    'description' => 'The Tripal Publication controlled vocabulary.',
-  ));
+  // No need to insert the TPUB cv/db those should already be added.
+
   // make sure we have our supported databases
   tripal_insert_db(
       array(
@@ -1307,37 +1259,14 @@ function tripal_chado_populate_vocab_UO() {
  * Adds the Taxonomic Rank Ontology database and terms.
  */
 function tripal_chado_populate_vocab_TAXRANK() {
-  tripal_insert_db(array(
-    'name' => 'TAXRANK',
-    'description' => 'Taxonomic rank vocabulary.',
-    'url' => 'https://github.com/phenoscape/taxrank',
-    'urlprefix' => 'http://purl.obolibrary.org/obo/TAXRANK_',
-  ));
-  tripal_insert_cv('taxrank','Taxonomic rank vocabulary. A vocabulary of taxonomic ranks (species, family, phylum, etc).');
-
 
-  $term = tripal_insert_cvterm(array(
-    'id' => 'TAXRANK:0000005',
-    'name' => 'genus',
-    'cv_name' => 'taxonomic_rank',
-    'description' => 'Taxonomic rank of Genus'
-  ));
+  $term = tripal_get_cvterm(array('id' => 'TAXRANK:0000005'));
   tripal_associate_chado_semweb_term('organism', 'genus', $term);
 
-  $term = tripal_insert_cvterm(array(
-    'id' => 'TAXRANK:0000006',
-    'name' => 'species',
-    'cv_name' => 'taxonomic_rank',
-    'description' => 'Taxonomic rank of species.'
-  ));
+  $term = tripal_get_cvterm(array('id' => 'TAXRANK:0000006'));
   tripal_associate_chado_semweb_term('organism', 'species', $term);
 
-  $term = tripal_insert_cvterm(array(
-    'id' => 'TAXRANK:0000045',
-    'name' => 'infraspecies',
-    'cv_name' => 'taxonomic_rank',
-    'description' => 'Taxonomic infraspecies name.'
-  ));
+  $term = tripal_get_cvterm(array('id' => 'TAXRANK:0000045'));
   tripal_associate_chado_semweb_term('organism', 'infraspecific_name', $term);
 }
 
@@ -1351,8 +1280,10 @@ function tripal_chado_populate_vocab_NCBITAXON() {
     'url' => 'http://www.berkeleybop.org/ontologies/ncbitaxon/',
     'urlprefix' => 'http://purl.obolibrary.org/obo/ncbitaxon#',
   ));
-  tripal_insert_cv('ncbitaxon','NCBI organismal classification. An ontology representation of the NCBI organismal taxonomy.');
-
+  tripal_insert_cv(
+    'ncbitaxon',
+    'NCBI organismal classification. An ontology representation of the NCBI organismal taxonomy.'
+  );
 
   $term = tripal_insert_cvterm(array(
     'id' => 'NCBITaxon:common_name',

+ 68 - 68
tripal_chado/includes/tripal_chado.setup.inc

@@ -86,7 +86,7 @@ function tripal_chado_load_ontologies() {
       'name' => 'Taxonomic Rank',
       'path' => 'http://purl.obolibrary.org/obo/taxrank.obo',
       'auto_load' => TRUE,
-      'cv_name' => 'taxrank'
+      'cv_name' => 'taxonomic_rank'
     ),
     array(
       'name' => 'Tripal Contact',
@@ -100,18 +100,18 @@ function tripal_chado_load_ontologies() {
       'auto_load' => TRUE,
       'cv_name' => 'tripal_pub'
     ),
-    array(
-      'name' => 'Sequence Ontology',
-      'path' => 'http://purl.obolibrary.org/obo/so.obo',
-      'auto_load' => TRUE,
-      'cv_name' => 'sequence'
-    ),
+     array(
+       'name' => 'Sequence Ontology',
+       'path' => 'http://purl.obolibrary.org/obo/so.obo',
+       'auto_load' => TRUE,
+       'cv_name' => 'sequence'
+     ),
 
   );
   for ($i = 0; $i < count($ontologies); $i++) {
     $obo_id = tripal_insert_obo($ontologies[$i]['name'], $ontologies[$i]['path']);
     if ($ontologies[$i]['auto_load'] == TRUE) {
-      // Only load ontolgogies that are not already in the cv table.
+      // Only load ontologies that are not already in the cv table.
       $cv = tripal_get_cv(array('name' => $ontologies[$i]['cv_name']));
       if (!$cv) {
         tripal_chado_load_obo_v1_2_id($obo_id);
@@ -126,6 +126,13 @@ function tripal_chado_prepare_chado() {
 
   try {
 
+    // We want to provide a set of commonly used entity types by default. This
+    // way when a user first installs Tripal there are some commonly used
+    // formats.
+    module_load_include('inc', 'tripal', 'api/tripal.api');
+    module_load_include('inc', 'tripal', 'includes/tripal.admin');
+    module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.semweb');
+
     // Get the effective version.  Pass true as second argument
     // to warn the user if the current version is not compatible.
     $version = chado_get_version(FALSE, FALSE);
@@ -133,11 +140,13 @@ function tripal_chado_prepare_chado() {
     // We want to force the version of Chado to be set properly.
     $real_version = chado_get_version(TRUE);
 
+    // Create the temp table we will use for loading OBO files.
+    tripal_chado_add_tripal_obo_temp_table();
+
     // Import commonly used ontologies if needed.
     tripal_chado_load_ontologies();
 
     // Populate the semantic web associations for Chado tables/fields.
-    module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.semweb');
     tripal_chado_populate_chado_semweb_table();
 
     // Initialize the population of the chado_cvterm_mapping table.  This will
@@ -145,67 +154,15 @@ function tripal_chado_prepare_chado() {
     // add new content types it simplifies the form for them.
     tripal_chado_map_cvterms();
 
-    // Add the cv_root_mview.
-    tripal_chado_add_cv_root_mview_mview();
-
-    // Create the temp table we will use for loading OBO files.
-    tripal_chado_add_tripal_obo_temp_table();
-
-    // Support for Analyses
-    // we may need the analysisfeatureprop table if it doesn't already exist
-    tripal_chado_add_analysisfeatureprop_table();
-
-    // add materialized views
-    tripal_chado_add_analysis_organism_mview();
-
-    // Support for Contacts
-    // Add the contactprop table to Chado.
-    tripal_chado_add_contactprop_table();
-
-    // Support for Features
-    // Add the materialized view.
-    tripal_chado_add_organism_feature_count_mview();
-
-    // Add the custom tables for the GFF loader.
-    tripal_chado_add_tripal_gff_temp_table();
-    tripal_chado_add_tripal_gffcds_temp_table();
-    tripal_chado_add_tripal_gffprotein_temp_table();
-
-    // Support for FeatureMaps.
-    // add the featuremapprop table to Chado
-    tripal_chado_add_featuremap_dbxref_table();
-    tripal_chado_add_featuremapprop_table();
-    //tripal_chado_add_featuremappos_table();
-
-    // Support for Libraries.
-    // add the materialized view
-    tripal_chado_add_library_feature_count_mview();
-
-    // Support for Pubs.
-    // add the custom tables
-    tripal_chado_add_pubauthor_contact_table();
-    // Add the supported loaders
-    variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));
-
-    // Support for Stocks.
-    // add the materialized view
-    tripal_chado_add_organism_stock_count_mview();
-
-    // We want to provide a set of commonly used entity types by default. This
-    // way when a user first installs Tripal there are some commonly used
-    // formats.
-    module_load_include('inc', 'tripal', 'api/tripal.api');
-    module_load_include('inc', 'tripal', 'includes/tripal.admin');
-
     // Create the 'Organism' entity type. This uses the obi:organism term.
     $error = '';
     $args = array(
-     'vocabulary' => 'OBI',
-     'accession' => '0100026',
-     'term_name' => 'organism',
-     'storage_args' => array(
-       'data_table' => 'organism',
-     )
+      'vocabulary' => 'OBI',
+      'accession' => '0100026',
+      'term_name' => 'organism',
+      'storage_args' => array(
+        'data_table' => 'organism',
+      )
     );
     $term = tripal_load_term_entity(array('vocabulary' => 'OBI', 'accession' => '0100026'));
     $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
@@ -325,6 +282,49 @@ function tripal_chado_prepare_chado() {
       }
     }
 
+    // Add the cv_root_mview.
+    tripal_chado_add_cv_root_mview_mview();
+
+    // Support for Analyses
+    // we may need the analysisfeatureprop table if it doesn't already exist
+    tripal_chado_add_analysisfeatureprop_table();
+
+    // add materialized views
+    tripal_chado_add_analysis_organism_mview();
+
+    // Support for Contacts
+    // Add the contactprop table to Chado.
+    tripal_chado_add_contactprop_table();
+
+    // Support for Features
+    // Add the materialized view.
+    tripal_chado_add_organism_feature_count_mview();
+
+    // Add the custom tables for the GFF loader.
+    tripal_chado_add_tripal_gff_temp_table();
+    tripal_chado_add_tripal_gffcds_temp_table();
+    tripal_chado_add_tripal_gffprotein_temp_table();
+
+    // Support for FeatureMaps.
+    // add the featuremapprop table to Chado
+    tripal_chado_add_featuremap_dbxref_table();
+    tripal_chado_add_featuremapprop_table();
+    //tripal_chado_add_featuremappos_table();
+
+    // Support for Libraries.
+    // add the materialized view
+    tripal_chado_add_library_feature_count_mview();
+
+    // Support for Pubs.
+    // add the custom tables
+    tripal_chado_add_pubauthor_contact_table();
+    // Add the supported loaders
+    variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));
+
+    // Support for Stocks.
+    // add the materialized view
+    tripal_chado_add_organism_stock_count_mview();
+
     // Set a variable to indicate the site is prepared.
     variable_set('tripal_chado_is_prepared', TRUE);
   }
@@ -1094,7 +1094,7 @@ function tripal_chado_add_tripal_obo_temp_table() {
   // do not want to use the Tripal Custom Table API because we don't want it to appear in the
   // list of custom tables.  It needs to be available for the Tripal Chado API so we create it
   // here and then define it in the tripal_cv/api/tripal_cv.schema.api.inc
-  if (!db_table_exists('chado.tripal_obo_temp')) {
+  if (!chado_table_exists('tripal_obo_temp')) {
     $sql = "
       CREATE TABLE {tripal_obo_temp} (
         id character varying(255) NOT NULL,

+ 1 - 1
tripal_chado/tripal_chado.info

@@ -3,7 +3,7 @@ description = Provides a set of Chado-based fields for the Tripal Entities.
 core = 7.x
 project = tripal
 package = Tripal
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 files[] = views_handlers/chado_views_handler_field.inc
 files[] = views_handlers/chado_views_handler_filter.inc

+ 1 - 2
tripal_chado/tripal_chado.module

@@ -71,7 +71,6 @@ function tripal_chado_set_globals() {
 
 /**
  * Implements hook_init().
- * Used to set the search_path, create default content and set default variables.
  *
  * @ingroup tripal_chado
  */
@@ -88,7 +87,7 @@ function tripal_chado_init() {
     }
     else {
       drupal_set_message('Tripal cannot find a Chado installation. Please ' .
-          l('install Chado', 'admin/tripal/storage/chado/chado_install') .
+          l('install Chado', 'admin/tripal/storage/chado/install') .
           ' before continuing.', 'warning');
     }
   }

+ 1 - 1
tripal_chado_views/tripal_chado_views.info

@@ -3,7 +3,7 @@ description = Integrates all Chado tables with Drupal Views and provides basic s
 core = 7.x
 project = tripal
 package = Tripal
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 configure = admin/tripal/storage/chado/views-integration
 
 files[] = views/handlers/tripal_views_handler_filter_textarea.inc

+ 1 - 1
tripal_ds/tripal_ds.info

@@ -3,7 +3,7 @@ description = Provides display options for Tripal Entities through extending Dis
 core = 7.x
 project = tripal
 package = Tripal
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 stylesheets[all][] = theme/css/tripaldsfeature.css
 

+ 1 - 1
tripal_ws/tripal_ws.info

@@ -3,6 +3,6 @@ description = Exposes Tripal Entites as RESTful web services.
 core = 7.x
 project = tripal
 package = Tripal
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-beta1
 
 dependencies[] = tripal