tripal_featuremap.install 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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_legacy_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_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
  18. }
  19. }
  20. /**
  21. * Implementation of hook_requirements().
  22. *
  23. * @ingroup tripal_legacy_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_legacy_featuremap
  43. */
  44. function tripal_featuremap_install() {
  45. // add the featuremapprop table to Chado
  46. tripal_featuremap_add_custom_tables();
  47. // Add cvterms
  48. tripal_featuremap_add_cvs();
  49. tripal_featuremap_add_cvterms();
  50. // set the default vocabularies
  51. tripal_set_default_cv('featuremapprop', 'type_id', 'featuremap_property');
  52. tripal_set_default_cv('featureposprop', 'type_id', 'featurepos_property');
  53. tripal_set_default_cv('featuremap', 'unittype_id', 'featuremap_units');
  54. }
  55. /**
  56. * Implementation of hook_uninstall().
  57. *
  58. * @ingroup tripal_legacy_featuremap
  59. */
  60. function tripal_featuremap_uninstall() {
  61. }
  62. /**
  63. * Implementation of hook_schema().
  64. *
  65. * @ingroup tripal_legacy_featuremap
  66. */
  67. function tripal_featuremap_schema() {
  68. $schema['chado_featuremap'] = array(
  69. 'fields' => array(
  70. 'vid' => array(
  71. 'type' => 'int',
  72. 'unsigned' => TRUE,
  73. 'not null' => TRUE,
  74. 'default' => 0
  75. ),
  76. 'nid' => array(
  77. 'type' => 'int',
  78. 'unsigned' => TRUE,
  79. 'not null' => TRUE,
  80. 'default' => 0
  81. ),
  82. 'featuremap_id' => array(
  83. 'type' => 'int',
  84. 'not null' => TRUE,
  85. 'default' => 0
  86. )
  87. ),
  88. 'indexes' => array(
  89. 'featuremap_id' => array('featuremap_id')
  90. ),
  91. 'unique keys' => array(
  92. 'nid_vid' => array('nid', 'vid'),
  93. 'vid' => array('vid')
  94. ),
  95. 'primary key' => array('nid'),
  96. );
  97. return $schema;
  98. }
  99. /**
  100. * Add cvs needed by the featuremap module
  101. *
  102. * @ingroup tripal_legacy_featuremap
  103. */
  104. function tripal_featuremap_add_cvs() {
  105. tripal_insert_cv(
  106. 'featuremap_units',
  107. 'Contains map unit types for the unittype_id column of the featuremap table.'
  108. );
  109. tripal_insert_cv(
  110. 'featurepos_property',
  111. 'Contains terms map properties.'
  112. );
  113. tripal_insert_cv(
  114. 'featuremap_property',
  115. 'Contains positional types for the feature positions'
  116. );
  117. }
  118. /**
  119. * Add cv terms needed by the featuremap module
  120. *
  121. * @ingroup tripal_legacy_featuremap
  122. */
  123. function tripal_featuremap_add_cvterms() {
  124. // add cvterms for the map unit types
  125. tripal_insert_cvterm(
  126. array(
  127. 'name' => 'cM',
  128. 'definition' => 'Centimorgan units',
  129. 'cv_name' => 'featuremap_units',
  130. 'is_relationship' => 0,
  131. 'db_name' => 'tripal'
  132. ),
  133. array('update_existing' => TRUE)
  134. );
  135. tripal_insert_cvterm(
  136. array(
  137. 'name' => 'bp',
  138. 'definition' => 'Base pairs units',
  139. 'cv_name' => 'featuremap_units',
  140. 'is_relationship' => 0,
  141. 'db_name' => 'tripal'
  142. ),
  143. array('update_existing' => TRUE)
  144. );
  145. tripal_insert_cvterm(
  146. array(
  147. 'name' => 'bin_unit',
  148. 'definition' => 'The bin unit',
  149. 'cv_name' => 'featuremap_units',
  150. 'is_relationship' => 0,
  151. 'db_name' => 'tripal'
  152. ),
  153. array('update_existing' => TRUE)
  154. );
  155. tripal_insert_cvterm(
  156. array(
  157. 'name' => 'marker_order',
  158. 'definition' => 'Units simply to define marker order.',
  159. 'cv_name' => 'featuremap_units',
  160. 'is_relationship' => 0,
  161. 'db_name' => 'tripal'
  162. ),
  163. array('update_existing' => TRUE)
  164. );
  165. tripal_insert_cvterm(
  166. array(
  167. 'name' => 'undefined',
  168. 'definition' => 'A catch-all for an undefined unit type',
  169. 'cv_name' => 'featuremap_units',
  170. 'is_relationship' => 0,
  171. 'db_name' => 'tripal'
  172. ),
  173. array('update_existing' => TRUE)
  174. );
  175. // featurepos properties
  176. tripal_insert_cvterm(
  177. array(
  178. 'name' => 'start',
  179. 'definition' => 'The start coordinate for a map feature.',
  180. 'cv_name' => 'featurepos_property',
  181. 'is_relationship' => 0,
  182. 'db_name' => 'tripal'
  183. ),
  184. array('update_existing' => TRUE)
  185. );
  186. tripal_insert_cvterm(
  187. array(
  188. 'name' => 'stop',
  189. 'definition' => 'The end coordinate for a map feature',
  190. 'cv_name' => 'featurepos_property',
  191. 'is_relationship' => 0,
  192. 'db_name' => 'tripal'
  193. ),
  194. array('update_existing' => TRUE)
  195. );
  196. // add cvterms for map properties
  197. tripal_insert_cvterm(
  198. array(
  199. 'name' => 'Map Dbxref',
  200. 'definition' => 'A unique identifer for the map in a remote database. The '
  201. . 'format is a database abbreviation and a unique accession separated '
  202. . 'by a colon. (e.g. Gramene:tsh1996a)',
  203. 'cv_name' => 'featuremap_property',
  204. 'is_relationship' => 0,
  205. 'db_name' => 'tripal'
  206. ),
  207. array('update_existing' => TRUE)
  208. );
  209. tripal_insert_cvterm(
  210. array(
  211. 'name' => 'Map Type',
  212. 'definition' => 'The type of Map (e.g. QTL, Physical, etc.)',
  213. 'cv_name' => 'featuremap_property',
  214. 'is_relationship' => 0,
  215. 'db_name' => 'tripal'
  216. ),
  217. array('update_existing' => TRUE)
  218. );
  219. tripal_insert_cvterm(
  220. array(
  221. 'name' => 'Genome Group',
  222. 'definition' => '',
  223. 'cv_name' => 'featuremap_property',
  224. 'is_relationship' => 0,
  225. 'db_name' => 'tripal'
  226. ),
  227. array('update_existing' => TRUE)
  228. );
  229. tripal_insert_cvterm(
  230. array(
  231. 'name' => 'URL',
  232. 'definition' => 'A univeral resource locator (URL) reference where the '
  233. . 'publication can be found. For maps found online, this would be '
  234. . 'the web address for the map.',
  235. 'cv_name' => 'featuremap_property',
  236. 'is_relationship' => 0,
  237. 'db_name' => 'tripal'
  238. ),
  239. array('update_existing' => TRUE)
  240. );
  241. tripal_insert_cvterm(
  242. array(
  243. 'name' => 'Population Type',
  244. 'definition' => 'A brief description of the population type used to generate '
  245. . 'the map (e.g. RIL, F2, BC1, etc).',
  246. 'cv_name' => 'featuremap_property',
  247. 'is_relationship' => 0,
  248. 'db_name' => 'tripal'
  249. ),
  250. array('update_existing' => TRUE)
  251. );
  252. tripal_insert_cvterm(
  253. array(
  254. 'name' => 'Population Size',
  255. 'definition' => 'The size of the population used to construct the map.',
  256. 'cv_name' => 'featuremap_property',
  257. 'is_relationship' => 0,
  258. 'db_name' => 'tripal'
  259. ),
  260. array('update_existing' => TRUE)
  261. );
  262. tripal_insert_cvterm(
  263. array(
  264. 'name' => 'Methods',
  265. 'definition' => 'A brief description of the methods used to construct the map.',
  266. 'cv_name' => 'featuremap_property',
  267. 'is_relationship' => 0,
  268. 'db_name' => 'tripal'
  269. ),
  270. array('update_existing' => TRUE)
  271. );
  272. tripal_insert_cvterm(
  273. array(
  274. 'name' => 'Software',
  275. 'definition' => 'The software used to construct the map.',
  276. 'cv_name' => 'featuremap_property',
  277. 'is_relationship' => 0,
  278. 'db_name' => 'tripal'
  279. ),
  280. array('update_existing' => TRUE)
  281. );
  282. }
  283. /**
  284. * Add custom tables needed by the feature map module
  285. * - featuremapprop
  286. * - featuremap_dbxref
  287. * - featureposprop
  288. *
  289. * @ingroup tripal_legacy_featuremap
  290. */
  291. // This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
  292. /* function tripal_featuremap_add_custom_tables(){
  293. // add the featuremaprop table to Chado
  294. $schema = array (
  295. 'table' => 'featuremapprop',
  296. 'fields' => array (
  297. 'featuremapprop_id' => array (
  298. 'type' => 'serial',
  299. 'not null' => true,
  300. ),
  301. 'featuremap_id' => array (
  302. 'type' => 'int',
  303. 'not null' => true,
  304. ),
  305. 'type_id' => array (
  306. 'type' => 'int',
  307. 'not null' => true,
  308. ),
  309. 'value' => array (
  310. 'type' => 'text',
  311. 'not null' => false,
  312. ),
  313. 'rank' => array (
  314. 'type' => 'int',
  315. 'not null' => true,
  316. 'default' => 0,
  317. ),
  318. ),
  319. 'primary key' => array (
  320. 0 => 'featuremapprop_id',
  321. ),
  322. 'unique keys' => array (
  323. 'featuremapprop_c1' => array (
  324. 0 => 'featuremap_id',
  325. 1 => 'type_id',
  326. 2 => 'rank',
  327. ),
  328. ),
  329. 'indexes' => array (
  330. 'featuremapprop_idx1' => array (
  331. 0 => 'featuremap_id',
  332. ),
  333. 'featuremapprop_idx2' => array (
  334. 0 => 'type_id',
  335. ),
  336. ),
  337. 'foreign keys' => array (
  338. 'cvterm' => array (
  339. 'table' => 'cvterm',
  340. 'columns' => array (
  341. 'type_id' => 'cvterm_id',
  342. ),
  343. ),
  344. 'featuremap' => array (
  345. 'table' => 'featuremap',
  346. 'columns' => array (
  347. 'featuremap_id' => 'featuremap_id',
  348. ),
  349. ),
  350. ),
  351. );
  352. chado_create_custom_table('featuremapprop', $schema, TRUE);
  353. // add the featuremap_dbxref table to Chado
  354. $schema = array (
  355. 'table' => 'featuremap_dbxref',
  356. 'fields' => array (
  357. 'featuremap_dbxref_id' => array (
  358. 'type' => 'serial',
  359. 'not null' => true,
  360. ),
  361. 'featuremap_id' => array (
  362. 'type' => 'int',
  363. 'not null' => true,
  364. ),
  365. 'dbxref_id' => array (
  366. 'type' => 'int',
  367. 'not null' => true,
  368. ),
  369. ),
  370. 'primary key' => array (
  371. 0 => 'featuremap_dbxref_id',
  372. ),
  373. 'unique keys' => array (
  374. 'featuremap_dbxref_c1' => array (
  375. 0 => 'featuremap_id',
  376. 1 => 'dbxref_id',
  377. ),
  378. ),
  379. 'indexes' => array (
  380. 'featuremap_dbxref_idx1' => array (
  381. 0 => 'featuremap_dbxref_id',
  382. ),
  383. 'featuremap_dbxref_idx2' => array (
  384. 0 => 'dbxref_id',
  385. ),
  386. ),
  387. 'foreign keys' => array (
  388. 'dbxref' => array (
  389. 'table' => 'dbxref',
  390. 'columns' => array (
  391. 'dbxref_id' => 'dbxref_id',
  392. ),
  393. ),
  394. 'featuremap' => array (
  395. 'table' => 'featuremap',
  396. 'columns' => array (
  397. 'featuremap_id' => 'featuremap_id',
  398. ),
  399. ),
  400. ),
  401. 'referring_tables' => NULL,
  402. );
  403. chado_create_custom_table('featuremap_dbxref', $schema, TRUE);
  404. $schema = array (
  405. 'table' => 'featureposprop',
  406. 'fields' => array (
  407. 'featureposprop_id' => array (
  408. 'type' => 'serial',
  409. 'not null' => true,
  410. ),
  411. 'featurepos_id' => array (
  412. 'type' => 'int',
  413. 'not null' => true,
  414. ),
  415. 'type_id' => array (
  416. 'type' => 'int',
  417. 'not null' => true,
  418. ),
  419. 'value' => array (
  420. 'type' => 'text',
  421. 'not null' => false,
  422. ),
  423. 'rank' => array (
  424. 'type' => 'int',
  425. 'not null' => true,
  426. 'default' => 0,
  427. ),
  428. ),
  429. 'primary key' => array (
  430. 0 => 'featureposprop_id',
  431. ),
  432. 'unique keys' => array (
  433. 'featureposprop_id' => array (
  434. 0 => 'featurepos_id',
  435. 1 => 'type_id',
  436. 2 => 'rank',
  437. ),
  438. ),
  439. 'indexes' => array (
  440. 'featureposprop_c1' => array (
  441. 0 => 'featurepos_id',
  442. ),
  443. 'featureposprop_idx2' => array (
  444. 0 => 'type_id',
  445. ),
  446. ),
  447. 'foreign keys' => array (
  448. 'cvterm' => array (
  449. 'table' => 'cvterm',
  450. 'columns' => array (
  451. 'type_id' => 'cvterm_id',
  452. ),
  453. ),
  454. 'featurepos' => array (
  455. 'table' => 'featurepos',
  456. 'columns' => array (
  457. 'featurepos_id' => 'featurepos_id',
  458. ),
  459. ),
  460. ),
  461. );
  462. chado_create_custom_table('featureposprop', $schema, TRUE);
  463. } */