tripal_featuremap.install 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <?php
  2. /**
  3. * @file
  4. * @todo Add file header description
  5. */
  6. /**
  7. * Disable default views when module is disabled
  8. */
  9. function tripal_featuremap_disable() {
  10. // Disable all default views provided by this module
  11. require_once("tripal_featuremap.views_default.inc");
  12. $views = tripal_featuremap_views_default_views();
  13. foreach (array_keys($views) as $view_name) {
  14. tripal_views_admin_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  15. }
  16. }
  17. /**
  18. * Implementation of hook_requirements().
  19. */
  20. function tripal_featuremap_requirements($phase) {
  21. $requirements = array();
  22. if ($phase == 'install') {
  23. // make sure chado is installed
  24. if (!$GLOBALS["chado_is_installed"]) {
  25. $requirements ['tripal_featuremap'] = array(
  26. 'title' => "tripal_featuremap",
  27. 'value' => "ERROR: Chado most be installed before this module can be enabled",
  28. 'severity' => REQUIREMENT_ERROR,
  29. );
  30. }
  31. }
  32. return $requirements;
  33. }
  34. /**
  35. * Implementation of hook_install().
  36. *
  37. * @ingroup tripal_featuremap
  38. */
  39. function tripal_featuremap_install() {
  40. // create the module's data directory
  41. tripal_create_moddir('tripal_featuremap');
  42. // add the featuremapprop table to Chado
  43. tripal_featuremap_add_custom_tables();
  44. // Add cvterms
  45. tripal_featuremap_add_cvterms();
  46. }
  47. /**
  48. * Implementation of hook_uninstall().
  49. *
  50. * @ingroup tripal_featuremap
  51. */
  52. function tripal_featuremap_uninstall() {
  53. }
  54. /**
  55. * Implementation of hook_schema().
  56. *
  57. * @ingroup tripal_featuremap
  58. */
  59. function tripal_featuremap_schema() {
  60. $schema['chado_featuremap'] = array(
  61. 'fields' => array(
  62. 'vid' => array(
  63. 'type' => 'int',
  64. 'unsigned' => TRUE,
  65. 'not null' => TRUE,
  66. 'default' => 0
  67. ),
  68. 'nid' => array(
  69. 'type' => 'int',
  70. 'unsigned' => TRUE,
  71. 'not null' => TRUE,
  72. 'default' => 0
  73. ),
  74. 'featuremap_id' => array(
  75. 'type' => 'int',
  76. 'not null' => TRUE,
  77. 'default' => 0
  78. )
  79. ),
  80. 'indexes' => array(
  81. 'featuremap_id' => array('featuremap_id')
  82. ),
  83. 'unique keys' => array(
  84. 'nid_vid' => array('nid', 'vid'),
  85. 'vid' => array('vid')
  86. ),
  87. 'primary key' => array('nid'),
  88. );
  89. return $schema;
  90. }
  91. /*
  92. *
  93. */
  94. function tripal_featuremap_add_cvterms() {
  95. // add cvterms for the map unit types
  96. tripal_cv_add_cvterm(array('name' => 'cM','def' => 'Centimorgan units'),
  97. 'featuremap_units', 0, 1, 'tripal');
  98. tripal_cv_add_cvterm(array('name' => 'bp','def' => 'Base pairs units'),
  99. 'featuremap_units', 0, 1, 'tripal');
  100. tripal_cv_add_cvterm(array('name' => 'bin_unit','def' => 'The bin unit'),
  101. 'featuremap_units', 0, 1, 'tripal');
  102. tripal_cv_add_cvterm(array('name' => 'marker_order','def' => 'Units simply to define marker order.'),
  103. 'featuremap_units', 0, 1, 'tripal');
  104. tripal_cv_add_cvterm(array('name' => 'undefined','def' => 'A catch-all for an undefined unit type'),
  105. 'featuremap_units', 0, 1, 'tripal');
  106. tripal_cv_add_cvterm(array('name' => 'start','def' => 'The start coordinate for a map feature.'),
  107. 'featurepos_property', 0, 1, 'tripal');
  108. tripal_cv_add_cvterm(array('name' => 'stop','def' => 'The end coordinate for a map feature'),
  109. 'featurepos_property', 0, 1, 'tripal');
  110. // add cvterms for map properties
  111. tripal_cv_add_cvterm(array('name' => 'Map Dbxref','def' => 'A unique identifer for the map in a remote database. The format is a database abbreviation and a unique accession separated by a colon. (e.g. Gramene:tsh1996a)'),
  112. 'featuremap_property', 0, 1, 'tripal');
  113. tripal_cv_add_cvterm(array('name' => 'Map Type','def' => 'The type of Map (e.g. QTL, Physical, etc.)'),
  114. 'featuremap_property', 0, 1, 'tripal');
  115. tripal_cv_add_cvterm(array('name' => 'Genome Group','def' => ''),
  116. 'featuremap_property', 0, 1, 'tripal');
  117. tripal_cv_add_cvterm(array('name' => 'URL','def' => 'A univeral resource locator (URL) reference where the publication can be found. For maps found online, this would be the web address for the map.'),
  118. 'featuremap_property', 0, 1, 'tripal');
  119. tripal_cv_add_cvterm(array('name' => 'Population Type','def' => 'A brief descriptoin of the population type used to generate the map (e.g. RIL, F2, BC1, etc).'),
  120. 'featuremap_property', 0, 1, 'tripal');
  121. tripal_cv_add_cvterm(array('name' => 'Population Size','def' => 'The size of the population used to construct the map.'),
  122. 'featuremap_property', 0, 1, 'tripal');
  123. tripal_cv_add_cvterm(array('name' => 'Methods','def' => 'A brief description of the methods used to construct the map.'),
  124. 'featuremap_property', 0, 1, 'tripal');
  125. tripal_cv_add_cvterm(array('name' => 'Software','def' => 'The software used to construct the map.'),
  126. 'featuremap_property', 0, 1, 'tripal');
  127. }
  128. /*
  129. *
  130. */
  131. function tripal_featuremap_add_custom_tables(){
  132. // add the featuremaprop table to Chado
  133. $schema = array (
  134. 'table' => 'featuremapprop',
  135. 'fields' => array (
  136. 'featuremapprop_id' => array (
  137. 'type' => 'serial',
  138. 'not null' => true,
  139. ),
  140. 'featuremap_id' => array (
  141. 'type' => 'int',
  142. 'not null' => true,
  143. ),
  144. 'type_id' => array (
  145. 'type' => 'int',
  146. 'not null' => true,
  147. ),
  148. 'value' => array (
  149. 'type' => 'text',
  150. 'not null' => false,
  151. ),
  152. 'rank' => array (
  153. 'type' => 'int',
  154. 'not null' => true,
  155. 'default' => 0,
  156. ),
  157. ),
  158. 'primary key' => array (
  159. 0 => 'featuremapprop_id',
  160. ),
  161. 'unique keys' => array (
  162. 'featuremapprop_c1' => array (
  163. 0 => 'featuremap_id',
  164. 1 => 'type_id',
  165. 2 => 'rank',
  166. ),
  167. ),
  168. 'indexes' => array (
  169. 'featuremapprop_idx1' => array (
  170. 0 => 'featuremap_id',
  171. ),
  172. 'featuremapprop_idx2' => array (
  173. 0 => 'type_id',
  174. ),
  175. ),
  176. 'foreign keys' => array (
  177. 'cvterm' => array (
  178. 'table' => 'cvterm',
  179. 'columns' => array (
  180. 'type_id' => 'cvterm_id',
  181. ),
  182. ),
  183. 'featuremap' => array (
  184. 'table' => 'featuremap',
  185. 'columns' => array (
  186. 'featuremap_id' => 'featuremap_id',
  187. ),
  188. ),
  189. ),
  190. );
  191. tripal_core_create_custom_table('featuremapprop', $schema, TRUE);
  192. // add the featuremap_dbxref table to Chado
  193. $schema = array (
  194. 'table' => 'featuremap_dbxref',
  195. 'fields' => array (
  196. 'featuremap_dbxref_id' => array (
  197. 'type' => 'serial',
  198. 'not null' => true,
  199. ),
  200. 'featuremap_id' => array (
  201. 'type' => 'int',
  202. 'not null' => true,
  203. ),
  204. 'dbxref_id' => array (
  205. 'type' => 'int',
  206. 'not null' => true,
  207. ),
  208. ),
  209. 'primary key' => array (
  210. 0 => 'featuremap_dbxref_id',
  211. ),
  212. 'unique keys' => array (
  213. 'featuremap_dbxref_c1' => array (
  214. 0 => 'featuremap_id',
  215. 1 => 'dbxref_id',
  216. ),
  217. ),
  218. 'indexes' => array (
  219. 'featuremap_dbxref_idx1' => array (
  220. 0 => 'featuremap_dbxref_id',
  221. ),
  222. 'featuremap_dbxref_idx2' => array (
  223. 0 => 'dbxref_id',
  224. ),
  225. ),
  226. 'foreign keys' => array (
  227. 'dbxref' => array (
  228. 'table' => 'dbxref',
  229. 'columns' => array (
  230. 'dbxref_id' => 'dbxref_id',
  231. ),
  232. ),
  233. 'featuremap' => array (
  234. 'table' => 'featuremap',
  235. 'columns' => array (
  236. 'featuremap_id' => 'featuremap_id',
  237. ),
  238. ),
  239. ),
  240. 'referring_tables' => NULL,
  241. );
  242. tripal_core_create_custom_table('featuremap_dbxref', $schema, TRUE);
  243. $schema = array (
  244. 'table' => 'featureposprop',
  245. 'fields' => array (
  246. 'featureposprop_id' => array (
  247. 'type' => 'serial',
  248. 'not null' => true,
  249. ),
  250. 'featurepos_id' => array (
  251. 'type' => 'int',
  252. 'not null' => true,
  253. ),
  254. 'type_id' => array (
  255. 'type' => 'int',
  256. 'not null' => true,
  257. ),
  258. 'value' => array (
  259. 'type' => 'text',
  260. 'not null' => false,
  261. ),
  262. 'rank' => array (
  263. 'type' => 'int',
  264. 'not null' => true,
  265. 'default' => 0,
  266. ),
  267. ),
  268. 'primary key' => array (
  269. 0 => 'featureposprop_id',
  270. ),
  271. 'unique keys' => array (
  272. 'featureposprop_id' => array (
  273. 0 => 'featurepos_id',
  274. 1 => 'type_id',
  275. 2 => 'rank',
  276. ),
  277. ),
  278. 'indexes' => array (
  279. 'featureposprop_c1' => array (
  280. 0 => 'featurepos_id',
  281. ),
  282. 'featureposprop_idx2' => array (
  283. 0 => 'type_id',
  284. ),
  285. ),
  286. 'foreign keys' => array (
  287. 'cvterm' => array (
  288. 'table' => 'cvterm',
  289. 'columns' => array (
  290. 'type_id' => 'cvterm_id',
  291. ),
  292. ),
  293. 'featurepos' => array (
  294. 'table' => 'featurepos',
  295. 'columns' => array (
  296. 'featurepos_id' => 'featurepos_id',
  297. ),
  298. ),
  299. ),
  300. );
  301. tripal_core_create_custom_table('featureposprop', $schema, TRUE);
  302. }