blast_ui.admin.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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']['target_upload'] = array(
  21. '#type' => 'checkbox',
  22. '#title' => 'Enable Taget Sequence Upload',
  23. '#default_value' => FALSE,
  24. '#description' => 'When this option is checked, a file upload field will '
  25. . 'show up on the various BLAST forms under the Database section. This '
  26. . 'will allow users to upload a FASTA file they want to BLAST against '
  27. . '(database) as well as a FASTA file containing their query, providing '
  28. . 'the ultimate in flexibility for your users. However, since this does '
  29. . 'allow & in fact encourage the upload of large files which are then '
  30. . 'processed into BLAST databases, this option is disabled by default.',
  31. '#default_value' => variable_get(
  32. 'blast_ui_allow_target_upload',
  33. FALSE
  34. )
  35. );
  36. $form['general']['blast_threads']= array(
  37. '#type' => 'textfield',
  38. '#title' => t('Enter the number of CPU threads to use in blast search.'),
  39. '#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.'),
  40. '#default_value' => variable_get('blast_threads', 1),
  41. );
  42. $form['example_sequence'] = array(
  43. '#type' => 'fieldset',
  44. '#title' => 'Set Example Sequences',
  45. '#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.'
  46. );
  47. $nucleotide_default = '>partial lipoxygenase Glyma15g03040
  48. TTTCGTATGA GATTAAAATG TGTGAAATTT TGTTTGATAG GACATGGGAA
  49. AGGAAAAGTT GGAAAGGCTA CAAATTTAAG AGGACAAGTG TCGTTACCAA
  50. CCTTGGGAGC TGGCGAAGAT GCATACGATG TTCATTTTGA ATGGGACAGT
  51. GACTTCGGAA TTCCCGGTGC ATTTTACATT AAGAACTTCA TGCAAGTTGA
  52. GTTCTATCTC AAGTCTCTAA CTCTCGAAGA CATTCCAAAC CACGGAACCA
  53. TTCACTTCGT ATGCAACTCC TGGGTTTACA ACTCAAAATC CTACCATTCT
  54. GATCGCATTT TCTTTGCCAA CAATGTAAGC TACTTAAATA CTGTTATACA
  55. TTGTCTAACA TCTTGTTAGA GTCTTGCATG ATGTGTACCG TTTATTGTTG
  56. TTGTTGAACT TTACCACATG GCATGGATGC AAAAGTTGTT ATACACATAA
  57. ATTATAATGC AGACATATCT TCCAAGCGAG ACACCGGCTC CACTTGTCAA
  58. GTACAGAGAA GAAGAATTGA AGAATGTAAG AGGGGATGGA ACTGGTGAGC
  59. GCAAGGAATG GGATAGGATC TATGATTATG ATGTCTACAA TGACTTGGGC
  60. GATCCAGATA AGGGTGAAAA GTATGCACGC CCCGTTCTTG GAGGTTCTGC
  61. CTTACCTTAC CCTCGCAGAG GAAGAACCGG AAGAGGAAAA ACTAGAAAAG
  62. GTTTCTCACT AGTCACTAAT TTATTACTTT TTAATGTTTG TTTTTAGGCA
  63. TCTTTTCTGA TGAAATGTAT ACTTTTGATG TTTTTTTGTT TTAGCATAAC
  64. TGAATTAGTA AAGTGTGTTG TGTTCCTTAG AAGTTAGAAA AGTACTAAGT
  65. ATAAGGTCTT TGAGTTGTCG TCTTTATCTT AACAGATCCC AACAGTGAGA
  66. AGCCCAGTGA TTTTGTTTAC CTTCCGAGAG ATGAAGCATT TGGTCACTTG
  67. AAGTCATCAG ATTTTCTCGT TTATGGAATC AAATCAGTGG CTCAAGACGT
  68. CTTGCCCGTG TTGACTGATG CGTTTGATGG CAATCTTTTG AGCCTTGAGT
  69. TTGATAACTT TGCTGAAGTG CGCAAACTCT ATGAAGGTGG AGTTACACTA
  70. CCTACAAACT TTCTTAGCAA GATCGCCCCT ATACCAGTGG TCAAGGAAAT
  71. TTTTCGAACT GATGGCGAAC AGTTCCTCAA GTATCCACCA CCTAAAGTGA
  72. TGCAGGGTAT GCTACATATT TTGAATATGT AGAATATTAT CAATATACTC
  73. CTGTTTTTAT TCAACATATT TAATCACATG GATGAATTTT TGAACTGTTA';
  74. $form['example_sequence']['nucleotide_example'] = array(
  75. '#type' => 'textarea',
  76. '#title' => 'Nucleotide Example',
  77. '#description' => t('Enter a complete nucleotide FASTA record including the header. More information: <a href="@fasta-format-url" target="_blank">FASTA format</a>.',
  78. array('@fasta-format-url' => 'http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')),
  79. '#default_value' => variable_get(
  80. 'blast_ui_nucleotide_example_sequence',
  81. $nucleotide_default
  82. )
  83. );
  84. $protein_default = '>gi|166477|gb|AAA96434.1| resveratrol synthase [Arachis hypogaea]
  85. MVSVSGIRKVQRAEGPATVLAIGTANPPNCIDQSTYADYYFRVTNSEHMTDLKKKFQRICERTQIKNRHM
  86. YLTEEILKENPNMCAYKAPSLDAREDMMIREVPRVGKEAATKAIKEWGQPMSKITHLIFCTTSGVALPGV
  87. DYELIVLLGLDPCVKRYMMYHQGCFAGGTVLRLAKDLAENNKDARVLIVCSENTAVTFRGPSETDMDSLV
  88. GQALFADGAAAIIIGSDPVPEVEKPIFELVSTDQKLVPGSHGAIGGLLREVGLTFYLNKSVPDIISQNIN
  89. DALNKAFDPLGISDYNSIFWIAHPGGRAILDQVEQKVNLKPEKMKATRDVLSNYGNMSSACVFFIMDLMR
  90. KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
  91. $form['example_sequence']['protein_example'] = array(
  92. '#type' => 'textarea',
  93. '#title' => 'Protein Example',
  94. '#description' => t('Enter a complete protein FASTA record including the header. More information: <a href="@fasta-format-url" target="_blank">FASTA format</a>.',
  95. array('@fasta-format-url' => 'http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')),
  96. '#default_value' => variable_get(
  97. 'blast_ui_protein_example_sequence',
  98. $protein_default
  99. )
  100. );
  101. $form['submit'] = array(
  102. '#type' => 'submit',
  103. '#value' => 'Save Configuration'
  104. );
  105. return $form;
  106. }
  107. /**
  108. * Form validator for the blastdb node
  109. */
  110. function blast_ui_admin_form_validate($form, &$form_state) {
  111. $blast_path = $form_state['values']['blast_path'];
  112. $blast_path .= 'blastn';
  113. if(!empty($blast_path)) {
  114. if(file_exists($blast_path) ) {
  115. variable_set('blast_path', $form_state['values']['blast_path']);
  116. }
  117. else {
  118. form_set_error('blast_path', t('Please enter a valid path or you can leave it blank'));
  119. }
  120. }
  121. }
  122. /**
  123. *
  124. */
  125. function blast_ui_admin_form_submit($form, $form_state) {
  126. variable_set('blast_path', $form_state['values']['blast_path']);
  127. variable_set('blast_ui_allow_target_upload', $form_state['values']['target_upload']);
  128. variable_set('blast_threads', $form_state['values']['blast_threads']);
  129. variable_set('blast_ui_nucleotide_example_sequence', $form_state['values']['nucleotide_example']);
  130. variable_set('blast_ui_protein_example_sequence', $form_state['values']['protein_example']);
  131. }