tripal_analysis_kegg.install 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*******************************************************************************
  3. * Implementation of hook_install();
  4. */
  5. function tripal_analysis_kegg_install(){
  6. // create the module's data directory
  7. tripal_create_moddir('tripal_analysis_kegg');
  8. // We need to register to tripal_analysis module so it can provide a control
  9. // for our kegg result. Basically the registration is done by inserting
  10. // modulename into the drupal {tripal_analysis} table AND inserting required
  11. // information to the chado Analysis table. Also in tripal_analysis_interpro.module,
  12. // we need to define HOOK_get_settings() for the module to work properly.
  13. // Inert into drupal's {tripal_analysis}
  14. tripal_analysis_register_child('tripal_analysis_kegg');
  15. // Add cvterm 'analysis_interpro_settings' for inserting into analysisprop table
  16. tripal_add_cvterms('analysis_kegg_settings', 'Settings of a KEGG analysis, '.
  17. 'Currently include only the heir.tar.gz file name & path.');
  18. tripal_add_cvterms('kegg_brite_data', 'This term is intended for use '.
  19. 'in the analysisfeatureprop table to store the KAAS results data.');
  20. // add the db and the cv for the KEGG terms
  21. tripal_add_db('KEGG','KEGG: Kyoto Encyclopedia of Genes and Genomes.',
  22. 'http://www.genome.jp',
  23. 'http://www.genome.jp/kegg/');
  24. tripal_add_mview(
  25. // view name
  26. 'kegg_by_organism',
  27. // tripal module name
  28. 'kegg_by_organism',
  29. // table name
  30. 'kegg_by_organism',
  31. // table schema definition
  32. 'analysis_name character varying(255),
  33. analysis_id integer,
  34. organism_id integer',
  35. // columns for indexing
  36. 'analysis_id,organism_id',
  37. // SQL statement to populate the view
  38. "SELECT DISTINCT A.name,A.analysis_id,F.organism_id
  39. FROM {analysisprop} AP
  40. INNER JOIN analysis A on A.analysis_id = AP.analysis_id
  41. INNER JOIN cvterm CVT on CVT.cvterm_id = AP.type_id
  42. INNER JOIN analysisfeature AF on AF.analysis_id = A.analysis_id
  43. INNER JOIN feature F on F.feature_id = AF.feature_id
  44. WHERE CVT.name = 'analysis_kegg_settings'",
  45. // special index
  46. ''
  47. );
  48. }
  49. /*******************************************************************************
  50. * Implementation of hook_uninstall()
  51. */
  52. function tripal_analysis_kegg_uninstall(){
  53. // tripal_delete_db('KEGG');
  54. tripal_analysis_unregister_child('tripal_analysis_kegg');
  55. $mview = tripal_mviews_get_mview_id('kegg_by_organism');
  56. if($mview){
  57. tripal_mviews_action('delete',$mview);
  58. }
  59. }
  60. /*******************************************************************************
  61. * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
  62. * Analysis' are enabled before installation
  63. */
  64. function tripal_analysis_kegg_requirements($phase) {
  65. $requirements = array();
  66. if ($phase == 'install') {
  67. if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
  68. $requirements ['tripal_analysis_kegg'] = array(
  69. 'title' => "tripal_analysis_kegg",
  70. 'value' => "error. Some required modules are just being installed. Please try again.",
  71. 'severity' => REQUIREMENT_ERROR,
  72. );
  73. }
  74. }
  75. return $requirements;
  76. }