blast_ui.admin.inc 6.5 KB

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