blast_ui.admin.inc 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. /**
  3. * @file
  4. * Administrative interface for the BLAST UI
  5. */
  6. /**
  7. *
  8. */
  9. function blast_ui_admin_form($form, $form_state) {
  10. $form['general'] = array(
  11. '#type' => 'fieldset',
  12. '#title' => 'General'
  13. );
  14. $form['general']['blast_path']= array(
  15. '#type' => 'textfield',
  16. '#title' => t('Enter the path of the BLAST program'),
  17. '#description' => t('You can ignore if your $PATH variable is set. Otherwise, enter the absoulte path to bin folder. For example, /opt/blast/2.2.29+/bin/'),
  18. '#default_value' => variable_get('blast_path', ''),
  19. );
  20. $form['general']['blast_threads']= array(
  21. '#type' => 'textfield',
  22. '#title' => t('Enter the number of CPU threads to use in blast search.'),
  23. '#description' => t('You can increase the number to reduce the search time. Before you increase, please check your hardware configurations . A value of one(1) can result in a slower search for some programs eg. tblastn.'),
  24. '#default_value' => variable_get('blast_threads', 1),
  25. );
  26. $form['general']['eVal']= array(
  27. '#type' => 'textfield',
  28. '#title' => t('Default e-Value (Expected Threshold)'),
  29. '#description' => t('Expected number of chance matches in a random model. This number should be give in a decimal format.'),
  30. '#default_value' => variable_get('eVal', 0.001),
  31. //'#default_value' => variable_get('blast_threads', 1),
  32. );
  33. $form['general']['qRange']= array(
  34. '#type' => 'textfield',
  35. '#title' => t('Default max matches in a query range'),
  36. '#description' => t('Limit the number of matches to a query range. This option is useful if many strong matches to one part of a query may prevent BLAST from presenting weaker matches to another part of the query.'),
  37. '#default_value' => variable_get('qRange', 0),
  38. );
  39. $form['file_upload'] = array(
  40. '#type' => 'fieldset',
  41. '#collapsible' => true,
  42. '#collapsed' => true,
  43. '#title' => 'Allow File Upload',
  44. '#description' => 'The following options allow you to control whether your users can
  45. upload files for the query or target respectively. The ability to upload files allows
  46. them to more conviently BLAST large sets of sequences. However, the size of the
  47. files could be problematic, storage-wise, on your server.<br />'
  48. );
  49. $form['file_upload']['query_upload'] = array(
  50. '#type' => 'checkbox',
  51. '#title' => 'Enable Query Sequence Upload',
  52. '#description' => 'When checked, a query file upload field will be available on BLAST request forms.',
  53. '#default_value' => FALSE,
  54. '#default_value' => variable_get('blast_ui_allow_query_upload', TRUE)
  55. );
  56. $form['file_upload']['target_upload'] = array(
  57. '#type' => 'checkbox',
  58. '#title' => 'Enable Target Sequence Upload',
  59. '#description' => 'When checked, a target file upload field will be available on BLAST request forms.',
  60. '#default_value' => FALSE,
  61. '#default_value' => variable_get('blast_ui_allow_target_upload', FALSE)
  62. );
  63. $form['example_sequence'] = array(
  64. '#type' => 'fieldset',
  65. '#collapsible' => true,
  66. '#collapsed' => true,
  67. '#title' => 'Set Example Sequences',
  68. '#description' => 'There is the ability to show example sequences built-in to the various BLAST forms. Use the following fields to set these example sequences. This allows you to provide more relevant examples to your users.'
  69. );
  70. $nucleotide_default = '>partial lipoxygenase Glyma15g03040
  71. TTTCGTATGA GATTAAAATG TGTGAAATTT TGTTTGATAG GACATGGGAA
  72. AGGAAAAGTT GGAAAGGCTA CAAATTTAAG AGGACAAGTG TCGTTACCAA
  73. CCTTGGGAGC TGGCGAAGAT GCATACGATG TTCATTTTGA ATGGGACAGT
  74. GACTTCGGAA TTCCCGGTGC ATTTTACATT AAGAACTTCA TGCAAGTTGA
  75. GTTCTATCTC AAGTCTCTAA CTCTCGAAGA CATTCCAAAC CACGGAACCA
  76. TTCACTTCGT ATGCAACTCC TGGGTTTACA ACTCAAAATC CTACCATTCT
  77. GATCGCATTT TCTTTGCCAA CAATGTAAGC TACTTAAATA CTGTTATACA
  78. TTGTCTAACA TCTTGTTAGA GTCTTGCATG ATGTGTACCG TTTATTGTTG
  79. TTGTTGAACT TTACCACATG GCATGGATGC AAAAGTTGTT ATACACATAA
  80. ATTATAATGC AGACATATCT TCCAAGCGAG ACACCGGCTC CACTTGTCAA
  81. GTACAGAGAA GAAGAATTGA AGAATGTAAG AGGGGATGGA ACTGGTGAGC
  82. GCAAGGAATG GGATAGGATC TATGATTATG ATGTCTACAA TGACTTGGGC
  83. GATCCAGATA AGGGTGAAAA GTATGCACGC CCCGTTCTTG GAGGTTCTGC
  84. CTTACCTTAC CCTCGCAGAG GAAGAACCGG AAGAGGAAAA ACTAGAAAAG
  85. GTTTCTCACT AGTCACTAAT TTATTACTTT TTAATGTTTG TTTTTAGGCA
  86. TCTTTTCTGA TGAAATGTAT ACTTTTGATG TTTTTTTGTT TTAGCATAAC
  87. TGAATTAGTA AAGTGTGTTG TGTTCCTTAG AAGTTAGAAA AGTACTAAGT
  88. ATAAGGTCTT TGAGTTGTCG TCTTTATCTT AACAGATCCC AACAGTGAGA
  89. AGCCCAGTGA TTTTGTTTAC CTTCCGAGAG ATGAAGCATT TGGTCACTTG
  90. AAGTCATCAG ATTTTCTCGT TTATGGAATC AAATCAGTGG CTCAAGACGT
  91. CTTGCCCGTG TTGACTGATG CGTTTGATGG CAATCTTTTG AGCCTTGAGT
  92. TTGATAACTT TGCTGAAGTG CGCAAACTCT ATGAAGGTGG AGTTACACTA
  93. CCTACAAACT TTCTTAGCAA GATCGCCCCT ATACCAGTGG TCAAGGAAAT
  94. TTTTCGAACT GATGGCGAAC AGTTCCTCAA GTATCCACCA CCTAAAGTGA
  95. TGCAGGGTAT GCTACATATT TTGAATATGT AGAATATTAT CAATATACTC
  96. CTGTTTTTAT TCAACATATT TAATCACATG GATGAATTTT TGAACTGTTA';
  97. $form['example_sequence']['nucleotide_example'] = array(
  98. '#type' => 'textarea',
  99. '#title' => 'Nucleotide Example',
  100. '#description' => t('Enter a complete nucleotide FASTA record including the header. More information: <a href="@fasta-format-url" target="_blank">FASTA format</a>.',
  101. array('@fasta-format-url' => 'https://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')),
  102. '#default_value' => variable_get(
  103. 'blast_ui_nucleotide_example_sequence',
  104. $nucleotide_default
  105. )
  106. );
  107. $protein_default = '>gi|166477|gb|AAA96434.1| resveratrol synthase [Arachis hypogaea]
  108. MVSVSGIRKVQRAEGPATVLAIGTANPPNCIDQSTYADYYFRVTNSEHMTDLKKKFQRICERTQIKNRHM
  109. YLTEEILKENPNMCAYKAPSLDAREDMMIREVPRVGKEAATKAIKEWGQPMSKITHLIFCTTSGVALPGV
  110. DYELIVLLGLDPCVKRYMMYHQGCFAGGTVLRLAKDLAENNKDARVLIVCSENTAVTFRGPSETDMDSLV
  111. GQALFADGAAAIIIGSDPVPEVEKPIFELVSTDQKLVPGSHGAIGGLLREVGLTFYLNKSVPDIISQNIN
  112. DALNKAFDPLGISDYNSIFWIAHPGGRAILDQVEQKVNLKPEKMKATRDVLSNYGNMSSACVFFIMDLMR
  113. KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
  114. $form['example_sequence']['protein_example'] = array(
  115. '#type' => 'textarea',
  116. '#title' => 'Protein Example',
  117. '#description' => t('Enter a complete protein FASTA record including the header. More information: <a href="@fasta-format-url" target="_blank">FASTA format</a>.',
  118. array('@fasta-format-url' => 'https://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')),
  119. '#default_value' => variable_get(
  120. 'blast_ui_protein_example_sequence',
  121. $protein_default
  122. )
  123. );
  124. // PROTECTION
  125. $form['protection'] = array(
  126. '#type' => 'fieldset',
  127. '#collapsible' => true,
  128. '#collapsed' => true,
  129. '#title' => 'Protect against large jobs',
  130. '#description' => 'Depending on the size and nature of your target databases, you may wish to constrain use of this module.',
  131. );
  132. $form['protection']['max_results_displayed'] = array(
  133. '#type' => 'textfield',
  134. '#title' => 'Maximum number of results to show on report page',
  135. '#description' => 'If there are more hits that this, the user is able to download but not visualize the results.',
  136. '#default_value' => variable_get('blast_ui_max_results_displayed', 500)
  137. );
  138. // SUBMIT
  139. $form['submit'] = array(
  140. '#type' => 'submit',
  141. '#value' => 'Save Configuration'
  142. );
  143. return $form;
  144. }
  145. /**
  146. * Validate the Admin/Settings form.
  147. */
  148. function blast_ui_admin_form_validate($form, &$form_state) {
  149. // Check path to BLAST executables
  150. $blast_path = $form_state['values']['blast_path'];
  151. $blast_path .= 'blastn';
  152. if(!empty($form_state['values']['blast_path'])) {
  153. if(file_exists($blast_path) ) {
  154. variable_set('blast_path', $form_state['values']['blast_path']);
  155. }
  156. else {
  157. form_set_error('blast_path', t('Please enter a valid path not including the name of the blast program (ie: /urs/bin/). You can leave this blank if you have your $PATH variable set appropriately.'));
  158. }
  159. }
  160. }
  161. /**
  162. * Submit the Admin/settings form.
  163. */
  164. function blast_ui_admin_form_submit($form, $form_state) {
  165. //General
  166. variable_set('blast_path', $form_state['values']['blast_path']);
  167. variable_set('blast_threads', $form_state['values']['blast_threads']);
  168. variable_set('eVal', $form_state['values']['eVal']);
  169. variable_set('qRange', $form_state['values']['qRange']);
  170. // Uploads
  171. variable_set('blast_ui_allow_query_upload', $form_state['values']['query_upload']);
  172. variable_set('blast_ui_allow_target_upload', $form_state['values']['target_upload']);
  173. // Example sequence
  174. variable_set('blast_ui_nucleotide_example_sequence', $form_state['values']['nucleotide_example']);
  175. variable_set('blast_ui_protein_example_sequence', $form_state['values']['protein_example']);
  176. /**: added by safetybrake*/
  177. variable_set('blast_ui_max_results_displayed', $form_state['values']['max_results_displayed']);
  178. }