blast_ui.install 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /**
  3. * @file
  4. * Contains hooks to handle installation of this module.
  5. *
  6. * Specifically, a database table (blastdb) is created to store additional information
  7. * related to blast database nodes such as the name/path to the NCBI BLAST database files
  8. * and the type (protein or nucleotide) of the database.
  9. */
  10. /**
  11. * Implements hook_install().
  12. */
  13. function blast_ui_install() {
  14. tripal_create_files_dir('tripal_blast');
  15. }
  16. /**
  17. * Implements hook_schema().
  18. * Create the blastdb database table for storing addditional info related to blastdb nodes.
  19. *
  20. * NOTE: This hook is called via Drupal magic during the installation process and no longer
  21. * needs to be called explicitly in hook_install().
  22. */
  23. function blast_ui_schema(){
  24. $schema['blastdb'] = array(
  25. 'description' => t('The base table for blastdb node'),
  26. 'fields' => array(
  27. 'nid' => array(
  28. 'description' => t('The primary identifier for a node.'),
  29. 'type' => 'serial',
  30. 'unsigned' => true,
  31. 'not null' => true,
  32. ),
  33. 'name' => array(
  34. 'description' => t('The human-readable name of the blast database.'),
  35. 'type' => 'varchar',
  36. 'length' => 255,
  37. 'not null' => true,
  38. ),
  39. 'path' => array(
  40. 'description' => t('The full path and filename prefix of the blast database.'),
  41. 'type' => 'varchar',
  42. 'length' => 1023,
  43. 'not null' => true,
  44. ),
  45. 'dbtype' => array(
  46. 'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
  47. 'type' => 'varchar',
  48. 'length' => 15,
  49. 'not null' => true,
  50. ),
  51. 'dbxref_id_regex' => array(
  52. 'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
  53. 'type' => 'text',
  54. ),
  55. 'dbxref_db_id' => array(
  56. 'description' => t('The Database records from this BLAST Database reference.'),
  57. 'type' => 'int',
  58. ),
  59. 'dbxref_linkout_type' => array(
  60. 'description' => t('Type of linkout to be used for this database reference.'),
  61. 'type' => 'varchar',
  62. 'length' => 50,
  63. 'not null' => true,
  64. 'default' => 'link'
  65. ),
  66. 'gbrowse_path' => array(
  67. 'description' => t('The gbrowse URL in the website of the target database.'),
  68. 'type' => 'varchar',
  69. 'length' => 1023,
  70. 'not null' => true,
  71. ),
  72. ),
  73. 'indexes' => array(
  74. 'name' => array('name'),
  75. ),
  76. 'primary key' => array('nid'),
  77. 'unique keys' => array(
  78. 'nid' => array('nid'),
  79. ),
  80. );
  81. return $schema;
  82. }
  83. /**
  84. * Make BlastDB type more readable & support Link-outs for BLAST Hits.
  85. */
  86. function blast_ui_update_7101() {
  87. // Changing the length of the type field to allow it to be more readable.
  88. db_change_field('blastdb', 'dbtype', 'dbtype',
  89. array(
  90. 'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
  91. 'type' => 'varchar',
  92. 'length' => 15,
  93. 'not null' => true,
  94. )
  95. );
  96. // Add fields related to Link-outs
  97. db_add_field(
  98. 'blastdb',
  99. 'dbxref_id_regex',
  100. array(
  101. 'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
  102. 'type' => 'text',
  103. )
  104. );
  105. db_add_field(
  106. 'blastdb',
  107. 'dbxref_db_id',
  108. array(
  109. 'description' => t('The Database records from this BLAST Database reference.'),
  110. 'type' => 'int',
  111. )
  112. );
  113. }
  114. /**
  115. * Support complex types of link-outs such as GBrowse & JBrowse coordinate links.
  116. */
  117. function blast_ui_update_7102() {
  118. db_add_field(
  119. 'blastdb',
  120. 'dbxref_linkout_type',
  121. array(
  122. 'description' => t('Type of linkout to be used for this database reference.'),
  123. 'type' => 'varchar',
  124. 'length' => 50,
  125. 'not null' => true,
  126. 'default' => 'link'
  127. )
  128. );
  129. }