tripal_featuremap.install 9.7 KB

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