blast_ui.install 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. // A table ot keep extra information related to blastdb nodes.
  25. $schema['blastdb'] = array(
  26. 'description' => t('The base table for blastdb node'),
  27. 'fields' => array(
  28. 'nid' => array(
  29. 'description' => t('The primary identifier for a node.'),
  30. 'type' => 'serial',
  31. 'unsigned' => true,
  32. 'not null' => true,
  33. ),
  34. 'name' => array(
  35. 'description' => t('The human-readable name of the blast database.'),
  36. 'type' => 'varchar',
  37. 'length' => 255,
  38. 'not null' => true,
  39. ),
  40. 'path' => array(
  41. 'description' => t('The full path and filename prefix of the blast database.'),
  42. 'type' => 'varchar',
  43. 'length' => 1023,
  44. 'not null' => true,
  45. ),
  46. 'dbtype' => array(
  47. 'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
  48. 'type' => 'varchar',
  49. 'length' => 15,
  50. 'not null' => true,
  51. ),
  52. 'dbxref_id_regex' => array(
  53. 'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
  54. 'type' => 'text',
  55. ),
  56. 'dbxref_db_id' => array(
  57. 'description' => t('The Database records from this BLAST Database reference.'),
  58. 'type' => 'int',
  59. ),
  60. 'dbxref_linkout_type' => array(
  61. 'description' => t('Type of linkout to be used for this database reference.'),
  62. 'type' => 'varchar',
  63. 'length' => 50,
  64. 'not null' => true,
  65. 'default' => 'link'
  66. ),
  67. ),
  68. 'indexes' => array(
  69. 'name' => array('name'),
  70. ),
  71. 'primary key' => array('nid'),
  72. 'unique keys' => array(
  73. 'nid' => array('nid'),
  74. ),
  75. );
  76. // BLAST JOBS
  77. // ------------------------
  78. // Keeps track of additional information related to tripal blast jobs.
  79. $schema['blastjob'] = array(
  80. 'description' => t('Keeps track of additional information related to tripal blast jobs.'),
  81. 'fields' => array(
  82. 'job_id' => array(
  83. 'description' => t('The Tripal job_id for the blast job.'),
  84. 'type' => 'int',
  85. 'unsigned' => true,
  86. 'not null' => true,
  87. ),
  88. 'blast_program' => array(
  89. 'description' => t('The program to use to run the blast (ie: blastn, blastp, etc.).'),
  90. 'type' => 'varchar',
  91. 'length' => 20,
  92. 'not null' => true,
  93. ),
  94. 'target_blastdb' => array(
  95. 'description' => t('The nid of the blastdb used to search against; NULL if target was uploaded.'),
  96. 'type' => 'int',
  97. 'unsigned' => true,
  98. ),
  99. 'target_file' => array(
  100. 'description' => t('The absolute path to the uploaded blast database after it was run through makeblastdb; NULL if target was NOT uploaded.'),
  101. 'type' => 'text',
  102. ),
  103. 'query_file' => array(
  104. 'description' => t('The absolute path to the query file.'),
  105. 'type' => 'text',
  106. ),
  107. 'result_filestub' => array(
  108. 'description' => t('The absolute path and filename (without extension) of the blast results.'),
  109. 'type' => 'text',
  110. ),
  111. 'options' => array(
  112. 'description' => t('A serialized array of options selected for the blast job where the key is the machine name of the option used when calling blast (ie: gapextend) and the value is the value of the option.'),
  113. 'type' => 'text',
  114. ),
  115. ),
  116. 'primary key' => array('job_id'),
  117. 'foreign keys' => array(
  118. 'job_id' => array(
  119. 'table' => 'tripal_jobs',
  120. 'columns' => array(
  121. 'job_id' => 'job_id',
  122. ),
  123. ),
  124. ),
  125. );
  126. return $schema;
  127. }
  128. /**
  129. * Make BlastDB type more readable & support Link-outs for BLAST Hits.
  130. */
  131. function blast_ui_update_7101() {
  132. // Changing the length of the type field to allow it to be more readable.
  133. db_change_field('blastdb', 'dbtype', 'dbtype',
  134. array(
  135. 'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
  136. 'type' => 'varchar',
  137. 'length' => 15,
  138. 'not null' => true,
  139. )
  140. );
  141. // Add fields related to Link-outs
  142. db_add_field(
  143. 'blastdb',
  144. 'dbxref_id_regex',
  145. array(
  146. 'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
  147. 'type' => 'text',
  148. )
  149. );
  150. db_add_field(
  151. 'blastdb',
  152. 'dbxref_db_id',
  153. array(
  154. 'description' => t('The Database records from this BLAST Database reference.'),
  155. 'type' => 'int',
  156. )
  157. );
  158. }
  159. /**
  160. * Support complex types of link-outs such as GBrowse & JBrowse coordinate links.
  161. */
  162. function blast_ui_update_7102() {
  163. db_add_field(
  164. 'blastdb',
  165. 'dbxref_linkout_type',
  166. array(
  167. 'description' => t('Type of linkout to be used for this database reference.'),
  168. 'type' => 'varchar',
  169. 'length' => 50,
  170. 'not null' => true,
  171. 'default' => 'link'
  172. )
  173. );
  174. }
  175. /**
  176. * Add saving of blast job information for recent job list & resubmit functionality.
  177. */
  178. function blast_ui_update_7103() {
  179. $schema = array();
  180. // Keeps track of additional information related to tripal blast jobs.
  181. $schema['blastjob'] = array(
  182. 'description' => t('Keeps track of additional information related to tripal blast jobs.'),
  183. 'fields' => array(
  184. 'job_id' => array(
  185. 'description' => t('The Tripal job_id for the blast job.'),
  186. 'type' => 'int',
  187. 'unsigned' => true,
  188. 'not null' => true,
  189. ),
  190. 'blast_program' => array(
  191. 'description' => t('The program to use to run the blast (ie: blastn, blastp, etc.).'),
  192. 'type' => 'varchar',
  193. 'length' => 20,
  194. 'not null' => true,
  195. ),
  196. 'target_blastdb' => array(
  197. 'description' => t('The nid of the blastdb used to search against; NULL if target was uploaded.'),
  198. 'type' => 'int',
  199. 'unsigned' => true,
  200. ),
  201. 'target_file' => array(
  202. 'description' => t('The absolute path to the uploaded blast database after it was run through makeblastdb; NULL if target was NOT uploaded.'),
  203. 'type' => 'text',
  204. ),
  205. 'query_file' => array(
  206. 'description' => t('The absolute path to the query file.'),
  207. 'type' => 'text',
  208. ),
  209. 'result_filestub' => array(
  210. 'description' => t('The absolute path and filename (without extension) of the blast results.'),
  211. 'type' => 'text',
  212. ),
  213. 'options' => array(
  214. 'description' => t('A serialized array of options selected for the blast job where the key is the machine name of the option used when calling blast (ie: gapextend) and the value is the value of the option.'),
  215. 'type' => 'text',
  216. ),
  217. ),
  218. 'primary key' => array('job_id'),
  219. 'foreign keys' => array(
  220. 'job_id' => array(
  221. 'table' => 'tripal_jobs',
  222. 'columns' => array(
  223. 'job_id' => 'job_id',
  224. ),
  225. ),
  226. ),
  227. );
  228. // First create the tables.
  229. db_create_table('blastjob', $schema['blastjob']);
  230. }