tripal_analysis.install 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /**
  3. * @file
  4. * Implements hooks from the Schema API.
  5. *
  6. * @ingroup tripal_legacy_analysis
  7. */
  8. /**
  9. * Implements hook_disable().
  10. * Disable default views when module is disabled
  11. *
  12. * @ingroup tripal_legacy_analysis
  13. */
  14. function tripal_analysis_disable() {
  15. // Disable all default views provided by this module
  16. require_once("tripal_analysis.views_default.inc");
  17. $views = tripal_analysis_views_default_views();
  18. foreach (array_keys($views) as $view_name) {
  19. tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  20. }
  21. }
  22. /**
  23. * Implementation of hook_requirements().
  24. *
  25. * @ingroup tripal_legacy_analysis
  26. */
  27. function tripal_analysis_requirements($phase) {
  28. $requirements = array();
  29. if ($phase == 'install') {
  30. // make sure chado is installed
  31. if (!$GLOBALS["chado_is_installed"]) {
  32. $requirements ['tripal_analysis'] = array(
  33. 'title' => "tripal_analysis",
  34. 'value' => "ERROR: Chado must be installed before this module can be enabled",
  35. 'severity' => REQUIREMENT_ERROR,
  36. );
  37. }
  38. }
  39. return $requirements;
  40. }
  41. /**
  42. * Implementation of hook_install().
  43. *
  44. * @ingroup tripal_legacy_analysis
  45. */
  46. function tripal_analysis_install() {
  47. // add vocabularies
  48. tripal_analysis_add_cvs();
  49. // add cvterms
  50. tripal_analysis_add_cvterms();
  51. // set the default vocabularies
  52. tripal_set_default_cv('analysisprop', 'type_id', 'analysis_property');
  53. }
  54. /**
  55. * Implementation of hook_uninstall().
  56. *
  57. * @ingroup tripal_legacy_analysis
  58. */
  59. function tripal_analysis_uninstall() {
  60. }
  61. /**
  62. * Add cvs related to analyses
  63. *
  64. * @ingroup tripal_legacy_analysis
  65. */
  66. function tripal_analysis_add_cvs() {
  67. // typically here we would add the analysis_property vocabulary
  68. // but it already comes with Chado.
  69. }
  70. /**
  71. * Adds controlled vocabulary terms needed by this module.
  72. *
  73. * @ingroup tripal_legacy_analysis
  74. */
  75. function tripal_analysis_add_cvterms() {
  76. tripal_insert_cv(
  77. 'tripal_analysis',
  78. 'Terms used for managing analyses in Tripal'
  79. );
  80. // add analysis_date. This is no longer used (as far as we can tell) but we don't
  81. // get rid of it in case it is used, so just keep it in the Tripal CV
  82. tripal_insert_cvterm(
  83. array(
  84. 'name' => 'analysis_date',
  85. 'definition' => 'The date that an analysis was performed.',
  86. 'cv_name' => 'tripal',
  87. 'is_relationship' => 0,
  88. 'db_name' => 'tripal'
  89. ),
  90. array('update_existing' => TRUE)
  91. );
  92. // add analysis_short_name. This is no longer used (as far as we can tell) but we don't
  93. // get rid of it in case it is used, so just keep it in the Tripal CV
  94. tripal_insert_cvterm(
  95. array(
  96. 'name' => 'analysis_short_name',
  97. 'definition' => 'A computer legible (no spaces or special characters) '
  98. . 'abbreviation for the analysis.',
  99. 'cv_name' => 'tripal',
  100. 'is_relationship' => 0,
  101. 'db_name' => 'local'
  102. ),
  103. array('update_existing' => TRUE)
  104. );
  105. // the 'analysis_property' vocabulary is for user definable properties wo we
  106. // will add an 'Analysis Type' to this vocubulary
  107. tripal_insert_cvterm(
  108. array(
  109. 'name' => 'Analysis Type',
  110. 'definition' => 'The type of analysis that was performed.',
  111. 'cv_name' => 'analysis_property',
  112. 'is_relationship' => 0,
  113. 'db_name' => 'local'
  114. ),
  115. array('update_existing' => TRUE)
  116. );
  117. }
  118. /**
  119. * Implementation of hook_schema().
  120. *
  121. * - chado_analysis table
  122. * stores nodes that are also saved in the analysis table of chado database.
  123. * - tripal_analysis table
  124. * stores the sub-module names, such as tripal_analysis_blast, that are registered
  125. * with this module.
  126. *
  127. * @ingroup tripal_legacy_analysis
  128. */
  129. function tripal_analysis_schema() {
  130. // chado_analysis table
  131. $schema['chado_analysis'] = array(
  132. 'fields' => array(
  133. 'vid' => array(
  134. 'type' => 'int',
  135. 'unsigned' => TRUE,
  136. 'not null' => TRUE,
  137. 'default' => 0
  138. ),
  139. 'nid' => array(
  140. 'type' => 'int',
  141. 'unsigned' => TRUE,
  142. 'not null' => TRUE,
  143. 'default' => 0
  144. ),
  145. 'analysis_id' => array(
  146. 'type' => 'int',
  147. 'not null' => TRUE,
  148. 'default' => 0
  149. )
  150. ),
  151. 'indexes' => array(
  152. 'analysis_id' => array('analysis_id')
  153. ),
  154. 'unique keys' => array(
  155. 'nid_vid' => array('nid', 'vid'),
  156. 'vid' => array('vid')
  157. ),
  158. 'primary key' => array('nid'),
  159. );
  160. // tripal_analysis table
  161. $schema['tripal_analysis'] = array(
  162. 'description' => 'Table to store analysis sub-modules',
  163. 'fields' => array(
  164. 'modulename' => array(
  165. 'type' => 'text',
  166. 'size' => 'small',
  167. 'not null' => TRUE,
  168. 'description' => 'The module name. Tripal Analysis will use the module name to call module_setting_form()'
  169. )
  170. ),
  171. 'unique keys' => array(
  172. 'modulename' => array('modulename')
  173. )
  174. );
  175. return $schema;
  176. }