blast_ui.install 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. ),
  67. 'indexes' => array(
  68. 'name' => array('name'),
  69. ),
  70. 'primary key' => array('nid'),
  71. 'unique keys' => array(
  72. 'nid' => array('nid'),
  73. ),
  74. );
  75. return $schema;
  76. }
  77. /**
  78. * Make BlastDB type more readable & support Link-outs for BLAST Hits.
  79. */
  80. function blast_ui_update_7101() {
  81. // Changing the length of the type field to allow it to be more readable.
  82. db_change_field('blastdb', 'dbtype', 'dbtype',
  83. array(
  84. 'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
  85. 'type' => 'varchar',
  86. 'length' => 15,
  87. 'not null' => true,
  88. )
  89. );
  90. // Add fields related to Link-outs
  91. db_add_field(
  92. 'blastdb',
  93. 'dbxref_id_regex',
  94. array(
  95. 'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
  96. 'type' => 'text',
  97. )
  98. );
  99. db_add_field(
  100. 'blastdb',
  101. 'dbxref_db_id',
  102. array(
  103. 'description' => t('The Database records from this BLAST Database reference.'),
  104. 'type' => 'int',
  105. )
  106. );
  107. }
  108. /**
  109. * Support complex types of link-outs such as GBrowse & JBrowse coordinate links.
  110. */
  111. function blast_ui_update_7102() {
  112. db_add_field(
  113. 'blastdb',
  114. 'dbxref_linkout_type',
  115. array(
  116. 'description' => t('Type of linkout to be used for this database reference.'),
  117. 'type' => 'varchar',
  118. 'length' => 50,
  119. 'not null' => true,
  120. 'default' => 'link'
  121. )
  122. );
  123. }