tripal_library.install 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. /**
  3. * @file
  4. * Installation of the library module
  5. */
  6. /**
  7. * Implements hook_disable().
  8. * Disable default views when module is disabled
  9. *
  10. * @ingroup tripal_legacy_library
  11. */
  12. function tripal_library_disable() {
  13. // Disable all default views provided by this module
  14. require_once("tripal_library.views_default.inc");
  15. $views = tripal_library_views_default_views();
  16. foreach (array_keys($views) as $view_name) {
  17. tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  18. }
  19. }
  20. /**
  21. * Implementation of hook_requirements().
  22. *
  23. * @ingroup tripal_legacy_library
  24. */
  25. function tripal_library_requirements($phase) {
  26. $requirements = array();
  27. if ($phase == 'install') {
  28. // make sure chado is installed
  29. if (!$GLOBALS["chado_is_installed"]) {
  30. $requirements ['tripal_library'] = array(
  31. 'title' => "tripal_library",
  32. 'value' => "ERROR: Chado must be installed before this module can be enabled",
  33. 'severity' => REQUIREMENT_ERROR,
  34. );
  35. }
  36. }
  37. return $requirements;
  38. }
  39. /**
  40. * Implementation of hook_install().
  41. *
  42. * @ingroup tripal_legacy_library
  43. */
  44. function tripal_library_install() {
  45. // add cvterms
  46. tripal_library_add_cvs();
  47. tripal_library_add_cvterms();
  48. // set the default vocabularies
  49. tripal_set_default_cv('libraryprop', 'type_id', 'library_property');
  50. tripal_set_default_cv('library', 'type_id', 'library_type');
  51. }
  52. /**
  53. * Implementation of hook_uninstall().
  54. *
  55. * @ingroup tripal_legacy_library
  56. */
  57. function tripal_library_uninstall() {
  58. }
  59. /**
  60. * Implementation of hook_schema().
  61. *
  62. * @ingroup tripal_legacy_library
  63. */
  64. function tripal_library_schema() {
  65. $schema['chado_library'] = array(
  66. 'fields' => array(
  67. 'vid' => array(
  68. 'type' => 'int',
  69. 'unsigned' => TRUE,
  70. 'not null' => TRUE,
  71. 'default' => 0
  72. ),
  73. 'nid' => array(
  74. 'type' => 'int',
  75. 'unsigned' => TRUE,
  76. 'not null' => TRUE,
  77. 'default' => 0
  78. ),
  79. 'library_id' => array(
  80. 'type' => 'int',
  81. 'not null' => TRUE,
  82. 'default' => 0
  83. )
  84. ),
  85. 'indexes' => array(
  86. 'chado_library_idx1' => array('library_id')
  87. ),
  88. 'unique keys' => array(
  89. 'chado_library_uq1' => array('nid', 'vid'),
  90. 'chado_library_uq2' => array('vid')
  91. ),
  92. 'primary key' => array('nid'),
  93. );
  94. return $schema;
  95. }
  96. /**
  97. * Adds new CV's used by this module
  98. *
  99. * @ingroup tripal_legacy_library
  100. */
  101. function tripal_library_add_cvs(){
  102. tripal_insert_cv(
  103. 'library_property',
  104. 'Contains properties for libraries.'
  105. );
  106. tripal_insert_cv(
  107. 'library_type',
  108. 'Contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).'
  109. );
  110. }
  111. /**
  112. * Adds cvterms needed for the library module
  113. *
  114. * @ingroup tripal_legacy_library
  115. */
  116. function tripal_library_add_cvterms() {
  117. // Insert cvterm 'library_description' into cvterm table of chado
  118. // database. This CV term is used to keep track of the library
  119. // description in the libraryprop table.
  120. tripal_insert_cvterm(
  121. array(
  122. 'name' => 'Library Description',
  123. 'definition' => 'Description of a library',
  124. 'cv_name' => 'library_property',
  125. 'is_relationship' => 0,
  126. 'db_name' => 'tripal'
  127. ),
  128. array('update_existing' => TRUE)
  129. );
  130. // add cvterms for the map unit types
  131. tripal_insert_cvterm(
  132. array(
  133. 'name' => 'cdna_library',
  134. 'definition' => 'cDNA library',
  135. 'cv_name' => 'library_type',
  136. 'is_relationship' => 0,
  137. 'db_name' => 'tripal'
  138. ),
  139. array('update_existing' => TRUE)
  140. );
  141. tripal_insert_cvterm(
  142. array(
  143. 'name' => 'bac_library',
  144. 'definition' => 'Bacterial Artifical Chromsome (BAC) library',
  145. 'cv_name' => 'library_type',
  146. 'is_relationship' => 0,
  147. 'db_name' => 'tripal'
  148. ),
  149. array('update_existing' => TRUE)
  150. );
  151. tripal_insert_cvterm(
  152. array(
  153. 'name' => 'fosmid_library',
  154. 'definition' => 'Fosmid library',
  155. 'cv_name' => 'library_type',
  156. 'is_relationship' => 0,
  157. 'db_name' => 'tripal'
  158. ),
  159. array('update_existing' => TRUE)
  160. );
  161. tripal_insert_cvterm(
  162. array(
  163. 'name' => 'cosmid_library',
  164. 'definition' => 'Cosmid library',
  165. 'cv_name' => 'library_type',
  166. 'is_relationship' => 0,
  167. 'db_name' => 'tripal'
  168. ),
  169. array('update_existing' => TRUE)
  170. );
  171. tripal_insert_cvterm(
  172. array(
  173. 'name' => 'yac_library',
  174. 'definition' => 'Yeast Artificial Chromosome (YAC) library',
  175. 'cv_name' => 'library_type',
  176. 'is_relationship' => 0,
  177. 'db_name' => 'tripal'
  178. ),
  179. array('update_existing' => TRUE)
  180. );
  181. tripal_insert_cvterm(
  182. array(
  183. 'name' => 'genomic_library',
  184. 'definition' => 'Genomic Library',
  185. 'cv_name' => 'library_type',
  186. 'is_relationship' => 0,
  187. 'db_name' => 'tripal'
  188. ),
  189. array('update_existing' => TRUE)
  190. );
  191. }