tripal_featuremap.install 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <?php
  2. /**
  3. * @file
  4. * Handles installation of the feature map module
  5. */
  6. /**
  7. * Implements hook_disable().
  8. * Disable default views when module is disabled
  9. *
  10. * @ingroup tripal_featuremap
  11. */
  12. function tripal_featuremap_disable() {
  13. // Disable all default views provided by this module
  14. require_once("tripal_featuremap.views_default.inc");
  15. $views = tripal_featuremap_views_default_views();
  16. foreach (array_keys($views) as $view_name) {
  17. tripal_views_admin_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  18. }
  19. }
  20. /**
  21. * Implementation of hook_requirements().
  22. *
  23. * @ingroup tripal_featuremap
  24. */
  25. function tripal_featuremap_requirements($phase) {
  26. $requirements = array();
  27. if ($phase == 'install') {
  28. // make sure chado is installed
  29. if (!$GLOBALS["chado_is_installed"]) {
  30. $requirements ['tripal_featuremap'] = array(
  31. 'title' => "tripal_featuremap",
  32. 'value' => "ERROR: Chado most 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_featuremap
  43. */
  44. function tripal_featuremap_install() {
  45. // create the module's data directory
  46. tripal_create_files_dir('tripal_featuremap');
  47. // add the featuremapprop table to Chado
  48. tripal_featuremap_add_custom_tables();
  49. // Add cvterms
  50. tripal_featuremap_add_cvs();
  51. tripal_featuremap_add_cvterms();
  52. }
  53. /**
  54. * Implementation of hook_uninstall().
  55. *
  56. * @ingroup tripal_featuremap
  57. */
  58. function tripal_featuremap_uninstall() {
  59. }
  60. /**
  61. * Implementation of hook_schema().
  62. *
  63. * @ingroup tripal_featuremap
  64. */
  65. function tripal_featuremap_schema() {
  66. $schema['chado_featuremap'] = array(
  67. 'fields' => array(
  68. 'vid' => array(
  69. 'type' => 'int',
  70. 'unsigned' => TRUE,
  71. 'not null' => TRUE,
  72. 'default' => 0
  73. ),
  74. 'nid' => array(
  75. 'type' => 'int',
  76. 'unsigned' => TRUE,
  77. 'not null' => TRUE,
  78. 'default' => 0
  79. ),
  80. 'featuremap_id' => array(
  81. 'type' => 'int',
  82. 'not null' => TRUE,
  83. 'default' => 0
  84. )
  85. ),
  86. 'indexes' => array(
  87. 'featuremap_id' => array('featuremap_id')
  88. ),
  89. 'unique keys' => array(
  90. 'nid_vid' => array('nid', 'vid'),
  91. 'vid' => array('vid')
  92. ),
  93. 'primary key' => array('nid'),
  94. );
  95. return $schema;
  96. }
  97. /**
  98. * Add cvs needed by the featuremap module
  99. *
  100. * @ingroup tripal_featuremap
  101. */
  102. function tripal_featuremap_add_cvs() {
  103. tripal_cv_add_cv(
  104. 'featuremap_units',
  105. 'Contains map unit types for the unittype_id column of the featuremap table.'
  106. );
  107. tripal_cv_add_cv(
  108. 'featurepos_property',
  109. 'Contains terms map properties.'
  110. );
  111. tripal_cv_add_cv(
  112. 'featuremap_property',
  113. 'Contains positional types for the feature positions'
  114. );
  115. }
  116. /**
  117. * Add cv terms needed by the featuremap module
  118. *
  119. * @ingroup tripal_featuremap
  120. */
  121. function tripal_featuremap_add_cvterms() {
  122. // add cvterms for the map unit types
  123. tripal_cv_add_cvterm(
  124. array(
  125. 'name' => 'cM',
  126. 'def' => 'Centimorgan units'
  127. ),
  128. 'featuremap_units', 0, 1, 'tripal'
  129. );
  130. tripal_cv_add_cvterm(
  131. array(
  132. 'name' => 'bp',
  133. 'def' => 'Base pairs units'
  134. ),
  135. 'featuremap_units', 0, 1, 'tripal'
  136. );
  137. tripal_cv_add_cvterm(
  138. array(
  139. 'name' => 'bin_unit',
  140. 'def' => 'The bin unit'
  141. ),
  142. 'featuremap_units', 0, 1, 'tripal'
  143. );
  144. tripal_cv_add_cvterm(
  145. array(
  146. 'name' => 'marker_order',
  147. 'def' => 'Units simply to define marker order.'
  148. ),
  149. 'featuremap_units', 0, 1, 'tripal'
  150. );
  151. tripal_cv_add_cvterm(
  152. array(
  153. 'name' => 'undefined',
  154. 'def' => 'A catch-all for an undefined unit type'
  155. ),
  156. 'featuremap_units', 0, 1, 'tripal'
  157. );
  158. // featurepos properties
  159. tripal_cv_add_cvterm(
  160. array(
  161. 'name' => 'start',
  162. 'def' => 'The start coordinate for a map feature.'
  163. ),
  164. 'featurepos_property', 0, 1, 'tripal'
  165. );
  166. tripal_cv_add_cvterm(
  167. array(
  168. 'name' => 'stop',
  169. 'def' => 'The end coordinate for a map feature'
  170. ),
  171. 'featurepos_property', 0, 1, 'tripal'
  172. );
  173. // add cvterms for map properties
  174. tripal_cv_add_cvterm(
  175. array(
  176. 'name' => 'Map Dbxref',
  177. '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)'
  178. ),
  179. 'featuremap_property', 0, 1, 'tripal'
  180. );
  181. tripal_cv_add_cvterm(
  182. array(
  183. 'name' => 'Map Type',
  184. 'def' => 'The type of Map (e.g. QTL, Physical, etc.)'
  185. ),
  186. 'featuremap_property', 0, 1, 'tripal'
  187. );
  188. tripal_cv_add_cvterm(
  189. array(
  190. 'name' => 'Genome Group',
  191. 'def' => ''
  192. ),
  193. 'featuremap_property', 0, 1, 'tripal'
  194. );
  195. tripal_cv_add_cvterm(
  196. array(
  197. 'name' => 'URL',
  198. '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.'
  199. ),
  200. 'featuremap_property', 0, 1, 'tripal'
  201. );
  202. tripal_cv_add_cvterm(
  203. array(
  204. 'name' => 'Population Type',
  205. 'def' => 'A brief description of the population type used to generate the map (e.g. RIL, F2, BC1, etc).'
  206. ),
  207. 'featuremap_property', 0, 1, 'tripal'
  208. );
  209. tripal_cv_add_cvterm(
  210. array(
  211. 'name' => 'Population Size',
  212. 'def' => 'The size of the population used to construct the map.'
  213. ),
  214. 'featuremap_property', 0, 1, 'tripal'
  215. );
  216. tripal_cv_add_cvterm(
  217. array(
  218. 'name' => 'Methods',
  219. 'def' => 'A brief description of the methods used to construct the map.'
  220. ),
  221. 'featuremap_property', 0, 1, 'tripal'
  222. );
  223. tripal_cv_add_cvterm(
  224. array(
  225. 'name' => 'Software',
  226. 'def' => 'The software used to construct the map.'
  227. ),
  228. 'featuremap_property', 0, 1, 'tripal'
  229. );
  230. }
  231. /**
  232. * Add custom tables needed by the feature map module
  233. * - featuremapprop
  234. * - featuremap_dbxref
  235. * - featureposprop
  236. *
  237. * @ingroup tripal_featuremap
  238. */
  239. function tripal_featuremap_add_custom_tables(){
  240. // add the featuremaprop table to Chado
  241. $schema = array (
  242. 'table' => 'featuremapprop',
  243. 'fields' => array (
  244. 'featuremapprop_id' => array (
  245. 'type' => 'serial',
  246. 'not null' => true,
  247. ),
  248. 'featuremap_id' => array (
  249. 'type' => 'int',
  250. 'not null' => true,
  251. ),
  252. 'type_id' => array (
  253. 'type' => 'int',
  254. 'not null' => true,
  255. ),
  256. 'value' => array (
  257. 'type' => 'text',
  258. 'not null' => false,
  259. ),
  260. 'rank' => array (
  261. 'type' => 'int',
  262. 'not null' => true,
  263. 'default' => 0,
  264. ),
  265. ),
  266. 'primary key' => array (
  267. 0 => 'featuremapprop_id',
  268. ),
  269. 'unique keys' => array (
  270. 'featuremapprop_c1' => array (
  271. 0 => 'featuremap_id',
  272. 1 => 'type_id',
  273. 2 => 'rank',
  274. ),
  275. ),
  276. 'indexes' => array (
  277. 'featuremapprop_idx1' => array (
  278. 0 => 'featuremap_id',
  279. ),
  280. 'featuremapprop_idx2' => array (
  281. 0 => 'type_id',
  282. ),
  283. ),
  284. 'foreign keys' => array (
  285. 'cvterm' => array (
  286. 'table' => 'cvterm',
  287. 'columns' => array (
  288. 'type_id' => 'cvterm_id',
  289. ),
  290. ),
  291. 'featuremap' => array (
  292. 'table' => 'featuremap',
  293. 'columns' => array (
  294. 'featuremap_id' => 'featuremap_id',
  295. ),
  296. ),
  297. ),
  298. );
  299. chado_create_custom_table('featuremapprop', $schema, TRUE);
  300. // add the featuremap_dbxref table to Chado
  301. $schema = array (
  302. 'table' => 'featuremap_dbxref',
  303. 'fields' => array (
  304. 'featuremap_dbxref_id' => array (
  305. 'type' => 'serial',
  306. 'not null' => true,
  307. ),
  308. 'featuremap_id' => array (
  309. 'type' => 'int',
  310. 'not null' => true,
  311. ),
  312. 'dbxref_id' => array (
  313. 'type' => 'int',
  314. 'not null' => true,
  315. ),
  316. ),
  317. 'primary key' => array (
  318. 0 => 'featuremap_dbxref_id',
  319. ),
  320. 'unique keys' => array (
  321. 'featuremap_dbxref_c1' => array (
  322. 0 => 'featuremap_id',
  323. 1 => 'dbxref_id',
  324. ),
  325. ),
  326. 'indexes' => array (
  327. 'featuremap_dbxref_idx1' => array (
  328. 0 => 'featuremap_dbxref_id',
  329. ),
  330. 'featuremap_dbxref_idx2' => array (
  331. 0 => 'dbxref_id',
  332. ),
  333. ),
  334. 'foreign keys' => array (
  335. 'dbxref' => array (
  336. 'table' => 'dbxref',
  337. 'columns' => array (
  338. 'dbxref_id' => 'dbxref_id',
  339. ),
  340. ),
  341. 'featuremap' => array (
  342. 'table' => 'featuremap',
  343. 'columns' => array (
  344. 'featuremap_id' => 'featuremap_id',
  345. ),
  346. ),
  347. ),
  348. 'referring_tables' => NULL,
  349. );
  350. chado_create_custom_table('featuremap_dbxref', $schema, TRUE);
  351. $schema = array (
  352. 'table' => 'featureposprop',
  353. 'fields' => array (
  354. 'featureposprop_id' => array (
  355. 'type' => 'serial',
  356. 'not null' => true,
  357. ),
  358. 'featurepos_id' => array (
  359. 'type' => 'int',
  360. 'not null' => true,
  361. ),
  362. 'type_id' => array (
  363. 'type' => 'int',
  364. 'not null' => true,
  365. ),
  366. 'value' => array (
  367. 'type' => 'text',
  368. 'not null' => false,
  369. ),
  370. 'rank' => array (
  371. 'type' => 'int',
  372. 'not null' => true,
  373. 'default' => 0,
  374. ),
  375. ),
  376. 'primary key' => array (
  377. 0 => 'featureposprop_id',
  378. ),
  379. 'unique keys' => array (
  380. 'featureposprop_id' => array (
  381. 0 => 'featurepos_id',
  382. 1 => 'type_id',
  383. 2 => 'rank',
  384. ),
  385. ),
  386. 'indexes' => array (
  387. 'featureposprop_c1' => array (
  388. 0 => 'featurepos_id',
  389. ),
  390. 'featureposprop_idx2' => array (
  391. 0 => 'type_id',
  392. ),
  393. ),
  394. 'foreign keys' => array (
  395. 'cvterm' => array (
  396. 'table' => 'cvterm',
  397. 'columns' => array (
  398. 'type_id' => 'cvterm_id',
  399. ),
  400. ),
  401. 'featurepos' => array (
  402. 'table' => 'featurepos',
  403. 'columns' => array (
  404. 'featurepos_id' => 'featurepos_id',
  405. ),
  406. ),
  407. ),
  408. );
  409. chado_create_custom_table('featureposprop', $schema, TRUE);
  410. }