blast_ui.admin.inc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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('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('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. '#title' => 'Allow File Upload',
  42. '#description' => 'The following options allow you to control whether your users can
  43. upload files for the query or target respectively. The ability to upload files allows
  44. them to more conviently BLAST large sets of sequences. However, the size of the
  45. files could be problematic, storage-wise, on your server.<br />'
  46. );
  47. $form['file_upload']['query_upload'] = array(
  48. '#type' => 'checkbox',
  49. '#title' => 'Enable Query Sequence Upload',
  50. '#description' => 'When checked, a query file upload field will be available on BLAST request forms.',
  51. '#default_value' => FALSE,
  52. '#default_value' => variable_get('blast_ui_allow_query_upload', TRUE)
  53. );
  54. $form['file_upload']['target_upload'] = array(
  55. '#type' => 'checkbox',
  56. '#title' => 'Enable Target Sequence Upload',
  57. '#description' => 'When checked, a target file upload field will be available on BLAST request forms.',
  58. '#default_value' => FALSE,
  59. '#default_value' => variable_get('blast_ui_allow_target_upload', FALSE)
  60. );
  61. $form['example_sequence'] = array(
  62. '#type' => 'fieldset',
  63. '#title' => 'Set Example Sequences',
  64. '#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.'
  65. );
  66. $nucleotide_default = '>partial lipoxygenase Glyma15g03040
  67. TTTCGTATGA GATTAAAATG TGTGAAATTT TGTTTGATAG GACATGGGAA
  68. AGGAAAAGTT GGAAAGGCTA CAAATTTAAG AGGACAAGTG TCGTTACCAA
  69. CCTTGGGAGC TGGCGAAGAT GCATACGATG TTCATTTTGA ATGGGACAGT
  70. GACTTCGGAA TTCCCGGTGC ATTTTACATT AAGAACTTCA TGCAAGTTGA
  71. GTTCTATCTC AAGTCTCTAA CTCTCGAAGA CATTCCAAAC CACGGAACCA
  72. TTCACTTCGT ATGCAACTCC TGGGTTTACA ACTCAAAATC CTACCATTCT
  73. GATCGCATTT TCTTTGCCAA CAATGTAAGC TACTTAAATA CTGTTATACA
  74. TTGTCTAACA TCTTGTTAGA GTCTTGCATG ATGTGTACCG TTTATTGTTG
  75. TTGTTGAACT TTACCACATG GCATGGATGC AAAAGTTGTT ATACACATAA
  76. ATTATAATGC AGACATATCT TCCAAGCGAG ACACCGGCTC CACTTGTCAA
  77. GTACAGAGAA GAAGAATTGA AGAATGTAAG AGGGGATGGA ACTGGTGAGC
  78. GCAAGGAATG GGATAGGATC TATGATTATG ATGTCTACAA TGACTTGGGC
  79. GATCCAGATA AGGGTGAAAA GTATGCACGC CCCGTTCTTG GAGGTTCTGC
  80. CTTACCTTAC CCTCGCAGAG GAAGAACCGG AAGAGGAAAA ACTAGAAAAG
  81. GTTTCTCACT AGTCACTAAT TTATTACTTT TTAATGTTTG TTTTTAGGCA
  82. TCTTTTCTGA TGAAATGTAT ACTTTTGATG TTTTTTTGTT TTAGCATAAC
  83. TGAATTAGTA AAGTGTGTTG TGTTCCTTAG AAGTTAGAAA AGTACTAAGT
  84. ATAAGGTCTT TGAGTTGTCG TCTTTATCTT AACAGATCCC AACAGTGAGA
  85. AGCCCAGTGA TTTTGTTTAC CTTCCGAGAG ATGAAGCATT TGGTCACTTG
  86. AAGTCATCAG ATTTTCTCGT TTATGGAATC AAATCAGTGG CTCAAGACGT
  87. CTTGCCCGTG TTGACTGATG CGTTTGATGG CAATCTTTTG AGCCTTGAGT
  88. TTGATAACTT TGCTGAAGTG CGCAAACTCT ATGAAGGTGG AGTTACACTA
  89. CCTACAAACT TTCTTAGCAA GATCGCCCCT ATACCAGTGG TCAAGGAAAT
  90. TTTTCGAACT GATGGCGAAC AGTTCCTCAA GTATCCACCA CCTAAAGTGA
  91. TGCAGGGTAT GCTACATATT TTGAATATGT AGAATATTAT CAATATACTC
  92. CTGTTTTTAT TCAACATATT TAATCACATG GATGAATTTT TGAACTGTTA';
  93. $form['example_sequence']['nucleotide_example'] = array(
  94. '#type' => 'textarea',
  95. '#title' => 'Nucleotide Example',
  96. '#description' => t('Enter a complete nucleotide FASTA record including the header. More information: <a href="@fasta-format-url" target="_blank">FASTA format</a>.',
  97. array('@fasta-format-url' => 'http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')),
  98. '#default_value' => variable_get(
  99. 'blast_ui_nucleotide_example_sequence',
  100. $nucleotide_default
  101. )
  102. );
  103. $protein_default = '>gi|166477|gb|AAA96434.1| resveratrol synthase [Arachis hypogaea]
  104. MVSVSGIRKVQRAEGPATVLAIGTANPPNCIDQSTYADYYFRVTNSEHMTDLKKKFQRICERTQIKNRHM
  105. YLTEEILKENPNMCAYKAPSLDAREDMMIREVPRVGKEAATKAIKEWGQPMSKITHLIFCTTSGVALPGV
  106. DYELIVLLGLDPCVKRYMMYHQGCFAGGTVLRLAKDLAENNKDARVLIVCSENTAVTFRGPSETDMDSLV
  107. GQALFADGAAAIIIGSDPVPEVEKPIFELVSTDQKLVPGSHGAIGGLLREVGLTFYLNKSVPDIISQNIN
  108. DALNKAFDPLGISDYNSIFWIAHPGGRAILDQVEQKVNLKPEKMKATRDVLSNYGNMSSACVFFIMDLMR
  109. KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
  110. $form['example_sequence']['protein_example'] = array(
  111. '#type' => 'textarea',
  112. '#title' => 'Protein Example',
  113. '#description' => t('Enter a complete protein FASTA record including the header. More information: <a href="@fasta-format-url" target="_blank">FASTA format</a>.',
  114. array('@fasta-format-url' => 'http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')),
  115. '#default_value' => variable_get(
  116. 'blast_ui_protein_example_sequence',
  117. $protein_default
  118. )
  119. );
  120. $form['submit'] = array(
  121. '#type' => 'submit',
  122. '#value' => 'Save Configuration'
  123. );
  124. return $form;
  125. }
  126. /**
  127. * Validate the Admin/Settings form.
  128. */
  129. function blast_ui_admin_form_validate($form, &$form_state) {
  130. $blast_path = $form_state['values']['blast_path'];
  131. $blast_path .= 'blastn';
  132. if(!empty($blast_path)) {
  133. if(file_exists($blast_path) ) {
  134. variable_set('blast_path', $form_state['values']['blast_path']);
  135. }
  136. else {
  137. form_set_error('blast_path', t('Please enter a valid path or you can leave it blank'));
  138. }
  139. }
  140. }
  141. /**
  142. * Submit the Admin/settings form.
  143. */
  144. function blast_ui_admin_form_submit($form, $form_state) {
  145. variable_set('blast_path', $form_state['values']['blast_path']);
  146. variable_set('blast_threads', $form_state['values']['blast_threads']);
  147. variable_set('eVal', $form_state['values']['eVal']);
  148. variable_set('qRange', $form_state['values']['qRange']);
  149. variable_set('blast_ui_allow_query_upload', $form_state['values']['query_upload']);
  150. variable_set('blast_ui_allow_target_upload', $form_state['values']['target_upload']);
  151. variable_set('blast_ui_nucleotide_example_sequence', $form_state['values']['nucleotide_example']);
  152. variable_set('blast_ui_protein_example_sequence', $form_state['values']['protein_example']);
  153. }