tripal_featuremap.install 8.4 KB

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