ソースを参照

Reworking to move node specific code to legacy directory and Chado specific code to the tripal_chado module. Created a new 'tripal' module to replace 'tripal_core'

Stephen Ficklin 9 年 前
コミット
8ed6d457a5
100 ファイル変更2648 行追加1679 行削除
  1. 0 69
      legacy/tripal_analysis/api/tripal_analysis.schema.api.inc
  2. 0 0
      legacy/tripal_core/api/tripal_core.DEPRECATED.inc
  3. 0 0
      legacy/tripal_core/api/tripal_core.chado_nodes.api.inc
  4. 0 0
      legacy/tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc
  5. 0 0
      legacy/tripal_core/api/tripal_core.chado_nodes.properties.api.inc
  6. 0 0
      legacy/tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
  7. 0 0
      legacy/tripal_core/api/tripal_core.chado_nodes.title_and_path.inc
  8. 0 78
      legacy/tripal_core/api/tripal_core.tripal_variables.api.inc
  9. 0 0
      legacy/tripal_core/includes/tripal_core.form_elements.inc
  10. 0 0
      legacy/tripal_core/includes/tripal_core.toc.inc
  11. 0 0
      legacy/tripal_core/theme/css/chado_node_api.css
  12. 0 0
      legacy/tripal_core/theme/css/tripal.css
  13. 0 0
      legacy/tripal_core/theme/images/TripalLogo-sm.png
  14. 0 0
      legacy/tripal_core/theme/js/chadoNodeApi_unsavedNotify.js
  15. 0 0
      legacy/tripal_core/theme/js/chadoNodeApi_updateVerticalTabSummary.js
  16. 0 0
      legacy/tripal_core/theme/js/tripal.js
  17. 0 0
      legacy/tripal_core/theme/templates/node--chado-generic.tpl.php
  18. 0 0
      legacy/tripal_core/theme/templates/tripal_core_customize.tpl.php
  19. 0 0
      legacy/tripal_core/theme/templates/tripal_core_customtables_help.tpl.php
  20. 0 0
      legacy/tripal_core/theme/templates/tripal_core_jobs_help.tpl.php
  21. 0 0
      legacy/tripal_core/theme/templates/tripal_core_mviews_help.tpl.php
  22. 0 0
      legacy/tripal_core/tripal_core.drush.inc
  23. 2 1
      legacy/tripal_core/tripal_core.info
  24. 1 14
      legacy/tripal_core/tripal_core.install
  25. 9 31
      legacy/tripal_core/tripal_core.module
  26. 0 0
      legacy/tripal_core/tripal_launch_jobs.php
  27. 0 0
      legacy/tripal_core/tripal_launch_jobs_multi.php
  28. 0 0
      legacy/tripal_cv/api/tripal_cv.DEPRECATED.inc
  29. 0 0
      legacy/tripal_cv/files/cv_property.obo
  30. 0 0
      legacy/tripal_cv/includes/tripal_cv.admin.inc
  31. 0 0
      legacy/tripal_cv/includes/tripal_cv.cv_form.inc
  32. 0 0
      legacy/tripal_cv/includes/tripal_cv.cvterm_form.inc
  33. 0 0
      legacy/tripal_cv/includes/tripal_cv.cvtermpath_form.inc
  34. 0 0
      legacy/tripal_cv/theme/templates/tripal_cv_help.tpl.php
  35. 0 0
      legacy/tripal_cv/tripal_cv.coder_ignores.txt
  36. 1 1
      legacy/tripal_cv/tripal_cv.info
  37. 0 0
      legacy/tripal_cv/tripal_cv.install
  38. 0 0
      legacy/tripal_cv/tripal_cv.module
  39. 0 0
      legacy/tripal_cv/tripal_cv.views_default.inc
  40. 0 0
      legacy/tripal_db/api/tripal_db.DEPRECATED.inc
  41. 0 0
      legacy/tripal_db/includes/tripal_db.admin.inc
  42. 0 0
      legacy/tripal_db/theme/templates/tripal_db_help.tpl.php
  43. 1 1
      legacy/tripal_db/tripal_db.info
  44. 0 0
      legacy/tripal_db/tripal_db.install
  45. 0 0
      legacy/tripal_db/tripal_db.module
  46. 0 0
      legacy/tripal_db/tripal_db.views_default.inc
  47. 0 31
      legacy/tripal_genetic/includes/tripal_genetic.schema.inc
  48. 0 22
      tripal/api/tripal.d3js.api.inc
  49. 3 3
      tripal/api/tripal.files.api.inc
  50. 19 14
      tripal/api/tripal.jobs.api.inc
  51. 5 15
      tripal/api/tripal.notice.api.inc
  52. 81 0
      tripal/api/tripal.variables.api.inc
  53. 21 21
      tripal/includes/tripal.extensions.inc
  54. 3 3
      tripal/includes/tripal.jobs.inc
  55. 259 0
      tripal/tripal.drush.inc
  56. 15 0
      tripal/tripal.info
  57. 188 0
      tripal/tripal.install
  58. 268 0
      tripal/tripal.module
  59. 16 16
      tripal/tripal.views.inc
  60. 16 16
      tripal/tripal.views_default.inc
  61. 9 9
      tripal_chado/api/get_FKs.php
  62. 0 0
      tripal_chado/api/modules/tripal_chado.analysis.api.inc
  63. 0 0
      tripal_chado/api/modules/tripal_chado.contact.api.inc
  64. 51 51
      tripal_chado/api/modules/tripal_chado.cv.api.inc
  65. 22 22
      tripal_chado/api/modules/tripal_chado.db.api.inc
  66. 38 38
      tripal_chado/api/modules/tripal_chado.feature.api.inc
  67. 0 0
      tripal_chado/api/modules/tripal_chado.organism.api.inc
  68. 0 0
      tripal_chado/api/modules/tripal_chado.pub.api.inc
  69. 0 0
      tripal_chado/api/modules/tripal_chado.stock.api.inc
  70. 6 6
      tripal_chado/api/tripal_chado.custom_tables.api.inc
  71. 6 6
      tripal_chado/api/tripal_chado.mviews.api.inc
  72. 12 151
      tripal_chado/api/tripal_chado.property.api.inc
  73. 175 41
      tripal_chado/api/tripal_chado.query.api.inc
  74. 4 4
      tripal_chado/api/tripal_chado.schema.api.inc
  75. 112 112
      tripal_chado/api/tripal_chado.schema_v1.11.api.inc
  76. 112 112
      tripal_chado/api/tripal_chado.schema_v1.2.api.inc
  77. 13 13
      tripal_chado/api/tripal_chado.variables.api.inc
  78. 0 0
      tripal_chado/chado_schema/default_schema-1.11-1.2-diff.sql
  79. 0 0
      tripal_chado/chado_schema/default_schema-1.11.sql
  80. 0 0
      tripal_chado/chado_schema/default_schema-1.2.sql
  81. 0 0
      tripal_chado/chado_schema/initialize-1.11.sql
  82. 0 0
      tripal_chado/chado_schema/initialize-1.2.sql
  83. 0 0
      tripal_chado/chado_schema/upgrade-1.11-1.2.sql
  84. 27 27
      tripal_chado/includes/exporters/tripal_chado.gff_exporter.inc
  85. 62 62
      tripal_chado/includes/exporters/tripal_chado.seq_extract.inc
  86. 12 12
      tripal_chado/includes/loaders/tripal_chado.fasta_loader.inc
  87. 90 90
      tripal_chado/includes/loaders/tripal_chado.gff_loader.inc
  88. 93 93
      tripal_chado/includes/loaders/tripal_chado.obo_loader.inc
  89. 159 21
      tripal_chado/includes/tripal_chado.schema.inc
  90. 33 33
      tripal_chado/includes/tripal_core.chado_install.inc
  91. 2 2
      tripal_chado/includes/tripal_core.custom_tables.inc
  92. 4 4
      tripal_chado/includes/tripal_core.mviews.inc
  93. 193 0
      tripal_chado/tripal_chado.drush.inc
  94. 1 3
      tripal_chado/tripal_chado.info
  95. 163 1
      tripal_chado/tripal_chado.install
  96. 339 1
      tripal_chado/tripal_chado.module
  97. 0 380
      tripal_core/includes/tripal_core.ws_hal.inc
  98. 0 47
      tripal_cv/api/tripal_cv.schema.api.inc
  99. 1 1
      tripal_entities/tripal_entities.info
  100. 1 1
      tripal_fields_layout/tripal_fields_layout.info

+ 0 - 69
legacy/tripal_analysis/api/tripal_analysis.schema.api.inc

@@ -1,69 +0,0 @@
-<?php
-
-/**
- * Implements hook_chado_schema_v1_11_analysisfeatureprop()
- * Purpose: To describe the structure of 'analysisfeatureprop' to tripal
- * @see chado_insert_record()
- * @see chado_update_record()
- * @see chado_select_record()
- *
- * @return
- *    An array describing the 'analysisfeatureprop' table
- *
- * @ingroup tripal_chado_v1.11_schema_api
- *
- */
-function tripal_core_chado_schema_v1_11_analysisfeatureprop() {
-  $description =  array(
-    'table' => 'analysisfeatureprop',
-    'fields' => array(
-      'analysisfeatureprop_id' => array(
-        'type' => 'serial',
-        'not NULL' => '1',
-      ),
-      'analysisfeature_id' => array(
-        'type' => 'int',
-        'not NULL' => '1',
-      ),
-      'type_id' => array(
-        'type' => 'int',
-        'not NULL' => '1',
-      ),
-      'value' => array(
-        'type' => 'text',
-        'not NULL' => '',
-      ),
-      'rank' => array(
-        'type' => 'int',
-        'not NULL' => '1',
-      ),
-    ),
-    'primary key' => array(
-      0 => 'analysisfeatureprop_id',
-    ),
-    'unique keys' => array(
-      'analysisfeature_id_type_id_rank' => array(
-        0 => 'analysisfeature_id',
-        1 => 'type_id',
-        2 => 'rank',
-      ),
-    ),
-    'indexes' => array(
-    ),
-    'foreign keys' => array(
-      'cvterm' => array(
-        'table' => 'cvterm',
-        'columns' => array(
-          'type_id' => 'cvterm_id',
-        ),
-      ),
-      'analysisfeature' => array(
-        'table' => 'analysisfeature',
-        'columns' => array(
-          'analysisfeature_id' => 'analysisfeature_id',
-        ),
-      ),
-    ),
-  );
-  return $description;
-}

+ 0 - 0
tripal_core/api/tripal_core.DEPRECATED.inc → legacy/tripal_core/api/tripal_core.DEPRECATED.inc


+ 0 - 0
tripal_core/api/tripal_core.chado_nodes.api.inc → legacy/tripal_core/api/tripal_core.chado_nodes.api.inc


+ 0 - 0
tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc → legacy/tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc


+ 0 - 0
tripal_core/api/tripal_core.chado_nodes.properties.api.inc → legacy/tripal_core/api/tripal_core.chado_nodes.properties.api.inc


+ 0 - 0
tripal_core/api/tripal_core.chado_nodes.relationships.api.inc → legacy/tripal_core/api/tripal_core.chado_nodes.relationships.api.inc


+ 0 - 0
tripal_core/api/tripal_core.chado_nodes.title_and_path.inc → legacy/tripal_core/api/tripal_core.chado_nodes.title_and_path.inc


+ 0 - 78
tripal_core/api/tripal_core.tripal_variables.api.inc → legacy/tripal_core/api/tripal_core.tripal_variables.api.inc

@@ -1,82 +1,4 @@
 <?php
-/**
- * @file
- * Provides an application programming interface (API) for managing variables
- * associated with Tripal managed Drupal nodes/
- */
-
-/**
- * @defgroup tripal_variables_api Tripal Variables API
- * @ingroup tripal_core_api
- * @{
- * Provides an application programming interface (API) for managing variables
- * associated with Tripal managed Drupal nodes. The Tripal Variables API
- * supports storing any type of variable such as a property or setting that
- * should be associated with a Tripal managed Drupal node.  Variables are
- * meant to store non-biological information only. All biological data should be
- * housed in the Chado tables. Be aware that any data stored as a Tripal
- * Variable will not be made visible through services such as Tripal Web
- * Services and therefore can be a good place to hide application specific
- * settings
- * @}
- *
- */
-
-/**
- * Adds a new variable name.
- *
- * @param $name
- *   The name of the variable
- * @param $description
- *   The description for the variable
- * @return
- *   A record object containg the variable that was added if successful.
- */
-function tripal_insert_variable($name, $description) {
-  $name = trim($name);
-  if (!$name) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
-        'Must have a variable name when adding a new Tripal Variable.', array());
-    return NULL;
-  }
-  if (!$description) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
-        'Must have a description when adding a new Tripal Variable.', array());
-    return NULL;
-  }
-
-  // Make sure the variable is not a duplicate. If so, then just select
-  // it and return the variable_id
-  $variable = tripal_get_variable($name);
-  if ($variable) {
-    return $variable;
-  }
-  else {
-    db_insert('tripal_variables')
-      ->fields(array(
-        'name' => $name,
-        'description' => $description,
-      ))
-      ->execute();
-    return tripal_get_variable($name);
-  }
-}
-
-/**
- * Retrieves the variable name record.
- *
- * @param $name
- *   The name of the variable to retrieve
- * @return
- *   A record object containg the variable.
- */
-function tripal_get_variable($name) {
-  return db_select('tripal_variables', 'v')
-    ->fields('v')
-    ->condition('name', $name)
-    ->execute()
-    ->fetchObject();
-}
 
 /**
  * Associates a variable and it's value to a node.

+ 0 - 0
tripal_core/includes/tripal_core.form_elements.inc → legacy/tripal_core/includes/tripal_core.form_elements.inc


+ 0 - 0
tripal_core/includes/tripal_core.toc.inc → legacy/tripal_core/includes/tripal_core.toc.inc


+ 0 - 0
tripal_core/theme/css/chado_node_api.css → legacy/tripal_core/theme/css/chado_node_api.css


+ 0 - 0
tripal_core/theme/css/tripal.css → legacy/tripal_core/theme/css/tripal.css


+ 0 - 0
tripal_core/theme/images/TripalLogo-sm.png → legacy/tripal_core/theme/images/TripalLogo-sm.png


+ 0 - 0
tripal_core/theme/js/chadoNodeApi_unsavedNotify.js → legacy/tripal_core/theme/js/chadoNodeApi_unsavedNotify.js


+ 0 - 0
tripal_core/theme/js/chadoNodeApi_updateVerticalTabSummary.js → legacy/tripal_core/theme/js/chadoNodeApi_updateVerticalTabSummary.js


+ 0 - 0
tripal_core/theme/js/tripal.js → legacy/tripal_core/theme/js/tripal.js


+ 0 - 0
tripal_core/theme/templates/node--chado-generic.tpl.php → legacy/tripal_core/theme/templates/node--chado-generic.tpl.php


+ 0 - 0
tripal_core/theme/templates/tripal_core_customize.tpl.php → legacy/tripal_core/theme/templates/tripal_core_customize.tpl.php


+ 0 - 0
tripal_core/theme/templates/tripal_core_customtables_help.tpl.php → legacy/tripal_core/theme/templates/tripal_core_customtables_help.tpl.php


+ 0 - 0
tripal_core/theme/templates/tripal_core_jobs_help.tpl.php → legacy/tripal_core/theme/templates/tripal_core_jobs_help.tpl.php


+ 0 - 0
tripal_core/theme/templates/tripal_core_mviews_help.tpl.php → legacy/tripal_core/theme/templates/tripal_core_mviews_help.tpl.php


+ 0 - 0
tripal_core/tripal_core.drush.inc → legacy/tripal_core/tripal_core.drush.inc


+ 2 - 1
tripal_core/tripal_core.info → legacy/tripal_core/tripal_core.info

@@ -2,7 +2,7 @@ name = Tripal Core
 description = Provides support for all Tripal modules and includes the Tripal API, jobs management, materialized views, Chado installation and custom tables.
 core = 7.x
 project = tripal
-package = Tripal
+package = Tripal v2 Legacy
 version = 7.x-2.0
 configure = admin/tripal
 
@@ -13,3 +13,4 @@ dependencies[] = views
 dependencies[] = path
 dependencies[] = search
 dependencies[] = php
+dependencies[] = tripal

+ 1 - 14
tripal_core/tripal_core.install → legacy/tripal_core/tripal_core.install

@@ -11,20 +11,7 @@
  */
 function tripal_core_install() {
 
-  // The foreign key specification doesn't really add one to the
-  // Drupal schema, it is just used internally, but we want one.
-  db_query('
-      ALTER TABLE {tripal_custom_tables}
-      ADD CONSTRAINT tripal_custom_tables_fk1
-      FOREIGN KEY (mview_id) REFERENCES {tripal_mviews} (mview_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-  ');
-  
-  // Warn users that they need to install chado before installing anything else.
-  drupal_set_message(t(
-    'Tripal requires the <a href="!link">installation fo the Chado Schema</a> before any other modules can be installed.', 
-    array('!link' => url('admin/tripal/storage/chado/chado_install'))), 
-    'warning');
+
 }
 /**
  * Implementation of hook_schema().

+ 9 - 31
tripal_core/tripal_core.module → legacy/tripal_core/tripal_core.module

@@ -4,46 +4,24 @@
  * The Tripal Core module
  */
 
-/**
- * @defgroup tripal_core Tripal Core Module
- * @ingroup tripal_modules
- * @{
- * Functionality useful for all other Tripal modules including the Tripal jobs, files,
- * materialized views and custom table functions.
- * @}
- */
 
-// APPLICATION PROGRAMMER INTERFACE -------------
-// Chado API
-require_once 'api/tripal_core.chado_general.api.inc';
-require_once 'api/tripal_core.chado_query.api.inc';
-require_once 'api/tripal_core.chado_variables.api.inc';
-require_once 'api/tripal_core.chado_schema.api.inc';
 require_once 'api/tripal_core.chado_nodes.api.inc';
 require_once 'api/tripal_core.chado_nodes.title_and_path.inc';
 require_once 'api/tripal_core.chado_nodes.properties.api.inc';
 require_once 'api/tripal_core.chado_nodes.dbxrefs.api.inc';
 require_once 'api/tripal_core.chado_nodes.relationships.api.inc';
-
-// Table API
-require_once 'api/tripal_core.custom_tables.api.inc';
-require_once 'api/tripal_core.mviews.api.inc';
-
-// Miscellaneous API
-require_once 'api/tripal_core.files.api.inc';
-require_once 'api/tripal_core.jobs.api.inc';
-require_once 'api/tripal_core.tripal.api.inc';
 require_once 'api/tripal_core.tripal_variables.api.inc';
-require_once 'api/tripal_core.d3js.api.inc';
-require_once 'api/tripal_core.DEPRECATED.inc';
-
-// INCLUDES
-require_once 'includes/tripal_core.jobs.inc';
-require_once 'includes/tripal_core.mviews.inc';
-require_once 'includes/tripal_core.custom_tables.inc';
-require_once 'includes/tripal_core.chado_install.inc';
 require_once 'includes/tripal_core.form_elements.inc';
 
+/**
+ * @defgroup tripal_core Tripal Core Module
+ * @ingroup tripal_modules
+ * @{
+ * Functionality useful for all other Tripal modules including the Tripal jobs, files,
+ * materialized views and custom table functions.
+ * @}
+ */
+
 tripal_core_set_globals();
 
 /**

+ 0 - 0
tripal_core/tripal_launch_jobs.php → legacy/tripal_core/tripal_launch_jobs.php


+ 0 - 0
tripal_core/tripal_launch_jobs_multi.php → legacy/tripal_core/tripal_launch_jobs_multi.php


+ 0 - 0
tripal_cv/api/tripal_cv.DEPRECATED.inc → legacy/tripal_cv/api/tripal_cv.DEPRECATED.inc


+ 0 - 0
tripal_cv/files/cv_property.obo → legacy/tripal_cv/files/cv_property.obo


+ 0 - 0
tripal_cv/includes/tripal_cv.admin.inc → legacy/tripal_cv/includes/tripal_cv.admin.inc


+ 0 - 0
tripal_cv/includes/tripal_cv.cv_form.inc → legacy/tripal_cv/includes/tripal_cv.cv_form.inc


+ 0 - 0
tripal_cv/includes/tripal_cv.cvterm_form.inc → legacy/tripal_cv/includes/tripal_cv.cvterm_form.inc


+ 0 - 0
tripal_cv/includes/tripal_cv.cvtermpath_form.inc → legacy/tripal_cv/includes/tripal_cv.cvtermpath_form.inc


+ 0 - 0
tripal_cv/theme/templates/tripal_cv_help.tpl.php → legacy/tripal_cv/theme/templates/tripal_cv_help.tpl.php


+ 0 - 0
tripal_cv/tripal_cv.coder_ignores.txt → legacy/tripal_cv/tripal_cv.coder_ignores.txt


+ 1 - 1
tripal_cv/tripal_cv.info → legacy/tripal_cv/tripal_cv.info

@@ -2,7 +2,7 @@ name = Tripal CV
 description = Supports the Controlled Vocabulary (CV) tables of Chado by providing pages for viewing and editing of CVs. Table list at: http://gmod.org/wiki/Chado_CV_Module.
 core = 7.x
 project = tripal
-package = Tripal
+package = Tripal v2 Legacy
 version = 7.x-2.0
 configure = admin/tripal/vocab
 

+ 0 - 0
tripal_cv/tripal_cv.install → legacy/tripal_cv/tripal_cv.install


+ 0 - 0
tripal_cv/tripal_cv.module → legacy/tripal_cv/tripal_cv.module


+ 0 - 0
tripal_cv/tripal_cv.views_default.inc → legacy/tripal_cv/tripal_cv.views_default.inc


+ 0 - 0
tripal_db/api/tripal_db.DEPRECATED.inc → legacy/tripal_db/api/tripal_db.DEPRECATED.inc


+ 0 - 0
tripal_db/includes/tripal_db.admin.inc → legacy/tripal_db/includes/tripal_db.admin.inc


+ 0 - 0
tripal_db/theme/templates/tripal_db_help.tpl.php → legacy/tripal_db/theme/templates/tripal_db_help.tpl.php


+ 1 - 1
tripal_db/tripal_db.info → legacy/tripal_db/tripal_db.info

@@ -2,7 +2,7 @@ name = Tripal DB
 description = Supports the database cross-reference tables of Chado by providing pages for viewing and editing of databases and their cross-references. Table list at: http://gmod.org/wiki/Chado_General_Module.
 core = 7.x
 project = tripal
-package = Tripal
+package = Tripal v2 Legacy
 version = 7.x-2.0
 configure = admin/tripal/chado/tripal_db
 

+ 0 - 0
tripal_db/tripal_db.install → legacy/tripal_db/tripal_db.install


+ 0 - 0
tripal_db/tripal_db.module → legacy/tripal_db/tripal_db.module


+ 0 - 0
tripal_db/tripal_db.views_default.inc → legacy/tripal_db/tripal_db.views_default.inc


+ 0 - 31
legacy/tripal_genetic/includes/tripal_genetic.schema.inc

@@ -1,31 +0,0 @@
-<?php
-/**
- * @file
- * Add to the tripal schema definitions
- */
-
-/**
- * Implements hook_chado_schema_v1_11_table()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the genotype table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_genetic_chado_schema_v1_11_genotype() {
-  $description = array();
-
-  $referring_tables = array('analysisfeature',
-    'feature_genotype',
-    'phendesc',
-    'phenotype_comparison',
-    'phenstatement',
-    'stock_genotype',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-
-}

+ 0 - 22
tripal_core/api/tripal_core.d3js.api.inc → tripal/api/tripal.d3js.api.inc

@@ -3,28 +3,6 @@
  *
  */
 
-/**
- * Implements hook_libraries_info().
- */
-function tripal_core_libraries_info() {
-  $libraries = array();
-  $libraries['d3'] = array(
-    'name' => 'D3.js',
-    'vendor url' => 'http://d3js.org/',
-    'download url' => 'https://github.com/mbostock/d3',
-    'version arguments' => array(
-      'file' => 'd3.js',
-      'pattern' => '/\s*version: "(\d+\.\d+\.\d+)"/',
-    ),
-    'files' => array(
-      'js' => array(
-        'd3.min.js',
-      ),
-    ),
-  );
-
-  return $libraries;
-}
 
 /**
  * Load D3.js releated javascripts for the current page.

+ 3 - 3
tripal_core/api/tripal_core.files.api.inc → tripal/api/tripal.files.api.inc

@@ -7,7 +7,7 @@
 
 /**
  * @defgroup tripal_files_api Tripal Files API
- * @ingroup tripal_core_api
+ * @ingroup tripal_api
  * @{
  * Provides an application programming interface (API) for managing files within
  * the Tripal data directory structure.
@@ -46,7 +46,7 @@ function tripal_create_files_dir($module_name, $path = FALSE) {
                  "behave correctly without this directory.  Please  create " .
                  "the directory manually or fix the problem and reinstall.";
       drupal_set_message(check_plain(t($message)), 'error');
-      tripal_report_error('tripal_core', TRIPAL_ERROR, $message, array());
+      tripal_report_error('tripal', TRIPAL_ERROR, $message, array());
     }
   }
   else {
@@ -59,7 +59,7 @@ function tripal_create_files_dir($module_name, $path = FALSE) {
     if (!file_prepare_directory($sub_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
       $message = "Can not create directory $sub_dir. ";
       drupal_set_message(check_plain(t($message)), 'error');
-      tripal_report_error('tripal_core', TRIPAL_ERROR, $message, array());
+      tripal_report_error('tripal', TRIPAL_ERROR, $message, array());
     }
   }
 }

+ 19 - 14
tripal_core/api/tripal_core.jobs.api.inc → tripal/api/tripal.jobs.api.inc

@@ -7,23 +7,28 @@
 
 /**
  * @defgroup tripal_jobs_api Tripal Jobs API
- * @ingroup tripal_core_api
+ * @ingroup tripal_api
  * @{
- * Tripal offers a job management subsystem for managing tasks that may require an extended period of time for
- * completion.  Drupal uses a UNIX-based cron job to handle tasks such as  checking  the  availability of updates,
- * indexing new nodes for searching, etc.   Drupal's cron uses the web interface for launching these tasks, however,
- * Tripal provides several administrative tasks that may time out and not complete due to limitations of the web
- * server.  Examples including syncing of a large number of features between chado and Drupal.  To circumvent this,
- * as well as provide more fine-grained control and monitoring, Tripal uses a jobs management sub-system built into
- * the Tripal Core module.   It is anticipated that this functionality will be used for managing analysis jobs provided by
+ * Tripal offers a job management subsystem for managing tasks that may require
+ * an extended period of time for completion.  Drupal uses a UNIX-based cron
+ * job to handle tasks such as  checking  the  availability of updates,
+ * indexing new nodes for searching, etc.   Drupal's cron uses the web interface
+ * for launching these tasks, however, Tripal provides several administrative
+ * tasks that may time out and not complete due to limitations of the web
+ * server. To circumvent this, as well as provide more fine-grained control and
+ * monitoring, Tripal uses a jobs management sub-system.   It is anticipated
+ * that this functionality will be used for managing analysis jobs provided by
  * future tools, with eventual support for distributed computing.
  *
- * The  Tripal jobs management system allows administrators to submit tasks to be performed which can then  be
- * launched through a UNIX command-line PHP script or cron job.  This command-line script can be added to a cron
- * entry along-side the Drupal cron entry for automatic, regular launching of Tripal jobs.  The order of execution of
- * waiting jobs is determined first by priority and second by the order the jobs were entered.
+ * The  Tripal jobs management system allows administrators to submit tasks
+ * to be performed which can then  be launched through a UNIX command-line PHP
+ * script or cron job.  This command-line script can be added to a cron
+ * entry along-side the Drupal cron entry for automatic, regular launching of
+ * Tripal jobs.  The order of execution of waiting jobs is determined first by
+ * priority and second by the order the jobs were entered.
  *
- * The API functions described below provide a programmatic interface for adding, checking and viewing jobs.
+ * The API functions described below provide a programmatic interface for
+ * adding, checking and viewing jobs.
  * @}
  */
 
@@ -375,7 +380,7 @@ function tripal_launch_job($do_parallel = 0, $job_id = NULL) {
  * @return
  *   True on success and False otherwise
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
 function tripal_set_job_progress($job_id, $percentage) {
 

+ 5 - 15
tripal_core/api/tripal_core.tripal.api.inc → tripal/api/tripal.notice.api.inc

@@ -3,13 +3,8 @@
  * @file
  * Provides an application programming interface (API) for Tripal
  *
- * The Tripal API currently provides generic insert/update/select functions for all chado content as
- * well as some module specific functions that insert/update/delete/select specific chado content.
- *
- * This API is currently in its infancy and some necessary functions might be missing. If you find
- * a missing function that you think should be included go to the sourceforge feature request
- * page and request it's inclusion in the API. Such feature requests with a working function
- * definition will be given priority.
+ * The Tripal API currently provides generic functionality for all Tripal
+ * extension modules.
  */
 
 /**
@@ -17,13 +12,8 @@
  * @{
  * Provides an application programming interface (API) for Tripal
  *
- * The Tripal API currently provides generic insert/update/select functions for all chado content as
- * well as some module specific functions that insert/update/delete/select specific chado content.
- *
- * This API is currently in its infancy and some necessary functions might be missing. If you find
- * a missing function that you think should be included go to the sourceforge feature request
- * page and request it's inclusion in the API. Such feature requests with a working function
- * definition will be given priority.
+ * The Tripal API currently provides generic functionality for all Tripal
+ * extension modules..
  * @}
  */
 
@@ -108,7 +98,7 @@ function tripal_report_error($type, $severity, $message, $variables = array(), $
     watchdog($type, $message, $variables, $severity);
   }
   catch (Exception $e) {
-    print "CRITICAL (TRIPAL_CORE): Unable to register error message with watchdog: " . $e->getMessage(). "\n.";
+    print "CRITICAL (TRIPAL): Unable to register error message with watchdog: " . $e->getMessage(). "\n.";
     $options['print'] = TRUE;
   }
 

+ 81 - 0
tripal/api/tripal.variables.api.inc

@@ -0,0 +1,81 @@
+<?php
+/**
+ * @file
+ * Provides an application programming interface (API) for managing variables
+ * associated with Tripal managed content.
+ */
+
+/**
+ * @defgroup tripal_variables_api Tripal Variables API
+ * @ingroup tripal_api
+ * @{
+ * Provides an application programming interface (API) for managing variables
+ * associated with Tripal managed content. The Tripal Variables API
+ * supports storing any type of variable such as a property or setting that
+ * should be associated with a Tripal managed Drupal node.  Variables are
+ * meant to store non-biological information only. Be aware that any data
+ * stored as a Tripal Variable will not be made visible through services such
+ * as Tripal Web Services and therefore can be a good place to hide application
+ * specific settings.
+ *
+ * @}
+ *
+ */
+
+/**
+ * Adds a new variable name.
+ *
+ * @param $name
+ *   The name of the variable
+ * @param $description
+ *   The description for the variable
+ * @return
+ *   A record object containg the variable that was added if successful.
+ */
+function tripal_insert_variable($name, $description) {
+  $name = trim($name);
+  if (!$name) {
+    tripal_report_error('tripal', TRIPAL_ERROR,
+        'Must have a variable name when adding a new Tripal Variable.', array());
+    return NULL;
+  }
+  if (!$description) {
+    tripal_report_error('tripal', TRIPAL_ERROR,
+        'Must have a description when adding a new Tripal Variable.', array());
+    return NULL;
+  }
+
+  // Make sure the variable is not a duplicate. If so, then just select
+  // it and return the variable_id
+  $variable = tripal_get_variable($name);
+  if ($variable) {
+    return $variable;
+  }
+  else {
+    db_insert('tripal_variables')
+      ->fields(array(
+        'name' => $name,
+        'description' => $description,
+      ))
+      ->execute();
+    return tripal_get_variable($name);
+  }
+}
+
+/**
+ * Retrieves the variable name record.
+ *
+ * @param $name
+ *   The name of the variable to retrieve
+ * @return
+ *   A record object containg the variable.
+ */
+function tripal_get_variable($name) {
+  return db_select('tripal_variables', 'v')
+    ->fields('v')
+    ->condition('name', $name)
+    ->execute()
+    ->fetchObject();
+}
+
+// TODO: add functions for getting/retrieving variables from/to entities.

+ 21 - 21
tripal_core/includes/tripal_core.extensions.inc → tripal/includes/tripal.extensions.inc

@@ -1,6 +1,6 @@
 <?php
 
-function tripal_core_extensions_form($form, &$form_state = NULL) {
+function tripal_extensions_form($form, &$form_state = NULL) {
   // Get the RSS feed XML from the tripa.info website and save it to
   // a temp file so that we don't have to keep pulling the XML
   // everythime the page is loaded. If the temp file is older than 1 hours
@@ -118,8 +118,8 @@ function tripal_core_extensions_form($form, &$form_state = NULL) {
     $chado_version = $form_state['values']['cv'];
   }
 
-  // Get the Tripal version. This is the version set in the tripal_core.info
-  $info = system_get_info('module', 'tripal_core');
+  // Get the Tripal version. This is the version set in the tripal.info
+  $info = system_get_info('module', 'tripal');
   $tripal_version = $info['version'];
   $tripal_version = preg_replace('/^.*?-(\d\.\d+).*$/', "v$1", $tripal_version);
   $my_tripal_version = $tripal_version;
@@ -180,8 +180,8 @@ function tripal_core_extensions_form($form, &$form_state = NULL) {
     '#options' => $options,
     '#default_value' => $tripal_version,
     '#ajax'  => array(
-      'callback' => "tripal_core_extensions_form_ajax_callback",
-      'wrapper'  => 'tripal_core_extensions',
+      'callback' => "tripal_extensions_form_ajax_callback",
+      'wrapper'  => 'tripal_extensions',
       'effect'   => 'fade',
       'method'   => 'replace',
     ),
@@ -201,8 +201,8 @@ function tripal_core_extensions_form($form, &$form_state = NULL) {
     '#options' => $options,
     '#default_value' => $chado_version,
     '#ajax'  => array(
-      'callback' => "tripal_core_extensions_form_ajax_callback",
-      'wrapper'  => 'tripal_core_extensions',
+      'callback' => "tripal_extensions_form_ajax_callback",
+      'wrapper'  => 'tripal_extensions',
       'effect'   => 'fade',
       'method'   => 'replace',
     ),
@@ -229,7 +229,7 @@ function tripal_core_extensions_form($form, &$form_state = NULL) {
   }
 
   // Iterate through all of the extensions and add them to the form.
-  tripal_core_extension_form_add_extensions($form, $form_state,
+  tripal_extension_form_add_extensions($form, $form_state,
     $extensions[$tripal_version][$chado_version], $categories, $tripal_version,
     $chado_version, $my_tripal_version, $my_chado_version, $type_ids,
     $namespace, $filters);
@@ -243,19 +243,19 @@ function tripal_core_extensions_form($form, &$form_state = NULL) {
     }
   }
 
-  $form['#prefix'] = '<div id="tripal_core_extensions">';
+  $form['#prefix'] = '<div id="tripal_extensions">';
   $form['#suffix'] = '</div>';
-  $form['#submit'][] = 'tripal_core_extensions_form_submit';
+  $form['#submit'][] = 'tripal_extensions_form_submit';
   return $form;
 }
 
 /**
  * Adds each extension to the form.
  *
- * This function exits to simplify the the tripal_core_extension_form()
+ * This function exits to simplify the the tripal_extension_form()
  * function.
  */
-function tripal_core_extension_form_add_extensions(&$form, $form_state, $extensions,
+function tripal_extension_form_add_extensions(&$form, $form_state, $extensions,
   $categories, $tripal_version, $chado_version, $my_tripal_version,
   $my_chado_version, $type_ids, $namespace, $filters) {
 
@@ -295,8 +295,8 @@ function tripal_core_extension_form_add_extensions(&$form, $form_state, $extensi
       '#options' => $options,
       '#default_value' => $default_filter,
       '#ajax'  => array(
-        'callback' => "tripal_core_extensions_form_ajax_callback",
-        'wrapper'  => 'tripal_core_extensions',
+        'callback' => "tripal_extensions_form_ajax_callback",
+        'wrapper'  => 'tripal_extensions',
         'effect'   => 'fade',
         'method'   => 'replace',
       ),
@@ -475,7 +475,7 @@ function tripal_core_extension_form_add_extensions(&$form, $form_state, $extensi
         default:
           break;
       }
-      $form[$type][$guid]['#theme'] = 'tripal_core_extensions_form_tables';
+      $form[$type][$guid]['#theme'] = 'tripal_extensions_form_tables';
       $extension_index++;
     }
 
@@ -516,7 +516,7 @@ function tripal_core_extension_form_add_extensions(&$form, $form_state, $extensi
  * @param $form
  * @param $form_state
  */
-function tripal_core_extensions_form_submit($form, &$form_state) {
+function tripal_extensions_form_submit($form, &$form_state) {
   // get the guid
   $clicked_button = $form_state['clicked_button']['#name'];
   $guid = preg_replace('/^import-(\d+)$/', "$1", $clicked_button);
@@ -547,7 +547,7 @@ function tripal_core_extensions_form_submit($form, &$form_state) {
         }
         break;
       case 'Materialized View':
-        $module_name = 'tripal_core';
+        $module_name = 'tripal';
         $mview_name = $extension[$namespace]['mview_name'];
         $mview_schema = $extension[$namespace]['mview_schema'];
         $mview_sql = $extension[$namespace]['mview_sql'];
@@ -569,7 +569,7 @@ function tripal_core_extensions_form_submit($form, &$form_state) {
           module_load_include('module', 'update', 'update');
           module_load_include('inc', 'update', 'update.manager');
           $project = $extension[$namespace]['drupal_project'];
-          $tar = tripal_core_extensions_get_latest_module_version($project);
+          $tar = tripal_extensions_get_latest_module_version($project);
           if (!$tar) {
             drupal_set_message('Cannot find a suitable release of this module
               for download. You may need to manually install this module.', 'error');
@@ -641,7 +641,7 @@ function tripal_core_extensions_form_submit($form, &$form_state) {
  *
  * @param $variables
  */
-function theme_tripal_core_extensions_form_tables($variables) {
+function theme_tripal_extensions_form_tables($variables) {
    $element = $variables['element'];
    $headers = array(
      array(
@@ -681,7 +681,7 @@ function theme_tripal_core_extensions_form_tables($variables) {
  *
  * @return unknown
  */
-function tripal_core_extensions_form_ajax_callback($form, $form_state) {
+function tripal_extensions_form_ajax_callback($form, $form_state) {
   // This function need not do anything as the form will take care of
   // updates needed. We just need to return the form.
   return $form;
@@ -696,7 +696,7 @@ function tripal_core_extensions_form_ajax_callback($form, $form_state) {
  *
  * @param $project
  */
-function tripal_core_extensions_get_latest_module_version($project_name) {
+function tripal_extensions_get_latest_module_version($project_name) {
   // First use the Drupal RESTful API to get the project
   $url = "https://www.drupal.org/api-d7/node.json?type=project_module&field_project_machine_name=$project_name";
   $result = json_decode(file_get_contents($url), TRUE);

+ 3 - 3
tripal_core/includes/tripal_core.jobs.inc → tripal/includes/tripal.jobs.inc

@@ -6,7 +6,7 @@
 
 /**
  * @defgroup tripal_jobs Jobs
- * @ingroup tripal_core
+ * @ingroup tripal
  * @{
  * Contains functions related to the display of Tripal jobs in a Tripal website.
  * @}
@@ -29,7 +29,7 @@ function tripal_jobs_admin_view() {
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
-  $view = views_embed_view('tripal_core_admin_jobs','default');
+  $view = views_embed_view('tripal_admin_jobs','default');
   if (isset($view)) {
     $output .= $view;
   }
@@ -233,7 +233,7 @@ function tripal_jobs_report() {
  *
  * @return
  *   The HTML describing the indicated job
- * @ingroup tripal_core
+ * @ingroup tripal
  *
  * @ingroup tripal_jobs
  */

+ 259 - 0
tripal/tripal.drush.inc

@@ -0,0 +1,259 @@
+<?php
+/**
+ * @file
+ * Contains function relating to drush-integration of this module.
+ */
+
+/**
+ * @defgroup tripal_drush Tripal Drush Integration
+ * @{
+ * Contains function relating to drush-integration of various tripal modules.
+ * @}
+ */
+
+/**
+ * Describes each drush command implemented by the module
+ *
+ * @return
+ *   The first line of description when executing the help for a given command
+ *
+ * @ingroup tripal_drush
+ */
+function tripal_drush_help($command) {
+  switch ($command) {
+
+    // TRIPAL JOBS
+    case 'trp-run-jobs':
+      return dt('Launches pending jobs waiting in the queue.');
+      break;
+    case 'trp-rerun-job':
+      return dt('Rerun a job in the queue.');
+      break;
+    case 'trp-get-currjob':
+      return dt('Returns details about the currently running tripal job including percent complete.');
+      break;
+    // Placeholders for unimplmeneted jobs
+    case 'trp-show-job':
+      break;
+    case 'trp-revert-jobs':
+      break;
+    case 'trp-cancel-job':
+      break;
+    case 'trp-list-jobs':
+      break;
+
+  }
+}
+
+/**
+ * Registers a drush command and constructs the full help for that command.
+ *
+ * @return
+ *   And array of command descriptions
+ *
+ * @ingroup tripal_drush
+ */
+function tripal_drush_command() {
+  $items = array();
+
+  $items['trp-get-currjob'] = array(
+    'description' => dt('Returns details about the currently running job including percent complete.'),
+    'arguments'   => array(),
+    'examples' => array(
+      'Standard example' => 'drush trp-get-currjob',
+    ),
+  );
+  $items['trp-run-jobs'] = array(
+    'description' => dt('Launches jobs waiting in the queue. Only one job can execute at a time unless the --parllel=1 option is provided.'),
+    'examples' => array(
+      'Single Job' => 'drush trp-run-jobs --username=administrator',
+      'Parallel Job' => 'drush trp-run-jobs --username=administrator --parallel=1'
+    ),
+    'arguments' => array(),
+    'options' => array(
+      'user' => array(
+        'description' => dt('DEPRECATED. Conflicts with Drush 7.x --user argument. Please use the --username argument.'),
+      ),
+      'username' => array(
+        'description' => dt('The Drupal user name for which the job should be run.  The permissions for this user will be used.'),
+      ),
+      'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
+      'job_id' => dt('Provide a job_id to run a specific job. Only jobs that have not been run already can be used'),
+    ),
+  );
+  $items['trp-rerun-job'] = array(
+    'description' => dt('Re-run a specific job from the queue.'),
+    'examples' => array(
+      'Single Job' => 'drush trp-rerun-job --username=administrator --job_id=2',
+      'Parallel Job' => 'drush trp-rerun-job --username=administrator  --job_id=2 --parallel=1'
+    ),
+    'arguments' => array(),
+    'options' => array(
+      'user' => array(
+        'description' => dt('DEPRECATED. Conflicts with Drush 7.x --user argument. Please use the --username argument.'),
+      ),
+      'username' => array(
+        'description' => dt('The Drupal user name for which the job should be run.  The permissions for this user will be used.'),
+      ),
+      'job_id' => array(
+        'description' => dt('The job ID to run.'),
+        'required' => TRUE,
+      ),
+      'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
+    ),
+  );
+
+  return $items;
+}
+
+/**
+ * Set the user to run a drush job.
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_set_user($username) {
+  if ($username) {
+    $sql = "SELECT uid FROM {users} WHERE name = :name";
+    $results = db_query($sql, array(':name' => $username));
+    $u = $results->fetchObject();
+    if (!$u) {
+      drush_print('ERROR: Please provide a valid username (--username argument) for running this job.');
+      exit;
+    }
+    global $user;
+    $user = user_load($u->uid);
+    return $u->uid;
+  }
+  else {
+    drush_print('ERROR: Please provide a username (--username argument) for running this job.');
+    exit;
+  }
+}
+
+/**
+ * Executes jobs in the Tripal Jobs Queue.
+ *
+ * Executed when 'drush trp-run-job' is called.
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_trp_run_jobs() {
+  $parallel = drush_get_option('parallel');
+  $job_id   = drush_get_option('job_id');
+
+  // Unfortunately later versions of Drush use the '--user' argument which
+  // makes it incompatible with how Tripal was using it.  For backwards
+  // compatabiliy we will accept --user with a non numeric value only. The
+  // numeric value should be for Drush. Tripal will instead use the
+  // --username argument for the fture.
+  $user = drush_get_option('user');
+  $uname = drush_get_option('username');
+  if ($user and is_numeric($user)) {
+  }
+  elseif ($user) {
+    print "\nNOTE: Use of the --user argument is deprecated as it conflicts with the --user argument of Drush 7.x. Please now use --username instead.\n\n";
+    $username = $user;
+  }
+  if ($uname) {
+    $username = $uname;
+  }
+
+  drush_tripal_set_user($username);
+
+  if ($parallel) {
+    drush_print("Tripal Job Launcher (in parallel)");
+    drush_print("Running as user '$username'");
+    drush_print("-------------------");
+    tripal_launch_job($parallel, $job_id);
+  }
+  else {
+    drush_print("Tripal Job Launcher");
+    drush_print("Running as user '$username'");
+    drush_print("-------------------");
+    tripal_launch_job(0, $job_id);
+  }
+}
+
+/**
+ * Executes jobs in the Tripal Jobs Queue.
+ *
+ * Executed when 'drush trp-rerun-job' is called.
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_trp_rerun_job() {
+  // Unfortunately later versions of Drush use the '--user' argument which
+  // makes it incompatible with how Tripal was using it.  For backwards
+  // compatabiliy we will accept --user with a non numeric value only. The
+  // numeric value should be for Drush. Tripal will instead use the
+  // --username argument for the fture.
+  $user = drush_get_option('user');
+  $uname = drush_get_option('username');
+  print "USER: '$user', UNAME: '$uname'\n";
+  if ($user and is_numeric($user)) {
+  }
+  elseif ($user) {
+    print "\nNOTE: Use of the --user argument is deprecated as it conflicts with the --user argument of Drush 7.x. Please now use --username instead.\n\n";
+    $username = $user;
+  }
+  if ($uname) {
+    $username = $uname;
+  }
+
+  $parallel = drush_get_option('parallel');
+  $job_id   = drush_get_option('job_id');
+
+  drush_tripal_set_user($username);
+  $new_job_id = tripal_rerun_job($job_id, FALSE);
+
+  if ($parallel) {
+    drush_print("Tripal Job Launcher (in parallel)");
+    drush_print("Running as user '$username'");
+    drush_print("-------------------");
+    tripal_launch_job($parallel, $new_job_id);
+  }
+  else {
+    drush_print("Tripal Job Launcher");
+    drush_print("Running as user '$username'");
+    drush_print("-------------------");
+    tripal_launch_job(0, $new_job_id);
+  }
+
+}
+
+/**
+ * Prints details about the current running job.
+ *
+ * Executed when 'drush trp-get-currjob' is called.
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_trp_get_currjob() {
+  $sql =  "
+    SELECT *
+    FROM {tripal_jobs} TJ
+    WHERE TJ.end_time IS NULL and NOT TJ.start_time IS NULL
+  ";
+  $jobs = db_query($sql);
+
+  foreach ($jobs as $job) {
+    $job_pid = $job->pid;
+    $output = "Name: " . $job->job_name . "\n" .
+        "Submitted: " . date(DATE_RFC822, $job->submit_date) . "\n" .
+        "Started: " . date(DATE_RFC822, $job->start_time) . "\n" .
+        "Module: " . $job->modulename . "\n" .
+        "Callback: " . $job->callback . "\n" .
+        "Process ID: " . $job->pid . "\n" .
+        "Progress: " . $job->progress . "%\n";
+    drush_print($output);
+  }
+  if (!$job_pid) {
+    drush_print('There are currently no running jobs.');
+  }
+  //log to the command line with an OK status
+  drush_log('Running tripal-current-job', 'ok');
+}
+
+
+
+

+ 15 - 0
tripal/tripal.info

@@ -0,0 +1,15 @@
+name = Tripal
+description = Tripal is an toolkit to facilitate construction of online genomic, genetic (and other biological) websites.
+core = 7.x
+project = tripal
+package = Tripal
+version = 7.x-3.0
+configure = admin/tripal
+
+stylesheets[all][] = theme/css/tripal.css
+scripts[]          = theme/js/tripal.js
+
+dependencies[] = views
+dependencies[] = path
+dependencies[] = search
+dependencies[] = php

+ 188 - 0
tripal/tripal.install

@@ -0,0 +1,188 @@
+<?php
+/**
+ * @file
+ * Contains functions used to install/uninstall tripal.
+ */
+
+/**
+ * Implementation of hook_install().
+ *
+ * @ingroup tripal
+ */
+function tripal_install() {
+
+}
+/**
+ * Implementation of hook_schema().
+ *
+ * @ingroup tripal
+ */
+function tripal_schema() {
+  $schema = array();
+  $schema['tripal_jobs'] = array(
+    'fields' => array(
+      'job_id' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not NULL' => TRUE
+      ),
+      'uid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not NULL' => TRUE,
+        'description' => 'The Drupal userid of the submitee'
+      ),
+      'job_name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not NULL' => TRUE
+      ),
+      'modulename' => array(
+        'type' => 'varchar',
+        'length' => 50,
+        'not NULL' => TRUE,
+        'description' => 'The module name that provides the callback for this job'
+      ),
+      'callback' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not NULL' => TRUE
+      ),
+      'arguments' => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => FALSE
+      ),
+      'progress' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'default' => 0,
+        'not NULL' => FALSE,
+        'description' => 'a value from 0 to 100 indicating percent complete'
+      ),
+      'status' => array(
+        'type' => 'varchar',
+        'length' => 50,
+        'not NULL' => TRUE
+      ),
+      'submit_date' => array(
+        'type' => 'int',
+        'not NULL' => TRUE,
+        'description' => 'UNIX integer submit time'
+      ),
+      'start_time' => array(
+        'type' => 'int',
+        'not NULL' => FALSE,
+        'description' => 'UNIX integer start time'
+      ),
+      'end_time' => array(
+        'type' => 'int',
+        'not NULL' => FALSE,
+        'description' => 'UNIX integer end time'
+      ),
+      'error_msg' => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => FALSE
+      ),
+      'pid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not NULL' => FALSE,
+        'description' => 'The process id for the job'
+      ),
+      'priority' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not NULL' => TRUE,
+        'default' => '0',
+        'description' => 'The job priority'
+      ),
+      'mlock' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not NULL' => FALSE,
+        'description' => 'If set to 1 then all jobs for the module are held until this one finishes'
+      ),
+      'lock' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not NULL' => FALSE,
+        'description' => 'If set to 1 then all jobs are held until this one finishes'
+      ),
+    ),
+    'indexes' => array(
+      'job_id' => array('job_id'),
+      'job_name' => array('job_name')
+    ),
+    'primary key' => array('job_id'),
+  );
+
+  $schema['tripal_token_formats'] = array(
+    'fields' => array(
+      'tripal_format_id' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE
+      ),
+      'content_type' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE
+      ),
+      'application' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE
+      ),
+      'format' => array(
+        'type' => 'text',
+        'not null' => TRUE
+      ),
+      'tokens' => array(
+        'type' => 'text',
+        'not null' => TRUE
+      ),
+    ),
+    'unique keys' => array(
+      'type_application' => array('content_type', 'application'),
+    ),
+    'primary key' => array('tripal_format_id'),
+  );
+
+
+  $schema['tripal_variables'] = array(
+    'description' => 'This table houses a list of unique variable names that ' .
+      'can be used in the tripal_node_variables table.',
+    'fields' => array(
+      'variable_id' => array (
+        'type' => 'serial',
+        'not null' => TRUE,
+      ),
+      'name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+      ),
+      'description' => array(
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array (
+        0 => 'variable_id',
+    ),
+    'unique keys' => array (
+      'tripal_variables_c1' => array (
+        0 => 'name',
+      ),
+    ),
+    'indexes' => array (
+      'tripal_variable_names_idx1' => array (
+        0 => 'variable_id',
+      ),
+    ),
+  );
+
+  return $schema;
+}

+ 268 - 0
tripal/tripal.module

@@ -0,0 +1,268 @@
+<?php
+/**
+ * @file
+ * The Tripal Core module
+ */
+
+require_once "api/tripal.notice.api.inc";
+
+/**
+ * @defgroup tripal Tripal Core Module
+ * @ingroup tripal_modules
+ * @{
+ * Functionality useful for all other Tripal modules including the Tripal jobs, files,
+ * materialized views and custom table functions.
+ * @}
+ */
+
+
+/**
+ * Implements hook_init().
+ * Used to set the search_path, create default content and set default variables.
+ *
+ * @ingroup tripal
+ */
+function tripal_init() {
+  global $base_url;
+
+  // add some variables for all javasript to use for building URLs
+  $theme_dir = drupal_get_path('theme', 'tripal');
+  $clean_urls = variable_get('clean_url', 0);
+  drupal_add_js(
+    " var baseurl  = '$base_url';
+      var themedir = '$theme_dir';
+      var isClean  =  $clean_urls;",
+    'inline', 'header');
+
+  // make sure the date time settings are the way Tripal will insert them
+  // otherwise PostgreSQL version that may have a different datestyle setting
+  // will fail when inserting or updating a date column in a table.
+  db_query("SET DATESTYLE TO :style", array(':style' => 'MDY'));
+
+}
+
+/**
+ * Implements hook_menu().
+ * Defines all menu items needed by Tripal Core
+ *
+ * @ingroup tripal
+ */
+function tripal_menu() {
+  $items = array();
+
+  // Tripal setting groups
+  $items['admin/tripal'] = array(
+    'title' => 'Tripal',
+    'description' => t("Manage the behavior or Tripal and its various modules."),
+    'weight' => -8,
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('administer tripal'),
+    'file' => 'system.admin.inc',
+    'file path' => drupal_get_path('module', 'system'),
+  );
+  $items['admin/tripal/tripal_jobs'] = array(
+    'title' => 'Jobs',
+    'description' => t('Jobs managed by Tripal'),
+    'page callback' => 'tripal_jobs_admin_view',
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => 0,
+    'file' => 'includes/tripal.jobs.inc',
+    'file path' => drupal_get_path('module', 'tripal'),
+  );
+
+  $items['admin/tripal/storage'] = array(
+    'title' => 'Storage Backend',
+    'description' => t("Functionality related to data storage and tools to interact with the storage backend."),
+    'weight' => 8,
+    'access arguments' => array('administer tripal'),
+  );
+
+  // Menu items for facilitating import of extension modules.
+  $items['admin/tripal/extension'] = array(
+    'title' => 'Extensions',
+    'description' => t('Configuration for Tripal extensions.'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'includes/tripal.extensions.inc',
+    'file path' => drupal_get_path('module', 'tripal'),
+    'weight' => 100
+  );
+  $items['admin/tripal/extension/import'] = array(
+    'title' => 'Import Extensions',
+    'description' => 'Provides a list of the available extensions that are registered at the tripal.info site. From this page you can easily import or install extensions to your site.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_extensions_form'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' =>  'includes/tripal.extensions.inc',
+    'file path' => drupal_get_path('module', 'tripal'),
+    'weight' => -100,
+  );
+
+
+/*
+  $items['admin/tripal/setup/customize'] = array(
+    'title' => 'Customize Tripal',
+    'description' => t('Information on how to customize tripal'),
+    'page callback' => 'theme',
+    'page arguments' => array('tripal_customize'),
+    'access arguments' => array('administer tripal'),
+    'weight' => 10
+  );
+*/
+
+  // Jobs Management
+  $items['admin/tripal/tripal_jobs/help'] = array(
+    'title' => 'Help',
+    'description' => t('Help for the tripal job management system'),
+    'page callback' => 'theme',
+    'page arguments' => array('tripal_job_help'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10
+  );
+  $items['admin/tripal/tripal_jobs/cancel/%'] = array(
+    'title' => 'Jobs',
+    'description' => t('Cancel a pending job'),
+    'page callback' => 'tripal_cancel_job',
+    'page arguments' => array(4),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/tripal_jobs/rerun/%'] = array(
+    'title' => 'Jobs',
+    'description' => t('Re-run an existing job.'),
+    'page callback' => 'tripal_rerun_job',
+    'page arguments' => array(4),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/tripal_jobs/view/%'] = array(
+    'title' => 'Jobs Details',
+    'description' => t('View job details.'),
+    'page callback' => 'tripal_jobs_view',
+    'page arguments' => array(4),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/tripal_jobs/views/jobs/enable'] = array(
+    'title' => 'Enable Jobs Administrative View',
+    'page callback' => 'tripal_enable_view',
+    'page arguments' => array('tripal_admin_jobs', 'admin/tripal/tripal_jobs'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+
+  return $items;
+}
+
+/**
+ * Implements hook_permission().
+ */
+function tripal_permission() {
+  return array(
+    'administer tripal' => array(
+      'title' => t('Administer Tripal'),
+      'description' => t('Allow the user to access administrative pages of Tripal.')
+    ),
+    'view dev helps' => array(
+      'title' => t('View Developer Hints'),
+      'description' => t('Tripal will provide blue shaded boxes that provide
+          instructions for how to customize or setup specific pages on a
+          site.  This permission should be enabled for developers. But can
+          be disabled once developers are accustomed to these hints.'),
+      'restrict access' => TRUE,
+    ),
+  );
+}
+
+/**
+ * Implements hook_theme().
+ * Registers template files/functions used by this module.
+ *
+ * @ingroup tripal
+ */
+function tripal_theme($existing, $type, $theme, $path) {
+  return array(
+    'tripal_customize' => array(
+      'arguments' => array('job_id' => NULL),
+      'template' => 'tripal_customize',
+      'path' => "$path/theme/templates"
+    ),
+    'theme_file_upload_combo' => array(
+      'render element' => 'element',
+    ),
+    'theme_sequence_combo' => array(
+      'render element' => 'element',
+    ),
+    'tripal_jobs_help' => array(
+      'template' => 'tripal_jobs_help',
+      'variables' =>  array(NULL),
+      'path' => "$path/theme/templates"
+    ),
+    'tripal_customtables_help' => array(
+      'template' => 'tripal_customtables_help',
+      'variables' =>  array(NULL),
+      'path' => "$path/theme/templates"
+    ),
+    // Admin messages theme
+    'tripal_admin_message' => array(
+      'function' => 'theme_tripal_admin_message',
+      'variables' => array('message' => NULL),
+    ),
+    // Theme function for the extension admin page.
+    'tripal_extensions_form_tables' => array(
+      'render element' => 'element',
+    )
+  );
+}
+
+
+/**
+ * Implements hook_coder_ignore().
+ * Defines the path to the file (tripal.coder_ignores.txt) where ignore rules for coder are stored
+ */
+function tripal_coder_ignore() {
+  return array(
+    'path' => drupal_get_path('module', 'tripal'),
+    'line prefix' => drupal_get_path('module', 'tripal'),
+  );
+}
+
+/**
+ * Implements hook_views_api()
+ * Purpose: Essentially this hook tells drupal that there is views support for
+ *  for this module which then includes tripal_db.views.inc where all the
+ *  views integration code is
+ *
+ * @ingroup tripal_organism
+ */
+function tripal_views_api() {
+  return array(
+    'api' => 3.0,
+  );
+}
+
+/**
+ * Implements hook_libraries_info().
+ */
+function tripal_libraries_info() {
+  $libraries = array();
+  $libraries['d3'] = array(
+    'name' => 'D3.js',
+    'vendor url' => 'http://d3js.org/',
+    'download url' => 'https://github.com/mbostock/d3',
+    'version arguments' => array(
+      'file' => 'd3.js',
+      'pattern' => '/\s*version: "(\d+\.\d+\.\d+)"/',
+    ),
+    'files' => array(
+      'js' => array(
+        'd3.min.js',
+      ),
+    ),
+  );
+
+  return $libraries;
+}

+ 16 - 16
tripal_core/tripal_core.views.inc → tripal/tripal.views.inc

@@ -8,19 +8,19 @@
  * Describe various Tripal Core systems to Views
  *   for the creation of administrative views.
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
-function tripal_core_views_data() {
+function tripal_views_data() {
   $data = array();
 
   // Job Management System
-  $data =   tripal_core_views_data_jobs($data);
+  $data =   tripal_views_data_jobs($data);
 
   // Custom Tables Management
-  $data = tripal_core_views_data_custom_tables($data);
+  $data = tripal_views_data_custom_tables($data);
 
   // Materialized Views Management
-  $data = tripal_core_views_data_mviews($data);
+  $data = tripal_views_data_mviews($data);
 
   return $data;
 }
@@ -29,13 +29,13 @@ function tripal_core_views_data() {
  * Provides the data array for the tripal job management system
  *
  * @param $data
- *   Previously generated tripal_core views data array
+ *   Previously generated tripal views data array
  * return
  *   $data array with job management system described
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
-function tripal_core_views_data_jobs($data) {
+function tripal_views_data_jobs($data) {
 
   $data['tripal_jobs']['table']['group'] = t('Tripal Jobs');
   $data['tripal_jobs']['table']['base'] = array(
@@ -292,13 +292,13 @@ function tripal_core_views_data_jobs($data) {
  * Provides the data array for the tripal custom tables management
  *
  * @param $data
- *   Previously generated tripal_core views data array
+ *   Previously generated tripal views data array
  * return
  *   $data array with custom tables management described
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
-function tripal_core_views_data_custom_tables($data) {
+function tripal_views_data_custom_tables($data) {
 
   $data['tripal_custom_tables']['table']['group'] = t('Tripal Custom Tables');
   $data['tripal_custom_tables']['table']['base'] = array(
@@ -361,7 +361,7 @@ function tripal_core_views_data_custom_tables($data) {
       'handler' => 'views_handler_argument_string',
     ),
   );
-  
+
   // Table ID
   $data['tripal_custom_tables']['mview_id'] = array(
     'title' => t('Materialized View ID'),
@@ -377,7 +377,7 @@ function tripal_core_views_data_custom_tables($data) {
       'handler' => 'views_handler_sort',
     ),
   );
-  
+
 
   return $data;
 }
@@ -386,13 +386,13 @@ function tripal_core_views_data_custom_tables($data) {
  * Provides the data array for the tripal custom tables management
  *
  * @param $data
- *   Previously generated tripal_core views data array
+ *   Previously generated tripal views data array
  * return
  *   $data array with custom tables management described
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
-function tripal_core_views_data_mviews($data) {
+function tripal_views_data_mviews($data) {
 
   $data['tripal_mviews']['table']['group'] = t('Tripal Materialized Views');
   $data['tripal_mviews']['table']['base'] = array(

+ 16 - 16
tripal_core/tripal_core.views_default.inc → tripal/tripal.views_default.inc

@@ -7,18 +7,18 @@
 /**
  * Describes core default views
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
-function tripal_core_views_default_views() {
+function tripal_views_default_views() {
   $views = array();
 
-  $view = tripal_core_admin_defaultview_jobs();
+  $view = tripal_admin_defaultview_jobs();
   $views[$view->name] = $view;
 
-  $view = tripal_core_admin_defaultview_custom_tables();
+  $view = tripal_admin_defaultview_custom_tables();
   $views[$view->name] = $view;
 
-  $view = tripal_core_admin_defaultview_mviews();
+  $view = tripal_admin_defaultview_mviews();
   $views[$view->name] = $view;
 
   return $views;
@@ -27,12 +27,12 @@ function tripal_core_views_default_views() {
 /**
  * Describes the jobs administration view.
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
-function tripal_core_admin_defaultview_jobs() {
+function tripal_admin_defaultview_jobs() {
 
   $view = new view();
-  $view->name = 'tripal_core_admin_jobs';
+  $view->name = 'tripal_admin_jobs';
   $view->description = 'DO NOT DISABLE';
   $view->tag = 'tripal admin';
   $view->base_table = 'tripal_jobs';
@@ -304,12 +304,12 @@ function tripal_core_admin_defaultview_jobs() {
 /**
  * Describes the custom tables administration view.
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
-function tripal_core_admin_defaultview_custom_tables() {
+function tripal_admin_defaultview_custom_tables() {
 
   $view = new view();
-  $view->name = 'tripal_core_admin_custom_table';
+  $view->name = 'tripal_admin_custom_table';
   $view->description = 'DO NOT DISABLE';
   $view->tag = 'tripal admin';
   $view->base_table = 'tripal_custom_tables';
@@ -317,7 +317,7 @@ function tripal_core_admin_defaultview_custom_tables() {
   $view->core = 7;
   $view->api_version = '3.0';
   $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-  
+
   /* Display: Master */
   $handler = $view->new_display('default', 'Master', 'default');
   $handler->display->display_options['title'] = 'Custom Tables';
@@ -416,7 +416,7 @@ function tripal_core_admin_defaultview_custom_tables() {
     1 => 0,
     3 => 0,
   );
-  
+
   /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page');
   $handler->display->display_options['path'] = 'admin/tripal/storage/chado/custom_tables/tables';
@@ -435,12 +435,12 @@ function tripal_core_admin_defaultview_custom_tables() {
 /**
  * Describes the materialized views administration view.
  *
- * @ingroup tripal_core
+ * @ingroup tripal
  */
-function tripal_core_admin_defaultview_mviews() {
+function tripal_admin_defaultview_mviews() {
 
   $view = new view();
-  $view->name = 'tripal_core_admin_mviews';
+  $view->name = 'tripal_admin_mviews';
   $view->description = 'DO NOT DISABLE';
   $view->tag = 'tripal admin';
   $view->base_table = 'tripal_mviews';

+ 9 - 9
tripal_core/api/get_FKs.php → tripal_chado/api/get_FKs.php

@@ -7,17 +7,17 @@
  * version of Chado.  The goal is to use the output of this script to
  * update the existing schema hooks.  Redirect the output of this script to
  * a file and then replace the existing schema API include file (e.g.
- * tripal_core.schema_v1.2.api.inc).  Be sure to check it before replacing
+ * tripal_chado.schema_v1.2.api.inc).  Be sure to check it before replacing
  *
  * This script requires a single argument (-v) which is the Chado version.
  *
  * Example usage in drupal directory root:
  *
- * php ./sites/all/modules/tripal/tripal_core/api/get_FKs.php -v 1.11 > \
- *   ./sites/all/modules/tripal/tripal_core/apitripal_core.schema_v1.11.api.inc.new
+ * php ./sites/all/modules/tripal/tripal_chado/api/get_FKs.php -v 1.11 > \
+ *   ./sites/all/modules/tripal/tripal_chado/apitripal_chado.schema_v1.11.api.inc.new
  *
- * php ./sites/all/modules/tripal/tripal_core/api/get_FKs.php -v 1.2 > \
- *   ./sites/all/modules/tripal/tripal_core/api/tripal_core.schema_v1.2.api.inc.new
+ * php ./sites/all/modules/tripal/tripal_chado/api/get_FKs.php -v 1.2 > \
+ *   ./sites/all/modules/tripal/tripal_chado/api/tripal_chado.schema_v1.2.api.inc.new
  */
 
 $arguments = getopt("v:");
@@ -38,8 +38,8 @@ if (isset($arguments['v'])) {
 
 /**
  * Builds the FK relationships array in the database.
- * 
- * This function does the actual work of determining the foreign key 
+ *
+ * This function does the actual work of determining the foreign key
  * relationships from the database and creating the schema file.
  */
 function get_chado_fk_relationships($version) {
@@ -65,7 +65,7 @@ function get_chado_fk_relationships($version) {
   print "<?php
 /* @file: This file contains default schema definitions for all chado v$version tables
  *        to be used by other function. Specifically these functions are used
- *        by the tripal_core select/insert/update API functions and by
+ *        by the tripal_chado select/insert/update API functions and by
  *        the Tripal Views module.
  *
  *        These schema definitions can be augmented by another modules
@@ -152,7 +152,7 @@ print "/**
  * @ingroup tripal_chado_v".$version."_schema_api
  *
  */
-function tripal_core_chado_schema_v".$v."_".$table."() {
+function tripal_chado_chado_schema_v".$v."_".$table."() {
   \$description =  $arr;
   return \$description;
 }

+ 0 - 0
legacy/tripal_analysis/api/tripal_analysis.api.inc → tripal_chado/api/modules/tripal_chado.analysis.api.inc


+ 0 - 0
legacy/tripal_contact/api/tripal_contact.api.inc → tripal_chado/api/modules/tripal_chado.contact.api.inc


+ 51 - 51
tripal_cv/api/tripal_cv.api.inc → tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -6,7 +6,7 @@
  */
 
 /**
- * @defgroup tripal_cv_api Controlled Vocabulary API
+ * @defgroup tripal_chado_api Controlled Vocabulary API
  * @ingroup tripal_api
  * This module provides a set of functions to simplify working with
  * controlled vocabularies.  Most of the API functions deal with retrieving
@@ -42,7 +42,7 @@
  *   will be returned (will be a chado variable from chado_generate_var()). Otherwise,
  *   FALSE will be returned.
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_cv($identifiers, $options = array()) {
 
@@ -55,7 +55,7 @@ function tripal_get_cv($identifiers, $options = array()) {
   // Error Checking of parameters
   if (!is_array($identifiers)) {
     tripal_report_error(
-      'tripal_cv_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_cv: The identifier passed in is expected to be an array with the key
         matching a column name in the cv table (ie: cv_id or name). You passed in %identifier.",
@@ -66,7 +66,7 @@ function tripal_get_cv($identifiers, $options = array()) {
   }
   elseif (empty($identifiers)) {
     tripal_report_error(
-      'tripal_cv_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_cv: You did not pass in anything to identify the cv you want. The identifier
         is expected to be an array with the key matching a column name in the cv table
@@ -87,7 +87,7 @@ function tripal_get_cv($identifiers, $options = array()) {
   // Ensure the cv is singular. If it's an array then it is not singular
   if (is_array($cv)) {
     tripal_report_error(
-      'tripal_cv_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_cv: The identifiers you passed in were not unique. You passed in %identifier.",
       array(
@@ -99,7 +99,7 @@ function tripal_get_cv($identifiers, $options = array()) {
   // Report an error if $cv is FALSE since then chado_generate_var has failed
   elseif ($cv === FALSE) {
     tripal_report_error(
-      'tripal_cv_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_cv: chado_generate_var() failed to return a cv based on the identifiers
         you passed in. You should check that your identifiers are correct, as well as, look
@@ -123,7 +123,7 @@ function tripal_get_cv($identifiers, $options = array()) {
  * @return
  *   An array(cv_id => name) for each cv in the chado cv table
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_cv_select_options() {
 
@@ -167,7 +167,7 @@ function tripal_get_cv_select_options() {
  *   will be returned (will be a chado variable from chado_generate_var()). Otherwise,
  *   FALSE will be returned.
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_cvterm($identifiers, $options = array()) {
 
@@ -179,14 +179,14 @@ function tripal_get_cvterm($identifiers, $options = array()) {
 
   // Error Checking of parameters
   if (!is_array($identifiers)) {
-    tripal_report_error('tripal_cv_api', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado_api', TRIPAL_ERROR,
       "tripal_get_cvterm: The identifier passed in is expected to be an array with the key
         matching a column name in the cvterm table (ie: cvterm_id or name). You passed in %identifier.",
       array('%identifier'=> print_r($identifiers, TRUE))
     );
   }
   elseif (empty($identifiers)) {
-    tripal_report_error('tripal_cv_api', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado_api', TRIPAL_ERROR,
       "tripal_get_cvterm: You did not pass in anything to identify the cvterm you want. The identifier
         is expected to be an array with the key matching a column name in the cvterm table
         (ie: cvterm_id or name). You passed in %identifier.",
@@ -242,7 +242,7 @@ function tripal_get_cvterm($identifiers, $options = array()) {
   // Ensure the cvterm is singular. If it's an array then it is not singular
   if (is_array($cvterm)) {
     tripal_report_error(
-      'tripal_cv_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_cvterm: The identifiers you passed in were not unique. You passed in %identifier.",
       array(
@@ -254,7 +254,7 @@ function tripal_get_cvterm($identifiers, $options = array()) {
   // Report an error if $cvterm is FALSE since then chado_generate_var has failed
   elseif ($cvterm === FALSE) {
     tripal_report_error(
-      'tripal_cv_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_cvterm: chado_generate_var() failed to return a cvterm based on the identifiers
         you passed in. You should check that your identifiers are correct, as well as, look
@@ -283,7 +283,7 @@ function tripal_get_cvterm($identifiers, $options = array()) {
  *   An associative array with the cvterm_id's as keys. The first
  *   element in the array has a key of '0' and a value of 'Select a Type'
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_cvterm_select_options($cv_id) {
   $columns = array('cvterm_id', 'name');
@@ -314,7 +314,7 @@ function tripal_get_cvterm_select_options($cv_id) {
  * @return
  *   TRUE on success FALSE on failure
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_update_cvtermpath($cv_id, $job_id = NULL) {
   // TODO: need better error checking in this function
@@ -334,7 +334,7 @@ function tripal_update_cvtermpath($cv_id, $job_id = NULL) {
   catch (Exception $e) {
     chado_set_active($previous);
     $error = $e->getMessage();
-    tripal_report_error('tripal_cv', TRIPAL_ERROR, "Could not fill cvtermpath table: @error", array('@error' => $error));
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "Could not fill cvtermpath table: @error", array('@error' => $error));
     return FALSE;
   }
 
@@ -353,7 +353,7 @@ function tripal_update_cvtermpath($cv_id, $job_id = NULL) {
  * @return
  *   An object populated with fields from the newly added database.
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_insert_cv($name, $definition) {
 
@@ -373,7 +373,7 @@ function tripal_insert_cv($name, $definition) {
     $ins_options = array('statement_name' => 'ins_cv_nade');
     $success = chado_insert_record('cv', $ins_values, $ins_options);
     if (!$success) {
-      tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to create the CV record", NULL);
+      tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to create the CV record", NULL);
       return FALSE;
     }
     $results = chado_select_record('cv', array('*'), $sel_values, $sel_options);
@@ -383,7 +383,7 @@ function tripal_insert_cv($name, $definition) {
     $upd_options = array('statement_name' => 'upd_cv_nade');
     $success = chado_update_record('cv', $sel_values, $ins_values, $upd_options);
     if (!$success) {
-      tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to update the CV record", NULL);
+      tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to update the CV record", NULL);
       return FALSE;
     }
     $results = chado_select_record('cv', array('*'), $sel_values, $sel_options);
@@ -433,7 +433,7 @@ function tripal_insert_cv($name, $definition) {
  * @return
  *   A CVTerm object
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_insert_cvterm($term, $options = array()) {
 
@@ -500,7 +500,7 @@ function tripal_insert_cvterm($term, $options = array()) {
     }
   }
   if (!$name and !$id) {
-    tripal_report_error('tripal_cv', TRIPAL_WARNING, "Cannot find cvterm without 'id' or 'name'", NULL);
+    tripal_report_error('tripal_chado', TRIPAL_WARNING, "Cannot find cvterm without 'id' or 'name'", NULL);
     return 0;
   }
   if (!$id) {
@@ -519,11 +519,11 @@ function tripal_insert_cvterm($term, $options = array()) {
 
   // check that we have a database name, give a different message if it's a relationship
   if ($is_relationship and !$dbname) {
-    tripal_report_error('tripal_cv', TRIPAL_WARNING, "A database name is not provided for this relationship term: $id", NULL);
+    tripal_report_error('tripal_chado', TRIPAL_WARNING, "A database name is not provided for this relationship term: $id", NULL);
     return 0;
   }
   if (!$is_relationship and !$dbname) {
-    tripal_report_error('tripal_cv', TRIPAL_WARNING, "A database identifier is missing from the term: $id", NULL);
+    tripal_report_error('tripal_chado', TRIPAL_WARNING, "A database identifier is missing from the term: $id", NULL);
     return 0;
   }
 
@@ -533,7 +533,7 @@ function tripal_insert_cvterm($term, $options = array()) {
     $cv = tripal_insert_cv($cvname, '');
   }
   if (!$cv) {
-    tripal_report_error('tripal_cv', TRIPAL_WARNING, "Cannot find namespace '$cvname' when adding/updating $id", NULL);
+    tripal_report_error('tripal_chado', TRIPAL_WARNING, "Cannot find namespace '$cvname' when adding/updating $id", NULL);
     return 0;
   }
 
@@ -558,7 +558,7 @@ function tripal_insert_cvterm($term, $options = array()) {
     $db = tripal_insert_db(array('name' => $dbname));
   }
   if (!$db) {
-    tripal_report_error('tripal_cv', TRIPAL_WARNING, "Cannot find database '$dbname' in Chado.", NULL);
+    tripal_report_error('tripal_chado', TRIPAL_WARNING, "Cannot find database '$dbname' in Chado.", NULL);
     return 0;
   }
 
@@ -614,7 +614,7 @@ function tripal_insert_cvterm($term, $options = array()) {
         $options = array('statement_name' => 'upd_cvterm_db');
         $success = chado_update_record('cvterm', $match, $values, $options);
         if (!$success) {
-          tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to correct the dbxref id for the cvterm " .
+          tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to correct the dbxref id for the cvterm " .
             "'$name' (id: $accession), for database $dbname", NULL);
           return 0;
         }
@@ -640,7 +640,7 @@ function tripal_insert_cvterm($term, $options = array()) {
         'accession' => $accession
       ));
       if (!$dbxref_new) {
-        tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to find or insert the dbxref record for cvterm, " .
+        tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to find or insert the dbxref record for cvterm, " .
           "$name (id: $accession), for database $dbname", NULL);
         return 0;
       }
@@ -662,7 +662,7 @@ function tripal_insert_cvterm($term, $options = array()) {
         );
         $success = chado_insert_record('cvterm_dbxref', $values, $options);
         if (!$success) {
-          tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to find or insert the cvterm_dbxref record for a " .
+          tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to find or insert the cvterm_dbxref record for a " .
             "duplicated cvterm:  $name (id: $accession), for database $dbname", NULL);
           return 0;
         }
@@ -688,7 +688,7 @@ function tripal_insert_cvterm($term, $options = array()) {
       'accession' => $accession
     ));
     if (!$dbxref) {
-      tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to find or insert the dbxref record for cvterm, " .
+      tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to find or insert the dbxref record for cvterm, " .
         "$name (id: $accession), for database $dbname", NULL);
       return 0;
     }
@@ -712,18 +712,18 @@ function tripal_insert_cvterm($term, $options = array()) {
       $success = chado_insert_record('cvterm', $ins_values, $ins_options);
       if (!$success) {
         if (!$is_relationship) {
-          tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to insert the term: $name ($dbname)", NULL);
+          tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to insert the term: $name ($dbname)", NULL);
           return 0;
         }
         else {
-          tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to insert the relationship term: $name (cv: " . $cvname . " db: $dbname)", NULL);
+          tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to insert the relationship term: $name (cv: " . $cvname . " db: $dbname)", NULL);
           return 0;
         }
       }
     }
     // this dbxref already exists in the cvterm table
     else {
-      tripal_report_error('tripal_cv', TRIPAL_WARNING, "The dbxref already exists for another cvterm record: $name (cv: " . $cvname . " db: $dbname)", NULL);
+      tripal_report_error('tripal_chado', TRIPAL_WARNING, "The dbxref already exists for another cvterm record: $name (cv: " . $cvname . " db: $dbname)", NULL);
       return 0;
     }
     $result = chado_query($cvtermsql, array(':accession' => $accession, ':name' => $dbname));
@@ -741,7 +741,7 @@ function tripal_insert_cvterm($term, $options = array()) {
     $upd_options = array('statement_name' => 'upd_cvterm_nadeisis');
     $success = chado_update_record('cvterm', $match, $upd_values, $upd_options);
     if (!$success) {
-      tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to update the term: $name", NULL);
+      tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to update the term: $name", NULL);
       return 0;
     }
     $result = chado_query($cvtermsql, array(':accession' => $accession, ':name' => $dbname));
@@ -783,7 +783,7 @@ function tripal_insert_cvterm($term, $options = array()) {
  * @return
  *   returns the job_id of the submitted job or FALSE if the job was not added
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_submit_obo_job($obo) {
   global $user;
@@ -795,30 +795,30 @@ function tripal_submit_obo_job($obo) {
   $obo['file']   = (isset($obo['file']))   ? $obo['file']   : NULL;
 
   if ($obo['obo_id']) {
-    $sql = "SELECT * FROM {tripal_cv_obo} WHERE obo_id = :obo_id";
+    $sql = "SELECT * FROM {tripal_chado_obo} WHERE obo_id = :obo_id";
     $result = db_query($sql, array(':obo_id' => $obo['obo_id']))->fetchObject();
 
     $args = array($result->obo_id);
-    return tripal_add_job("Load OBO " . $result->name, 'tripal_cv',
-       "tripal_cv_load_obo_v1_2_id", $args, $user->uid);
+    return tripal_add_job("Load OBO " . $result->name, 'tripal_chado',
+       "tripal_chado_load_obo_v1_2_id", $args, $user->uid);
   }
   else {
     if ($obo['url']) {
       $args = array($obo['name'], $obo['url']);
-      return tripal_add_job("Load OBO " . $obo['name'], 'tripal_cv',
-        "tripal_cv_load_obo_v1_2_url", $args, $user->uid);
+      return tripal_add_job("Load OBO " . $obo['name'], 'tripal_chado',
+        "tripal_chado_load_obo_v1_2_url", $args, $user->uid);
     }
     elseif ($obo['file']) {
       $args = array($obo['name'], $obo['file']);
-      return tripal_add_job("Load OBO " . $obo['name'], 'tripal_cv',
-        "tripal_cv_load_obo_v1_2_file", $args, $user->uid);
+      return tripal_add_job("Load OBO " . $obo['name'], 'tripal_chado',
+        "tripal_chado_load_obo_v1_2_file", $args, $user->uid);
     }
   }
   return FALSE;
 }
 
 /**
- * Add the OBO to the tripal_cv_obo table in the Drupal database.
+ * Add the OBO to the tripal_chado_obo table in the Drupal database.
  *
  * If the OBO name already exists in the table then the path is updated.
  *
@@ -830,18 +830,18 @@ function tripal_submit_obo_job($obo) {
  * @return
  *   Returns the ontology ID
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_insert_obo($name, $path) {
   // make sure an OBO with the same name doesn't already exist
-  $obo_id = db_select('tripal_cv_obo', 'tco')
+  $obo_id = db_select('tripal_chado_obo', 'tco')
     ->fields('tco', array('obo_id'))
     ->condition('name', $name)
     ->execute()
     ->fetchField();
 
   if ($obo_id) {
-    db_update('tripal_cv_obo')
+    db_update('tripal_chado_obo')
       ->fields(array(
         'path' => $path,
       ))
@@ -853,7 +853,7 @@ function tripal_insert_obo($name, $path) {
     $record = new stdClass;
     $record->name = $name;
     $record->path = $path;
-    drupal_write_record('tripal_cv_obo', $record);
+    drupal_write_record('tripal_chado_obo', $record);
     return $record->obo_id;
   }
 }
@@ -870,7 +870,7 @@ function tripal_insert_obo($name, $path) {
  * @return
  * A json array of terms that begin with the provided string
  *
- * @ingroup tripal_cv_api
+ * @ingroup tripal_chado_api
  */
 function tripal_autocomplete_cvterm($cv_id, $string = '') {
   if ($cv_id) {
@@ -926,7 +926,7 @@ function tripal_autocomplete_cvterm($cv_id, $string = '') {
  *   An associative array of options. Valid keys include:
  *     - insert_cvterm: Insert the cvterm if it doesn't already exist. FALSE is the default
  *
- * @ingroup tripal_db_api
+ * @ingroup tripal_chado_api
  */
 function tripal_associate_cvterm($basetable, $record_id, $cvterm, $options = array()) {
   $linking_table = $basetable . '_cvterm';
@@ -949,7 +949,7 @@ function tripal_associate_cvterm($basetable, $record_id, $cvterm, $options = arr
       );
     }
     else {
-      tripal_report_error('tripal_cv_api', TRIPAL_WARNING,
+      tripal_report_error('tripal_chado_api', TRIPAL_WARNING,
         "tripal_associate_cvterm: The cvterm needs to have either the cv_name or cv_id
           supplied. You were trying to associate a cvterm with the %base %record_id
           and supplied the cvterm values: %cvterm.",
@@ -971,7 +971,7 @@ function tripal_associate_cvterm($basetable, $record_id, $cvterm, $options = arr
         $cvterm['cvterm_id'] = $insert->cvterm_id;
       }
       else {
-        tripal_report_error('tripal_cv_api', TRIPAL_WARNING,
+        tripal_report_error('tripal_chado_api', TRIPAL_WARNING,
           "tripal_associate_cvterm: Unable to insert the cvterm using the cvterm values: %cvterm.",
           array('%cvterm' => print_r($cvterm,TRUE))
         );
@@ -1061,14 +1061,14 @@ function tripal_set_default_cv($table, $field, $cv_name, $cv_id = FALSE) {
     ->execute();
 
     if (!$cv_default_id) {
-      tripal_report_error('tripal_cv', TRIPAL_WARNING,
+      tripal_report_error('tripal_chado', TRIPAL_WARNING,
       "Cannot set default vocabulary for %table.%field. Check the error logs.",
       array('%table' => $table, '%field' => $field));
       return FALSE;
     }
   }
   else {
-    tripal_report_error('tripal_cv', TRIPAL_WARNING,
+    tripal_report_error('tripal_chado', TRIPAL_WARNING,
     "Cannot set default vocabulary for %table.%field. The vocabulary name, '%cvname', doesn't exist.",
     array('%table' => $table, '%field' => $field, '%cvname' => $cv_name));
     return FALSE;

+ 22 - 22
tripal_db/api/tripal_db.api.inc → tripal_chado/api/modules/tripal_chado.db.api.inc

@@ -6,7 +6,7 @@
  */
 
 /**
- * @defgroup tripal_db_api Database Reference API
+ * @defgroup tripal_chado_api Database Reference API
  * @ingroup tripal_api
  * @{
  * Provides an application programming interface (API) to manage references to external databases
@@ -52,7 +52,7 @@
  *   will be returned (will be a chado variable from chado_generate_var()). Otherwise,
  *   an array of objects will be returned.
  *
- * @ingroup tripal_db_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_db($identifiers, $options = array()) {
 
@@ -65,7 +65,7 @@ function tripal_get_db($identifiers, $options = array()) {
   // Error Checking of parameters
   if (!is_array($identifiers)) {
     tripal_report_error(
-      'tripal_db_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_db: The identifier passed in is expected to be an array with the key
         matching a column name in the db table (ie: db_id or name). You passed in %identifier.",
@@ -76,7 +76,7 @@ function tripal_get_db($identifiers, $options = array()) {
   }
   elseif (empty($identifiers)) {
     tripal_report_error(
-      'tripal_db_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_db: You did not pass in anything to identify the db you want. The identifier
         is expected to be an array with the key matching a column name in the db table
@@ -97,7 +97,7 @@ function tripal_get_db($identifiers, $options = array()) {
   // Ensure the db is singular. If it's an array then it is not singular
   if (is_array($db)) {
     tripal_report_error(
-      'tripal_db_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_db: The identifiers you passed in were not unique. You passed in %identifier.",
       array(
@@ -109,7 +109,7 @@ function tripal_get_db($identifiers, $options = array()) {
   // Report an error if $db is FALSE since then chado_generate_var has failed
   elseif ($db === FALSE) {
     tripal_report_error(
-      'tripal_db_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_db: chado_generate_var() failed to return a db based on the identifiers
         you passed in. You should check that your identifiers are correct, as well as, look
@@ -133,7 +133,7 @@ function tripal_get_db($identifiers, $options = array()) {
  * @return
  *   An array(db_id => name) for each db in the chado db table
  *
- * @ingroup tripal_db_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_db_select_options() {
 
@@ -141,7 +141,7 @@ function tripal_get_db_select_options() {
 
   $options = array();
   $options[] = 'Select a Database';
-  
+
   foreach ($dbs as $db) {
     $options[$db->db_id] = $db->name;
   }
@@ -200,7 +200,7 @@ function tripal_get_db_select_options() {
  *   will be returned (will be a chado variable from chado_generate_var()). Otherwise,
  *   FALSE will be returned.
  *
- * @ingroup tripal_db_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_dbxref($identifiers, $options = array()) {
 
@@ -213,7 +213,7 @@ function tripal_get_dbxref($identifiers, $options = array()) {
   // Error Checking of parameters
   if (!is_array($identifiers)) {
     tripal_report_error(
-      'tripal_db_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_dbxref: The identifier passed in is expected to be an array with the key
         matching a column name in the dbxref table (ie: dbxref_id or name). You passed in %identifier.",
@@ -224,7 +224,7 @@ function tripal_get_dbxref($identifiers, $options = array()) {
   }
   elseif (empty($identifiers)) {
     tripal_report_error(
-      'tripal_db_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_dbxref: You did not pass in anything to identify the dbxref you want. The identifier
         is expected to be an array with the key matching a column name in the dbxref table
@@ -240,7 +240,7 @@ function tripal_get_dbxref($identifiers, $options = array()) {
     $property = $identifiers['property'];
     unset($identifiers['property']);
     $dbxref = chado_get_record_with_property(
-      array('table' => 'dbxref', 'base_records' => $identifiers), 
+      array('table' => 'dbxref', 'base_records' => $identifiers),
       array('type_name' => $property),
       $options
     );
@@ -253,7 +253,7 @@ function tripal_get_dbxref($identifiers, $options = array()) {
 
   // Ensure the dbxref is singular. If it's an array then it is not singular
   if (is_array($dbxref)) {
-    tripal_report_error('tripal_db_api', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado_api', TRIPAL_ERROR,
       "tripal_get_dbxref: The identifiers you passed in were not unique. You passed in %identifier.",
       array('%identifier'=> print_r($identifiers, TRUE))
     );
@@ -262,7 +262,7 @@ function tripal_get_dbxref($identifiers, $options = array()) {
   // Report an error if $dbxref is FALSE since then chado_generate_var has failed
   elseif ($dbxref === FALSE) {
     tripal_report_error(
-      'tripal_db_api',
+      'tripal_chado_api',
       TRIPAL_ERROR,
       "tripal_get_dbxref: chado_generate_var() failed to return a dbxref based on the identifiers
         you passed in. You should check that your identifiers are correct, as well as, look
@@ -300,7 +300,7 @@ function tripal_get_dbxref($identifiers, $options = array()) {
  *   An object populated with fields from the newly added database.  If the
  *   database already exists it returns the values in the current entry.
  *
- * @ingroup tripal_db_api
+ * @ingroup tripal_chado_api
  */
 function tripal_insert_db($values, $options = array()) {
 
@@ -329,7 +329,7 @@ function tripal_insert_db($values, $options = array()) {
     $ins_options = array('statement_name' => 'ins_db_nadeurur');
     $success = chado_insert_record('db', $ins_values, $ins_options);
     if (!$success) {
-      tripal_report_error('tripal_db', TRIPAL_WARNING, "Cannot create db '$dbname'.", NULL);
+      tripal_report_error('tripal_chado', TRIPAL_WARNING, "Cannot create db '$dbname'.", NULL);
       return 0;
     }
     $result = chado_select_record('db', array('*'), $sel_values, $sel_options);
@@ -339,7 +339,7 @@ function tripal_insert_db($values, $options = array()) {
     $upd_options = array('statement_name' => 'upd_db_nadeurur');
     $success = chado_update_record('db', $sel_values, $ins_values, $upd_options);
     if (!$success) {
-      tripal_report_error('tripal_db', TRIPAL_WARNING, "Cannot update db '$dbname'.", NULL);
+      tripal_report_error('tripal_chado', TRIPAL_WARNING, "Cannot update db '$dbname'.", NULL);
       return 0;
     }
     $result = chado_select_record('db', array('*'), $sel_values, $sel_options);
@@ -360,7 +360,7 @@ function tripal_insert_db($values, $options = array()) {
  *    - version: (Optional) The version of the database reference
  *    - description: (Optional) A description of the database reference
  *
- * @ingroup tripal_db_api
+ * @ingroup tripal_chado_api
  */
 function tripal_insert_dbxref($values) {
 
@@ -388,7 +388,7 @@ function tripal_insert_dbxref($values) {
   if (!$result) {
     $success = chado_insert_record('dbxref', $ins_values);
     if (!$success) {
-      tripal_report_error('tripal_cv', TRIPAL_WARNING, "Failed to insert the dbxref record $accession", NULL);
+      tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to insert the dbxref record $accession", NULL);
       return 0;
     }
     $result = chado_select_record('dbxref', array('*'), $sel_values);
@@ -418,7 +418,7 @@ function tripal_insert_dbxref($values) {
  *   An associative array of options. Valid keys include:
  *    - insert_dbxref: Insert the dbxref if it doesn't already exist. TRUE is the default
  *
- * @ingroup tripal_db_api
+ * @ingroup tripal_chado_api
  */
 function tripal_associate_dbxref($basetable, $record_id, $dbxref, $options = array()) {
   $linking_table = $basetable . '_dbxref';
@@ -442,7 +442,7 @@ function tripal_associate_dbxref($basetable, $record_id, $dbxref, $options = arr
     }
     else {
       tripal_report_error(
-        'tripal_db_api',
+        'tripal_chado_api',
         TRIPAL_WARNING,
         "tripal_associate_dbxref: The dbxref needs to have either the db_name or db_id
           supplied. You were trying to associate a dbxref with the %base %record_id
@@ -463,7 +463,7 @@ function tripal_associate_dbxref($basetable, $record_id, $dbxref, $options = arr
       }
       else {
         tripal_report_error(
-          'tripal_db_api',
+          'tripal_chado_api',
           TRIPAL_WARNING,
           "tripal_associate_dbxref: Unable to insert the dbxref using the dbxref values: %dbxref.",
           array('%dbxref' => print_r($dbxref,TRUE))

+ 38 - 38
legacy/tripal_feature/api/tripal_feature.api.inc → tripal_chado/api/modules/tripal_chado.feature.api.inc

@@ -5,7 +5,7 @@
  */
 
 /**
- * @defgroup tripal_feature_api Feature API
+ * @defgroup tripal_chado_api Feature API
  * @ingroup tripal_api
  * @{
  * Provides an application programming interface (API) for working with features
@@ -21,7 +21,7 @@
  * @return
  *   an upper-case reverse complemented sequence
  *
- * @ingroup tripal_feature_api
+ * @ingroup tripal_chado_api
  */
 function tripal_reverse_compliment_sequence($sequence) {
 
@@ -52,16 +52,16 @@ function tripal_reverse_compliment_sequence($sequence) {
  *   An associative array describing the feature. Valid keys include:
  *    - feature_id: The feature_id of the feature for which the sequence will be retrieved
  *    - name: The feature name. This will appear on the FASTA definition line
- *    - parent_id:  (optional) only retrieve a sequence if 'derive_from_parent' is true 
+ *    - parent_id:  (optional) only retrieve a sequence if 'derive_from_parent' is true
  *        and the parent matches this ID.
- *    - featureloc_id: (optional) only retrieve a sequence if 'derive_from_parent' is 
+ *    - featureloc_id: (optional) only retrieve a sequence if 'derive_from_parent' is
  *        true and the alignment is defined with this featureloc_id
  * @param $options
  *   An associative array of options. Valid keys include:
  *    - width: Indicate the number of bases to use per line.  A new line will be added
  *        after the specified number of bases on each line.
  *    - is_html: Set to '1' if  the sequence is meant to be displayed on a web page.
- *        This will cause a <br> tag to separate lines of the FASTA sequence. 
+ *        This will cause a <br> tag to separate lines of the FASTA sequence.
  *    - derive_from_parent: Set to '1' if the sequence should be obtained from the parent
  *        to which this feature is aligned.
  *    - aggregate: Set to '1' if the sequence should only contain sub features, excluding
@@ -87,7 +87,7 @@ function tripal_reverse_compliment_sequence($sequence) {
  *      'residues'      => the residues
  *      'featureloc_id' => the featureloc_id if the sequences is from an alignment
  *
- * @ingroup tripal_feature_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_feature_sequences($feature, $options) {
 
@@ -107,10 +107,10 @@ function tripal_get_feature_sequences($feature, $options) {
   $relationship       = array_key_exists('relationship_type', $options)  ? $options['relationship_type']  : '';
   $rel_part           = array_key_exists('relationship_part', $options)  ? $options['relationship_part']  : '';
   $is_html            = array_key_exists('is_html', $options)            ? $options['is_html']            : 0;
-  
+
   // make sure the sub_features variable is an array
   if (!is_array($sub_features)) {
-    tripal_report_error('tripal_feature', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       "'sub_features' option must be an array for function tripal_get_feature_sequences().",
       array()
     );
@@ -118,7 +118,7 @@ function tripal_get_feature_sequences($feature, $options) {
   }
 
   // if a relationship was specified then retreive and the sequences that
-  // have the given relationship and the recurse to extract the appropriate 
+  // have the given relationship and the recurse to extract the appropriate
   // sequence
   if ($rel_part == "object" or $rel_part == "subject") {
     if ($rel_part == "subject") {
@@ -163,17 +163,17 @@ function tripal_get_feature_sequences($feature, $options) {
       }
       return tripal_get_feature_sequences(
         array(
-          'feature_id' => $feature->feature_id, 
+          'feature_id' => $feature->feature_id,
           'name' => $defline,
           'parent_id' => $parent_id,
         ),
         array(
-          'width' => $num_bases_per_line, 
-          'derive_from_parent' => $derive_from_parent, 
-          'aggregate' => $aggregate, 
-          'upstream' => $upstream, 
-          'downstream' => $downstream, 
-          'sub_features' => $sub_features, 
+          'width' => $num_bases_per_line,
+          'derive_from_parent' => $derive_from_parent,
+          'aggregate' => $aggregate,
+          'upstream' => $upstream,
+          'downstream' => $downstream,
+          'sub_features' => $sub_features,
         )
       );
     }
@@ -277,14 +277,14 @@ function tripal_get_feature_sequences($feature, $options) {
 
   // the array to be returned
   $sequences = array();
-  
+
   // if we need to get the sequence from the parent then do so now.
   if ($derive_from_parent) {
 
     // execute the query to get the sequence from the parent
     $parents = chado_query($parent_sql, array(':upstream' => $upstream, ':downstream' => $downstream, ':feature_id' => $feature_id));
     while ($parent = $parents->fetchObject()) {
-      
+
       // if the user specified a particular parent and this one doesn't match then skip it
       if ($parent_id and $parent_id != $parent->srcfeature_id) {
         continue;
@@ -360,7 +360,7 @@ function tripal_get_feature_sequences($feature, $options) {
             if ($subseq->srcfeature_id == $parent->srcfeature_id) {
               $seq .= $subseq->residues;
             }
-            if ($subseq->upstream > 0 ) { 
+            if ($subseq->upstream > 0 ) {
               $notes .= "Includes " . $subseq->upstream . " bases upstream.  ";
             }
             if ($subseq->downstream > 0) {
@@ -420,7 +420,7 @@ function tripal_get_feature_sequences($feature, $options) {
       // get a proper feature object
       $f = chado_generate_var('feature', array('feature_id' => $feature_id));
       $defline = tripal_get_fasta_defline($f, $notes, $featureloc, '', $length);
-      
+
       $sequences[] = array(
         'types'         => $types,
         'upstream'      => $parent->upstream,
@@ -445,7 +445,7 @@ function tripal_get_feature_sequences($feature, $options) {
     else {
       $residues = wordwrap($residues, $num_bases_per_line, "\r\n", TRUE);
     }
-    
+
     // get the definintion line for this feature
     $f = chado_generate_var('feature', array('feature_id' => $feature_id));
     $defline = tripal_get_fasta_defline($f, '', NULL, '', $length);
@@ -495,12 +495,12 @@ function tripal_get_feature_sequences($feature, $options) {
  *    - width: Indicate the number of bases to use per line.  A new line will be added
  *        after the specified number of bases on each line.
  *    - is_html: Set to '1' if  the sequence is meant to be displayed on a web page.
- *        This will cause a <br> tag to separate lines of the FASTA sequence. 
+ *        This will cause a <br> tag to separate lines of the FASTA sequence.
  *    - print: Set to TRUE to print the sequences rather otherwise an array
- *        of sequences will be returned.  
+ *        of sequences will be returned.
  * @return
  *   Returns an array of sequences unless the option 'print' is used.  If 'print is used
- *   then nothing is returned but sequences are printed to STDOUT.  If returned, the 
+ *   then nothing is returned but sequences are printed to STDOUT.  If returned, the
  *   sequences will be in an array with the following keys for each sequence:
  *      'types'         => an array of feature types that were used to derive the sequence (e.g. from an aggregated sequence)
  *      'upstream'      => the number of upstream bases included in the sequence
@@ -509,7 +509,7 @@ function tripal_get_feature_sequences($feature, $options) {
  *      'residues'      => the residues
  *      'featureloc_id' => the featureloc_id if the sequences is from an alignment
  *
- * @ingroup tripal_feature_api
+ * @ingroup tripal_chado_api
  */
 function tripal_get_bulk_feature_sequences($options) {
 
@@ -635,7 +635,7 @@ function tripal_get_bulk_feature_sequences($options) {
 
 /**
  * Returns a definition line that can be used in a FASTA file
- * 
+ *
  * @param $feature
  *   A single feature object containing all the fields from the chado.feature table.
  *   Best case is to provide an object generated by the chado_generate_var() function.
@@ -650,13 +650,13 @@ function tripal_get_bulk_feature_sequences($options) {
  *   Optional: the type of sequence. By default the feature type is used.
  * @param $length
  *   Optional: the length of the sequence
- *   
+ *
  * @return
  *   A string of the format: uniquename|name|type|feature_id
- *   or if an alignment:  srcfeature_name:fmin..fmax[+-]; alignment of uniquename|name|type|feature_id 
+ *   or if an alignment:  srcfeature_name:fmin..fmax[+-]; alignment of uniquename|name|type|feature_id
  */
 function tripal_get_fasta_defline($feature, $notes = '', $featureloc = NULL, $type = '', $length = 0) {
-    
+
   // make sure the featureloc object has the srcfeature if not, then add it
   if ($featureloc) {
     if (!is_object($featureloc->srcfeature_id)) {
@@ -670,18 +670,18 @@ function tripal_get_fasta_defline($feature, $notes = '', $featureloc = NULL, $ty
   if (!is_object($feature->organism_id)) {
     $feature->organism_id = chado_generate_var('organism', array('organism_id' => $feature->organism_id));
   }
-  
+
   // if a type is not provided then use the default type
   if (!$type) {
     $type = $feature->type_id->name;
   }
-  
+
   // construct the definition line
-  $defline = $feature->uniquename . " " . 
+  $defline = $feature->uniquename . " " .
              'ID=' . $feature->uniquename . "|" .
-             'Name=' . $feature->name . "|" . 
+             'Name=' . $feature->name . "|" .
              'organism=' . $feature->organism_id->genus . " " . $feature->organism_id->species .  "|" .
-             'type=' . $type . '|'; 
+             'type=' . $type . '|';
   if ($length > 0) {
     $defline .= "length=" . $length . "bp|";
   }
@@ -698,14 +698,14 @@ function tripal_get_fasta_defline($feature, $notes = '', $featureloc = NULL, $ty
 
 /**
  * Returns a string representing a feature location in an alignment
- *  
+ *
  * @param unknown $featureloc
  *   A single featureloc object generated using chado_generate_var that
  *   contains a record from the chado.featureloc table.
  */
 function tripal_get_location_string($featureloc) {
   $feature = $featureloc->feature_id;
-  
+
   $strand = '';
   if ($featureloc->strand == 1) {
     $strand = '+';
@@ -713,7 +713,7 @@ function tripal_get_location_string($featureloc) {
   elseif ($featureloc->strand == -1) {
     $strand = '-';
   }
-  
-  return $featureloc->srcfeature_id->name . ":" . ($featureloc->fmin + 1) . ".." . $featureloc->fmax .  $strand;  
+
+  return $featureloc->srcfeature_id->name . ":" . ($featureloc->fmin + 1) . ".." . $featureloc->fmax .  $strand;
 }
 

+ 0 - 0
legacy/tripal_organism/api/tripal_organism.api.inc → tripal_chado/api/modules/tripal_chado.organism.api.inc


+ 0 - 0
legacy/tripal_pub/api/tripal_pub.api.inc → tripal_chado/api/modules/tripal_chado.pub.api.inc


+ 0 - 0
legacy/tripal_stock/api/tripal_stock.api.inc → tripal_chado/api/modules/tripal_chado.stock.api.inc


+ 6 - 6
tripal_core/api/tripal_core.custom_tables.api.inc → tripal_chado/api/tripal_chado.custom_tables.api.inc

@@ -6,7 +6,7 @@
 
 /**
  * @defgroup tripal_custom_tables_api Tripal Custom Tables API
- * @ingroup tripal_core_api
+ * @ingroup tripal_chado_api
  * @{
  * Provides an API to manage custom tables in Chado.
  * @}
@@ -46,7 +46,7 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_if_exist
 
     // if this is a materialized view then don't allow editing with this function
     if ($custom_table->mview_id) {
-      tripal_report_error('tripal_core', TRIPAL_ERROR, "Please use the tripal_edit_mview() function to edit this custom table as it is a materialized view.", array());
+      tripal_report_error('tripal_chado', TRIPAL_ERROR, "Please use the tripal_edit_mview() function to edit this custom table as it is a materialized view.", array());
       drupal_set_message("This custom table is a materialized view. Please use the "  . l('Materialized View', 'admin/tripal/storage/chado/mviews') . " interface to edit it.", 'error');
       return FALSE;
     }
@@ -72,7 +72,7 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_if_exist
   }
   catch (Exception $e) {
     $transaction->rollback();
-    watchdog_exception('tripal_core', $e);
+    watchdog_exception('tripal_chado', $e);
     $error = _drupal_decode_exception($e);
     drupal_set_message(t("Could not update custom table '%table_name': %message.",
     array('%table_name' => $table, '%message' => $error['!message'])), 'error');
@@ -190,7 +190,7 @@ function chado_create_custom_table($table, $schema, $skip_if_exists = 1, $mview_
   }
   catch (Exception $e) {
     $transaction->rollback();
-    watchdog_exception('tripal_core', $e);
+    watchdog_exception('tripal_chado', $e);
     $error = _drupal_decode_exception($e);
     drupal_set_message(t("Could not add custom table '%table_name': %message.",
       array('%table_name' => $table, '%message' => $error['!message'])), 'error');
@@ -329,7 +329,7 @@ function chado_delete_custom_table($table_id) {
 
   // if this is a materialized view then don't allow deletion with this function
   if ($custom_table->mview_id) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "Please use the tripal_delete_mview() function to delete this custom table as it is a materialized view. Table not deleted.", array());
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "Please use the tripal_delete_mview() function to delete this custom table as it is a materialized view. Table not deleted.", array());
     drupal_set_message("This custom table is a materialized view. Please use the "  . l('Materialized View', 'admin/tripal/storage/chado/mviews') . " interface to delete it.", 'error');
     return FALSE;
   }
@@ -348,7 +348,7 @@ function chado_delete_custom_table($table_id) {
       drupal_set_message(t("Custom Table '%name' dropped", array('%name' => $custom_table->table_name)));
     }
     else {
-      tripal_report_error('tripal_core', TRIPAL_ERROR, "Cannot drop the custom table: %name", array('%name' => $custom_table->table_name));
+      tripal_report_error('tripal_chado', TRIPAL_ERROR, "Cannot drop the custom table: %name", array('%name' => $custom_table->table_name));
       drupal_set_message(t("Cannot drop the custom table: '%name'", array('%name' => $custom_table->table_name)));
     }
   }

+ 6 - 6
tripal_core/api/tripal_core.mviews.api.inc → tripal_chado/api/tripal_chado.mviews.api.inc

@@ -6,7 +6,7 @@
 
 /**
  * @defgroup tripal_mviews_api Tripal Materalized Views API
- * @ingroup tripal_core_api
+ * @ingroup tripal_chado_api
  * @{
  * Provides an application programming interface (API) to manage materialized views in Chado.
  * The Perl-based chado comes with an interface for managing materialzed views.  This
@@ -116,7 +116,7 @@ function tripal_add_legacy_mview($name, $modulename, $mv_table, $mv_specs, $inde
 function tripal_add_mview($name, $modulename, $mv_schema, $query, $comment = NULL) {
 
   if (!array_key_exists('table', $mv_schema)) {
-     tripal_report_error('tripal_core', TRIPAL_ERROR,
+     tripal_report_error('tripal_chado', TRIPAL_ERROR,
        'Must have a table name when creating an mview.', array());
      return NULL;
   }
@@ -159,7 +159,7 @@ function tripal_add_mview($name, $modulename, $mv_schema, $query, $comment = NUL
     }
     catch (Exception $e) {
       $transaction->rollback();
-      watchdog_exception('tripal_core', $e);
+      watchdog_exception('tripal_chado', $e);
       $error = _drupal_decode_exception($e);
       drupal_set_message(t("Could not create the materialized view %table_name: %message.",
       array('%table_name' => $name, '%message' => $error['!message'])), 'error');
@@ -169,7 +169,7 @@ function tripal_add_mview($name, $modulename, $mv_schema, $query, $comment = NUL
     return TRUE;
   }
   else {
-    tripal_report_error('tripal_cv', TRIPAL_WARNING,
+    tripal_report_error('tripal_chado', TRIPAL_WARNING,
       "Materialized view, %vname, already exists. Cannot create.",
       array('%vname' => $name));
     drupal_set_message(t("Materialized view, $name, already exists. Cannot create.", array('%name' => $name)));
@@ -269,7 +269,7 @@ function tripal_edit_mview($mview_id, $name, $modulename, $mv_table, $mv_specs,
   }
   catch (Exception $e) {
     $transaction->rollback();
-    watchdog_exception('tripal_core', $e);
+    watchdog_exception('tripal_chado', $e);
     $error = _drupal_decode_exception($e);
     drupal_set_message(t("Could not update materialized view '%table_name': %message.",
     array('%table_name' => $mv_table, '%message' => $error['!message'])), 'error');
@@ -345,7 +345,7 @@ function tripal_refresh_mview($mview_id) {
 
   // add a job to populate the mview
   $args = array("$mview_id");
-  tripal_add_job("Populate materialized view '$mview->name'", 'tripal_core',
+  tripal_add_job("Populate materialized view '$mview->name'", 'tripal_chado',
      'tripal_populate_mview', $args, $user->uid);
 
 }

+ 12 - 151
tripal_core/api/tripal_core.chado_general.api.inc → tripal_chado/api/tripal_chado.property.api.inc

@@ -4,12 +4,10 @@
  * Provides an application programming interface (API) to manage data withing the Chado database.
  */
 
-require_once 'tripal_core.schema_v1.2.api.inc';
-require_once 'tripal_core.schema_v1.11.api.inc';
 
 /**
  * @defgroup tripal_chado_api Chado API
- * @ingroup tripal_core_api
+ * @ingroup tripal_chado_api
  * @{
  * Provides an application programming interface (API) to manage data withing the Chado database.
  *
@@ -40,143 +38,6 @@ require_once 'tripal_core.schema_v1.11.api.inc';
  *
  */
 
-/**
- * Set the Tripal Database
- *
- * The chado_set_active function is used to prevent namespace collisions
- * when Chado and Drupal are installed in the same database but in different
- * schemas. It is also used when using Drupal functions such as
- * db_table_exists().
- *
- * The connection settings can be altered through the hook
- * hook_chado_connection_alter.
- *
- * Current active connection name is stored in the global variable
- * $GLOBALS['chado_active_db'].
- *
- * @see hook_chado_connection_alter()
- *
- * @ingroup tripal_chado_api
- */
-function chado_set_active($dbname = 'default') {
-
-  // Check if the chado_active_db has been set yet.
-  if (!array_key_exists('chado_active_db', $GLOBALS)) {
-    $GLOBALS['chado_active_db'] = 'default';
-  }
-
-  $previous_db = $active_db = $GLOBALS['chado_active_db'];
-  $search_path = 'public';
-
-  // Change only if 'chado' has been specified.
-  if ($dbname == 'chado') {
-    $active_db = 'chado';
-    $search_path = 'chado,public';
-  }
-
-  $settings = array(
-    'dbname'          => $dbname,
-    'new_active_db'   => &$active_db,
-    'new_search_path' => &$search_path,
-  );
-
-  // Will call all modules implementing hook_chado_search_path_alter
-  // note: hooks can alter $active_db and $search_path.
-  drupal_alter('chado_connection', $settings);
-
-  // set chado_active_db to remember active db
-  $GLOBALS['chado_active_db'] = $active_db;
-
-  // set PostgreSQL search_path
-  db_query('SET search_path TO ' . $search_path);
-
-  return $previous_db;
-}
-
-
-/**
- * Alter Chado connection settings.
- *
- * This hook is useful for multi-chado instances. Tripal core functions
- * call the chado_set_active() function (e.g. chado_query) but there is no
- * opportunity elsewhere to set the active database.  This is useful in two
- * cases:  1) Users are managed at the database level as in the case of
- * SouthGreen Bioinformatics Platform tools (e.g. Banana Genone Hub).
- * This allows custom modules to change the database connections on a per-user
- * basis, and each user permissions is managed at the database level.  Users
- * are managed at the database level to provid the same access restrictions
- * across various tools that use Chado (e,g, Artemis) 2) When there are
- * simply two Chado instances housed in different Chado databases and the
- * module needs to control which one is being used at any given time.
- *
- * @param $settings
- *   An array containing
- *
- * @see chado_set_active()
- *
- * @ingroup tripal_chado_api
- */
-function hook_chado_connection_alter(&$settings) {
-  // This example shows how we could make sure no table of the 'public' schema
-  // would be allowed in the coming queries: to do so, the caller will call
-  // "chado_set_active('chado_only');" and the hook will remove 'public' from
-  // the search path.
-  if ('chado_only' == $settings['dbname']) {
-    $settings['new_active_db']   = 'chado';
-    // We don't include 'public' in search path.
-    $settings['new_search_path'] = 'chado';
-  }
-}
-
-
-/**
- * Get max rank for a given set of criteria
- * This function was developed with the many property tables in chado in mind but will
- * work for any table with a rank
- *
- * @params tablename: the name of the chado table you want to select the max rank from
- *    this table must contain a rank column of type integer
- * @params where_options: array(
- *                          <column_name> => array(
- *                            'type' => <type of column: INT/STRING>,
- *                            'value' => <the value you want to filter on>,
- *                            'exact' => <if TRUE use =; if FALSE use ~>,
- *                          )
- *        )
- *     where options should include the id and type for that table to correctly
- *     group a set of records together where the only difference are the value and rank
- * @return the maximum rank
- *
- * @ingroup tripal_chado_api
- */
-function chado_get_table_max_rank($tablename, $where_options) {
-
-  $where_clauses = array();
-  $where_args = array();
-
-  //generate the where clause from supplied options
-  // the key is the column name
-  $i = 0;
-  $sql = "
-    SELECT max(rank) as max_rank, count(rank) as count
-    FROM {".$tablename."}
-    WHERE
-  ";
-  foreach ($where_options as $key => $value) {
-    $where_clauses[] = "$key = :$key";
-    $where_args[":$key"] = $value;
-  }
-  $sql .= implode($where_clauses, ' AND ');
-
-  $result = chado_query($sql, $where_args)->fetchObject();
-  if ($result->count > 0) {
-    return $result->max_rank;
-  }
-  else {
-    return -1;
-  }
-
-}
 
 /**
  * Retrieve a property for a given base table record.
@@ -245,13 +106,13 @@ function chado_get_property($record, $property) {
   $options = array();
   $term = chado_select_record('cvterm', array('cvterm_id'), $type, $options);
   if (!$term or count($term) == 0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_get_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_get_property: " .
         "Cannot find the term described by: %property.",
         array('%property' => print_r($property, TRUE)));
         return FALSE;
   }
   if (count($term) > 1) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_get_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_get_property: " .
         "Multiple terms found. Cannot add the property. Property was described " .
         "by: %property.",
         array('%property' => print_r($property, TRUE)));    return FALSE;
@@ -370,7 +231,7 @@ function chado_insert_property($record, $property, $options = array()) {
         $rank++;
       }
       else {
-        tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_insert_property: " .
+        tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_insert_property: " .
          "The property is already assigned to the record with the following " .
          "rank.  And, because the 'force_rank' option is used, the property " .
          "cannot be added: %property.",
@@ -402,13 +263,13 @@ function chado_insert_property($record, $property, $options = array()) {
   $options = array();
   $term = chado_select_record('cvterm', array('cvterm_id'), $values, $options);
   if (!$term or count($term) == 0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_insert_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_insert_property: " .
       "Cannot find the term described by: %property.",
       array('%property' => print_r($property, TRUE)));
     return FALSE;
   }
   if (count($term) > 1) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_insert_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_insert_property: " .
       "Multiple terms found. Cannot add the property. Property was described " .
       "by: %property.",
       array('%property' => print_r($property, TRUE)));    return FALSE;
@@ -510,13 +371,13 @@ function chado_update_property($record, $property, $options = array()) {
   $options = array();
   $term = chado_select_record('cvterm', array('cvterm_id'), $type, $options);
   if (!$term or count($term) == 0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_update_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_update_property: " .
         "Cannot find the term described by: %property.",
         array('%property' => print_r($property, TRUE)));
     return FALSE;
   }
   if (count($term) > 1) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_update_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_update_property: " .
         "Multiple terms found. Cannot add the property. Property was described " .
         "by: %property.",
         array('%property' => print_r($property, TRUE)));
@@ -623,13 +484,13 @@ function chado_delete_property($record, $property) {
   $options = array();
   $term = chado_select_record('cvterm', array('cvterm_id'), $type, $options);
   if (!$term or count($term) == 0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_delete_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_delete_property: " .
         "Cannot find the term described by: %property.",
         array('%property' => print_r($property, TRUE)));
         return FALSE;
   }
   if (count($term) > 1) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_delete_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_delete_property: " .
         "Multiple terms found. Cannot add the property. Property was described " .
         "by: %property.",
         array('%property' => print_r($property, TRUE)));    return FALSE;
@@ -726,13 +587,13 @@ function chado_get_record_with_property($record, $property, $options = array())
   // Make sure the CV term exists;
   $term = chado_select_record('cvterm', array('cvterm_id'), $type);
   if (!$term or count($term) == 0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_update_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_update_property: " .
         "Cannot find the term described by: %property.",
         array('%property' => print_r($property, TRUE)));
         return FALSE;
   }
   if (count($term) > 1) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR, "chado_update_property: " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "chado_update_property: " .
         "Multiple terms found. Cannot add the property. Property was described " .
         "by: %property.",
         array('%property' => print_r($property, TRUE)));    return FALSE;

+ 175 - 41
tripal_core/api/tripal_core.chado_query.api.inc → tripal_chado/api/tripal_chado.query.api.inc

@@ -5,6 +5,140 @@
  * selecting from chado.
  */
 
+/**
+ * Get max rank for a given set of criteria
+ * This function was developed with the many property tables in chado in mind but will
+ * work for any table with a rank
+ *
+ * @params tablename: the name of the chado table you want to select the max rank from
+ *    this table must contain a rank column of type integer
+ * @params where_options: array(
+ *                          <column_name> => array(
+ *                            'type' => <type of column: INT/STRING>,
+ *                            'value' => <the value you want to filter on>,
+ *                            'exact' => <if TRUE use =; if FALSE use ~>,
+ *                          )
+ *        )
+ *     where options should include the id and type for that table to correctly
+ *     group a set of records together where the only difference are the value and rank
+ * @return the maximum rank
+ *
+ * @ingroup tripal_chado_api
+ */
+function chado_get_table_max_rank($tablename, $where_options) {
+
+  $where_clauses = array();
+  $where_args = array();
+
+  //generate the where clause from supplied options
+  // the key is the column name
+  $i = 0;
+  $sql = "
+    SELECT max(rank) as max_rank, count(rank) as count
+    FROM {".$tablename."}
+    WHERE
+  ";
+  foreach ($where_options as $key => $value) {
+    $where_clauses[] = "$key = :$key";
+    $where_args[":$key"] = $value;
+  }
+  $sql .= implode($where_clauses, ' AND ');
+
+  $result = chado_query($sql, $where_args)->fetchObject();
+  if ($result->count > 0) {
+    return $result->max_rank;
+  }
+  else {
+    return -1;
+  }
+
+}
+/**
+ * Alter Chado connection settings.
+ *
+ * This hook is useful for multi-chado instances. Tripal core functions
+ * call the chado_set_active() function (e.g. chado_query) but there is no
+ * opportunity elsewhere to set the active database.  This is useful in two
+ * cases:  1) Users are managed at the database level as in the case of
+ * SouthGreen Bioinformatics Platform tools (e.g. Banana Genone Hub).
+ * This allows custom modules to change the database connections on a per-user
+ * basis, and each user permissions is managed at the database level.  Users
+ * are managed at the database level to provid the same access restrictions
+ * across various tools that use Chado (e,g, Artemis) 2) When there are
+ * simply two Chado instances housed in different Chado databases and the
+ * module needs to control which one is being used at any given time.
+ *
+ * @param $settings
+ *   An array containing
+ *
+ * @see chado_set_active()
+ *
+ * @ingroup tripal_chado_api
+ */
+function hook_chado_connection_alter(&$settings) {
+  // This example shows how we could make sure no table of the 'public' schema
+  // would be allowed in the coming queries: to do so, the caller will call
+  // "chado_set_active('chado_only');" and the hook will remove 'public' from
+  // the search path.
+  if ('chado_only' == $settings['dbname']) {
+    $settings['new_active_db']   = 'chado';
+    // We don't include 'public' in search path.
+    $settings['new_search_path'] = 'chado';
+  }
+}
+
+/**
+ * Set the Tripal Database
+ *
+ * The chado_set_active function is used to prevent namespace collisions
+ * when Chado and Drupal are installed in the same database but in different
+ * schemas. It is also used when using Drupal functions such as
+ * db_table_exists().
+ *
+ * The connection settings can be altered through the hook
+ * hook_chado_connection_alter.
+ *
+ * Current active connection name is stored in the global variable
+ * $GLOBALS['chado_active_db'].
+ *
+ * @see hook_chado_connection_alter()
+ *
+ * @ingroup tripal_chado_api
+ */
+function chado_set_active($dbname = 'default') {
+
+  // Check if the chado_active_db has been set yet.
+  if (!array_key_exists('chado_active_db', $GLOBALS)) {
+    $GLOBALS['chado_active_db'] = 'default';
+  }
+
+  $previous_db = $active_db = $GLOBALS['chado_active_db'];
+  $search_path = 'public';
+
+  // Change only if 'chado' has been specified.
+  if ($dbname == 'chado') {
+    $active_db = 'chado';
+    $search_path = 'chado,public';
+  }
+
+  $settings = array(
+    'dbname'          => $dbname,
+    'new_active_db'   => &$active_db,
+    'new_search_path' => &$search_path,
+  );
+
+  // Will call all modules implementing hook_chado_search_path_alter
+  // note: hooks can alter $active_db and $search_path.
+  drupal_alter('chado_connection', $settings);
+
+  // set chado_active_db to remember active db
+  $GLOBALS['chado_active_db'] = $active_db;
+
+  // set PostgreSQL search_path
+  db_query('SET search_path TO ' . $search_path);
+
+  return $previous_db;
+}
 /**
  * @defgroup tripal_chado_query_api Chado Query API
  * @ingroup tripal_chado_api
@@ -261,14 +395,14 @@ function chado_insert_record($table, $values, $options = array()) {
   $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
 
   if (!is_array($values)) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass non array as values for inserting.', array(),
       array('print' => $print_errors)
     );
     return FALSE;
   }
   if (count($values)==0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass an empty array as values for inserting.',
       array(),array('print' => $print_errors)
     );
@@ -300,7 +434,7 @@ function chado_insert_record($table, $values, $options = array()) {
   // get the table description
   $table_desc = chado_get_schema($table);
   if (empty($table_desc)) {
-    tripal_report_error('tripal_core', TRIPAL_WARNING,
+    tripal_report_error('tripal_chado', TRIPAL_WARNING,
       'chado_insert_record; There is no table description for !table_name',
       array('!table_name' => $table), array('print' => $print_errors)
     );
@@ -313,7 +447,7 @@ function chado_insert_record($table, $values, $options = array()) {
     // make sure the field is in the table description. If not then return an error
     // message
     if (!array_key_exists($field, $table_desc['fields'])) {
-      tripal_report_error('tripal_core', TRIPAL_ERROR,
+      tripal_report_error('tripal_chado', TRIPAL_ERROR,
         "chado_insert_record; The field '%field' does not exist " .
           "for the table '%table'.  Cannot perform insert. Values: %array",
         array('%field' => $field, '%table' => $table, '%array' => print_r($values, 1)),
@@ -327,7 +461,7 @@ function chado_insert_record($table, $values, $options = array()) {
       $results = chado_schema_get_foreign_key($table_desc, $field, $value);
 
       if (sizeof($results) > 1) {
-        tripal_report_error('tripal_core', TRIPAL_ERROR,
+        tripal_report_error('tripal_chado', TRIPAL_ERROR,
           'chado_insert_record: Too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
@@ -335,7 +469,7 @@ function chado_insert_record($table, $values, $options = array()) {
         return FALSE;
       }
       elseif (sizeof($results) < 1) {
-        tripal_report_error('tripal_core', TRIPAL_DEBUG,
+        tripal_report_error('tripal_chado', TRIPAL_DEBUG,
           'chado_insert_record: no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
@@ -376,7 +510,7 @@ function chado_insert_record($table, $values, $options = array()) {
         }
         // now check the constraint
         if (chado_select_record($table, $ukselect_cols, $ukselect_vals)) {
-          tripal_report_error('tripal_core', TRIPAL_ERROR,
+          tripal_report_error('tripal_chado', TRIPAL_ERROR,
             "chado_insert_record; Cannot insert duplicate record into $table table: !values",
             array('!values' => print_r($values, TRUE)), array('print' => $print_errors)
           );
@@ -392,7 +526,7 @@ function chado_insert_record($table, $values, $options = array()) {
       if (array_key_exists($pkey, $insert_values)) {
         $coptions = array();
         if (chado_select_record($table, array($pkey), array($pkey => $insert_values[$pkey]), $coptions)) {
-          tripal_report_error('tripal_core', TRIPAL_ERROR,
+          tripal_report_error('tripal_chado', TRIPAL_ERROR,
             'chado_insert_record; Cannot insert duplicate primary key into !table table: !values',
             array('!table' => $table, '!values' => print_r($values, TRUE)),
             array('print' => $print_errors)
@@ -405,7 +539,7 @@ function chado_insert_record($table, $values, $options = array()) {
     // Make sure required fields have a value.
     if (!is_array($table_desc['fields'])) {
       $table_desc['fields'] = array();
-      tripal_report_error('tripal_core', TRIPAL_WARNING,
+      tripal_report_error('tripal_chado', TRIPAL_WARNING,
         "chado_insert_record; %table missing fields: \n %schema",
         array('%table' => $table, '%schema' => print_r($table_desc, 1)),
         array('print' => $print_errors)
@@ -418,7 +552,7 @@ function chado_insert_record($table, $values, $options = array()) {
           !array_key_exists($field, $insert_values) and
           !array_key_exists('default', $def) and
           strcmp($def['type'], serial) != 0) {
-        tripal_report_error('tripal_core', TRIPAL_ERROR,
+        tripal_report_error('tripal_chado', TRIPAL_ERROR,
           "chado_insert_record; Field %table.%field cannot be NULL: %values",
           array('%table' => $table, '%field' => $field, '%values' => print_r($values, 1)),
           array('print' => $print_errors)
@@ -456,7 +590,7 @@ function chado_insert_record($table, $values, $options = array()) {
         $results = chado_query($sql);
         $value = $results->fetchField();
         if (!$value) {
-          tripal_report_error('tripal_core', TRIPAL_ERROR,
+          tripal_report_error('tripal_chado', TRIPAL_ERROR,
             "chado_insert_record; not able to retrieve primary key after insert: %sql",
             array('%sql' => $sql),
             array('print' => $print_errors)
@@ -472,7 +606,7 @@ function chado_insert_record($table, $values, $options = array()) {
     return TRUE;
   }
   else {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'chado_insert_record; Cannot insert record into "%table": %values',
       array('%table' => $table, '%values' => print_r($values, 1)),
       array('print' => $print_errors)
@@ -553,14 +687,14 @@ function chado_update_record($table, $match, $values, $options = NULL) {
   $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
 
   if (!is_array($values)) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass non array as values for updating.',
       array(), array('print' => $print_errors)
     );
     return FALSE;
   }
   if (count($values)==0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass an empty array as values for updating.',
       array(), array('print' => $print_errors)
     );
@@ -568,14 +702,14 @@ function chado_update_record($table, $match, $values, $options = NULL) {
   }
 
   if (!is_array($match)) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass non array as values for matching.',
       array(), array('print' => $print_errors)
     );
     return FALSE;
   }
   if (count($match)==0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass an empty array as values for matching.',
       array(), array('print' => $print_errors)
     );
@@ -598,7 +732,7 @@ function chado_update_record($table, $match, $values, $options = NULL) {
   // get the table description
   $table_desc = chado_get_schema($table);
   if (!$table_desc) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'The table name, %table, does not exist.',
       array('%table', $table), array('print' => $print_errors)
     );
@@ -632,7 +766,7 @@ function chado_update_record($table, $match, $values, $options = NULL) {
     if (is_array($value)) {
       $results = chado_schema_get_foreign_key($table_desc, $field, $value);
       if (sizeof($results) > 1) {
-        tripal_report_error('tripal_core', TRIPAL_ERROR,
+        tripal_report_error('tripal_chado', TRIPAL_ERROR,
           'chado_update_record: When trying to find record to update, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
@@ -640,7 +774,7 @@ function chado_update_record($table, $match, $values, $options = NULL) {
         return FALSE;
       }
       elseif (sizeof($results) < 1) {
-        tripal_report_error('tripal_core', TRIPAL_DEBUG,
+        tripal_report_error('tripal_chado', TRIPAL_DEBUG,
           'chado_update_record: When trying to find record to update, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
@@ -663,7 +797,7 @@ function chado_update_record($table, $match, $values, $options = NULL) {
       // select the value from the foreign key relationship for this value
       $results = chado_schema_get_foreign_key($table_desc, $field, $value, $foreign_options);
       if (sizeof($results) > 1) {
-        tripal_report_error('tripal_core', TRIPAL_ERROR,
+        tripal_report_error('tripal_chado', TRIPAL_ERROR,
           'chado_update_record: When trying to find update values, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
           array('print' => $print_errors)
@@ -671,7 +805,7 @@ function chado_update_record($table, $match, $values, $options = NULL) {
         return FALSE;
       }
       elseif (sizeof($results) < 1) {
-        tripal_report_error('tripal_core', TRIPAL_DEBUG,
+        tripal_report_error('tripal_chado', TRIPAL_DEBUG,
           'chado_update_record: When trying to find update values, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
           array('!foreign_key' => $field, '!criteria' => print_r($value,TRUE)),
           array('print' => $print_errors)
@@ -733,7 +867,7 @@ function chado_update_record($table, $match, $values, $options = NULL) {
     return TRUE;
   }
   else {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       "chado_update_record: Cannot update record in %table table.  \nMatch: %match \nValues: %values",
       array('%table' => table, '%match' => print_r($match,TRUE), '%values' => print_r($values, 1)),
       array('print' => $print_errors)
@@ -804,12 +938,12 @@ function chado_update_record($table, $match, $values, $options = NULL) {
 function chado_delete_record($table, $match, $options = NULL) {
 
   if (!is_array($match)) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass non array as values for matching.', array());
     return FALSE;
   }
   if (count($match)==0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass an empty array as values for matching.', array());
     return FALSE;
   }
@@ -826,7 +960,7 @@ function chado_delete_record($table, $match, $options = NULL) {
   $table_desc = chado_get_schema($table);
   $fields = $table_desc['fields'];
   if (empty($table_desc)) {
-    tripal_report_error('tripal_core', TRIPAL_WARNING,
+    tripal_report_error('tripal_chado', TRIPAL_WARNING,
       'chado_insert_record; There is no table description for !table_name',
       array('!table_name' => $table), array('print' => $print_errors)
     );
@@ -843,13 +977,13 @@ function chado_delete_record($table, $match, $options = NULL) {
       else {
         $results = chado_schema_get_foreign_key($table_desc, $field, $value);
         if (sizeof($results) > 1) {
-          tripal_report_error('tripal_core', TRIPAL_ERROR,
+          tripal_report_error('tripal_chado', TRIPAL_ERROR,
             'chado_delete_record: When trying to find record to delete, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
             array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)));
           return FALSE;
         }
         elseif (sizeof($results) < 1) {
-          //tripal_report_error('tripal_core', TRIPAL_ERROR, 'chado_delete_record: When trying to find record to delete, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value,TRUE)));
+          //tripal_report_error('tripal_chado', TRIPAL_ERROR, 'chado_delete_record: When trying to find record to delete, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value,TRUE)));
         }
         else {
           $delete_matches[$field] = $results[0];
@@ -896,7 +1030,7 @@ function chado_delete_record($table, $match, $options = NULL) {
     return TRUE;
   }
   else {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       "Cannot delete record in $table table.  Match:" . print_r($match, 1) . ". Values: " . print_r($values, 1), array());
     return FALSE;
   }
@@ -1061,7 +1195,7 @@ function chado_select_record($table, $columns, $values, $options = NULL) {
 
   // Check that our columns and values arguments are proper arrays.
   if (!is_array($columns)) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'chado_select_record; the $columns argument must be an array. Columns:%columns',
       array('%columns' => print_r($columns, TRUE)),
       array('print' => $print_errors)
@@ -1069,7 +1203,7 @@ function chado_select_record($table, $columns, $values, $options = NULL) {
     return FALSE;
   }
   if (!is_array($values)) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'chado_select_record; the $values argument must be an array. Values:%values',
       array('%values' => print_r($values, TRUE)),
       array('print' => $print_errors)
@@ -1080,7 +1214,7 @@ function chado_select_record($table, $columns, $values, $options = NULL) {
   // Get the table description.
   $table_desc = chado_get_schema($table);
   if (empty($table_desc)) {
-    tripal_report_error('tripal_core', TRIPAL_WARNING,
+    tripal_report_error('tripal_chado', TRIPAL_WARNING,
       'chado_insert_record; There is no table description for !table_name',
       array('!table_name' => $table), array('print' => $print_errors)
     );
@@ -1148,7 +1282,7 @@ function chado_select_record($table, $columns, $values, $options = NULL) {
         // and there is no default value then we cannot check if the record
         // is a duplicate so return FALSE
         else {
-          tripal_report_error('tripal_core', TRIPAL_ERROR,
+          tripal_report_error('tripal_chado', TRIPAL_ERROR,
             'chado_select_record: There is no value for %field thus we cannot ' .
             'check if this record for table, %table, is unique. %values',
             array('%field' => $field, '%table' => $table, '%values' => print_r($values, TRUE)),
@@ -1181,7 +1315,7 @@ function chado_select_record($table, $columns, $values, $options = NULL) {
 
     // Require the field be in the table description.
     if (!array_key_exists($field, $table_desc['fields'])) {
-      tripal_report_error('tripal_core', TRIPAL_ERROR,
+      tripal_report_error('tripal_chado', TRIPAL_ERROR,
         'chado_select_record: The field "%field" does not exist for the table "%table".  Cannot perform query. Values: %array',
         array('%field' => $field, '%table' => $table, '%array' => print_r($values, 1)),
         array('print' => $print_errors)
@@ -1250,7 +1384,7 @@ function chado_select_record($table, $columns, $values, $options = NULL) {
 
           // Ensure that looking up the foreign key didn't fail in an error.
           if ($results === FALSE OR $results === NULL) {
-            tripal_report_error('tripal_core', TRIPAL_ERROR,
+            tripal_report_error('tripal_chado', TRIPAL_ERROR,
               'chado_select_record: could not follow the foreign key definition
               for %field where the definition supplied was %value',
               array('%field' => $field, '%value' => print_r($value, TRUE))
@@ -1259,7 +1393,7 @@ function chado_select_record($table, $columns, $values, $options = NULL) {
           }
           // Ensure that there were results returned.
           elseif (count($results)==0) {
-            tripal_report_error('tripal_core', TRIPAL_ERROR,
+            tripal_report_error('tripal_chado', TRIPAL_ERROR,
               'chado_select_record: the foreign key definition for \'%field\' '.
               'returned no results where the definition supplied was %value',
               array('%field' => $field, '%value' => print_r($value, TRUE))
@@ -1480,7 +1614,7 @@ function chado_query($sql, $args = array()) {
 
   // Args should be an array
   if (!is_array($args)) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'chado_query; Need to pass an array to chado_query, "%value" passed instead. Query: %query',
       array('%value' => $args, '%query' => $sql)
     );
@@ -1554,7 +1688,7 @@ function chado_pager_query($query, $args, $limit, $element, $count_query = '') {
   // We calculate the total of pages as ceil(items / limit).
   $results = chado_query($count_query, $args);
   if (!$results) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       "chado_pager_query(): Query failed: %cq", array('%cq' => $count_query));
     return;
   }
@@ -1636,7 +1770,7 @@ function chado_pager_get_count($element) {
  * species.  The cvterm is also specified using its foreign key and the cv_id
  * for the cvterm is nested as well.
  *
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  */
 function chado_schema_get_foreign_key($table_desc, $field, $values, $options = NULL) {
 
@@ -1667,7 +1801,7 @@ function chado_schema_get_foreign_key($table_desc, $field, $values, $options = N
           . "implemented and defined this foreign key when it wasn't supposed to. Modules "
           . "this hook was implemented in: " . implode(', ',
         module_implements("chado_" . $table_desc['table'] . "_schema")) . ".";
-        tripal_report_error('tripal_core', $message);
+        tripal_report_error('tripal_chado', $message);
         drupal_set_message(check_plain($message), 'error');
         continue;
       }
@@ -1702,8 +1836,8 @@ function chado_schema_get_foreign_key($table_desc, $field, $values, $options = N
        To define a foreign key relationship, determine the table this foreign
        key referrs to (<foreign table>) and then implement
        hook_chado_chado_schema_v<version>_<foreign table>(). See
-       tripal_feature_chado_v1_2_schema_feature for an example. Chado version: $version");
-    tripal_report_error('tripal_core', $message);
+       tripal_chado_chado_v1_2_schema_feature for an example. Chado version: $version");
+    tripal_report_error('tripal_chado', $message);
     drupal_set_message(check_plain($message), 'error');
   }
 

+ 4 - 4
tripal_core/api/tripal_core.chado_schema.api.inc → tripal_chado/api/tripal_chado.schema.api.inc

@@ -189,7 +189,7 @@ function chado_is_installed() {
 /**
  * Returns the version number of the currently installed Chado instance.
  * It can return the real or effective version.  Note, this function
- * is executed in the hook_init() of the tripal_core module which then
+ * is executed in the hook_init() of the tripal_chado module which then
  * sets the $GLOBAL['exact_chado_version'] and $GLOBAL['chado_version']
  * variable.  You can access these variables rather than calling this function.
  *
@@ -308,7 +308,7 @@ function chado_get_version($exact = FALSE, $warn_if_unsupported = FALSE) {
  * @param $include_custom
  *   Optional.  Set as TRUE to include any custom tables created in the
  *   Chado schema. Custom tables are added to Chado using the
- *   tripal_core_chado_create_table() function.
+ *   tripal_chado_chado_create_table() function.
  *
  * @returns
  *   An associative array where the key and value pairs are the Chado table names.
@@ -322,13 +322,13 @@ function chado_get_table_names($include_custom = NULL) {
 
   $tables = array();
   if ($v == '1.2') {
-    $tables_v1_2 = tripal_core_chado_get_v1_2_tables();
+    $tables_v1_2 = tripal_chado_chado_get_v1_2_tables();
     foreach ($tables_v1_2 as $table) {
       $tables[$table] = $table;
     }
   }
   if ($v == '1.11' or $v == '1.11 or older') {
-    $tables_v1_11 = tripal_core_chado_get_v1_11_tables();
+    $tables_v1_11 = tripal_chado_chado_get_v1_11_tables();
     foreach ($tables_v1_11 as $table) {
       $tables[$table] = $table;
     }

ファイルの差分が大きいため隠しています
+ 112 - 112
tripal_chado/api/tripal_chado.schema_v1.11.api.inc


ファイルの差分が大きいため隠しています
+ 112 - 112
tripal_chado/api/tripal_chado.schema_v1.2.api.inc


+ 13 - 13
tripal_core/api/tripal_core.chado_variables.api.inc → tripal_chado/api/tripal_chado.variables.api.inc

@@ -114,7 +114,7 @@ function chado_generate_var($table, $values, $base_options = array()) {
   // get description for the current table----------------------------------------------------------
   $table_desc = chado_get_schema($table);
   if (!$table_desc or count($table_desc) == 0) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       "chado_generate_var: The table '%table' has not been defined. " .
       "and cannot be expanded. If this is a custom table, please add it using the Tripal " .
       "custom table interface.", array('%table' => $table));
@@ -145,7 +145,7 @@ function chado_generate_var($table, $values, $base_options = array()) {
   // where <table> is the current table a variable is being created for.
 
   // This allows modules to specify that some fields should be excluded by default
-  // For example, tripal core provides a tripal_core_exclude_field_from_feature_by_default()
+  // For example, tripal core provides a tripal_chado_exclude_field_from_feature_by_default()
   // which says that we usually don't want to include the residues field by default since
   // it can be very large and cause performance issues.
 
@@ -185,7 +185,7 @@ function chado_generate_var($table, $values, $base_options = array()) {
   // This gets all implementations of hook_exclude_type_by_default().
 
   // This allows modules to specify that some types of fields should be excluded by default
-  // For example, tripal core provides a tripal_core_exclude_type_by_default() which says
+  // For example, tripal core provides a tripal_chado_exclude_type_by_default() which says
   // that text fields are often very large and if they are longer than 250 characters then
   // we want to exclude them by default
 
@@ -494,7 +494,7 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
 
   // make sure we have a value
   if (!$object) {
-    tripal_report_error('tripal_core', TRIPAL_ERROR,
+    tripal_report_error('tripal_chado', TRIPAL_ERROR,
       'Cannot pass non array as argument, $object, to chado_expand_var function.', array());
     return $object;
   }
@@ -557,7 +557,7 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
       // Otherwise we weren't able to extract the parts of the field to expand
       // Thus we will warn the administrator
       else {
-        tripal_report_error('tripal_core', TRIPAL_ERROR,
+        tripal_report_error('tripal_chado', TRIPAL_ERROR,
           'chado_expand_var: Field (%field) not in the right format. " .
           "It should be <tablename>.<fieldname>', array('%field' => $to_expand));
       }
@@ -608,7 +608,7 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
             }
             // Otherwise we weren't able to expand the foreign key
             else {
-              tripal_report_error('tripal_core', TRIPAL_ERROR,
+              tripal_report_error('tripal_chado', TRIPAL_ERROR,
                 'chado_expand_var: unable to retrieve the object desribed by the foreign key
                 while trying to expand %fk.',
                 array('%fk' => $to_expand));
@@ -616,7 +616,7 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
           }
           // Else we were unable to determine the field name in the foreign table
           else {
-            tripal_report_error('tripal_core', TRIPAL_ERROR,
+            tripal_report_error('tripal_chado', TRIPAL_ERROR,
               'chado_expand_var: unable to determine the field name in the table the foreign
               key points to while trying to expand %fk.',
               array('%fk' => $to_expand));
@@ -641,7 +641,7 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
       // Otherwise we weren't able to extract the parts of the foreign key to expand
       // Thus we will warn the administrator
       else {
-        tripal_report_error('tripal_core', TRIPAL_ERROR,
+        tripal_report_error('tripal_chado', TRIPAL_ERROR,
           'chado_expand_var: foreign_key (%fk) not in the right format. " .
           "It should be <tablename>.<fieldname>', array('%fk' => $to_expand));
       }
@@ -682,7 +682,7 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
               // then warn them but proceed as though criteria was not supplied.
               $filter_criteria = array($left => $object->{$right});
 
-              tripal_report_error('tripal_core', TRIPAL_WARNING,
+              tripal_report_error('tripal_chado', TRIPAL_WARNING,
                 'chado_expand_var: unable to apply supplied filter criteria
                 since it should be an array. You supplied %criteria',
                 array('%criteria' => print_r($table_options['filter'], TRUE))
@@ -769,7 +769,7 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
         // if we did not expand this table we should return a message that the foreign table
         // could not be expanded
         if (!$did_expansion) {
-          tripal_report_error('tripal_core', TRIPAL_ERROR, 'chado_expand_var: Could not expand %table. ' .
+          tripal_report_error('tripal_chado', TRIPAL_ERROR, 'chado_expand_var: Could not expand %table. ' .
             'The table is either not related to the base object through a foreign key relationships or ' .
             'it is already expanded. First check the object to ensure it doesn’t already contain the ' .
             'data needed and otherwise check the table definition using chado_get_schema() to ensure ' .
@@ -834,11 +834,11 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
 
           // Warn the administrator
           if (isset($object->nid)) {
-            tripal_report_error('tripal_core', TRIPAL_ERROR, 'chado_expand_var: No node matches the nid (%nid) supplied.',
+            tripal_report_error('tripal_chado', TRIPAL_ERROR, 'chado_expand_var: No node matches the nid (%nid) supplied.',
               array('%nid' => $object->nid));
           }
           else {
-            tripal_report_error('tripal_core', TRIPAL_NOTICE, 'chado_expand_var: There is no node for the current object: <pre>%object</pre>', array('%object' => print_r($object,TRUE)));
+            tripal_report_error('tripal_chado', TRIPAL_NOTICE, 'chado_expand_var: There is no node for the current object: <pre>%object</pre>', array('%object' => print_r($object,TRUE)));
           }
         } //end of if node
       }
@@ -862,7 +862,7 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
 
     // The $type to be expanded is not yet supported
     default:
-      tripal_report_error('tripal_core', TRIPAL_ERROR, 'chado_expand_var: Unrecognized type (%type). Should be one of "field", "table", "node".',
+      tripal_report_error('tripal_chado', TRIPAL_ERROR, 'chado_expand_var: Unrecognized type (%type). Should be one of "field", "table", "node".',
         array('%type' => $type));
       return FALSE;
   }

+ 0 - 0
tripal_core/chado_schema/default_schema-1.11-1.2-diff.sql → tripal_chado/chado_schema/default_schema-1.11-1.2-diff.sql


+ 0 - 0
tripal_core/chado_schema/default_schema-1.11.sql → tripal_chado/chado_schema/default_schema-1.11.sql


+ 0 - 0
tripal_core/chado_schema/default_schema-1.2.sql → tripal_chado/chado_schema/default_schema-1.2.sql


+ 0 - 0
tripal_core/chado_schema/initialize-1.11.sql → tripal_chado/chado_schema/initialize-1.11.sql


+ 0 - 0
tripal_core/chado_schema/initialize-1.2.sql → tripal_chado/chado_schema/initialize-1.2.sql


+ 0 - 0
tripal_core/chado_schema/upgrade-1.11-1.2.sql → tripal_chado/chado_schema/upgrade-1.11-1.2.sql


+ 27 - 27
legacy/tripal_feature/includes/tripal_feature.gff_exporter.inc → tripal_chado/includes/exporters/tripal_chado.gff_exporter.inc

@@ -1,16 +1,16 @@
-<?php 
+<?php
+
+function tripal_chado_gff3_exporter($source, $filters) {
 
-function tripal_feature_gff3_exporter($source, $filters) {
-  
   // Make sure the filters array is setup properly.
   if (!array_key_exists('types', $filters) and
       !array_key_exists('feature_id', $filters)) {
-    tripal_report_error("tripal_feature", TRIPAL_ERROR,
+    tripal_report_error("tripal_chado", TRIPAL_ERROR,
     "Please provide one or more types to include in the exported GFF file.",
     array());
     exit;
   }
-  
+
   $select = "
     SELECT SF.uniquename as landmark_uname, SF.name as landmark_name,
       F.feature_id, F.dbxref_id, F.uniquename, F.name, CVT.name as type,
@@ -30,11 +30,11 @@ function tripal_feature_gff3_exporter($source, $filters) {
   ";
 
   $args = array();
-  
+
   // Filter by organism
   if (array_key_exists('genus', $filters) or array_key_exists('species', $filters)) {
     $from .= "INNER JOIN {organism} O on F.organism_id = O.organism_id ";
-    if (array_key_exists('genus', $filters)) { 
+    if (array_key_exists('genus', $filters)) {
       $where .= "AND O.genus = :genus ";
       $args[':genus'] = $filters['genus'];
     }
@@ -50,20 +50,20 @@ function tripal_feature_gff3_exporter($source, $filters) {
       $args[':types'] = $filters['types'];
     }
     else {
-      tripal_report_error("tripal_feature", TRIPAL_ERROR,
+      tripal_report_error("tripal_chado", TRIPAL_ERROR,
       "The 'types' element of the filters array must be an array.",
       array());
       exit;
     }
   }
-  
+
   // Filter by exact feature_id
   if (array_key_exists('feature_id', $filters)) {
     $where .= "AND F.feature_id = :feature_id ";
     $args[':feature_id'] = $filters['feature_id'];
   }
   // Filter by analysis
-  if (array_key_exists('analysis_id', $filters) or 
+  if (array_key_exists('analysis_id', $filters) or
       array_key_exists('analysis_name', $filters)) {
     $from .= "INNER JOIN {analysisfeature} AF on AF.feature_id = F.feature_id ";
     if (array_key_exists('analysis_id', $filters)) {
@@ -87,7 +87,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
     WHERE FP.feature_id = :feature_id
     ORDER BY CVT.name
   ";
-  
+
   // The SQL statement for Dbxrefs associated with this feature
   $dbxref_sql = "
     SELECT DB.name as dbname, DBX.accession
@@ -96,12 +96,12 @@ function tripal_feature_gff3_exporter($source, $filters) {
     WHERE DBX.dbxref_id = :dbxref_id
     UNION
     SELECT DB.name, DBX.accession
-    FROM {feature_dbxref} FDBX 
+    FROM {feature_dbxref} FDBX
       INNER JOIN {dbxref} DBX on DBX.dbxref_id = FDBX.dbxref_id
       INNER JOIN {db} DB on DB.db_id = DBX.db_id
     WHERE FDBX.feature_id = :feature_id
   ";
-  
+
   // The SQL statement for CVTerms assigned to this feature.
   $cvterm_sql = "
     SELECT CV.name as db_name, DBX.accession
@@ -111,7 +111,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
       INNER JOIN {dbxref} DBX on CVT.dbxref_id = DBX.dbxref_id
     WHERE FCVT.feature_id = :feature_id
   ";
-  
+
   // The SQL for finding the parents of this feature.
   $parent_sql = "
     SELECT F.name, F.uniquename, F.feature_id
@@ -120,7 +120,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
       INNER JOIN {feature} F on FR.object_id = F.feature_id
     WHERE CVT.name = 'part_of' AND FR.subject_id = :feature_id
   ";
-  
+
   // The SQL for aliases of this feature.
   $alias_sql = "
     SELECT S.name
@@ -128,7 +128,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
       INNER JOIN {synonym} S on FS.synonym_id = S.synonym_id
     WHERE FS.feature_id = :feature_id
   ";
-  
+
   // Get the score
   $score_sql = "
     SELECT rawscore as score
@@ -137,10 +137,10 @@ function tripal_feature_gff3_exporter($source, $filters) {
     ORDER BY AF.analysis_id
     OFFSET 0 LIMIT 1
   ";
-  
+
   $results = chado_query($sql, $args);
   while ($line = $results->fetchObject()) {
-    
+
     // Get the score for this feature
     $score = chado_query($score_sql, array(':feature_id' => $line->feature_id))->fetchField();
     print $line->landmark_uname . "\t";
@@ -157,7 +157,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
     }
     if ($line->strand) {
       print $line->strand . "\t";
-    } 
+    }
     else {
       print '.' . "\t";
     }
@@ -168,7 +168,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
       print '.' . "\t";
     }
     print "ID=" . $line->uniquename . ";Name=" . $line->name . ";";
-    
+
     // Look for a parent of this feature
     $args = array(':feature_id' => $line->feature_id);
     $parents = chado_query($parent_sql, $args);
@@ -179,7 +179,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
     if ($attr) {
       print "Parent=" . substr($attr, 0, -1) . ";";
     }
-    
+
     // Add in any aliases
     $args = array(':feature_id' => $line->feature_id);
     $aliases = chado_query($alias_sql, $args);
@@ -190,7 +190,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
     if ($attr) {
       print "Alias=" . substr($attr, 0, -1) . ";";
     }
-    
+
     $props = chado_query($props_sql, array(':feature_id' => $line->feature_id));
     $prop_name = '';
     while ($prop = $props->fetchobject()) {
@@ -214,7 +214,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
     if ($prop_name) {
       print ";";
     }
-    
+
     // Add in any DBXref records
     $args = array(
       ':feature_id' => $line->feature_id,
@@ -231,7 +231,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
     if ($xrefs) {
       print "Dbxref=" . substr($xrefs, 0, -1) . ";";
     }
-    
+
     // Add in any CVTerm records
     $args = array(':feature_id' => $line->feature_id);
     $cvterms = chado_query($cvterm_sql, $args);
@@ -242,9 +242,9 @@ function tripal_feature_gff3_exporter($source, $filters) {
     if ($xrefs) {
       print "Ontology_term=" . substr($xrefs, 0, -1) . ";";
     }
-    
+
     print "\n";
-    
+
     // Look for children of this feature and recursively add them.
     $children_sql = "
       SELECT FR.subject_id
@@ -257,7 +257,7 @@ function tripal_feature_gff3_exporter($source, $filters) {
       $child_filters = array(
         'feature_id' => $child->subject_id,
       );
-      tripal_feature_gff3_exporter($source, $child_filters);
+      tripal_chado_gff3_exporter($source, $child_filters);
     }
   }
 }

+ 62 - 62
legacy/tripal_feature/includes/tripal_feature.seq_extract.inc → tripal_chado/includes/exporters/tripal_chado.seq_extract.inc

@@ -7,24 +7,24 @@
 /**
  * The page allowing users to download feature sequences
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_chado
  */
-function tripal_feature_seq_extract_page() {
-
-  if ($_SESSION['tripal_feature_seq_extract']['download']) {
-    $genus      = $_SESSION['tripal_feature_seq_extract']['genus'];
-    $species    = $_SESSION['tripal_feature_seq_extract']['species'];
-    $analysis   = $_SESSION['tripal_feature_seq_extract']['analysis'];
-    $ftype      = $_SESSION['tripal_feature_seq_extract']['ftype'];
-    $fnames     = $_SESSION['tripal_feature_seq_extract']['fnames'];
-    $upstream   = $_SESSION['tripal_feature_seq_extract']['upstream'];
-    $downstream = $_SESSION['tripal_feature_seq_extract']['downstream'];
-    $format     = $_SESSION['tripal_feature_seq_extract']['format'];
-    $use_parent = $_SESSION['tripal_feature_seq_extract']['use_parent'];
-    $aggregate  = $_SESSION['tripal_feature_seq_extract']['aggregate'];
-    $agg_types  = $_SESSION['tripal_feature_seq_extract']['agg_types'];
-
-    unset($_SESSION['tripal_feature_seq_extract']['download']);
+function tripal_chado_seq_extract_page() {
+
+  if ($_SESSION['tripal_chado_seq_extract']['download']) {
+    $genus      = $_SESSION['tripal_chado_seq_extract']['genus'];
+    $species    = $_SESSION['tripal_chado_seq_extract']['species'];
+    $analysis   = $_SESSION['tripal_chado_seq_extract']['analysis'];
+    $ftype      = $_SESSION['tripal_chado_seq_extract']['ftype'];
+    $fnames     = $_SESSION['tripal_chado_seq_extract']['fnames'];
+    $upstream   = $_SESSION['tripal_chado_seq_extract']['upstream'];
+    $downstream = $_SESSION['tripal_chado_seq_extract']['downstream'];
+    $format     = $_SESSION['tripal_chado_seq_extract']['format'];
+    $use_parent = $_SESSION['tripal_chado_seq_extract']['use_parent'];
+    $aggregate  = $_SESSION['tripal_chado_seq_extract']['aggregate'];
+    $agg_types  = $_SESSION['tripal_chado_seq_extract']['agg_types'];
+
+    unset($_SESSION['tripal_chado_seq_extract']['download']);
 
     if ($format == 'fasta_html') {
       drupal_add_http_header('Content-Type: text/html');
@@ -35,16 +35,16 @@ function tripal_feature_seq_extract_page() {
     }
 
     tripal_get_bulk_feature_sequences(array(
-      'genus' => $genus, 
-      'species' => $species, 
+      'genus' => $genus,
+      'species' => $species,
       'analysis_name' => $analysis,
-      'type' => $ftype, 
-      'feature_name' => $fnames['items_array'], 
-      'upstream' => $upstream, 
-      'downstream' => $downstream, 
+      'type' => $ftype,
+      'feature_name' => $fnames['items_array'],
+      'upstream' => $upstream,
+      'downstream' => $downstream,
       'print' => 1,
-      'output_format' => $format, 
-      'derive_from_parent' => $use_parent, 
+      'output_format' => $format,
+      'derive_from_parent' => $use_parent,
       'aggregate' => $aggregate,
       'sub_feature_types' => $agg_types
     ));
@@ -56,14 +56,14 @@ function tripal_feature_seq_extract_page() {
   // generate the search form
   $output .= '';
   if (user_access('administer tripal')) {
-    $output .= tripal_set_message("Administrators, the " . 
+    $output .= tripal_set_message("Administrators, the " .
         l('organism_feature_count', 'admin/tripal/storage/chado/mviews') . " and " .
         l('analysis_organism', 'admin/tripal/storage/chado/mviews') . " materialized
         views must be populated before using this form.  Those views should be re-populated
         when new data is added.");
   }
   $output .= "<div id=\"tripal-feature-seq-extract-form-block\">";
-  $output .= drupal_get_form('tripal_feature_seq_extract_form');
+  $output .= drupal_get_form('tripal_chado_seq_extract_form');
   $output .= "</div>";
   return $output;
 }
@@ -71,9 +71,9 @@ function tripal_feature_seq_extract_page() {
 /**
  * Theme the Form to choose which features to extract sequence for
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_chado
  */
-function theme_tripal_feature_seq_extract_form($form, &$form_state) {
+function theme_tripal_chado_seq_extract_form($form, &$form_state) {
   $rows = array(
     0 => array(
       array('data' => drupal_render($form['description']), 'colspan' => 3),
@@ -118,9 +118,9 @@ function theme_tripal_feature_seq_extract_form($form, &$form_state) {
 /**
  * Form to choose which features to extract sequence for
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_chado
  */
-function tripal_feature_seq_extract_form(&$form_state = NULL) {
+function tripal_chado_seq_extract_form(&$form_state = NULL) {
   tripal_core_ahah_init_form();
 
   // we want to allow the query string to provide values for the form
@@ -156,17 +156,17 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
   }
 
   // get defaults
-  $dgenus      = isset($form_state['values']['genus'])      ? $form_state['values']['genus']      : $_SESSION['tripal_feature_seq_extract']['genus'];
-  $dspecies    = isset($form_state['values']['species'])    ? $form_state['values']['species']    : $_SESSION['tripal_feature_seq_extract']['species'];
-  $danalysis   = isset($form_state['values']['analysis'])   ? $form_state['values']['analysis']   : $_SESSION['tripal_feature_seq_extract']['analysis'];
-  $dftype      = isset($form_state['values']['ftype'])      ? $form_state['values']['ftype']      : $_SESSION['tripal_feature_seq_extract']['ftype'];
-  $dfnames     = isset($form_state['values']['fnames'])     ? $form_state['values']['fnames']     : $_SESSION['tripal_feature_seq_extract']['fnames'];
-  $dupstream   = isset($form_state['values']['upstream'])   ? $form_state['values']['upstream']   : $_SESSION['tripal_feature_seq_extract']['upstream'];
-  $ddownstream = isset($form_state['values']['downstream']) ? $form_state['values']['downstream'] : $_SESSION['tripal_feature_seq_extract']['downstream'];
+  $dgenus      = isset($form_state['values']['genus'])      ? $form_state['values']['genus']      : $_SESSION['tripal_chado_seq_extract']['genus'];
+  $dspecies    = isset($form_state['values']['species'])    ? $form_state['values']['species']    : $_SESSION['tripal_chado_seq_extract']['species'];
+  $danalysis   = isset($form_state['values']['analysis'])   ? $form_state['values']['analysis']   : $_SESSION['tripal_chado_seq_extract']['analysis'];
+  $dftype      = isset($form_state['values']['ftype'])      ? $form_state['values']['ftype']      : $_SESSION['tripal_chado_seq_extract']['ftype'];
+  $dfnames     = isset($form_state['values']['fnames'])     ? $form_state['values']['fnames']     : $_SESSION['tripal_chado_seq_extract']['fnames'];
+  $dupstream   = isset($form_state['values']['upstream'])   ? $form_state['values']['upstream']   : $_SESSION['tripal_chado_seq_extract']['upstream'];
+  $ddownstream = isset($form_state['values']['downstream']) ? $form_state['values']['downstream'] : $_SESSION['tripal_chado_seq_extract']['downstream'];
   $dformat     = isset($form_state['values']['format'])     ? $form_state['values']['format']     : 'fasta_txt';
-  $duse_parent = isset($form_state['values']['use_parent']) ? $form_state['values']['use_parent'] : $_SESSION['tripal_feature_seq_extract']['use_parent'];
-  $daggregate  = isset($form_state['values']['aggregate'])  ? $form_state['values']['aggregate']  : $_SESSION['tripal_feature_seq_extract']['aggregate'];
-  $dagg_types  = isset($form_state['values']['agg_types'])  ? $form_state['values']['agg_types']  : $_SESSION['tripal_feature_seq_extract']['agg_types'];
+  $duse_parent = isset($form_state['values']['use_parent']) ? $form_state['values']['use_parent'] : $_SESSION['tripal_chado_seq_extract']['use_parent'];
+  $daggregate  = isset($form_state['values']['aggregate'])  ? $form_state['values']['aggregate']  : $_SESSION['tripal_chado_seq_extract']['aggregate'];
+  $dagg_types  = isset($form_state['values']['agg_types'])  ? $form_state['values']['agg_types']  : $_SESSION['tripal_chado_seq_extract']['agg_types'];
 
 
   $form = array();
@@ -366,9 +366,9 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
 /**
  * AJAX callback
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_chado
  */
-function tripal_feature_seq_extract_form_ahah_update() {
+function tripal_chado_seq_extract_form_ahah_update() {
   $status = TRUE;
 
   // prepare and render the form. If no form is returned that means
@@ -378,10 +378,10 @@ function tripal_feature_seq_extract_form_ahah_update() {
   // otherwise, if the form already exists we just theme it.
   $form = tripal_core_ahah_prepare_form();
   if ($form) {
-    $data = theme('tripal_feature_seq_extract_form', $form);
+    $data = theme('tripal_chado_seq_extract_form', $form);
   }
   else {
-    $data = drupal_get_form('tripal_feature_seq_extract_form');
+    $data = drupal_get_form('tripal_chado_seq_extract_form');
   }
 
   // bind javascript events to the new objects that will be returned
@@ -401,9 +401,9 @@ function tripal_feature_seq_extract_form_ahah_update() {
 /**
  * Validate the extract sequence form
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_chado
  */
-function tripal_feature_seq_extract_form_validate($form, &$form_state) {
+function tripal_chado_seq_extract_form_validate($form, &$form_state) {
   $genus      = $form_state['values']['genus'];
   $species    = $form_state['values']['species'];
   $analysis   = $form_state['values']['analysis'];
@@ -433,9 +433,9 @@ function tripal_feature_seq_extract_form_validate($form, &$form_state) {
 /**
  * Submit the extract sequence form
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_chado
  */
-function tripal_feature_seq_extract_form_submit($form, &$form_state) {
+function tripal_chado_seq_extract_form_submit($form, &$form_state) {
   $genus      = $form_state['values']['genus'];
   $species    = $form_state['values']['species'];
   $analysis   = $form_state['values']['analysis'];
@@ -456,20 +456,20 @@ function tripal_feature_seq_extract_form_submit($form, &$form_state) {
   }
 
   if ($op == 'Retrieve') {
-    $_SESSION['tripal_feature_seq_extract']['genus']      = $genus;
-    $_SESSION['tripal_feature_seq_extract']['species']    = $species;
-    $_SESSION['tripal_feature_seq_extract']['analysis']   = $analysis;
-    $_SESSION['tripal_feature_seq_extract']['ftype']      = $ftype;
-    $_SESSION['tripal_feature_seq_extract']['fnames']     = $fnames;
-    $_SESSION['tripal_feature_seq_extract']['upstream']   = $upstream;
-    $_SESSION['tripal_feature_seq_extract']['downstream'] = $downstream;
-    $_SESSION['tripal_feature_seq_extract']['format']     = $format;
-    $_SESSION['tripal_feature_seq_extract']['use_parent'] = $use_parent;
-    $_SESSION['tripal_feature_seq_extract']['aggregate']  = $aggregate;
-    $_SESSION['tripal_feature_seq_extract']['agg_types']  = $agg_types;
-    $_SESSION['tripal_feature_seq_extract']['download']   = 1;
+    $_SESSION['tripal_chado_seq_extract']['genus']      = $genus;
+    $_SESSION['tripal_chado_seq_extract']['species']    = $species;
+    $_SESSION['tripal_chado_seq_extract']['analysis']   = $analysis;
+    $_SESSION['tripal_chado_seq_extract']['ftype']      = $ftype;
+    $_SESSION['tripal_chado_seq_extract']['fnames']     = $fnames;
+    $_SESSION['tripal_chado_seq_extract']['upstream']   = $upstream;
+    $_SESSION['tripal_chado_seq_extract']['downstream'] = $downstream;
+    $_SESSION['tripal_chado_seq_extract']['format']     = $format;
+    $_SESSION['tripal_chado_seq_extract']['use_parent'] = $use_parent;
+    $_SESSION['tripal_chado_seq_extract']['aggregate']  = $aggregate;
+    $_SESSION['tripal_chado_seq_extract']['agg_types']  = $agg_types;
+    $_SESSION['tripal_chado_seq_extract']['download']   = 1;
   }
   if ($op == 'Reset') {
-    unset($_SESSION['tripal_feature_seq_extract']);
+    unset($_SESSION['tripal_chado_seq_extract']);
   }
 }

+ 12 - 12
legacy/tripal_feature/includes/tripal_feature.fasta_loader.inc → tripal_chado/includes/loaders/tripal_chado.fasta_loader.inc

@@ -7,7 +7,7 @@
 
 /**
  * @defgroup fasta_loader FASTA Feature Loader
- * @ingroup tripal_feature
+ * @ingroup tripal_chado
  * @{
  * Provides fasta loading functionality.
  * Creates features based on their specification
@@ -20,7 +20,7 @@
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_load_form() {
+function tripal_chado_fasta_load_form() {
   $form['fasta_file'] = array('#type' => 'textfield','#title' => t('FASTA File'),
     '#description' => t('Please enter the full system path for the FASTA file, or a path within the Drupal
                            installation (e.g. /sites/default/files/xyz.obo).  The path must be accessible to the
@@ -201,7 +201,7 @@ function tripal_feature_fasta_load_form() {
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_load_form_validate($form, &$form_state) {
+function tripal_chado_fasta_load_form_validate($form, &$form_state) {
   $fasta_file = trim($form_state['values']['fasta_file']);
   $organism_id = $form_state['values']['organism_id'];
   $type = trim($form_state['values']['seqtype']);
@@ -302,7 +302,7 @@ function tripal_feature_fasta_load_form_validate($form, &$form_state) {
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_load_form_submit($form, &$form_state) {
+function tripal_chado_fasta_load_form_submit($form, &$form_state) {
   global $user;
 
   $dfile = $form_state['storage']['dfile'];
@@ -342,7 +342,7 @@ function tripal_feature_fasta_load_form_submit($form, &$form_state) {
   );
 
   $fname = preg_replace("/.*\/(.*)/", "$1", $dfile);
-  tripal_add_job("Import FASTA file: $fname", 'tripal_feature', 'tripal_feature_load_fasta', $args, $user->uid);
+  tripal_add_job("Import FASTA file: $fname", 'tripal_chado', 'tripal_chado_load_fasta', $args, $user->uid);
 }
 
 /**
@@ -385,7 +385,7 @@ function tripal_feature_fasta_load_form_submit($form, &$form_state) {
  *
  *          @ingroup fasta_loader
  */
-function tripal_feature_load_fasta($dfile, $organism_id, $type, $re_name, $re_uname, $re_accession,
+function tripal_chado_load_fasta($dfile, $organism_id, $type, $re_name, $re_uname, $re_accession,
   $db_id, $rel_type, $re_subject, $parent_type, $method, $uid, $analysis_id, $match_type,
   $job = NULL) {
   $transaction = db_transaction();
@@ -596,7 +596,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type, $re_name, $re_un
         print "Current feature: " . $seq['uname'] . ".\n";
       }
 
-      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_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_set_job_progress($job, 100);
     fclose($fh);
@@ -613,11 +613,11 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type, $re_name, $re_un
 }
 
 /**
- * A helper function for tripal_feature_load_fasta() to load a single feature
+ * A helper function for tripal_chado_load_fasta() to load a single feature
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_load_fasta_feature($fh, $name, $uname, $db_id, $accession, $parent,
+function tripal_chado_load_fasta_feature($fh, $name, $uname, $db_id, $accession, $parent,
   $rel_type, $parent_type, $analysis_id, $organism_id, $cvterm, $source, $method, $re_name,
   $match_type, $parentcvterm, $relcvterm, $seq_start, $seq_end) {
 
@@ -707,7 +707,7 @@ function tripal_feature_load_fasta_feature($fh, $name, $uname, $db_id, $accessio
     }
 
     // Add the residues for this feature
-    tripal_feature_load_fasta_residues($fh, $feature->feature_id, $seq_start, $seq_end);
+    tripal_chado_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 +791,7 @@ function tripal_feature_load_fasta_feature($fh, $name, $uname, $db_id, $accessio
   }
 
   // Update the residues for this feature
-  tripal_feature_load_fasta_residues($fh, $feature->feature_id, $seq_start, $seq_end);
+  tripal_chado_load_fasta_residues($fh, $feature->feature_id, $seq_start, $seq_end);
 
   // add in the analysis link
   if ($analysis_id) {
@@ -906,7 +906,7 @@ function tripal_feature_load_fasta_feature($fh, $name, $uname, $db_id, $accessio
  * @param unknown $seq_start
  * @param unknown $seq_end
  */
-function tripal_feature_load_fasta_residues($fh, $feature_id, $seq_start, $seq_end) {
+function tripal_chado_load_fasta_residues($fh, $feature_id, $seq_start, $seq_end) {
 
   // First position the file at the beginning of the sequence
   fseek($fh, $seq_start, SEEK_SET);

+ 90 - 90
legacy/tripal_feature/includes/tripal_feature.gff_loader.inc → tripal_chado/includes/loaders/tripal_chado.gff_loader.inc

@@ -7,7 +7,7 @@
 
 /**
  * @defgroup gff3_loader GFF3 Feature Loader
- * @ingroup tripal_feature
+ * @ingroup tripal_chado
  * @{
  * Provides gff3 loading functionality. Creates features based on their specification in a GFF3 file.
  * @}
@@ -18,7 +18,7 @@
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_gff3_load_form() {
+function tripal_chado_gff3_load_form() {
 
   $form['gff_file']= array(
     '#type'          => 'textfield',
@@ -214,7 +214,7 @@ function tripal_feature_gff3_load_form() {
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_gff3_load_form_validate($form, &$form_state) {
+function tripal_chado_gff3_load_form_validate($form, &$form_state) {
 
   $gff_file = trim($form_state['values']['gff_file']);
   $organism_id = $form_state['values']['organism_id'];
@@ -263,7 +263,7 @@ function tripal_feature_gff3_load_form_validate($form, &$form_state) {
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_gff3_load_form_submit($form, &$form_state) {
+function tripal_chado_gff3_load_form_submit($form, &$form_state) {
   global $user;
 
   $gff_file = trim($form_state['values']['gff_file']);
@@ -302,8 +302,8 @@ function tripal_feature_gff3_load_form_submit($form, &$form_state) {
     $type = 'delete features';
   }
   $fname = preg_replace("/.*\/(.*)/", "$1", $gff_file);
-  tripal_add_job("$type GFF3 file: $fname", 'tripal_feature',
-    'tripal_feature_load_gff3', $args, $user->uid);
+  tripal_add_job("$type GFF3 file: $fname", 'tripal_chado',
+    'tripal_chado_load_gff3', $args, $user->uid);
 
   return '';
 }
@@ -380,7 +380,7 @@ function tripal_feature_gff3_load_form_submit($form, &$form_state) {
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
+function tripal_chado_load_gff3($gff_file, $organism_id, $analysis_id,
   $add_only = 0, $update = 1, $refresh = 0, $remove = 0, $use_transaction = 1,
   $target_organism_id = NULL, $target_type = NULL,  $create_target = 0,
   $start_line = 1, $landmark_type = '', $alt_id_attr = '', $create_organism = FALSE,
@@ -419,7 +419,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
       $dfile = $gff_file;
     }
     if (!file_exists($dfile)) {
-      tripal_report_error('tripal_feature', TRIPAL_ERROR, "Cannot find the file: %dfile",
+      tripal_report_error('tripal_chado', TRIPAL_ERROR, "Cannot find the file: %dfile",
         array('%dfile' => $dfile));
       return 0;
     }
@@ -429,7 +429,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
     //$lines = file($dfile,FILE_SKIP_EMPTY_LINES);
     $fh = fopen($dfile, 'r');
     if (!$fh) {
-      tripal_report_error('tripal_feature', TRIPAL_ERROR, "cannot open file: %dfile",
+      tripal_report_error('tripal_chado', TRIPAL_ERROR, "cannot open file: %dfile",
         array('%dfile' => $dfile));
       return 0;
     }
@@ -440,7 +440,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
     $sql = "SELECT * FROM {cv} WHERE name = :cvname";
     $cv = chado_query($sql, array(':cvname' => 'sequence'))->fetchObject();
     if (!$cv) {
-      tripal_report_error('tripal_feature', TRIPAL_ERROR,
+      tripal_report_error('tripal_chado', TRIPAL_ERROR,
         "Cannot find the 'sequence' ontology", array());
       return '';
     }
@@ -478,7 +478,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
       $result = chado_query($sel_cvterm_sql, $query);
       $landmark_cvterm = $result->fetchObject();
       if (!$landmark_cvterm) {
-        tripal_report_error('tripal_feature', TRIPAL_ERROR,
+        tripal_report_error('tripal_chado', TRIPAL_ERROR,
           'cannot find landmark feature type \'%landmark_type\'.',
           array('%landmark_type' => $landmark_type));
         return '';
@@ -513,7 +513,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_feature_load_gff3_fasta($fh, $interval, $num_read, $intv_read, $line_num, $filesize, $job);
+        tripal_chado_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 +522,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
         $rstart = $region_matches[2];
         $rend = $region_matches[3];
         if ($landmark_type) {
-          tripal_feature_load_gff3_feature($organism, $analysis_id, $landmark_cvterm, $rid,
+          tripal_chado_load_gff3_feature($organism, $analysis_id, $landmark_cvterm, $rid,
             $rid, '', 'f', 'f', 1, 0);
         }
         continue;
@@ -541,7 +541,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
       // get the columns
       $cols = explode("\t", $line);
       if (sizeof($cols) != 9) {
-        tripal_report_error('tripal_feature', TRIPAL_ERROR, 'improper number of columns on line %line_num',
+        tripal_report_error('tripal_chado', TRIPAL_ERROR, 'improper number of columns on line %line_num',
           array('%line_num' => $line_num));
         return '';
       }
@@ -587,7 +587,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
         $cvterm = $result->fetchObject();
         $cvterm_lookup[$type] = $cvterm;
         if (!$cvterm) {
-          tripal_report_error('tripal_feature', TRIPAL_ERROR, 'cannot find feature term \'%type\' on line %line_num of the GFF file',
+          tripal_report_error('tripal_chado', TRIPAL_ERROR, 'cannot find feature term \'%type\' on line %line_num of the GFF file',
             array('%type' => $type, '%line_num' => $line_num));
           return '';
         }
@@ -619,7 +619,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
           continue;
         }
         if (!preg_match('/^[^\=]+\=.+$/', $attr)) {
-          tripal_report_error('tripal_feature', TRIPAL_ERROR, 'Attribute is not correctly formatted on line %line_num: %attr',
+          tripal_report_error('tripal_chado', TRIPAL_ERROR, 'Attribute is not correctly formatted on line %line_num: %attr',
             array('%line_num' => $line_num, '%attr' => $attr));
           return '';
         }
@@ -661,13 +661,13 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
               if ($create_organism) {
                 $feature_organism = (object) chado_insert_record('organism', $values);
                 if (!$feature_organism) {
-                  tripal_report_error('tripal_feature', TRIPAL_ERROR, "Could not add the organism, '%org', from line %line. Skipping this line. ",
+                  tripal_report_error('tripal_chado', TRIPAL_ERROR, "Could not add the organism, '%org', from line %line. Skipping this line. ",
                     array('%org' => $attr_organism, '%line' => $line_num));
                   $skip_feature = 1;
                 }
               }
               else {
-                tripal_report_error('tripal_feature', TRIPAL_ERROR, "The organism attribute '%org' on line %line does not exist. Skipping this line. ",
+                tripal_report_error('tripal_chado', TRIPAL_ERROR, "The organism attribute '%org' on line %line does not exist. Skipping this line. ",
                   array('%org' => $attr_organism, '%line' => $line_num));
                 $skip_feature = 1;
               }
@@ -678,7 +678,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
             }
           }
           else {
-            tripal_report_error('tripal_feature', TRIPAL_ERROR, "The organism attribute '%org' on line %line is not properly formated. It " .
+            tripal_report_error('tripal_chado', TRIPAL_ERROR, "The organism attribute '%org' on line %line is not properly formated. It " .
               "should be of the form: organism=Genus:species.  Skipping this line.",
               array('%org' => $attr_organism, '%line' => $line_num));
             $skip_feature = 1;
@@ -762,20 +762,20 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
           }
           $count = chado_select_record('feature', $columns, $select);
           if (!$count or count($count) == 0 or $count[0]->num_landmarks == 0) {
-            tripal_report_error('tripal_feature', TRIPAL_ERROR, "The landmark '%landmark' cannot be found for this organism (%species) " .
+            tripal_report_error('tripal_chado', TRIPAL_ERROR, "The landmark '%landmark' cannot be found for this organism (%species) " .
                   "Please add the landmark and then retry the import of this GFF3 " .
                   "file", array('%landmark' => $landmark, '%species' => $organism->genus . " " . $organism->species));
             return '';
           }
           elseif ($count[0]->num_landmarks > 1) {
-            tripal_report_error('tripal_feature', TRIPAL_ERROR, "The landmark '%landmark' has more than one entry for this organism (%species) " .
+            tripal_report_error('tripal_chado', TRIPAL_ERROR, "The landmark '%landmark' has more than one entry for this organism (%species) " .
                   "Cannot continue", array('%landmark' => $landmark, '%species' => $organism->genus . " " . $organism->species));
             return '';
           }
 
         }
         if ($count[0]->num_landmarks > 1) {
-          tripal_report_error('tripal_feature', TRIPAL_ERROR, "The landmark '%landmark' is not unique for this organism. " .
+          tripal_report_error('tripal_chado', TRIPAL_ERROR, "The landmark '%landmark' is not unique for this organism. " .
                 "The features cannot be associated", array('%landmark' => $landmark));
           return '';
         }
@@ -794,7 +794,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
         );
         $result = chado_delete_record('feature', $match);
         if (!$result) {
-          tripal_report_error('tripal_feature', TRIPAL_ERROR, "cannot delete feature %attr_uniquename",
+          tripal_report_error('tripal_chado', TRIPAL_ERROR, "cannot delete feature %attr_uniquename",
             array('%attr_uniquename' => $attr_uniquename));
         }
         $feature = 0;
@@ -805,7 +805,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_feature_load_gff3_feature($feature_organism, $analysis_id, $cvterm,
+        $feature = tripal_chado_load_gff3_feature($feature_organism, $analysis_id, $cvterm,
           $attr_uniquename, $attr_name, $residues, $attr_is_analysis,
           $attr_is_obsolete, $add_only, $score);
 
@@ -825,65 +825,65 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
           if (count($results) == 0) {
             $result = chado_insert_record('tripal_gff_temp', $values);
             if (!$result) {
-              tripal_report_error('tripal_feature', TRIPAL_ERROR, "Cound not save record in temporary table, Cannot continue.", array());
+              tripal_report_error('tripal_chado', TRIPAL_ERROR, "Cound not save record in temporary table, Cannot continue.", array());
               exit;
             }
           }
           // 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_feature_load_gff3_featureloc($feature, $organism,
+            tripal_chado_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_feature_load_gff3_alias($feature, $tags['Alias']);
+            tripal_chado_load_gff3_alias($feature, $tags['Alias']);
           }
           // add any dbxrefs for this feature
           if (array_key_exists('Dbxref', $tags)) {
-            tripal_feature_load_gff3_dbxref($feature, $tags['Dbxref']);
+            tripal_chado_load_gff3_dbxref($feature, $tags['Dbxref']);
           }
           // add any ontology terms for this feature
           if (array_key_exists('Ontology_term', $tags)) {
-            tripal_feature_load_gff3_ontology($feature, $tags['Ontology_term']);
+            tripal_chado_load_gff3_ontology($feature, $tags['Ontology_term']);
           }
           // add parent relationships
           if (array_key_exists('Parent', $tags)) {
-            tripal_feature_load_gff3_parents($feature, $cvterm, $tags['Parent'],
+            tripal_chado_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_feature_load_gff3_target($feature, $tags, $target_organism_id, $target_type, $create_target, $attr_locgroup);
+            tripal_chado_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_feature_load_gff3_property($feature, 'Gap', $value);
+              tripal_chado_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_feature_load_gff3_property($feature, 'Note', $value);
+                tripal_chado_load_gff3_property($feature, 'Note', $value);
             }
           }
           // add the Derives_from relationship (e.g. polycistronic genes).
           if (array_key_exists('Derives_from', $tags)) {
-            tripal_feature_load_gff3_derives_from($feature, $cvterm, $tags['Derives_from'][0],
+            tripal_chado_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_feature_load_gff3_dbxref($feature, $source_ref);
+          tripal_chado_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_feature_load_gff3_property($feature, $tag_name, $value);
+                tripal_chado_load_gff3_property($feature, $tag_name, $value);
               }
             }
           }
@@ -948,15 +948,15 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
             }
 
             // Add the new protein record.
-            $feature = tripal_feature_load_gff3_feature($organism, $analysis_id,
+            $feature = tripal_chado_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_feature_load_gff3_derives_from($feature, $cvterm,
+            tripal_chado_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_feature_load_gff3_featureloc($feature, $organism, $landmark,
+            tripal_chado_load_gff3_featureloc($feature, $organism, $landmark,
               $pfmin, $pfmax, $strand, '', 'f', 'f', '', 0);
           }
         }
@@ -1054,7 +1054,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
     else {
       print "FAILED\n";
     }
-    watchdog_exception('tripal_feature', $e);
+    watchdog_exception('tripal_chado', $e);
     return 0;
   }
 
@@ -1071,7 +1071,7 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_derives_from($feature, $cvterm, $object,
+function tripal_chado_load_gff3_derives_from($feature, $cvterm, $object,
   $organism, $fmin, $fmax) {
 
   $type = $cvterm->name;
@@ -1100,12 +1100,12 @@ function tripal_feature_load_gff3_derives_from($feature, $cvterm, $object,
   if (!$type_id) {
     $result = chado_select_record('feature', array('type_id'), $values);
     if (count($result) > 1) {
-      watchdog("tripal_feature", "Cannot find feature type for, '%subject' , in 'derives_from' relationship. Multiple matching features exist with this uniquename.",
+      watchdog("tripal_chado", "Cannot find feature type for, '%subject' , in 'derives_from' relationship. Multiple matching features exist with this uniquename.",
         array('%subject' => $object), WATCHDOG_WARNING);
       return '';
     }
     else if (count($result) == 0) {
-      watchdog("tripal_feature", "Cannot find feature type for, '%subject' , in 'derives_from' relationship.",
+      watchdog("tripal_chado", "Cannot find feature type for, '%subject' , in 'derives_from' relationship.",
         array('%subject' => $object), WATCHDOG_WARNING);
       return '';
     }
@@ -1122,7 +1122,7 @@ function tripal_feature_load_gff3_derives_from($feature, $cvterm, $object,
   );
   $ofeature = chado_select_record('feature', array('feature_id'), $match);
   if (count($ofeature) == 0) {
-    tripal_report_error('tripal_feature', TRIPAL_ERROR, "Could not add 'Derives_from' relationship " .
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "Could not add 'Derives_from' relationship " .
       "for %uniquename and %subject.  Subject feature, '%subject', " .
       "cannot be found", array('%uniquename' => $feature->uniquename, '%subject' => $subject));
     return;
@@ -1138,7 +1138,7 @@ function tripal_feature_load_gff3_derives_from($feature, $cvterm, $object,
     );
     $result = chado_insert_record('tripal_gffprotein_temp', $values);
     if (!$result) {
-      tripal_report_error('tripal_feature', TRIPAL_ERROR, "Cound not save record in temporary protein table, Cannot continue.", array());
+      tripal_report_error('tripal_chado', TRIPAL_ERROR, "Cound not save record in temporary protein table, Cannot continue.", array());
       exit;
     }
   }
@@ -1164,7 +1164,7 @@ function tripal_feature_load_gff3_derives_from($feature, $cvterm, $object,
   // finally insert the relationship if it doesn't exist
   $ret = chado_insert_record('feature_relationship', $values);
   if (!$ret) {
-    tripal_report_error("tripal_feature", TRIPAL_WARNING, "Could not add 'Derives_from' relationship for $feature->uniquename and $subject",
+    tripal_report_error("tripal_chado", TRIPAL_WARNING, "Could not add 'Derives_from' relationship for $feature->uniquename and $subject",
       array());
   }
 }
@@ -1180,7 +1180,7 @@ function tripal_feature_load_gff3_derives_from($feature, $cvterm, $object,
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_parents($feature, $cvterm, $parents,
+function tripal_chado_load_gff3_parents($feature, $cvterm, $parents,
   $organism_id, $strand, $phase, $fmin, $fmax) {
 
   $uname = $feature->uniquename;
@@ -1205,7 +1205,7 @@ function tripal_feature_load_gff3_parents($feature, $cvterm, $parents,
     );
     $result = chado_select_record('tripal_gff_temp', array('type_name'), $values);
     if (count($result) == 0) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot find parent: %parent", array('%parent' => $parent));
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot find parent: %parent", array('%parent' => $parent));
        return '';
     }
     $parent_type = $result[0]->type_name;
@@ -1243,7 +1243,7 @@ function tripal_feature_load_gff3_parents($feature, $cvterm, $parents,
         );
         $result = chado_insert_record('feature_relationship', $values);
         if (!$result) {
-          tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to insert feature relationship '$uname' ($type) $rel_type '$parent' ($parent_type)",
+          tripal_report_error("tripal_chado", TRIPAL_WARNING, "Failed to insert feature relationship '$uname' ($type) $rel_type '$parent' ($parent_type)",
             array());
         }
       }
@@ -1261,13 +1261,13 @@ function tripal_feature_load_gff3_parents($feature, $cvterm, $parents,
         );
         $result = chado_insert_record('tripal_gffcds_temp', $values);
         if (!$result) {
-          tripal_report_error('tripal_feature', TRIPAL_ERROR, "Cound not save record in temporary CDS table, Cannot continue.", array());
+          tripal_report_error('tripal_chado', TRIPAL_ERROR, "Cound not save record in temporary CDS table, Cannot continue.", array());
           exit;
         }
       }
     }
     else {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot establish relationship '$uname' ($type) $rel_type '$parent' ($parent_type): Cannot find the parent",
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot establish relationship '$uname' ($type) $rel_type '$parent' ($parent_type): Cannot find the parent",
         array());
     }
   }
@@ -1281,7 +1281,7 @@ function tripal_feature_load_gff3_parents($feature, $cvterm, $parents,
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
+function tripal_chado_load_gff3_dbxref($feature, $dbxrefs) {
 
   // iterate through each of the dbxrefs
   foreach ($dbxrefs as $dbxref) {
@@ -1312,7 +1312,7 @@ function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
         $db = chado_select_record('db', array('db_id'), $values);
       }
       else {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot find or add the database $dbname", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot find or add the database $dbname", array());
         return 0;
       }
     }
@@ -1357,7 +1357,7 @@ function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
       );
       $success = chado_insert_record('feature_dbxref', $values);
       if (!$success) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to insert Dbxref: $dbname:$accession", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Failed to insert Dbxref: $dbname:$accession", array());
         return 0;
       }
     }
@@ -1373,7 +1373,7 @@ function tripal_feature_load_gff3_dbxref($feature, $dbxrefs) {
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
+function tripal_chado_load_gff3_ontology($feature, $dbxrefs) {
 
    // iterate through each of the dbxrefs
   foreach ($dbxrefs as $dbxref) {
@@ -1389,7 +1389,7 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
       // now look for the name without the 'DB:' prefix.
       $db = chado_select_record('db', array('db_id'), array('name' => "$dbname"));
       if (sizeof($db) == 0) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Database, $dbname, is not present. Cannot associate term: $dbname:$accession", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Database, $dbname, is not present. Cannot associate term: $dbname:$accession", array());
         return 0;
       }
     }
@@ -1399,7 +1399,7 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
     $dbxref = chado_select_record('dbxref', array('dbxref_id'),
       array('accession' => $accession, 'db_id' => $db->db_id));
     if (sizeof($dbxref) == 0) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Accession, $accession is missing for reference: $dbname:$accession", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Accession, $accession is missing for reference: $dbname:$accession", array());
       return 0;
     }
     $dbxref = $dbxref[0];
@@ -1412,7 +1412,7 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
       $cvterm = chado_select_record('cvterm_dbxref', array('cvterm_id'), array(
         'dbxref_id' => $dbxref->dbxref_id));
       if (sizeof($cvterm) == 0) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "CV Term is missing for reference: $dbname:$accession", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "CV Term is missing for reference: $dbname:$accession", array());
         return 0;
       }
     }
@@ -1435,7 +1435,7 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
       $success = chado_insert_record('feature_cvterm', $values);
 
       if (!$success) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to insert ontology term: $dbname:$accession", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Failed to insert ontology term: $dbname:$accession", array());
         return 0;
       }
     }
@@ -1451,7 +1451,7 @@ function tripal_feature_load_gff3_ontology($feature, $dbxrefs) {
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_alias($feature, $aliases) {
+function tripal_chado_load_gff3_alias($feature, $aliases) {
 
   // make sure we have a 'synonym_type' vocabulary
   $select = array('name' => 'synonym_type');
@@ -1465,7 +1465,7 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
     );
     $success = chado_insert_record('cv', $values);
     if (!$success) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to add the synonyms type vocabulary", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Failed to add the synonyms type vocabulary", array());
       return 0;
     }
     // now that we've added the cv we need to get the record
@@ -1497,7 +1497,7 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
     );
     $syntype = tripal_insert_cvterm($term, array('update_existing' => TRUE));
     if (!$syntype) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot add synonym type: internal:$type", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot add synonym type: internal:$type", array());
       return 0;
     }
   }
@@ -1523,7 +1523,7 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
       );
       $success = chado_insert_record('synonym', $values);
       if (!$success) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot add alias $alias to synonym table", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot add alias $alias to synonym table", array());
         return 0;
       }
       $result = chado_select_record('synonym', array('*'), $select);
@@ -1549,14 +1549,14 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
       ";
       $status = chado_query($psql);
       if (!$status) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot prepare statement 'ins_pub_uniquename_typeid", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot prepare statement 'ins_pub_uniquename_typeid", array());
         return 0;
       }
 
       // insert the null pub
       $result = chado_query($pub_sql, array(':uname' => 'null', ':type_id' => 'null'))->fetchObject();
       if (!$result) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot add null publication needed for setup of alias", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot add null publication needed for setup of alias", array());
         return 0;
       }
       $result = chado_select_record('pub', array('*'), $select);
@@ -1584,7 +1584,7 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
       $success = chado_insert_record('feature_synonym', $values);
 
       if (!$success) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot add alias $alias to feature synonym table", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot add alias $alias to feature synonym table", array());
         return 0;
       }
     }
@@ -1608,7 +1608,7 @@ function tripal_feature_load_gff3_alias($feature, $aliases) {
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uniquename,
+function tripal_chado_load_gff3_feature($organism, $analysis_id, $cvterm, $uniquename,
   $name, $residues, $is_analysis = 'f', $is_obsolete = 'f', $add_only, $score) {
 
   // Check to see if the feature already exists.
@@ -1650,7 +1650,7 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
     );
     $feature = (object) chado_insert_record('feature', $values);
     if (!$feature) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to insert feature '$uniquename' ($cvterm->name)", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Failed to insert feature '$uniquename' ($cvterm->name)", array());
       return 0;
     }
   }
@@ -1668,7 +1668,7 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
     );
     $result = chado_update_record('feature', $match, $values);
     if (!$result) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to update feature '$uniquename' ($cvterm->name)", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Failed to update feature '$uniquename' ($cvterm->name)", array());
       return 0;
     }
   }
@@ -1691,7 +1691,7 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
       $af_values['significance'] = $score;
     }
     if (!chado_insert_record('analysisfeature', $af_values)) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Could not add analysisfeature record: $analysis_id, $feature->feature_id", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Could not add analysisfeature record: $analysis_id, $feature->feature_id", array());
     }
   }
   else {
@@ -1706,7 +1706,7 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
     if (!$add_only) {
       $ret = chado_update_record('analysisfeature', $af_values, $new_vals);
       if (!$ret) {
-        tripal_report_error("tripal_feature", TRIPAL_WARNING, "Could not update analysisfeature record: $analysis_id, $feature->feature_id", array());
+        tripal_report_error("tripal_chado", TRIPAL_WARNING, "Could not update analysisfeature record: $analysis_id, $feature->feature_id", array());
       }
     }
   }
@@ -1735,7 +1735,7 @@ function tripal_feature_load_gff3_feature($organism, $analysis_id, $cvterm, $uni
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fmin,
+function tripal_chado_load_gff3_featureloc($feature, $organism, $landmark, $fmin,
   $fmax, $strand, $phase, $is_fmin_partial, $is_fmax_partial, $residue_info, $locgroup,
   $landmark_type_id = '', $landmark_organism_id = '', $create_landmark = 0,
   $landmark_is_target = 0) {
@@ -1784,7 +1784,7 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
             );
             $results = chado_insert_record('feature', $values);
             if (!$results) {
-              tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot find landmark feature: '%landmark', nor could it be inserted",
+              tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot find landmark feature: '%landmark', nor could it be inserted",
                 array('%landmark' => $landmark));
               return 0;
             }
@@ -1792,14 +1792,14 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
             $srcfeature->feature_id = $results['feature_id'];
          }
          else {
-           tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot find unique landmark feature: '%landmark'.",
+           tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot find unique landmark feature: '%landmark'.",
              array('%landmark' => $landmark));
            return 0;
          }
        }
     }
     elseif (count($results) > 1) {
-       tripal_report_error("tripal_feature", TRIPAL_WARNING, "multiple landmarks exist with the name: '%landmark'.  Cannot
+       tripal_report_error("tripal_chado", TRIPAL_WARNING, "multiple landmarks exist with the name: '%landmark'.  Cannot
          resolve which one to use. Cannot add the feature location record",
          array('%landmark' => $landmark));
        return 0;
@@ -1809,7 +1809,7 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
     }
   }
   elseif (count($results) > 1) {
-    tripal_report_error("tripal_feature", TRIPAL_WARNING, "multiple landmarks exist with the name: '%landmark'.  Cannot
+    tripal_report_error("tripal_chado", TRIPAL_WARNING, "multiple landmarks exist with the name: '%landmark'.  Cannot
       resolve which one to use. Cannot add the feature location record",
       array('%landmark' => $landmark));
     return 0;
@@ -1899,7 +1899,7 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
     }
     $success = chado_insert_record('featureloc', $values);
     if (!$success) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Failed to insert featureloc", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Failed to insert featureloc", array());
       exit;
       return 0;
     }
@@ -1916,7 +1916,7 @@ function tripal_feature_load_gff3_featureloc($feature, $organism, $landmark, $fm
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_property($feature, $property, $value) {
+function tripal_chado_load_gff3_property($feature, $property, $value) {
 
   // first make sure the cvterm exists.  if not, then add it
   $select = array(
@@ -1939,7 +1939,7 @@ function tripal_feature_load_gff3_property($feature, $property, $value) {
     );
     $cvterm = (object) tripal_insert_cvterm($term, array('update_existing' => FALSE));
     if (!$cvterm) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "Cannot add cvterm, $property", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "Cannot add cvterm, $property", array());
       return 0;
     }
   }
@@ -1980,7 +1980,7 @@ function tripal_feature_load_gff3_property($feature, $property, $value) {
     );
     $result = chado_insert_record('featureprop', $values);
     if (!$result) {
-      tripal_report_error("tripal_feature", TRIPAL_WARNING, "cannot add featureprop, $property", array());
+      tripal_report_error("tripal_chado", TRIPAL_WARNING, "cannot add featureprop, $property", array());
     }
   }
 }
@@ -1998,7 +1998,7 @@ function tripal_feature_load_gff3_property($feature, $property, $value) {
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read, &$line_num, $filesize, $job) {
+function tripal_chado_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read, &$line_num, $filesize, $job) {
   print "\nLoading FASTA sequences\n";
   $residues = '';
   $id = NULL;
@@ -2032,7 +2032,7 @@ function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read,
         $values = array('uniquename' => $id);
         $result = chado_select_record('tripal_gff_temp', array('*'), $values);
         if (count($result) == 0) {
-          tripal_report_error('tripal_feature', TRIPAL_WARNING, 'Cannot find feature to assign FASTA sequence: %uname',
+          tripal_report_error('tripal_chado', TRIPAL_WARNING, 'Cannot find feature to assign FASTA sequence: %uname',
              array('%uname' => $id));
         }
         else {
@@ -2061,7 +2061,7 @@ function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read,
   $values = array('uniquename' => $id);
   $result = chado_select_record('tripal_gff_temp', array('*'), $values);
   if (count($result) == 0) {
-    tripal_report_error('tripal_feature', TRIPAL_WARNING, 'Cannot find feature to assign FASTA sequence: %uname',
+    tripal_report_error('tripal_chado', TRIPAL_WARNING, 'Cannot find feature to assign FASTA sequence: %uname',
        array('%uname' => $id));
   }
   else {
@@ -2089,7 +2089,7 @@ function tripal_feature_load_gff3_fasta($fh, $interval, &$num_read, &$intv_read,
  *
  * @ingroup gff3_loader
  */
-function tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $target_type, $create_target, $attr_locgroup) {
+function tripal_chado_load_gff3_target($feature, $tags, $target_organism_id, $target_type, $create_target, $attr_locgroup) {
   // format is: "target_id start end [strand]", where strand is optional and may be "+" or "-"
   $matched = preg_match('/^(.*?)\s+(\d+)\s+(\d+)(\s+[\+|\-])*$/', trim($tags['Target'][0]), $matches);
 
@@ -2142,13 +2142,13 @@ function tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $
           $t_organism_id = $torganism[0]->organism_id;
         }
         else {
-          tripal_report_error('tripal_feature', TRIPAL_WARNING, "Cannot find organism for target %target.",
+          tripal_report_error('tripal_chado', TRIPAL_WARNING, "Cannot find organism for target %target.",
             array('%target' => $gff_target_organism));
           $t_organism_id = '';
         }
       }
       else {
-        tripal_report_error('tripal_feature', TRIPAL_WARNING, "The target_organism attribute is improperly formatted: %target.
+        tripal_report_error('tripal_chado', TRIPAL_WARNING, "The target_organism attribute is improperly formatted: %target.
           It should be target_organism=genus:species.",
           array('%target' => $gff_target_organism));
         $t_organism_id = '';
@@ -2170,7 +2170,7 @@ function tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $
         $t_type_id = $type[0]->cvterm_id;
       }
       else {
-        tripal_report_error('tripal_feature', TRIPAL_ERROR, "The target type does not exist in the sequence ontology: %type. ",
+        tripal_report_error('tripal_chado', TRIPAL_ERROR, "The target type does not exist in the sequence ontology: %type. ",
           array('%type' => $target_type));
         exit;
       }
@@ -2202,7 +2202,7 @@ function tripal_feature_load_gff3_target($feature, $tags, $target_organism_id, $
           $t_type_id = $synonym->cvterm_id;
         }
         else {
-          tripal_report_error('tripal_feature', TRIPAL_WARNING, "The target_type attribute does not exist in the sequence ontology: %type. ",
+          tripal_report_error('tripal_chado', TRIPAL_WARNING, "The target_type attribute does not exist in the sequence ontology: %type. ",
             array('%type' => $gff_target_type));
           $t_type_id = '';
         }
@@ -2211,13 +2211,13 @@ 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_feature_load_gff3_featureloc($feature, $organism, $target_feature, $target_fmin,
+    tripal_chado_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);
   }
   // the target attribute is not correctly formatted
   else {
-    tripal_report_error('tripal_feature', TRIPAL_ERROR, "Could not add 'Target' alignment as it is improperly formatted:  '%target'",
+    tripal_report_error('tripal_chado', TRIPAL_ERROR, "Could not add 'Target' alignment as it is improperly formatted:  '%target'",
       array('%target' => $tags['Target'][0]));
   }
 }

+ 93 - 93
tripal_cv/includes/tripal_cv.obo_loader.inc → tripal_chado/includes/loaders/tripal_chado.obo_loader.inc

@@ -6,7 +6,7 @@
 
 /**
  * @defgroup tripal_obo_loader Ontology Loader
- * @ingroup tripal_cv
+ * @ingroup tripal_chado
  * @{
  * Functions to aid in loading ontologies into the chado cv module
  * @}
@@ -26,10 +26,10 @@
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_form($form, &$form_state) {
+function tripal_chado_obo_form($form, &$form_state) {
 
   // get a list of db from chado for user to choose
-  $sql = "SELECT * FROM {tripal_cv_obo} ORDER BY name";
+  $sql = "SELECT * FROM {tripal_chado_obo} ORDER BY name";
   $results = db_query($sql);
 
   $obos = array();
@@ -79,7 +79,7 @@ function tripal_cv_obo_form($form, &$form_state) {
     '#type' => 'select',
     '#options' => $obos,
     '#ajax' => array(
-      'callback' => 'tripal_cv_obo_form_ajax_callback',
+      'callback' => 'tripal_chado_obo_form_ajax_callback',
       'wrapper' => 'obo-existing-fieldset',
     ),
   );
@@ -91,7 +91,7 @@ function tripal_cv_obo_form($form, &$form_state) {
     $uobo_url = '';
     $uobo_file = '';
 
-    $vocab = db_select('tripal_cv_obo', 't')
+    $vocab = db_select('tripal_chado_obo', 't')
       ->fields('t', array('name', 'path'))
       ->condition('obo_id', $obo_id)
       ->execute()
@@ -199,7 +199,7 @@ function tripal_cv_obo_form($form, &$form_state) {
     '#name' => 'add_new_obo',
   );
 
-  $form['#redirect'] = 'admin/tripal/tripal_cv/obo_loader';
+  $form['#redirect'] = 'admin/tripal/tripal_chado/obo_loader';
 
   return $form;
 }
@@ -209,7 +209,7 @@ function tripal_cv_obo_form($form, &$form_state) {
  * @param $form
  * @param $form_state
  */
-function tripal_cv_obo_form_validate($form, &$form_state) {
+function tripal_chado_obo_form_validate($form, &$form_state) {
   $obo_id    = $form_state['values']['obo_id'];
   $obo_name  = trim($form_state['values']['obo_name']);
   $obo_url   = trim($form_state['values']['obo_url']);
@@ -222,7 +222,7 @@ function tripal_cv_obo_form_validate($form, &$form_state) {
   if ($form_state['clicked_button']['#name'] == 'update_obo_details' or
       $form_state['clicked_button']['#name'] == 'update_load_obo') {
     // Get the current record
-    $vocab = db_select('tripal_cv_obo', 't')
+    $vocab = db_select('tripal_chado_obo', 't')
       ->fields('t', array('obo_id', 'name', 'path'))
       ->condition('name', $uobo_name)
       ->execute()
@@ -246,7 +246,7 @@ function tripal_cv_obo_form_validate($form, &$form_state) {
   }
   if ($form_state['clicked_button']['#name'] == 'add_new_obo') {
     // Get the current record
-    $vocab = db_select('tripal_cv_obo', 't')
+    $vocab = db_select('tripal_chado_obo', 't')
       ->fields('t', array('obo_id', 'name', 'path'))
       ->condition('name', $obo_name)
       ->execute()
@@ -282,7 +282,7 @@ function tripal_cv_obo_form_validate($form, &$form_state) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_form_submit($form, &$form_state) {
+function tripal_chado_obo_form_submit($form, &$form_state) {
 
   $obo_id    = $form_state['values']['obo_id'];
   $obo_name  = trim($form_state['values']['obo_name']);
@@ -295,7 +295,7 @@ function tripal_cv_obo_form_submit($form, &$form_state) {
   // If the user requested to alter the details then do that.
   if ($form_state['clicked_button']['#name'] == 'update_obo_details' or
       $form_state['clicked_button']['#name'] == 'update_load_obo') {
-    $success = db_update('tripal_cv_obo')
+    $success = db_update('tripal_chado_obo')
       ->fields(array(
         'name' => $uobo_name,
         'path' => $uobo_url ? $uobo_url : $uobo_file,
@@ -316,7 +316,7 @@ function tripal_cv_obo_form_submit($form, &$form_state) {
     tripal_submit_obo_job(array('obo_id' => $obo_id));
   }
   if ($form_state['clicked_button']['#name'] == 'add_new_obo') {
-    $success = db_insert('tripal_cv_obo')
+    $success = db_insert('tripal_chado_obo')
     ->fields(array(
       'name' => $obo_name,
       'path' => $obo_url ? $obo_url : $obo_file,
@@ -338,16 +338,16 @@ function tripal_cv_obo_form_submit($form, &$form_state) {
  * management after a user submits a job via the Load Onotloies form.
  *
  * @param $obo_id
- *   An obo_id from the tripal_cv_obo file that specifies which OBO file to import
+ *   An obo_id from the tripal_chado_obo file that specifies which OBO file to import
  * @param $job_id
  *   The job_id of the job from the Tripal jobs management system.
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_load_obo_v1_2_id($obo_id, $jobid = NULL) {
+function tripal_chado_load_obo_v1_2_id($obo_id, $jobid = NULL) {
 
   // Get the OBO reference.
-  $sql = "SELECT * FROM {tripal_cv_obo} WHERE obo_id = :obo_id";
+  $sql = "SELECT * FROM {tripal_chado_obo} WHERE obo_id = :obo_id";
   $obo = db_query($sql, array(':obo_id' => $obo_id))->fetchObject();
 
   // Convert the module name to the real path if present
@@ -359,20 +359,20 @@ function tripal_cv_load_obo_v1_2_id($obo_id, $jobid = NULL) {
 
   // if the reference is for a remote URL then run the URL processing function
   if (preg_match("/^http:\/\//", $obo->path) or preg_match("/^ftp:\/\//", $obo->path)) {
-    tripal_cv_load_obo_v1_2_url($obo->name, $obo->path, $jobid, 0);
+    tripal_chado_load_obo_v1_2_url($obo->name, $obo->path, $jobid, 0);
   }
   // if the reference is for a local file then run the file processing function
   else {
     // check to see if the file is located local to Drupal
     $dfile = $_SERVER['DOCUMENT_ROOT'] . base_path() . $obo->path;
     if (file_exists($dfile)) {
-      tripal_cv_load_obo_v1_2_file($obo->name, $dfile , $jobid, 0);
+      tripal_chado_load_obo_v1_2_file($obo->name, $dfile , $jobid, 0);
     }
     // if not local to Drupal, the file must be someplace else, just use
     // the full path provided
     else {
       if (file_exists($obo->path)) {
-        tripal_cv_load_obo_v1_2_file($obo->name, $obo->path, $jobid, 0);
+        tripal_chado_load_obo_v1_2_file($obo->name, $obo->path, $jobid, 0);
       }
       else {
         print "ERROR: counld not find OBO file: '$obo->path'\n";
@@ -395,21 +395,21 @@ function tripal_cv_load_obo_v1_2_id($obo_id, $jobid = NULL) {
  *   The job_id of the job from the Tripal jobs management system.
  * @param $is_new
  *   Set to TRUE if this is a new ontology that does not yet exist in the
- *   tripal_cv_obo table.  If TRUE the OBO will be added to the table.
+ *   tripal_chado_obo table.  If TRUE the OBO will be added to the table.
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_load_obo_v1_2_file($obo_name, $file, $jobid = NULL, $is_new = TRUE) {
+function tripal_chado_load_obo_v1_2_file($obo_name, $file, $jobid = NULL, $is_new = TRUE) {
   $newcvs = array();
 
   if ($is_new) {
     tripal_insert_obo($obo_name, $file);
   }
 
-  $success = tripal_cv_load_obo_v1_2($file, $jobid, $newcvs);
+  $success = tripal_chado_load_obo_v1_2($file, $jobid, $newcvs);
   if ($success) {
     // update the cvtermpath table
-    tripal_cv_load_update_cvtermpath($newcvs, $jobid);
+    tripal_chado_load_update_cvtermpath($newcvs, $jobid);
     print "\nDone\n";
   }
 }
@@ -428,11 +428,11 @@ function tripal_cv_load_obo_v1_2_file($obo_name, $file, $jobid = NULL, $is_new =
  *   The job_id of the job from the Tripal jobs management system.
  * @param $is_new
  *   Set to TRUE if this is a new ontology that does not yet exist in the
- *   tripal_cv_obo table.  If TRUE the OBO will be added to the table.
+ *   tripal_chado_obo table.  If TRUE the OBO will be added to the table.
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = TRUE) {
+function tripal_chado_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = TRUE) {
 
   $newcvs = array();
 
@@ -442,7 +442,7 @@ function tripal_cv_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = T
   $url_fh = fopen($url, "r");
   $obo_fh = fopen($temp, "w");
   if (!$url_fh) {
-    tripal_cv_obo_quiterror("Unable to download the remote OBO file at $url. Could a firewall be blocking outgoing connections? " .
+    tripal_chado_obo_quiterror("Unable to download the remote OBO file at $url. Could a firewall be blocking outgoing connections? " .
       " if you are unable to download the file you may manually downlod the OBO file and use the web interface to " .
       " specify the location of the file on your server.");
 
@@ -458,11 +458,11 @@ function tripal_cv_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = T
   }
 
   // second, parse the OBO
-  $success = tripal_cv_load_obo_v1_2($temp, $jobid, $newcvs);
+  $success = tripal_chado_load_obo_v1_2($temp, $jobid, $newcvs);
   if ($success) {
 
     // update the cvtermpath table
-    tripal_cv_load_update_cvtermpath($newcvs, $jobid);
+    tripal_chado_load_update_cvtermpath($newcvs, $jobid);
     print "Done\n";
   }
   // now remove the temp file
@@ -482,7 +482,7 @@ function tripal_cv_load_obo_v1_2_url($obo_name, $url, $jobid = NULL, $is_new = T
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_load_update_cvtermpath($newcvs, $jobid) {
+function tripal_chado_load_update_cvtermpath($newcvs, $jobid) {
 
   print "\nUpdating cvtermpath table.  This may take a while...\n";
   foreach ($newcvs as $namespace => $cvid) {
@@ -492,8 +492,8 @@ function tripal_cv_load_update_cvtermpath($newcvs, $jobid) {
 
 /**
  * Imports a given OBO file into Chado.  This function is usually called by
- * one of three wrapper functions:  tripal_cv_load_obo_v1_2_id,
- * tripal_cv_load_obo_v1_2_file or tirpal_cv_load_obo_v1_2_url. But, it can
+ * one of three wrapper functions:  tripal_chado_load_obo_v1_2_id,
+ * tripal_chado_load_obo_v1_2_file or tirpal_cv_load_obo_v1_2_url. But, it can
  * be called directly if the full path to an OBO file is available on the
  * file system.
  *
@@ -509,7 +509,7 @@ function tripal_cv_load_update_cvtermpath($newcvs, $jobid) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
+function tripal_chado_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
 
   $transaction = db_transaction();
   print "\nNOTE: Loading of this OBO file is performed using a database transaction. \n" .
@@ -529,14 +529,14 @@ function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
 
     // make sure we have an 'internal' and a '_global' database
     if (!tripal_insert_db(array('name' => 'internal'))) {
-      tripal_cv_obo_quiterror("Cannot add 'internal' database");
+      tripal_chado_obo_quiterror("Cannot add 'internal' database");
     }
     if (!tripal_insert_db(array('name' => '_global'))) {
-      tripal_cv_obo_quiterror("Cannot add '_global' database");
+      tripal_chado_obo_quiterror("Cannot add '_global' database");
     }
 
     // parse the obo file
-    $default_db = tripal_cv_obo_parse($file, $header, $jobid);
+    $default_db = tripal_chado_obo_parse($file, $header, $jobid);
 
     // add the CV for this ontology to the database.  The v1.2 definition
     // specifies a 'default-namespace' to be used if a 'namespace' is not
@@ -545,7 +545,7 @@ function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
     if (array_key_exists('default-namespace', $header)) {
       $defaultcv = tripal_insert_cv($header['default-namespace'][0], '');
       if (!$defaultcv) {
-        tripal_cv_obo_quiterror('Cannot add namespace ' . $header['default-namespace'][0]);
+        tripal_chado_obo_quiterror('Cannot add namespace ' . $header['default-namespace'][0]);
       }
       $newcvs[$header['default-namespace'][0]] = $defaultcv->cv_id;
     }
@@ -557,7 +557,7 @@ function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
       if (array_key_exists('ontology', $header)) {
         $defaultcv = tripal_insert_cv(strtoupper($header['ontology'][0]), '');
         if (!$defaultcv) {
-          tripal_cv_obo_quiterror('Cannot add namespace ' . strtoupper($header['ontology'][0]));
+          tripal_chado_obo_quiterror('Cannot add namespace ' . strtoupper($header['ontology'][0]));
         }
         $newcvs[strtoupper(strtoupper($header['ontology'][0]))] = $defaultcv->cv_id;
       }
@@ -571,12 +571,12 @@ function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
 
     // add any typedefs to the vocabulary first
     print "\nStep 2: Loading type defs...\n";
-    tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid);
+    tripal_chado_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid);
 
     // next add terms to the vocabulary
     print "\nStep 3: Loading terms...\n";
-    if (!tripal_cv_obo_process_terms($defaultcv, $jobid, $newcvs, $default_db)) {
-      tripal_cv_obo_quiterror('Cannot add terms from this ontology');
+    if (!tripal_chado_obo_process_terms($defaultcv, $jobid, $newcvs, $default_db)) {
+      tripal_chado_obo_quiterror('Cannot add terms from this ontology');
     }
   }
   catch (Exception $e) {
@@ -598,7 +598,7 @@ function tripal_cv_load_obo_v1_2($file, $jobid = NULL, &$newcvs) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_quiterror($message) {
+function tripal_chado_obo_quiterror($message) {
 
   tripal_report_error("T_obo_loader", TRIPAL_ERROR, $message, array());
   exit;
@@ -622,7 +622,7 @@ function tripal_cv_obo_quiterror($message) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
+function tripal_chado_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
   $sql = "SELECT * FROM {tripal_obo_temp} WHERE type = 'Typedef' ";
   $typedefs = chado_query($sql);
 
@@ -650,7 +650,7 @@ function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
       printf("%d of %d records. (%0.2f%%) Memory: %s bytes\r", $i, $count, $complete * 3, number_format(memory_get_usage()));
     }
 
-    tripal_cv_obo_process_term($term, $defaultcv->name, 1, $newcvs, $default_db);
+    tripal_chado_obo_process_term($term, $defaultcv->name, 1, $newcvs, $default_db);
 
     $i++;
   }
@@ -684,7 +684,7 @@ function tripal_cv_obo_load_typedefs($defaultcv, $newcvs, $default_db, $jobid) {
  *   The name of the default database.
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $default_db) {
+function tripal_chado_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $default_db) {
 
   $i = 0;
 
@@ -720,8 +720,8 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
     }
 
     // add/update this term
-    if (!tripal_cv_obo_process_term($term, $defaultcv->name, 0, $newcvs, $default_db)) {
-      tripal_cv_obo_quiterror("Failed to process terms from the ontology");
+    if (!tripal_chado_obo_process_term($term, $defaultcv->name, 0, $newcvs, $default_db)) {
+      tripal_chado_obo_quiterror("Failed to process terms from the ontology");
     }
 
     $i++;
@@ -757,14 +757,14 @@ function tripal_cv_obo_process_terms($defaultcv, $jobid = NULL, &$newcvs, $defau
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$newcvs, $default_db) {
+function tripal_chado_obo_process_term($term, $defaultcv, $is_relationship = 0, &$newcvs, $default_db) {
 
   // make sure we have a namespace for this term
   if (!array_key_exists('namespace', $term) and !($defaultcv or $defaultcv == '')) {
-    tripal_cv_obo_quiterror("Cannot add the term: no namespace defined. " . $term['id'][0]);
+    tripal_chado_obo_quiterror("Cannot add the term: no namespace defined. " . $term['id'][0]);
   }
 
-  // construct the term array for sending to the tripal_cv_add_cvterm function
+  // construct the term array for sending to the tripal_chado_add_cvterm function
   // for adding a new cvterm
   $t = array();
   $t['id'] = $term['id'][0];
@@ -789,7 +789,7 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
   // add the cvterm
   $cvterm = tripal_insert_cvterm($t, array('update_existing' => TRUE));
   if (!$cvterm) {
-    tripal_cv_obo_quiterror("Cannot add the term " . $term['id'][0]);
+    tripal_chado_obo_quiterror("Cannot add the term " . $term['id'][0]);
   }
 
   if (array_key_exists('namespace', $term)) {
@@ -802,8 +802,8 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
   }
   if (array_key_exists('alt_id', $term)) {
     foreach ($term['alt_id'] as $alt_id) {
-      if (!tripal_cv_obo_add_cvterm_dbxref($cvterm, $alt_id)) {
-        tripal_cv_obo_quiterror("Cannot add alternate id $alt_id");
+      if (!tripal_chado_obo_add_cvterm_dbxref($cvterm, $alt_id)) {
+        tripal_chado_obo_quiterror("Cannot add alternate id $alt_id");
       }
     }
   }
@@ -813,8 +813,8 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
   }
   // add synonyms for this cvterm
   if (array_key_exists('synonym', $term)) {
-    if (!tripal_cv_obo_add_synonyms($term, $cvterm)) {
-      tripal_cv_obo_quiterror("Cannot add synonyms");
+    if (!tripal_chado_obo_add_synonyms($term, $cvterm)) {
+      tripal_chado_obo_quiterror("Cannot add synonyms");
     }
   }
 
@@ -840,8 +840,8 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
       }
     }
 
-    if (!tripal_cv_obo_add_synonyms($term, $cvterm)) {
-      tripal_cv_obo_quiterror("Cannot add/update synonyms");
+    if (!tripal_chado_obo_add_synonyms($term, $cvterm)) {
+      tripal_chado_obo_quiterror("Cannot add/update synonyms");
     }
   }
 
@@ -850,8 +850,8 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
     $comments = $term['comment'];
     $j = 0;
     foreach ($comments as $comment) {
-      if (!tripal_cv_obo_add_cvterm_prop($cvterm, 'comment', $comment, $j)) {
-        tripal_cv_obo_quiterror("Cannot add/update cvterm property");
+      if (!tripal_chado_obo_add_cvterm_prop($cvterm, 'comment', $comment, $j)) {
+        tripal_chado_obo_quiterror("Cannot add/update cvterm property");
       }
       $j++;
     }
@@ -860,23 +860,23 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
   // add any other external dbxrefs
   if (array_key_exists('xref', $term)) {
     foreach ($term['xref'] as $xref) {
-      if (!tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref)) {
-        tripal_cv_obo_quiterror("Cannot add/update cvterm database reference (dbxref).");
+      if (!tripal_chado_obo_add_cvterm_dbxref($cvterm, $xref)) {
+        tripal_chado_obo_quiterror("Cannot add/update cvterm database reference (dbxref).");
       }
     }
   }
 
   if (array_key_exists('xref_analog', $term)) {
     foreach ($term['xref_analog'] as $xref) {
-      if (!tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref)) {
-        tripal_cv_obo_quiterror("Cannot add/update cvterm database reference (dbxref).");
+      if (!tripal_chado_obo_add_cvterm_dbxref($cvterm, $xref)) {
+        tripal_chado_obo_quiterror("Cannot add/update cvterm database reference (dbxref).");
       }
     }
   }
   if (array_key_exists('xref_unk', $term)) {
     foreach ($term['xref_unk'] as $xref) {
-      if (!tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref)) {
-        tripal_cv_obo_quiterror("Cannot add/update cvterm database reference (dbxref).");
+      if (!tripal_chado_obo_add_cvterm_dbxref($cvterm, $xref)) {
+        tripal_chado_obo_quiterror("Cannot add/update cvterm database reference (dbxref).");
       }
     }
   }
@@ -884,8 +884,8 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
   // add is_a relationships for this cvterm
   if (array_key_exists('is_a', $term)) {
     foreach ($term['is_a'] as $is_a) {
-      if (!tripal_cv_obo_add_relationship($cvterm, $defaultcv, 'is_a', $is_a, $is_relationship, $default_db)) {
-        tripal_cv_obo_quiterror("Cannot add relationship is_a: $is_a");
+      if (!tripal_chado_obo_add_relationship($cvterm, $defaultcv, 'is_a', $is_a, $is_relationship, $default_db)) {
+        tripal_chado_obo_quiterror("Cannot add relationship is_a: $is_a");
       }
     }
   }
@@ -903,8 +903,8 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
     foreach ($term['relationship'] as $value) {
       $rel = preg_replace('/^(.+?)\s.+?$/', '\1', $value);
       $object = preg_replace('/^.+?\s(.+?)$/', '\1', $value);
-      if (!tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel, $object, $is_relationship, $default_db)) {
-        tripal_cv_obo_quiterror("Cannot add relationship $rel: $object");
+      if (!tripal_chado_obo_add_relationship($cvterm, $defaultcv, $rel, $object, $is_relationship, $default_db)) {
+        tripal_chado_obo_quiterror("Cannot add relationship $rel: $object");
       }
     }
   }
@@ -942,7 +942,7 @@ function tripal_cv_obo_process_term($term, $defaultcv, $is_relationship = 0, &$n
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
+function tripal_chado_obo_add_relationship($cvterm, $defaultcv, $rel,
   $objname, $object_is_relationship = 0, $default_db = 'OBO_REL') {
 
   // make sure the relationship cvterm exists
@@ -971,14 +971,14 @@ function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
     );
     $relcvterm = tripal_insert_cvterm($term, array('update_existing' => FALSE));
     if (!$relcvterm) {
-      tripal_cv_obo_quiterror("Cannot find the relationship term in the current ontology or in the relationship ontology: $rel\n");
+      tripal_chado_obo_quiterror("Cannot find the relationship term in the current ontology or in the relationship ontology: $rel\n");
     }
   }
 
   // get the object term
-  $oterm = tripal_cv_obo_get_term($objname);
+  $oterm = tripal_chado_obo_get_term($objname);
   if (!$oterm) {
-    tripal_cv_obo_quiterror("Could not find object term $objname\n");
+    tripal_chado_obo_quiterror("Could not find object term $objname\n");
   }
 
   $objterm = array();
@@ -1003,7 +1003,7 @@ function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
 
   $objcvterm = tripal_insert_cvterm($objterm, array('update_existing' => TRUE));
   if (!$objcvterm) {
-    tripal_cv_obo_quiterror("Cannot add cvterm " . $oterm['name'][0]);
+    tripal_chado_obo_quiterror("Cannot add cvterm " . $oterm['name'][0]);
   }
 
   // check to see if the cvterm_relationship already exists, if not add it
@@ -1017,7 +1017,7 @@ function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
     $options = array('return_record' => FALSE);
     $success = chado_insert_record('cvterm_relationship', $values, $options);
     if (!$success) {
-      tripal_cv_obo_quiterror("Cannot add term relationship: '$cvterm->name' $rel '$objcvterm->name'");
+      tripal_chado_obo_quiterror("Cannot add term relationship: '$cvterm->name' $rel '$objcvterm->name'");
     }
   }
 
@@ -1032,7 +1032,7 @@ function tripal_cv_obo_add_relationship($cvterm, $defaultcv, $rel,
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_get_term($id) {
+function tripal_chado_obo_get_term($id) {
   $values = array('id' => $id);
   $result = chado_select_record('tripal_obo_temp', array('stanza'), $values);
   if (count($result) == 0) {
@@ -1051,7 +1051,7 @@ function tripal_cv_obo_get_term($id) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_add_synonyms($term, $cvterm) {
+function tripal_chado_obo_add_synonyms($term, $cvterm) {
 
   // make sure we have a 'synonym_type' vocabulary
   $syncv = tripal_insert_cv('synonym_type', 'A vocabulary added by the Tripal CV module OBO loader for storing synonym types.');
@@ -1090,7 +1090,7 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
         );
         $syntype = tripal_insert_cvterm($term, array('update_existing' => TRUE));
         if (!$syntype) {
-          tripal_cv_obo_quiterror("Cannot add synonym type: internal:$scope");
+          tripal_chado_obo_quiterror("Cannot add synonym type: internal:$scope");
         }
       }
 
@@ -1109,7 +1109,7 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
         $options = array('return_record' => FALSE);
         $success = chado_insert_record('cvtermsynonym', $values, $options);
         if (!$success) {
-          tripal_cv_obo_quiterror("Failed to insert the synonym for term: $name ($def)");
+          tripal_chado_obo_quiterror("Failed to insert the synonym for term: $name ($def)");
         }
       }
 
@@ -1123,7 +1123,7 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
       foreach ($dbxrefs as $dbxref) {
        $dbxref = preg_replace('/,_/',", ",$dbxref);
         if ($dbxref) {
-          tripal_cv_obo_add_cvterm_dbxref($syn,$dbxref);
+          tripal_chado_obo_add_cvterm_dbxref($syn,$dbxref);
         }
       }
       */
@@ -1146,7 +1146,7 @@ function tripal_cv_obo_add_synonyms($term, $cvterm) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
+function tripal_chado_obo_parse($obo_file, &$header, $jobid) {
   $in_header = 1;
   $stanza = array();
   $default_db = '_global';
@@ -1274,7 +1274,7 @@ function tripal_cv_obo_parse($obo_file, &$header, $jobid) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref) {
+function tripal_chado_obo_add_cvterm_dbxref($cvterm, $xref) {
 
   $dbname = preg_replace('/^(.+?):.*$/', '$1', $xref);
   $accession = preg_replace('/^.+?:\s*(.*?)(\{.+$|\[.+$|\s.+$|\".+$|$)/', '$1', $xref);
@@ -1282,7 +1282,7 @@ function tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref) {
   $dbxrefs = preg_replace('/^.+?\[(.+?)\].*?$/', '$1', $xref);
 
   if (!$accession) {
-    tripal_cv_obo_quiterror();
+    tripal_chado_obo_quiterror();
     tripal_report_error("T_obo_loader", TRIPAL_WARNING, "Cannot add a dbxref without an accession: '$xref'", NULL);
     return FALSE;
   }
@@ -1296,13 +1296,13 @@ function tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref) {
   // add the database
   $db = tripal_insert_db(array('name' => $dbname));
   if (!$db) {
-    tripal_cv_obo_quiterror("Cannot find database '$dbname' in Chado.");
+    tripal_chado_obo_quiterror("Cannot find database '$dbname' in Chado.");
   }
 
   // now add the dbxref
-  $dbxref = tripal_cv_obo_add_dbxref($db->db_id, $accession, '', $description);
+  $dbxref = tripal_chado_obo_add_dbxref($db->db_id, $accession, '', $description);
   if (!$dbxref) {
-    tripal_cv_obo_quiterror("Cannot find or add the database reference (dbxref)");
+    tripal_chado_obo_quiterror("Cannot find or add the database reference (dbxref)");
   }
 
   // finally add the cvterm_dbxref but first check to make sure it exists
@@ -1315,7 +1315,7 @@ function tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref) {
     $ins_options = array('return_record' => FALSE);
     $result = chado_insert_record('cvterm_dbxref', $values, $ins_options);
     if (!$result) {
-      tripal_cv_obo_quiterror("Cannot add cvterm_dbxref: $xref");
+      tripal_chado_obo_quiterror("Cannot add cvterm_dbxref: $xref");
       return FALSE;
     }
   }
@@ -1337,12 +1337,12 @@ function tripal_cv_obo_add_cvterm_dbxref($cvterm, $xref) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
+function tripal_chado_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
 
   // make sure the 'cvterm_property_type' CV exists
   $cv = tripal_insert_cv('cvterm_property_type', '');
   if (!$cv) {
-    tripal_cv_obo_quiterror("Cannot add/find cvterm_property_type cvterm");
+    tripal_chado_obo_quiterror("Cannot add/find cvterm_property_type cvterm");
   }
 
   // get the property type cvterm.  If it doesn't exist then we want to add it
@@ -1362,7 +1362,7 @@ function tripal_cv_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
     );
     $cvproptype = tripal_insert_cvterm($term, array('update_existing' => FALSE));
     if (!$cvproptype) {
-      tripal_cv_obo_quiterror("Cannot add cvterm property: internal:$property");
+      tripal_chado_obo_quiterror("Cannot add cvterm property: internal:$property");
       return FALSE;
     }
   }
@@ -1375,7 +1375,7 @@ function tripal_cv_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
     $values = array('cvterm_id' => $cvterm->cvterm_id);
     $success = chado_delete_record('cvtermprop', $values);
     if (!$success) {
-       tripal_cv_obo_quiterror("Could not remove existing properties to update property $property for term\n");
+       tripal_chado_obo_quiterror("Could not remove existing properties to update property $property for term\n");
        return FALSE;
     }
   }
@@ -1390,7 +1390,7 @@ function tripal_cv_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
   $options = array('return_record' => FALSE);
   $result = chado_insert_record('cvtermprop', $values, $options);
   if (!$result) {
-    tripal_cv_obo_quiterror("Could not add property $property for term\n");
+    tripal_chado_obo_quiterror("Could not add property $property for term\n");
     return FALSE;
   }
   return TRUE;
@@ -1410,7 +1410,7 @@ function tripal_cv_obo_add_cvterm_prop($cvterm, $property, $value, $rank) {
  *
  * @ingroup tripal_obo_loader
  */
-function tripal_cv_obo_add_dbxref($db_id, $accession, $version='', $description='') {
+function tripal_chado_obo_add_dbxref($db_id, $accession, $version='', $description='') {
 
   // check to see if the dbxref exists if not, add it
   $values = array(
@@ -1428,7 +1428,7 @@ function tripal_cv_obo_add_dbxref($db_id, $accession, $version='', $description=
     $ins_options = array('return_record' => FALSE);
     $result = chado_insert_record('dbxref', $ins_values, $ins_options);
     if (!$result) {
-      tripal_cv_obo_quiterror("Failed to insert the dbxref record $accession");
+      tripal_chado_obo_quiterror("Failed to insert the dbxref record $accession");
       return FALSE;
     }
     $result = chado_select_record('dbxref', array('dbxref_id'), $values, $options);
@@ -1437,6 +1437,6 @@ function tripal_cv_obo_add_dbxref($db_id, $accession, $version='', $description=
 }
 
 
-function tripal_cv_obo_form_ajax_callback($form, $form_state) {
+function tripal_chado_obo_form_ajax_callback($form, $form_state) {
   return $form['obo_existing'];
 }

+ 159 - 21
legacy/tripal_natural_diversity/includes/tripal_natural_diversity.schema.inc → tripal_chado/includes/tripal_chado.schema.inc

@@ -1,4 +1,115 @@
 <?php
+
+/**
+ * Implements hook_chado_schema_v1_11_analysisfeatureprop()
+ * Purpose: To describe the structure of 'analysisfeatureprop' to tripal
+ * @see chado_insert_record()
+ * @see chado_update_record()
+ * @see chado_select_record()
+ *
+ * @return
+ *    An array describing the 'analysisfeatureprop' table
+ *
+ * @ingroup tripal_chado_v1.11_schema_api
+ *
+ */
+function tripal_chado_chado_schema_v1_11_analysisfeatureprop() {
+  $description =  array(
+    'table' => 'analysisfeatureprop',
+    'fields' => array(
+      'analysisfeatureprop_id' => array(
+        'type' => 'serial',
+        'not NULL' => '1',
+      ),
+      'analysisfeature_id' => array(
+        'type' => 'int',
+        'not NULL' => '1',
+      ),
+      'type_id' => array(
+        'type' => 'int',
+        'not NULL' => '1',
+      ),
+      'value' => array(
+        'type' => 'text',
+        'not NULL' => '',
+      ),
+      'rank' => array(
+        'type' => 'int',
+        'not NULL' => '1',
+      ),
+    ),
+    'primary key' => array(
+      0 => 'analysisfeatureprop_id',
+    ),
+    'unique keys' => array(
+      'analysisfeature_id_type_id_rank' => array(
+        0 => 'analysisfeature_id',
+        1 => 'type_id',
+        2 => 'rank',
+      ),
+    ),
+    'indexes' => array(
+    ),
+    'foreign keys' => array(
+      'cvterm' => array(
+        'table' => 'cvterm',
+        'columns' => array(
+          'type_id' => 'cvterm_id',
+        ),
+      ),
+      'analysisfeature' => array(
+        'table' => 'analysisfeature',
+        'columns' => array(
+          'analysisfeature_id' => 'analysisfeature_id',
+        ),
+      ),
+    ),
+  );
+  return $description;
+}
+
+/**
+ * Implements hook_chado_schema_v1_2_tripal_obo_temp()
+ * Purpose: To describe the structure of 'tripal_obo_temp' to tripal
+ * @see chado_insert_record()
+ * @see chado_update_record()
+ * @see chado_select_record()
+ *
+ * @return
+ *    An array describing the 'tripal_obo_temp' table
+ *
+ * @ingroup tripal_chado_v1.2_schema_api
+ */
+function tripal_chado_chado_schema_v1_2_tripal_obo_temp() {
+  $schema = array(
+    'table' => 'tripal_obo_temp',
+    'fields' => array(
+      'id' => array(
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+      ),
+      'stanza' => array(
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+      'type' => array(
+        'type' => 'varchar',
+        'length' => '50',
+        'not null' => TRUE,
+      ),
+    ),
+    'indexes' => array(
+      'tripal_obo_temp_idx0' => array('id'),
+      'tripal_obo_temp_idx0' => array('type'),
+    ),
+    'unique keys' => array(
+      'tripal_obo_temp_uq0' => array('id'),
+    ),
+  );
+  return $schema;
+}
+
 /**
  * @file
  * Adds to the tripal schema description.
@@ -21,7 +132,7 @@
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment() {
+function tripal_chado_chado_schema_v1_11_nd_experiment() {
   $description = array();
 
   $description = array(
@@ -83,7 +194,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_contact() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_contact() {
   $description = array();
 
   $description = array(
@@ -137,7 +248,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_contact() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_dbxref() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_dbxref() {
   $description = array();
 
   $description = array(
@@ -191,7 +302,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_dbxref() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_genotype() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_genotype() {
   $description = array();
 
   $description = array(
@@ -245,7 +356,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_genotype() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_phenotype() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_phenotype() {
   $description = array();
 
   $description = array(
@@ -299,7 +410,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_phenotype() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_project() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_project() {
   $description = array();
 
   $description = array(
@@ -353,7 +464,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_project() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_protocol() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_protocol() {
   $description = array();
 
   $description = array(
@@ -407,7 +518,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_protocol() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_pub() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_pub() {
   $description = array();
 
   $description = array(
@@ -461,7 +572,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_pub() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_stock() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_stock() {
   $description = array();
 
   $description = array(
@@ -526,7 +637,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_stock() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_stockprop() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_stockprop() {
   $description = array();
 
   $description = array(
@@ -587,7 +698,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_stockprop() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_stock_dbxref() {
+function tripal_chado_chado_schema_v1_11_nd_experiment_stock_dbxref() {
   $description = array();
 
   $description = array(
@@ -641,7 +752,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_stock_dbxref(
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_experimentprop() {
+function tripal_chado_chado_schema_v1_11_nd_experimentprop() {
   $description = array();
 
   $description = array(
@@ -702,7 +813,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experimentprop() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_geolocation() {
+function tripal_chado_chado_schema_v1_11_nd_geolocation() {
   $description = array();
 
   $description = array(
@@ -750,7 +861,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_geolocation() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_geolocationprop() {
+function tripal_chado_chado_schema_v1_11_nd_geolocationprop() {
   $description = array();
 
   $description = array(
@@ -811,7 +922,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_geolocationprop() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_protocol() {
+function tripal_chado_chado_schema_v1_11_nd_protocol() {
   $description = array();
 
   $description = array(
@@ -827,7 +938,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_protocol() {
       ),
     ),
     'primary key' => array(
-     '0' => 'nd_protocol_id',
+      '0' => 'nd_protocol_id',
     ),
     'referring_tables' => array(
       'nd_experiment_protocol',
@@ -849,7 +960,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_protocol() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_protocol_reagent() {
+function tripal_chado_chado_schema_v1_11_nd_protocol_reagent() {
   $description = array();
 
   $description = array(
@@ -913,7 +1024,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_protocol_reagent() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_protocolprop() {
+function tripal_chado_chado_schema_v1_11_nd_protocolprop() {
   $description = array();
 
   $description = array(
@@ -974,7 +1085,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_protocolprop() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_reagent() {
+function tripal_chado_chado_schema_v1_11_nd_reagent() {
   $description = array();
 
   $description = array(
@@ -1029,7 +1140,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_reagent() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_reagent_relationship() {
+function tripal_chado_chado_schema_v1_11_nd_reagent_relationship() {
   $description = array();
 
   $description = array(
@@ -1085,7 +1196,7 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_reagent_relationship() {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_natural_diversity_chado_schema_v1_11_nd_reagentprop() {
+function tripal_chado_chado_schema_v1_11_nd_reagentprop() {
   $description = array();
 
   $description = array(
@@ -1135,3 +1246,30 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_reagentprop() {
 
   return $description;
 }
+
+/**
+ * Implements hook_chado_schema_v1_11_table()
+ * Purpose: To add descriptions and foreign keys to default table description
+ * Note: This array will be merged with the array from all other implementations
+ *
+ * @return
+ *    Array describing the genotype table
+ *
+ * @ingroup tripal_schema_api
+ */
+function tripal_chado_chado_schema_v1_11_genotype() {
+  $description = array();
+
+  $referring_tables = array(
+    'analysisfeature',
+    'feature_genotype',
+    'phendesc',
+    'phenotype_comparison',
+    'phenstatement',
+    'stock_genotype',
+  );
+  $description['referring_tables'] = $referring_tables;
+
+  return $description;
+
+}

+ 33 - 33
tripal_core/includes/tripal_core.chado_install.inc → tripal_chado/includes/tripal_core.chado_install.inc

@@ -7,9 +7,9 @@
 /**
  * Load Chado Schema Form
  *
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  */
-function tripal_core_chado_load_form() {
+function tripal_chado_chado_load_form() {
 
   // we want to force the version of Chado to be set properly
   $real_version = chado_get_version(TRUE);
@@ -49,7 +49,7 @@ function tripal_core_chado_load_form() {
   return $form;
 }
 
-function tripal_core_chado_load_form_validate($form, &$form_state) {
+function tripal_chado_chado_load_form_validate($form, &$form_state) {
   // We do not want to allow re-installation of Chado if other
   // Tripal modules are installed.  This is because the install files
   // of those modules may add content to Chado and reinstalling Chado
@@ -61,7 +61,7 @@ function tripal_core_chado_load_form_validate($form, &$form_state) {
     $modules = system_get_info('module');
     $list = array();
     foreach ($modules as $mname => $module) {
-      if (array_key_exists('dependencies', $module) and in_array('tripal_core', $module['dependencies'])) {
+      if (array_key_exists('dependencies', $module) and in_array('tripal_chado', $module['dependencies'])) {
         $list[] = $module['name'] . " ($mname)";
       }
     }
@@ -83,21 +83,21 @@ function tripal_core_chado_load_form_validate($form, &$form_state) {
 /**
  * Submit Load Chado Schema Form
  *
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  */
-function tripal_core_chado_load_form_submit($form, &$form_state) {
+function tripal_chado_chado_load_form_submit($form, &$form_state) {
   global $user;
   $action_to_do = trim($form_state['values']['action_to_do']);
   $args = array($action_to_do);
-  tripal_add_job($action_to_do, 'tripal_core', 'tripal_core_install_chado', $args, $user->uid);
+  tripal_add_job($action_to_do, 'tripal_chado', 'tripal_chado_install_chado', $args, $user->uid);
 }
 
 /**
  * Install Chado Schema
  *
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  */
-function tripal_core_install_chado($action) {
+function tripal_chado_install_chado($action) {
 
   $vsql = "
     INSERT INTO {chadoprop} (type_id, value)
@@ -110,10 +110,10 @@ function tripal_core_install_chado($action) {
   ";
 
   if ($action == 'Install Chado v1.2') {
-    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.2.sql';
-    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/initialize-1.2.sql';
-    if (tripal_core_reset_chado_schema()) {
-      $success = tripal_core_install_sql($schema_file);
+    $schema_file = drupal_get_path('module', 'tripal_chado') . '/chado_schema/default_schema-1.2.sql';
+    $init_file = drupal_get_path('module', 'tripal_chado') . '/chado_schema/initialize-1.2.sql';
+    if (tripal_chado_reset_chado_schema()) {
+      $success = tripal_chado_install_sql($schema_file);
       if ($success) {
         print "Install of Chado v1.2 (Step 1 of 2) Successful!\n";
       }
@@ -121,7 +121,7 @@ function tripal_core_install_chado($action) {
         print "Installation (Step 1 of 2) Problems!  Please check output above for errors.\n";
         exit;
       }
-      $success = tripal_core_install_sql($init_file);
+      $success = tripal_chado_install_sql($init_file);
       if ($success) {
         print "Install of Chado v1.2 (Step 2 of 2) Successful.\nInstallation Complete\n";
       }
@@ -137,9 +137,9 @@ function tripal_core_install_chado($action) {
     }
   }
   elseif ($action == 'Upgrade Chado v1.11 to v1.2') {
-    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.11-1.2-diff.sql';
-    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/upgrade-1.11-1.2.sql';
-    $success = tripal_core_install_sql($schema_file);
+    $schema_file = drupal_get_path('module', 'tripal_chado') . '/chado_schema/default_schema-1.11-1.2-diff.sql';
+    $init_file = drupal_get_path('module', 'tripal_chado') . '/chado_schema/upgrade-1.11-1.2.sql';
+    $success = tripal_chado_install_sql($schema_file);
     if ($success) {
       print "Upgrade from v1.11 to v1.2 (Step 1 of 2) Successful!\n";
     }
@@ -147,7 +147,7 @@ function tripal_core_install_chado($action) {
       print "Upgrade (Step 1 of 2) problems!  Please check output above for errors.\n";
       exit;
     }
-    $success = tripal_core_install_sql($init_file);
+    $success = tripal_chado_install_sql($init_file);
     if ($success) {
       print "Upgrade from v1.11 to v1.2 (Step 2 of 2) Successful.\nUpgrade Complete!\n";
     }
@@ -158,10 +158,10 @@ function tripal_core_install_chado($action) {
     chado_query($vsql, array(':version' => '1.2')); # set the version
   }
   elseif ($action == 'Install Chado v1.11') {
-    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.11.sql';
-    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/initialize-1.11.sql';
-    if (tripal_core_reset_chado_schema()) {
-      $success = tripal_core_install_sql($schema_file);
+    $schema_file = drupal_get_path('module', 'tripal_chado') . '/chado_schema/default_schema-1.11.sql';
+    $init_file = drupal_get_path('module', 'tripal_chado') . '/chado_schema/initialize-1.11.sql';
+    if (tripal_chado_reset_chado_schema()) {
+      $success = tripal_chado_install_sql($schema_file);
       if ($success) {
         print "Install of Chado v1.11 (Step 1 of 2) Successful!\n";
       }
@@ -169,7 +169,7 @@ function tripal_core_install_chado($action) {
         print "Installation (Step 1 of 2) Problems!  Please check output above for errors.\n";
         exit;
       }
-      $success = tripal_core_install_sql($init_file);
+      $success = tripal_chado_install_sql($init_file);
       if ($success) {
         print "Install of Chado v1.11 (Step 2 of 2) Successful.\nInstallation Complete!\n";
       }
@@ -189,9 +189,9 @@ function tripal_core_install_chado($action) {
  * Reset the Chado Schema
  * This drops the current chado and chado-related schema and re-creates it
  *
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  */
-function tripal_core_reset_chado_schema() {
+function tripal_chado_reset_chado_schema() {
 
   // drop current chado and chado-related schema
   if (chado_dbschema_exists('genetic_code')) {
@@ -235,9 +235,9 @@ function tripal_core_reset_chado_schema() {
  * @param $sql_file
  *   Contains SQL statements to be executed
  *
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  */
-function tripal_core_install_sql($sql_file) {
+function tripal_chado_install_sql($sql_file) {
 
   $chado_local = chado_dbschema_exists('chado');
 
@@ -369,12 +369,12 @@ function tripal_core_install_sql($sql_file) {
     }
     else {
       print "UNHANDLED $i, $in_string: $line";
-      tripal_core_chado_install_done();
+      tripal_chado_chado_install_done();
       return FALSE;
     }
     if (preg_match_all("/\n/", $query, $temp) > 100) {
       print "SQL query is too long.  Terminating:\n$query\n";
-      tripal_core_chado_install_done();
+      tripal_chado_chado_install_done();
       return FALSE;
     }
     if ($type and sizeof($stack) == 0) {
@@ -391,23 +391,23 @@ function tripal_core_install_sql($sql_file) {
       if (!$result) {
         $error  = pg_last_error();
         print "FAILED. Line  $i, $in_string\n$error:\n$query\n\n";
-        tripal_core_chado_install_done();
+        tripal_chado_chado_install_done();
         $success = 0;
         return $success;
       }
       $query = '';
     }
   }
-  tripal_core_chado_install_done();
+  tripal_chado_chado_install_done();
   return $success;
 }
 
 /**
  * Finish the Chado Schema Installation
  *
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  */
-function tripal_core_chado_install_done() {
+function tripal_chado_chado_install_done() {
 
   db_query("set search_path to default");
 }

+ 2 - 2
tripal_core/includes/tripal_core.custom_tables.inc → tripal_chado/includes/tripal_core.custom_tables.inc

@@ -9,7 +9,7 @@
 
 /**
  * @defgroup tripal_custom_tables Custom Chado Tables
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  * @{
  * Contains functions for creating, editing and deleting custom tables
  * on the Tripal website.
@@ -34,7 +34,7 @@ function tripal_custom_table_admin_view() {
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
-  $view = views_embed_view('tripal_core_admin_custom_table','default');
+  $view = views_embed_view('tripal_chado_admin_custom_table','default');
   if (isset($view)) {
     $output .= $view;
   }

+ 4 - 4
tripal_core/includes/tripal_core.mviews.inc → tripal_chado/includes/tripal_core.mviews.inc

@@ -7,7 +7,7 @@
 
 /**
  * @defgroup tripal_mviews Tripal Materialized Views
- * @ingroup tripal_core
+ * @ingroup tripal_chado
  * @{
  * Contains functions for viewing and editing of Materialized Views
  * on a Tripal website.
@@ -32,7 +32,7 @@ function tripal_mview_admin_view() {
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
-  $view = views_embed_view('tripal_core_admin_mviews','default');
+  $view = views_embed_view('tripal_chado_admin_mviews','default');
   if (isset($view)) {
     $output .= $view;
   }
@@ -210,7 +210,7 @@ function tripal_mviews_form($form, &$form_state = NULL, $mview_id = NULL) {
       $default_schema = $mview->mv_schema;
     }
     if (!$default_modulename) {
-      $default_modulename = $mview->modulename ? $mview->modulename : 'tripal_core';
+      $default_modulename = $mview->modulename ? $mview->modulename : 'tripal_chado';
     }
 
     if ($mview->mv_specs) {
@@ -569,7 +569,7 @@ function tripal_mviews_form_submit($form, &$form_state) {
   }
 
   if (!$modulename) {
-    $modulename = 'tripal_core';
+    $modulename = 'tripal_chado';
   }
 
   // if this is an edit action

+ 193 - 0
tripal_chado/tripal_chado.drush.inc

@@ -0,0 +1,193 @@
+<?php
+/**
+ * @file
+ * Contains function relating to drush-integration of this module.
+ */
+
+/**
+ * @defgroup tripal_drush Tripal Drush Integration
+ * @{
+ * Contains function relating to drush-integration of various tripal modules.
+ * @}
+ */
+
+/**
+ * Describes each drush command implemented by the module
+ *
+ * @return
+ *   The first line of description when executing the help for a given command
+ *
+ * @ingroup tripal_drush
+ */
+function tripal_chado_drush_help($command) {
+  switch ($command) {
+    // Tripal Materialized Views
+    case 'drush:tripal-update-mview':
+      return dt('Updates the specified materialized view.');
+      break;
+
+    // Chado Specific
+    case 'drush:tripal-chado-version':
+      return dt('Returns the current version of chado associated with this drupal site.');
+      break;
+    case 'drush:tripal-chadotable-desc':
+      return dt('Returns the table description as specified in the Tripal Schema API for the supplied table.');
+      break;
+
+  }
+}
+
+/**
+ * Registers a drush command and constructs the full help for that command.
+ *
+ * @return
+ *   And array of command descriptions
+ *
+ * @ingroup tripal_drush
+ */
+function tripal_chado_drush_command() {
+  $items = array();
+
+  $items['trp-refresh-mview'] = array(
+    'description' => dt('Refreshes the contents of the specified materialized view.'),
+    'arguments' => array(),
+    'examples' => array(
+      'By Materialized View ID' => 'drush trp-refresh-mview --mview=5',
+      'By Table Name' => 'drush trp-refresh-mview --table=organism_feature_count'
+    ),
+    'options' => array(
+      'mview' => dt('The ID of the materialized view to update'),
+      'table' => dt('The name of the materialized view table to update.'),
+    ),
+  );
+
+  $items['trp-get-cversion'] = array(
+    'description' => dt('Returns the current installed version of Chado.'),
+    'arguments' => array(),
+    'examples' => array(
+      'Standard Example' => 'drush trp-get-cversion',
+    ),
+  );
+  $items['trp-get-table'] = array(
+    'description' => dt('Returns a table description in Drupal Schema API format.'),
+    'arguments' => array(),
+    'examples' => array(
+      'By Table Name' => 'drush trp-get-table --table=feature',
+      'By Section' => 'drush trp-get-table --table=feature --section=fields'
+    ),
+    'options' => array(
+      'table' => array(
+        'description' => dt('The name of the table. The table can be a true Chado table or a custom Chado table.'),
+        'required' => TRUE,
+      ),
+      'section' => dt('Only return the specified section of the schema array. Possible sections include: description, fields, primary key, unique keys, foreign keys, indexes, referring_tables.'),
+    ),
+  );
+
+
+  return $items;
+}
+
+/**
+ * Set the user to run a drush job.
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_chado_set_user($username) {
+  if ($username) {
+    $sql = "SELECT uid FROM {users} WHERE name = :name";
+    $results = db_query($sql, array(':name' => $username));
+    $u = $results->fetchObject();
+    if (!$u) {
+      drush_print('ERROR: Please provide a valid username (--username argument) for running this job.');
+      exit;
+    }
+    global $user;
+    $user = user_load($u->uid);
+    return $u->uid;
+  }
+  else {
+    drush_print('ERROR: Please provide a username (--username argument) for running this job.');
+    exit;
+  }
+}
+
+
+
+/**
+ * Updates the specified materialized view
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_chado_trp_refresh_mview() {
+  $mview_id   = drush_get_option('mview');
+  $table_name = drush_get_option('table');
+
+  // Either table_name or mview is required
+  if (!$mview_id) {
+    if ($table_name) {
+      // if table_name supplied use that to get mview_id
+      $sql = "SELECT mview_id FROM {tripal_mviews} WHERE mv_table = :mv_table";
+      $results = db_query($sql, array(':mv_table' => $table_name));
+      $r = $resuls->fetchObject();
+      if (!$r->mview_id) {
+        drush_set_error('No Materialized View associated with that table_name.');
+      }
+      $mview_id=$r->mview_id;
+    }
+    else {
+      drush_set_error('Plese provide one option of --mview or --table.');
+    }
+  }
+
+  drush_print('Updating the Materialized View with ID=' . $mview_id);
+  $status = tripal_populate_mview($mview_id);
+  if ($status) {
+    drush_log('Materialized View Updated', 'ok');
+  }
+  else {
+    drush_set_error('Update failed.');
+  }
+}
+
+/**
+ * Returns the current version of chado.
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_chado_trp_get_cversion() {
+  $version = $GLOBALS["exact_chado_version"];
+  drush_print('Current Chado Version: ' . $version);
+}
+
+/**
+ * Returns the Tripal Schema API Description of the given table
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_chado_trp_get_table() {
+  $section = drush_get_option('section');
+  $table_name = drush_get_option('table');
+
+  drush_print("Schema API Description for $table_name:");
+  $desc = chado_get_schema($table_name);
+
+  if (!empty($section)) {
+    drush_print("$section = " . print_r($desc[$section], TRUE));
+  }
+  else {
+    drush_print(print_r($desc, TRUE));
+  }
+}
+
+/**
+ * Clean-up orphaned Drupal nodes and chado records.
+ *
+ * @ingroup tripal_drush
+ */
+function drush_tripal_chado_trp_clean_nodes() {
+  $table = drush_get_option('table');
+
+  chado_cleanup_orphaned_nodes($table, 0);
+}
+

+ 1 - 3
tripal_chado/tripal_chado.info

@@ -7,8 +7,6 @@ version = 7.x-2.0
 
 stylesheets[all][] = theme/css/tripal_chado.css
 
-dependencies[] = tripal_core
+dependencies[] = tripal
 dependencies[] = tripal_entities
-dependencies[] = tripal_db
-dependencies[] = tripal_cv
 dependencies[] = date

+ 163 - 1
tripal_chado/tripal_chado.install

@@ -1,6 +1,15 @@
 <?php
 
 function tripal_chado_install() {
+  // The foreign key specification doesn't really add one to the
+  // Drupal schema, it is just used internally, but we want one.
+  db_query('
+      ALTER TABLE {tripal_custom_tables}
+      ADD CONSTRAINT tripal_custom_tables_fk1
+      FOREIGN KEY (mview_id) REFERENCES {tripal_mviews} (mview_id)
+      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
+  ');
+
   // Unfortunately, some Chado base tables do not have a type_id, so we must
   // take special action for those tables.  These include: organism and
   // analysis. Until we can find an appropriate controlled vocabulary
@@ -78,6 +87,20 @@ function tripal_chado_install() {
   }
 }
 
+/**
+ * Implementation of hook_uninstall().
+ *
+ * @ingroup tripal
+ */
+function tripal_chado_uninstall() {
+
+  // Drop the foreign key between tripal_custom_tables and tripal_mviews
+  // so that Drupal can then drop the tables
+  db_query('
+    ALTER TABLE {tripal_custom_tables}
+    DROP CONSTRAINT tripal_custom_tables_fk1 CASCADE
+  ');
+}
 
 /**
  * Implements hook_schema().
@@ -86,6 +109,22 @@ function tripal_chado_schema() {
 
   // Links TripalEntity entities to the chado record.
   $schema['chado_entity'] = tripal_chado_chado_entity_schema();
+  $schema['tripal_mviews'] = tripal_chado_tripal_mviews_schema();
+  $schema['tripal_custom_tables'] = tripal_chado_tripal_custom_tables_schema();
+
+  // if this module is already installed and enabled, then we want to provide
+  // the schemas for all of the custom tables.  This will allow Views to
+  // see the schemas.  We check if the module is installed because during
+  // installation we don't want to make these custom tables available as we don't
+  // want them created in the Drupal database.  The custom tables go in the
+  // Chado database.
+  if (db_table_exists('tripal_custom_tables')) {
+    $sql = 'SELECT * FROM {tripal_custom_tables}';
+    $results = db_query($sql);
+    foreach ($results as $custom) {
+      $schema[$custom->table_name] = unserialize($custom->schema);
+    }
+  }
 
   return $schema;
 }
@@ -94,7 +133,130 @@ function tripal_chado_schema() {
  * @section
  * Schema Definitions.
  */
-
+/**
+ * Describes the Tripal Custom Tables (tripal_custom_tables) table
+ * This keeps track of tables created by Tripal and stored in chado that may or may not
+ * also be materialized views.
+ *
+ * @ingroup tripal
+ */
+function tripal_chado_tripal_custom_tables_schema() {
+  return array(
+    'fields' => array(
+      'table_id' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not NULL' => TRUE
+      ),
+      'table_name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not NULL' => TRUE
+      ),
+      'schema' => array(
+        'type' => 'text',
+        'not NULL' => TRUE
+      ),
+      'mview_id' => array(
+        'type' => 'int',
+        'not NULL' => FALSE
+      )
+    ),
+    'indexes' => array(
+      'table_id' => array('table_id'),
+    ),
+    'primary key' => array('table_id'),
+    'foreign keys' => array(
+      'tripal_mviews' => array(
+        'table' => 'tripal_mviews',
+        'columns' => array(
+          'mview_id' => 'mview_id'
+        ),
+      ),
+    ),
+  );
+}
+/**
+ * Describes the Tripal Materialized View (tripal_mviews) table
+ * This table keeps track of all materialized views created by Tripal and stored in chado
+ *
+ * @ingroup tripal
+ */
+function tripal_chado_tripal_mviews_schema() {
+  return array(
+    'fields' => array(
+      'mview_id' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not NULL' => TRUE
+      ),
+      'name' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not NULL' => TRUE
+      ),
+      'modulename' => array(
+        'type' => 'varchar',
+        'length' => 50,
+        'not NULL' => TRUE,
+        'description' => 'The module name that provides the callback for this job'
+      ),
+      'mv_table' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not NULL' => FALSE
+      ),
+      'mv_specs' => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => FALSE
+      ),
+      'mv_schema' => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => FALSE
+      ),
+      'indexed' => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => FALSE
+      ),
+      'query' => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => TRUE
+      ),
+      'special_index' => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => FALSE
+      ),
+      'last_update' => array(
+        'type' => 'int',
+        'not NULL' => FALSE,
+        'description' => 'UNIX integer time'
+      ),
+      'status'        => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => FALSE
+      ),
+      'comment' => array(
+        'type' => 'text',
+        'size' => 'normal',
+        'not NULL' => FALSE
+      ),
+    ),
+    'indexes' => array(
+      'mview_id' => array('mview_id')
+    ),
+    'unique keys' => array(
+      'mv_table' => array('mv_table'),
+      'mv_name' => array('name'),
+    ),
+    'primary key' => array('mview_id'),
+  );
+}
 
 /**
  * Links Biological Data Entities to the chado "base" table the data is stored in.

+ 339 - 1
tripal_chado/tripal_chado.module

@@ -1,10 +1,282 @@
 <?php
 
+// APPLICATION PROGRAMMER INTERFACE -------------
+// Chado API
 require_once "api/tripal_chado.api.inc";
+require_once 'api/tripal_chado.general.api.inc';
+require_once 'api/tripal_chado.query.api.inc';
+require_once 'api/tripal_chado.variables.api.inc';
+require_once 'api/tripal_chado.schema.api.inc';
+require_once 'api/tripal_chado.custom_tables.api.inc';
+require_once 'api/tripal_chado.mviews.api.inc';
+require_once 'api/tripal_chado.schema_v1.2.api.inc';
+require_once 'api/tripal_chado.schema_v1.11.api.inc';
+
+require_once 'api/modules/tripal_chado.analysis.api.inc';
+require_once 'api/modules/tripal_chado.contact.api.inc';
+require_once 'api/modules/tripal_chado.cv.api.inc';
+require_once 'api/modules/tripal_chado.db.api.inc';
+require_once 'api/modules/tripal_chado.feature.api.inc';
+require_once 'api/modules/tripal_chado.organism.api.inc';
+require_once 'api/modules/tripal_chado.pub.api.inc';
+require_once 'api/modules/tripal_chado.stock.api.inc';
+
 require_once "includes/tripal_chado.entity.inc";
+require_once "includes/tripal_chado.schema.inc";
 require_once "includes/tripal_chado.term_storage.inc";
 require_once "includes/tripal_chado.field_storage.inc";
 
+tripal_chado_set_globals();
+
+/**
+ * This function is used to set the global Chado variables
+ *
+ * @ingroup tripal_chado
+*/
+function tripal_chado_set_globals() {
+  // these global variables are meant to be accessed by all Tripal
+  // modules to find the chado version installed and if Chado is local.
+  // these variables are stored as globals rather than using the drupal_set_variable
+  // functions because the Drupal functions make databaes queries and for long
+  // running loaders we don't want those queries repeatedly.
+  $GLOBALS["chado_is_installed"]  = chado_is_installed();
+  if ($GLOBALS["chado_is_installed"]) {
+    $GLOBALS["chado_is_local"]      = chado_is_local();
+    $GLOBALS["chado_version"]       = chado_get_version();
+    $GLOBALS["exact_chado_version"] = chado_get_version(TRUE);
+  }
+}
+
+/**
+ * Implements hook_init().
+ * Used to set the search_path, create default content and set default variables.
+ *
+ * @ingroup tripal_chado
+ */
+function tripal_chado_init() {
+
+  // create the 'tripal' controlled volcabulary in chado but only if it doesn't already exist, and
+  // only if the chado database is present.
+  if ($GLOBALS["chado_is_installed"]) {
+
+    // if the Tripal cv is missing then add
+    $results = chado_query("SELECT * FROM {cv} WHERE name = 'tripal'");
+    $cv = $results->fetchObject();
+    if (!$cv) {
+      $results = chado_query(
+          "INSERT INTO {cv} (name,definition) " .
+          "VALUES ('tripal', 'Terms used by Tripal for modules to manage data such as that stored in property tables like featureprop, analysisprop, etc')"
+      );
+    }
+
+    // if the Tripal db is missing then add it
+    $results = chado_query("SELECT * FROM {db} WHERE name = 'tripal'");
+    $db = $results->fetchObject();
+    if (!$db) {
+      $results = chado_query(
+          "INSERT INTO {db} (name,description) " .
+          "VALUES ('tripal', 'Used as a database placeholder for tripal defined objects such as tripal cvterms')"
+      );
+    }
+  }
+}
+
+/**
+ * Implements hook_menu().
+ */
+function tripal_chado_menu() {
+  $items = array();
+
+  $items['admin/tripal/loaders'] = array(
+    'title' => 'Data Loaders',
+    'description' => t('Tools facilitating data import.'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => 6
+  );
+
+  // Chado Storage Backend
+  $items['admin/tripal/storage/chado'] = array(
+    'title' => 'Chado Schema',
+    'description' => t("Tools to extend the chado schema through custom tables & materialized views."),
+    'weight' => -100,
+    'access arguments' => array('administer tripal'),
+  );
+  $items['admin/tripal/storage/chado/chado_install'] = array(
+    'title' => 'Install Chado Schema',
+    'description' => t('Installs the Chado database tables, views, etc., inside the current Drupal database'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_chado_load_form'),
+    'access arguments' => array('install chado'),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => -100
+  );
+
+  // Materialized Views
+  $items['admin/tripal/storage/chado/mviews'] = array(
+    'title' => 'Materialized Views',
+    'description' => t('Materialized views are used to improve speed of large or complex queries.'),
+    'page callback' => 'tripal_mview_admin_view',
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => -10
+  );
+  $items['admin/tripal/storage/chado/mviews/help'] = array(
+    'title' => 'Help',
+    'description' => t('Help for the materialized views management system'),
+    'page callback' => 'theme',
+    'page arguments' => array('tripal_mviews_help'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10
+  );
+  $items['admin/tripal/storage/chado/mviews/report/%'] = array(
+    'title' => 'Materialized View',
+    'description' => t('Materialized views are used to improve speed of large or complex queries. These are database views as compared to Drupal views.'),
+    'page callback' => 'tripal_mview_report',
+    'page arguments' => array(5),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/mviews/new'] = array(
+    'title' => 'Create Materialized View',
+    'description' => t('Create a new materialized view.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_mviews_form'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/mviews/edit/%'] = array(
+    'title' => 'Edit Materialized View',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_mviews_form', 5),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/mviews/update/%'] = array(
+    'title' => 'Create Materialized View',
+    'description' => t('Materialized views are used to improve speed of large or complex queries.'),
+    'page callback' => 'tripal_mviews_add_populate_job',
+    'page arguments' => array(5),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/mviews/delete/%'] = array(
+    'title' => 'Create Materialized View',
+    'description' => t('Materialized views are used to improve speed of large or complex queries.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_mviews_delete_form', 5),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  // TODO: complete the code for exporting and importing of MViews.
+  // Need to address security issues of sharing SQL.
+  $items['admin/tripal/storage/chado/mviews/import'] = array(
+    'title' => 'Import MView',
+    'description' => 'Import a materialized view from another Tripal instance.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_mviews_import_form'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/mviews/%tblid/export'] = array(
+    'title' => 'Export MView',
+    'description' => 'Export a materialized view for use by another Tripal instance.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_mviews_export_form', 5),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+
+  // Custom Tables
+  $items['admin/tripal/storage/chado/custom_tables'] = array(
+    'title' => 'Custom Tables',
+    'description' => t('Creation of custom tables that are added to Chado database.'),
+    'page callback' => 'tripal_custom_table_admin_view',
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => -10
+  );
+  $items['admin/tripal/storage/chado/custom_tables/help'] = array(
+    'title' => 'Help',
+    'description' => t('Help for the tripal job management system'),
+    'page callback' => 'theme',
+    'page arguments' => array('tripal_job_help'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10
+  );
+  $items['admin/tripal/storage/chado/custom_tables/view/%'] = array(
+    'title' => 'Custom Tables',
+    'description' => t('Custom tables are added to Chado.'),
+    'page callback' => 'tripal_custom_table_view',
+    'page arguments' => array(5),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/custom_tables/new'] = array(
+    'title' => 'Create Custom Table',
+    'description' => t('An interface for creating your own custom tables.'),
+    'page callback' => 'tripal_custom_table_new_page',
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/custom_tables/edit/%'] = array(
+    'title' => 'Edit Custom Table',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_custom_tables_form', 5),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/custom_tables/delete/%'] = array(
+    'title' => 'Create Custom Table',
+    'description' => t('Custom tables are added to Chado.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_custom_tables_delete_form', 5),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/storage/chado/custom_tables/views/tables/enable'] = array(
+    'title' => 'Enable Custom Tables Administrative View',
+    'page callback' => 'tripal_enable_view',
+    'page arguments' => array('tripal_admin_custom_table', 'admin/tripal/storage/chado/custom_tables'),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+
+  return $items;
+
+}
+
+/**
+ * Implements hook_permission().
+ *
+ * Set the permission types that the chado module uses.  Essentially we
+ *  want permissionis that protect creation, editing and deleting of chado
+ *  data objects
+ *
+ * @ingroup tripal
+ */
+function tripal_chado_permission() {
+  return array(
+    'install chado' => array(
+      'title' => t('Install Chado'),
+      'description' => t('Allow the user to install or upgrade a Chado database in the existing Drupal database.')
+    ),
+    'view chado_ids' => array(
+      'title' => t('View Internal IDs'),
+      'description' => t('On content pages Tripal will typically provide
+          a table of information pulled from the Chado database but the
+          primary key IDs for that data is typically not shown.  The
+          default Tripal templates can show the primary key ID inside of a
+          blue shaded table row if this permission is enabled. This can
+          be useful for site developers who might want these IDs when working
+          with the underlying database.'),
+      'restrict access' => TRUE,
+    )
+  );
+}
+
 /**
  * Implements hook_field_info().
  */
@@ -812,4 +1084,70 @@ function tripal_chado_get_table_column_field_default($table_name, $schema, $colu
   }
 
   return $field;
-}
+}
+
+/**
+ * Implements hook_exclude_type_by_default()
+ *
+ * This hooks allows fields of a specified type that match a specified criteria
+ * to be excluded by default from any table when chado_generate_var() is called.
+ * Keep in mind that if fields are excluded by default they can always be
+ * expanded at a later date using chado_expand_var().
+ *
+ * Criteria are php strings that evaluate to either TRUE or FALSE. These
+ * strings are evaluated using drupal_eval() which suppresses syntax errors and
+ * throws watchdog entries of type php. There are also watchdog entries of type
+ * tripal stating the exact criteria evaluated. Criteria can
+ * contain the following tokens:
+ *   - <field_name>
+ *       Replaced by the name of the field to be excluded
+ *   - <field_value>
+ *       Replaced by the value of the field in the current record
+ * Also keep in mind that if your criteria doesn't contain the
+ * &gt;field_value&lt;  token then it will be evaluated before the query is
+ * executed and if the field is excluded it won't be included in the
+ * query.
+ *
+ * @return
+ *   An array of type => criteria where the type is excluded if the criteria
+ *   evaluates to TRUE
+ *
+ * @ingroup tripal
+ */
+function tripal_chado_exclude_type_by_default() {
+  return array('text' => 'strlen("<field_value> ") > 250');
+}
+
+/**
+ * Implements hook_job_describe_args().
+ *
+ * Describes the arguements for the tripal_populate_mview job to allow for
+ * greater readability in the jobs details pages.
+ *
+ * @param $callback
+ *   The callback of the current tripal job (this is the function that will be
+ *   executed when tripal_launch_jobs.php is run.
+ * @param $args
+ *   An array of arguments passed in when the job was registered.
+ *
+ * @return
+ *   A more readable $args array
+ *
+ * @ingroup tripal
+ */
+function tripal_chado_describe_args($callback, $args) {
+  $new_args = array();
+  if ($callback == 'tripal_populate_mview') {
+    // get this mview details
+    $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id ";
+    $results = db_query($sql, array(':mview_id' => $args[0]));
+    $mview = $results->fetchObject();
+    $new_args['View Name'] = $mview->name;
+  }
+
+  elseif ($callback == 'tripal_install_chado') {
+    $new_args['Action'] = $args[0];
+  }
+  return $new_args;
+}
+

+ 0 - 380
tripal_core/includes/tripal_core.ws_hal.inc

@@ -1,380 +0,0 @@
-<?php 
-
-
-function tripal_core_chado_hal_api() {
-  global $base_url;
-
-  // Set some initial variables.
-  $response = array();
-  $result = array();
-  $status = 'success';
-  $version = 'v0.1';
-  $message = '';
-  $api_url = "$base_url/ws/chado/$version";
-  $page_limit = 25;
-  $pager_id = 0;
-  
-  // Lump everything ito a try block so that if there is a problem we can
-  // throw an error and have that returned in the response.
-  try {
-    $id = 0;
-    $action = '';
-    
-    // If we don't have a table name then return the list of all tables.
-    if (!arg(3)) {
-      $tables = chado_get_table_names(FALSE);
-      foreach ($tables as $table) {
-        $result['_links']['chado_tables'][] = array('href' => "$api_url/$table");
-      }
-//       $tables = chado_get_custom_table_names(FALSE);
-//       foreach ($tables as $table) {
-//         $result['_links']['custom_tables'][] = array('href' => "$api_url/$table");
-//       }
-//       $tables = chado_get_mview_table_names();
-//       foreach ($tables as $table) {
-//         $result['_links']['mviews'][] = array('href' => "$api_url/$table");
-//       }
-    }
-    else {
-    
-      // GET THE BASE TABLE TO QUERY
-      // The table name is always specifid as the 3rd argument in the 
-      // current Drupal path.
-      $table_name = arg(3);
-      if (!chado_table_exists($table_name)) {
-        throw new Exception("Table, '$table_name', is not a valid table.");
-      }
-      $schema = chado_get_schema($table_name);
-      $pkey = $schema['primary key'][0];
-      
-      // GET THE RECORD AND THE ACTION TO PERFORM
-      // If the fourth argument is numeric then the user is requesting a
-      // record from the table.  Otherwise the users is specifying an
-      // action to perform on the table.
-      if (is_numeric(arg(4))) {
-        $id = arg(4);
-        if (arg(5)) {
-          $action = arg(5);
-        }
-      }
-      else {
-        $action = arg(4);
-      }
-      
-      // Get any URL query arguments
-      $query = drupal_get_query_parameters();
-      
-      switch ($action) {
-        case 'schema':
-          $result = $schema;
-          break;
-        case 'add':
-        case 'edit':
-        case 'delete':
-          throw new Exception("Action, '$action', is currently not supported.");
-          break;
-        default: 
-          // Specify the values for selecing records.
-          $values = array();
-          if ($id) {
-            $values[$pkey] = $id;
-          }
-  
-          // Specify the options for retrieving data.
-          $options = array(
-            'return_array' => 1,
-            'pager' => array(
-              'limit' => $page_limit,
-              'element' => $pager_id
-            ),
-          );
-          
-          // Generate the chado variable.
-          $var = chado_generate_var($table_name, $values, $options);
-    
-          // If we have more than one record returned then this is a collection and
-          // we should create the appropriate JSON for a collection.
-          if (count($var) > 1) {
-            
-            // Get the total number of records
-            $total = chado_pager_get_count($pager_id);
-            $curr_page = array_key_exists('page', $query) ? $query['page'] : 0;
-            
-            $first_page = '0';
-            $last_page = ceil($total / $page_limit) - 1;
-            $result['_links']['first'] = array('href' => "$api_url/$table_name");
-            if ($curr_page > 0) {
-              $prev_page = $curr_page - 1;
-              if ($prev_page != $first_page) {
-                $result['_links']['previous'] = array('href' => "$api_url/$table_name?page=$prev_page");
-              }
-              else {
-                $result['_links']['previous'] = $result['_links']['first'];
-              }
-            }
-            if ($curr_page < $last_page) { 
-              $next_page = $curr_page + 1;
-              $result['_links']['next'] = array('href' => "$api_url/$table_name?page=$next_page");
-            }
-            if ($last_page > $first_page) {
-              $result['_links']['last'] = array('href' => "$api_url/$table_name?page=$last_page");
-            }
-  
-            // Add the number of elements for this collection
-            $result['count'] = count($var);
-            $result['total'] = (integer) $total;
-            $result['current_page'] = (integer) $curr_page;
-            $result['items_per_page'] = $page_limit;
-            
-            // Do any expansion requested.
-            if ($action == 'expand') {
-              $var = tripal_core_chado_ws_api_expand_object($var, $query);
-            }
-      
-            // recursively reformat the expanded objects to match HAL requirements.
-            foreach ($var as $item) {    
-              $item = tripal_core_chado_ws_api_object_format($table_name, $item, $schema, $api_url, $query);
-              $result['_embedded'][$table_name][] = $item;
-            }
-          }
-          // If we only have one record then add it as a single record to the JSON.
-          else {
-            $item = $var[0];
-            
-            // Do any expansion requested.
-            if ($action == 'expand') {
-              $item = tripal_core_chado_ws_api_expand_object($item, $query);
-            }
-      
-            // recursively reformat the expanded objects to match HAL requirements.
-            $item = tripal_core_chado_ws_api_object_format($table_name, $item, $schema, $api_url, $query);
-            $result = $item;
-          }
-      }
-    }
-  }
-  catch (Exception $e) {
-    watchdog('tripal_ws', $e->getMessage(), array(), WATCHDOG_ERROR);
-    $message = $e->getMessage();
-    $status = 'error';
-    $result = array();
-  }
-
-  // The responses follow the same format as the AGAVE API with a
-  // status, message, version and all data in the "result" object.
-  $response['status']  = $status;
-  $response['message'] = $message;
-  $response['version'] = $version;
-  $response['source'] = array(
-      'site_name' => variable_get('site_name', "Unspecified"),
-      'site_url' => $base_url,
-      'site_slogan' => variable_get('site_slogan', "Unspecified"),
-      'site_email' =>  variable_get('site_mail', "Unspecified"),
-  );
-  $response['result']  = $result;
-  print drupal_json_output($response);
-}
-
-/**
- * 
- * @param unknown $object
- * @param unknown $query
- */
-function tripal_core_chado_ws_api_expand_object($var, $query) {
-
-  $page_limit = 25;
-  $pager_id = 0;
-  $options = array(
-    'return_array' => 1,
-    'pager' => array(
-      'limit' => $page_limit,
-      'element' => $pager_id
-    ),
-  );
-
-  // If the user has requested to expand any fields then do that
-  if (array_key_exists('table', $query)) {
-    $expand_tables = explode(',', $query['table']);
-    foreach($expand_tables as $table) {
-      // Does the table exist?
-      if(!chado_table_exists($table)) {
-        throw new Exception("Table, '$table', is not a valid table and thus cannot be expanded.");
-      }
-  
-      // Expand the variable.
-      $var = chado_expand_var($var, 'table', $table, $options);
-  
-      // if the table could not be expanded then the chado_expand_var
-      // function just returns an empty record but sets the table name
-      // in the object. For the JSON, we still want to create an _embedded
-      // record so we have to create a stdClass object and set the
-      // table name.
-      if (property_exists($var, $table) and !isset($var->$table)) {
-        $var->$table = new stdClass();
-        $var->$table->tablename = $table;
-      }
-    }
-  }
-  if (array_key_exists('field', $query)) {
-    $expand_fields = explode(',', $query['field']);
-    foreach($expand_fields as $field) {
-      // TODO: check to make sure the field exists
-      $var = chado_expand_var($var, 'field', $field);
-    }
-  }
-  if (array_key_exists('fkey', $query)) {
-    $expand_fkeys = explode(',', $query['fkey']);
-    foreach($expand_fkeys as $fkey) {
-      // TODO: check to make sure the fkey exists
-      $var = chado_expand_var($var, 'foreign_key', $fkey);
-    }
-  }
-  
-  return $var;
-}
-
-/**
- * 
- * @param $object
- * @param $schema
- * @param $api_url
- */
-function tripal_core_chado_ws_api_object_format($table_name, $object, $schema, $api_url, $query) {
-
-  global $base_url;
-  $pkey = $schema['primary key'][0];
-  $id = $object->$pkey;
-
-  // Add the self link first
-  if ($id) {
-    $object->_links['self'] = array('href' => "$api_url/$table_name/$id");
-    $object->_links['show_expansion'] = array('href' => "$api_url/$table_name/$id?show_expansion=1");
-  }
-  else {
-    $object->_links['self'] = array('href' => "$api_url/$table_name");
-    $object->_links['show_expansion'] = array('href' => "$api_url/$table_name?show_expansion=1");
-  }
-    
-  // Add the links for the table.
-  $object->_links["tables"] = array('href' => "$api_url");
-  $object->_links["schema"] = array('href' => "$api_url/$table_name/schema");
-  
-  // Add links for editing, insert, delete but only if user has permission.
-  // TODO: how do we set permissions?
-  $object->_links["add"] = array('href' => "$api_url/$table_name/add");
-
-  // Add the links if an id is available.
-  if ($id) {
-    $object->_links["edit"] = array('href' => "$api_url/$table_name/$id/edit");
-    $object->_links["delete"] = array('href' => "$api_url/$table_name/$id/delete");
-  }
-    
-  // Add the link to the Drupal page if a node exists.
-  if (property_exists($object, 'nid')) {
-    $object->_links["view"] = array('href' => $base_url . url("node/$object->nid"));
-    // Unset the node ID because it's really only needed within the context
-    // of the local Drupal site.
-    unset($object->nid);
-  }
-  
-  // It doesn't make sense to allow expansion of node information outside
-  // of the context of the local Drupal site so remove this object.
-  unset($object->expandable_nodes);
-  
-  // Only include links for expanding if the option to exclude them has not
-  // been passed.
-  if (!array_key_exists('show_expansion', $query)) {
-     unset($object->expandable_fields);
-     unset($object->expandable_foreign_keys);
-     unset($object->expandable_tables);
-  }
-  
-  // Deal with the expandable tables/fields/fkeys/nodes. Sometimes there are
-  // specified in PHP with explicit numerical indexes and sometimes not. But,
-  // the JSON converter will maintain the indexes if present which creates
-  // an inconsistent look. So, we use the array_values function to just
-  // get the list. 
-  if (array_key_exists('expandable_tables', $object)) {
-    $object->expandable_tables = array_values($object->expandable_tables);
-    if (count($object->expandable_tables) > 0) {
-      $object->_links["expand_table"][] = array('href' => "$api_url/$table_name/expand?table={table}[,{table}...]");
-      $object->_links["expand_table"][] = array('href' => "$api_url/$table_name/$id/expand?table={table}[,{table}...]");
-    }
-    else {
-      unset($object->expandable_tables);
-    }
-  }
-  if (array_key_exists('expandable_fields', $object)) {
-    $object->expandable_fields = array_values($object->expandable_fields);
-    if (count($object->expandable_fields) > 0) {
-      $object->_links["expand_field"][] = array('href' => "$api_url/$table_name/expand?field={field}[,{field}...]");
-      $object->_links["expand_field"][] = array('href' => "$api_url/$table_name/$id/expand?field={field}[,{field}...]");
-    }
-    else {
-      unset($object->expandable_fields);
-    }
-  }
-  if (array_key_exists('expandable_foreign_keys', $object)) {
-    $object->expandable_foreign_keys = array_values($object->expandable_foreign_keys);
-    if (count($object->expandable_foreign_keys) > 0) {
-      $object->_links["expand_fkey"][] = array('href' => "$api_url/$table_name/expand?fkey={fkey}[,{fkey}...]");
-      $object->_links["expand_fkey"][] = array('href' => "$api_url/$table_name/$id/expand?fkey={fkey}[,{fkey}...]");
-    }
-    else {
-      unset($object->expandable_foreign_keys);
-    }
-  }
-  
-  // iterate through the items in the object and see if they in turn are
-  // objects.  If so, then recurse.
-  foreach ($object as $key => $value) {
-    
-    // If any values are objects then recurse and format them correctly.
-    if (is_object($value)) {
-
-      $table_name = $value->tablename;
-      $schema = chado_get_schema($table_name);
-      if ($schema) {
-        // Replace the object with the actual value if it exists.  If there is
-        // no key value then this is probably an expanded table so just unset
-        if (property_exists($value, $key)) {
-          $object->$key = $value->$key;
-        }
-        else {
-          unset($object->$key);
-        }
-        // Recursively format the object.
-        $value = tripal_core_chado_ws_api_object_format($table_name, $value, $schema, $api_url, $query);
-        // Add the object as an "_embedded" object of the JSON.
-        if (property_exists($object,'_embedded') and 
-            array_key_exists($table_name, $object->_embedded)) {
-          // If the element is already an array then add to it, otherwise
-          // convert it into an array.
-          if (is_array($object->_embedded[$table_name])) {
-            $object->_embedded[$table_name][] = $value;
-          }
-          else {
-            $first = $object->_embedded[$table_name];
-            $object->_embedded[$table_name] = array();
-            $object->_embedded[$table_name] = $first;
-            $object->_embedded[$table_name][] = $value;
-          }
-        }
-        // This is the first time this embedded table has been seen
-        // there fore, add the value as a single element.
-        else {
-          $object->_embedded[$table_name] = $value;
-        }
-      }
-      else {
-        throw new Exception("Table, '$table_name', is not a valid table.");
-      } 
-    }
-  }
-  
-  if (array_key_exists('no_links', $query)) {
-    unset($object->_links);
-  }
-  
-  return $object;
-}

+ 0 - 47
tripal_cv/api/tripal_cv.schema.api.inc

@@ -1,47 +0,0 @@
-<?php
-/**
- * @file
- * Describes some chado tables to the tripal schema api
- */
-
-/**
- * Implements hook_chado_schema_v1_2_tripal_obo_temp()
- * Purpose: To describe the structure of 'tripal_obo_temp' to tripal
- * @see chado_insert_record()
- * @see chado_update_record()
- * @see chado_select_record()
- *
- * @return
- *    An array describing the 'tripal_obo_temp' table
- *
- * @ingroup tripal_chado_v1.2_schema_api
- */
-function tripal_cv_chado_schema_v1_2_tripal_obo_temp() {
-  $schema = array(
-    'table' => 'tripal_obo_temp',
-    'fields' => array(
-      'id' => array(
-        'type' => 'varchar',
-        'length' => '255',
-        'not null' => TRUE,
-      ),
-      'stanza' => array(
-        'type' => 'text',
-        'not null' => TRUE,
-      ),
-      'type' => array(
-        'type' => 'varchar',
-        'length' => '50',
-        'not null' => TRUE,
-      ),
-    ),
-    'indexes' => array(
-      'tripal_obo_temp_idx0' => array('id'),
-      'tripal_obo_temp_idx0' => array('type'),
-    ),
-    'unique keys' => array(
-      'tripal_obo_temp_uq0' => array('id'),
-    ),
-  );
-  return $schema;
-}

+ 1 - 1
tripal_entities/tripal_entities.info

@@ -7,4 +7,4 @@ version = 7.x-2.0
 
 dependencies[] = date
 dependencies[] = entity
-dependencies[] = tripal_core
+dependencies[] = tripal

+ 1 - 1
tripal_fields_layout/tripal_fields_layout.info

@@ -5,5 +5,5 @@ project = tripal
 package = Tripal
 version = 7.x-2.0
 
-dependencies[] = tripal_core
+dependencies[] = tripal
 dependencies[] = tripal_entities

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません