tripal_feature.install

  1. 2.x tripal_feature/tripal_feature.install
  2. 3.x legacy/tripal_feature/tripal_feature.install
  3. 1.x tripal_feature/tripal_feature.install

Installation of the feature module

File

legacy/tripal_feature/tripal_feature.install
View source
  1. <?php
  2. /**
  3. * @file
  4. * Installation of the feature module
  5. */
  6. /**
  7. * Implements hook_disable().
  8. *
  9. * Disable default views when module is disabled
  10. *
  11. * @ingroup tripal_legacy_feature
  12. */
  13. function tripal_feature_disable() {
  14. // Disable all default views provided by this module
  15. require_once("tripal_feature.views_default.inc");
  16. $views = tripal_feature_views_default_views();
  17. foreach (array_keys($views) as $view_name) {
  18. tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  19. }
  20. }
  21. /**
  22. * Implements hook_requirements().
  23. *
  24. * @ingroup tripal_legacy_feature
  25. */
  26. function tripal_feature_requirements($phase) {
  27. $requirements = array();
  28. if ($phase == 'install') {
  29. // make sure chado is installed
  30. if (!$GLOBALS["chado_is_installed"]) {
  31. $requirements ['tripal_feature'] = array(
  32. 'title' => "t ripal_feature",
  33. 'value' => "ERROR: Chado must be installed before this module can be enabled",
  34. 'severity' => REQUIREMENT_ERROR,
  35. );
  36. }
  37. }
  38. return $requirements;
  39. }
  40. /**
  41. * Implements hook_install().
  42. *
  43. * @ingroup tripal_legacy_feature
  44. */
  45. function tripal_feature_install() {
  46. // Note: the feature_property OBO that came with Chado v1.2 should not
  47. // be automatically installed. Some of the terms are duplicates of
  48. // others in better maintained vocabularies. New Tripal sites should
  49. // use those.
  50. // $obo_path = '{tripal_feature}/files/feature_property.obo';
  51. // $obo_id = tripal_insert_obo('Chado Feature Properties', $obo_path);
  52. // tripal_submit_obo_job(array('obo_id' => $obo_id));
  53. // Add the vocabularies used by the feature module.
  54. tripal_feature_add_cvs();
  55. // Set the default vocabularies.
  56. tripal_set_default_cv('feature', 'type_id', 'sequence');
  57. tripal_set_default_cv('featureprop', 'type_id', 'feature_property');
  58. tripal_set_default_cv('feature_relationship', 'type_id', 'feature_relationship');
  59. }
  60. /**
  61. * Implements hook_uninstall().
  62. *
  63. * @ingroup tripal_legacy_feature
  64. */
  65. function tripal_feature_uninstall() {
  66. }
  67. /**
  68. * Implementation of hook_schema().
  69. *
  70. * @ingroup tripal_legacy_feature
  71. */
  72. function tripal_feature_schema() {
  73. $schema['chado_feature'] = array(
  74. 'fields' => array(
  75. 'vid' => array(
  76. 'type' => 'int',
  77. 'unsigned' => TRUE,
  78. 'not null' => TRUE,
  79. 'default' => 0
  80. ),
  81. 'nid' => array(
  82. 'type' => 'int',
  83. 'unsigned' => TRUE,
  84. 'not null' => TRUE,
  85. 'default' => 0
  86. ),
  87. 'feature_id' => array(
  88. 'type' => 'int',
  89. 'not null' => TRUE,
  90. 'default' => 0
  91. ),
  92. 'sync_date' => array(
  93. 'type' => 'int',
  94. 'not null' => FALSE,
  95. 'description' => 'UNIX integer sync date/time'
  96. ),
  97. ),
  98. 'indexes' => array(
  99. 'chado_feature_idx1' => array('feature_id')
  100. ),
  101. 'unique keys' => array(
  102. 'chado_feature_uq1' => array('nid', 'vid'),
  103. 'chado_feature_uq2' => array('vid')
  104. ),
  105. 'primary key' => array('nid'),
  106. );
  107. return $schema;
  108. };
  109. /**
  110. * Add cvs related to publications
  111. *
  112. * @ingroup tripal_pub
  113. */
  114. function tripal_feature_add_cvs() {
  115. // Add cv for relationship types
  116. tripal_insert_cv(
  117. 'feature_relationship',
  118. 'Contains types of relationships between features.'
  119. );
  120. // The feature_property CV may already exists. It comes with Chado, but
  121. // we need to add it just in case it doesn't get added before the feature
  122. // module is installed. But as of Tripal v3.0 the Chado version of this
  123. // vocabulary is no longer loaded by default.
  124. tripal_insert_cv(
  125. 'feature_property',
  126. 'Stores properties about features'
  127. );
  128. // the feature type vocabulary should be the sequence ontology, and even though
  129. // this ontology should get loaded we will create it here just so that we can
  130. // set the default vocabulary for the feature.type_id field
  131. tripal_insert_cv(
  132. 'sequence',
  133. 'The Sequence Ontology'
  134. );
  135. }