blast_ui.install 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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' => array(
  56. 'description' => t('The Database records from this BLAST Database reference.'),
  57. 'type' => 'int',
  58. ),
  59. ),
  60. 'indexes' => array(
  61. 'name' => array('name'),
  62. ),
  63. 'primary key' => array('nid'),
  64. 'unique keys' => array(
  65. 'nid' => array('nid'),
  66. ),
  67. );
  68. return $schema;
  69. }
  70. /**
  71. * Make BlastDB type more readable & support Link-outs for BLAST Hits.
  72. */
  73. function blast_ui_update_7101() {
  74. // Changing the length of the type field to allow it to be more readable.
  75. db_change_field('blastdb', 'dbtype', 'dbtype',
  76. array(
  77. 'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
  78. 'type' => 'varchar',
  79. 'length' => 15,
  80. 'not null' => true,
  81. )
  82. );
  83. // Add fields related to Link-outs
  84. db_add_field(
  85. 'blastdb',
  86. 'dbxref_id_regex',
  87. array(
  88. 'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
  89. 'type' => 'text',
  90. )
  91. );
  92. db_add_field(
  93. 'blastdb',
  94. 'dbxref_db_id',
  95. array(
  96. 'description' => t('The Database records from this BLAST Database reference.'),
  97. 'type' => 'int',
  98. )
  99. );
  100. }