tripal_analysis_kegg.install 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 the cvterms needed for this module
  16. tripal_analysis_kegg_add_cvterms ();
  17. // add the db and the cv for the KEGG terms
  18. tripal_add_db('KEGG','KEGG: Kyoto Encyclopedia of Genes and Genomes.',
  19. 'http://www.genome.jp',
  20. 'http://www.genome.jp/kegg/');
  21. tripal_add_mview(
  22. // view name
  23. 'kegg_by_organism',
  24. // tripal module name
  25. 'kegg_by_organism',
  26. // table name
  27. 'kegg_by_organism',
  28. // table schema definition
  29. 'analysis_name character varying(255),
  30. analysis_id integer,
  31. organism_id integer',
  32. // columns for indexing
  33. 'analysis_id,organism_id',
  34. // SQL statement to populate the view
  35. "SELECT DISTINCT A.name,A.analysis_id,F.organism_id
  36. FROM {analysisprop} AP
  37. INNER JOIN analysis A on A.analysis_id = AP.analysis_id
  38. INNER JOIN cvterm CVT on CVT.cvterm_id = AP.type_id
  39. INNER JOIN analysisfeature AF on AF.analysis_id = A.analysis_id
  40. INNER JOIN feature F on F.feature_id = AF.feature_id
  41. WHERE CVT.name = 'analysis_kegg_settings'",
  42. // special index
  43. ''
  44. );
  45. }
  46. /*******************************************************************************
  47. * Provide update script for adding new cvterms
  48. */
  49. function tripal_analysis_kegg_update_6000(){
  50. // we have some new cvterms to add
  51. tripal_analysis_kegg_add_cvterms();
  52. $ret = array(
  53. '#finished' => 1,
  54. );
  55. return $ret;
  56. }
  57. /**
  58. *
  59. */
  60. function tripal_analysis_kegg_add_cvterms () {
  61. tripal_add_cvterms('analysis_kegg_settings', 'Settings of a KEGG analysis, Currently include only the heir.tar.gz file name & path.');
  62. tripal_add_cvterms('kegg_brite_data', 'This term is intended for use in the analysisfeatureprop table to store the KAAS results data.');
  63. tripal_add_cvterms('analysis_kegg_query_re','The regular expression for finding the feature name in the query definition line of the blast results');
  64. tripal_add_cvterms('analysis_kegg_query_type','The feature type (e.g. mRNA, polypeptide) of the query input file. This type is used to identify the query feature when multiple features have the same name');
  65. tripal_add_cvterms('analysis_kegg_query_uniquename','Indicates if the matched name in the query definition line of the blast results is feature uniquename');
  66. tripal_add_cvterms('analysis_kegg_output_keywords', 'Selected keywords for kegg html output which are indexed for search.');
  67. }
  68. /*******************************************************************************
  69. * Implementation of hook_uninstall()
  70. */
  71. function tripal_analysis_kegg_uninstall(){
  72. // tripal_delete_db('KEGG');
  73. tripal_analysis_unregister_child('tripal_analysis_kegg');
  74. $mview = tripal_mviews_get_mview_id('kegg_by_organism');
  75. if($mview){
  76. tripal_mviews_action('delete',$mview);
  77. }
  78. }
  79. /*******************************************************************************
  80. * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
  81. * Analysis' are enabled before installation
  82. */
  83. function tripal_analysis_kegg_requirements($phase) {
  84. $requirements = array();
  85. if ($phase == 'install') {
  86. if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
  87. $requirements ['tripal_analysis_kegg'] = array(
  88. 'title' => "tripal_analysis_kegg",
  89. 'value' => "error. Some required modules are just being installed. Please try again.",
  90. 'severity' => REQUIREMENT_ERROR,
  91. );
  92. }
  93. }
  94. return $requirements;
  95. }