blast_ui.install 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 to 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. 'cvitjs_enabled' => array(
  68. 'description' => t('Indicate if CViTjs should be used to display hits on a whole genome'),
  69. 'type' => 'int',
  70. 'not null' => false,
  71. 'default' => 0
  72. ),
  73. ),
  74. 'indexes' => array(
  75. 'name' => array('name'),
  76. ),
  77. 'primary key' => array('nid'),
  78. 'unique keys' => array(
  79. 'nid' => array('nid'),
  80. ),
  81. );
  82. // BLAST JOBS
  83. // ------------------------
  84. // Keeps track of additional information related to tripal blast jobs.
  85. $schema['blastjob'] = array(
  86. 'description' => t('Keeps track of additional information related to tripal blast jobs.'),
  87. 'fields' => array(
  88. 'job_id' => array(
  89. 'description' => t('The Tripal job_id for the blast job.'),
  90. 'type' => 'int',
  91. 'unsigned' => true,
  92. 'not null' => true,
  93. ),
  94. 'blast_program' => array(
  95. 'description' => t('The program to use to run the blast (ie: blastn, blastp, etc.).'),
  96. 'type' => 'varchar',
  97. 'length' => 20,
  98. 'not null' => true,
  99. ),
  100. 'target_blastdb' => array(
  101. 'description' => t('The nid of the blastdb used to search against; NULL if target was uploaded.'),
  102. 'type' => 'int',
  103. 'unsigned' => true,
  104. ),
  105. 'target_file' => array(
  106. 'description' => t('The absolute path to the uploaded blast database after it was run through makeblastdb; NULL if target was NOT uploaded.'),
  107. 'type' => 'text',
  108. ),
  109. 'query_file' => array(
  110. 'description' => t('The absolute path to the query file.'),
  111. 'type' => 'text',
  112. ),
  113. 'result_filestub' => array(
  114. 'description' => t('The absolute path and filename (without extension) of the blast results.'),
  115. 'type' => 'text',
  116. ),
  117. 'options' => array(
  118. '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.'),
  119. 'type' => 'text',
  120. ),
  121. ),
  122. 'primary key' => array('job_id'),
  123. 'foreign keys' => array(
  124. 'job_id' => array(
  125. 'table' => 'tripal_jobs',
  126. 'columns' => array(
  127. 'job_id' => 'job_id',
  128. ),
  129. ),
  130. ),
  131. );
  132. return $schema;
  133. }
  134. /**
  135. * Make BlastDB type more readable & support Link-outs for BLAST Hits.
  136. */
  137. function blast_ui_update_7101() {
  138. // Changing the length of the type field to allow it to be more readable.
  139. db_change_field('blastdb', 'dbtype', 'dbtype',
  140. array(
  141. 'description' => t('Type of the blast database. Should be either n for nucleotide or p for protein.'),
  142. 'type' => 'varchar',
  143. 'length' => 15,
  144. 'not null' => true,
  145. )
  146. );
  147. // Add fields related to Link-outs
  148. db_add_field(
  149. 'blastdb',
  150. 'dbxref_id_regex',
  151. array(
  152. 'description' => t('The Regular Expression to use to extract the id from the FASTA header of the BLAST database hit.'),
  153. 'type' => 'text',
  154. )
  155. );
  156. db_add_field(
  157. 'blastdb',
  158. 'dbxref_db_id',
  159. array(
  160. 'description' => t('The Database records from this BLAST Database reference.'),
  161. 'type' => 'int',
  162. )
  163. );
  164. }
  165. /**
  166. * Support complex types of link-outs such as GBrowse & JBrowse coordinate links.
  167. */
  168. function blast_ui_update_7102() {
  169. db_add_field(
  170. 'blastdb',
  171. 'dbxref_linkout_type',
  172. array(
  173. 'description' => t('Type of linkout to be used for this database reference.'),
  174. 'type' => 'varchar',
  175. 'length' => 50,
  176. 'not null' => true,
  177. 'default' => 'link'
  178. )
  179. );
  180. }
  181. /**
  182. * Add saving of blast job information for recent job list & resubmit functionality.
  183. */
  184. function blast_ui_update_7103() {
  185. $schema = array();
  186. // Keeps track of additional information related to tripal blast jobs.
  187. $schema['blastjob'] = array(
  188. 'description' => t('Keeps track of additional information related to tripal blast jobs.'),
  189. 'fields' => array(
  190. 'job_id' => array(
  191. 'description' => t('The Tripal job_id for the blast job.'),
  192. 'type' => 'int',
  193. 'unsigned' => true,
  194. 'not null' => true,
  195. ),
  196. 'blast_program' => array(
  197. 'description' => t('The program to use to run the blast (ie: blastn, blastp, etc.).'),
  198. 'type' => 'varchar',
  199. 'length' => 20,
  200. 'not null' => true,
  201. ),
  202. 'target_blastdb' => array(
  203. 'description' => t('The nid of the blastdb used to search against; NULL if target was uploaded.'),
  204. 'type' => 'int',
  205. 'unsigned' => true,
  206. ),
  207. 'target_file' => array(
  208. 'description' => t('The absolute path to the uploaded blast database after it was run through makeblastdb; NULL if target was NOT uploaded.'),
  209. 'type' => 'text',
  210. ),
  211. 'query_file' => array(
  212. 'description' => t('The absolute path to the query file.'),
  213. 'type' => 'text',
  214. ),
  215. 'result_filestub' => array(
  216. 'description' => t('The absolute path and filename (without extension) of the blast results.'),
  217. 'type' => 'text',
  218. ),
  219. 'options' => array(
  220. '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.'),
  221. 'type' => 'text',
  222. ),
  223. ),
  224. 'primary key' => array('job_id'),
  225. 'foreign keys' => array(
  226. 'job_id' => array(
  227. 'table' => 'tripal_jobs',
  228. 'columns' => array(
  229. 'job_id' => 'job_id',
  230. ),
  231. ),
  232. ),
  233. );
  234. // First create the tables.
  235. db_create_table('blastjob', $schema['blastjob']);
  236. }
  237. /**
  238. * Add fields to blastp table for CViTjs support.
  239. */
  240. function blast_ui_update_7104() {
  241. db_add_field(
  242. 'blastdb',
  243. 'cvitjs_enabled',
  244. array(
  245. 'description' => t('Indicate if CViTjs should be used to display hits on a whole genome'),
  246. 'type' => 'int',
  247. 'not null' => false,
  248. 'default' => 0
  249. )
  250. );
  251. }