blast_ui.admin.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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['example_sequence'] = array(
  37. '#type' => 'fieldset',
  38. '#title' => 'Set Example Sequences',
  39. '#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.'
  40. );
  41. $nucleotide_default = '>partial lipoxygenase Glyma15g03040
  42. TTTCGTATGA GATTAAAATG TGTGAAATTT TGTTTGATAG GACATGGGAA
  43. AGGAAAAGTT GGAAAGGCTA CAAATTTAAG AGGACAAGTG TCGTTACCAA
  44. CCTTGGGAGC TGGCGAAGAT GCATACGATG TTCATTTTGA ATGGGACAGT
  45. GACTTCGGAA TTCCCGGTGC ATTTTACATT AAGAACTTCA TGCAAGTTGA
  46. GTTCTATCTC AAGTCTCTAA CTCTCGAAGA CATTCCAAAC CACGGAACCA
  47. TTCACTTCGT ATGCAACTCC TGGGTTTACA ACTCAAAATC CTACCATTCT
  48. GATCGCATTT TCTTTGCCAA CAATGTAAGC TACTTAAATA CTGTTATACA
  49. TTGTCTAACA TCTTGTTAGA GTCTTGCATG ATGTGTACCG TTTATTGTTG
  50. TTGTTGAACT TTACCACATG GCATGGATGC AAAAGTTGTT ATACACATAA
  51. ATTATAATGC AGACATATCT TCCAAGCGAG ACACCGGCTC CACTTGTCAA
  52. GTACAGAGAA GAAGAATTGA AGAATGTAAG AGGGGATGGA ACTGGTGAGC
  53. GCAAGGAATG GGATAGGATC TATGATTATG ATGTCTACAA TGACTTGGGC
  54. GATCCAGATA AGGGTGAAAA GTATGCACGC CCCGTTCTTG GAGGTTCTGC
  55. CTTACCTTAC CCTCGCAGAG GAAGAACCGG AAGAGGAAAA ACTAGAAAAG
  56. GTTTCTCACT AGTCACTAAT TTATTACTTT TTAATGTTTG TTTTTAGGCA
  57. TCTTTTCTGA TGAAATGTAT ACTTTTGATG TTTTTTTGTT TTAGCATAAC
  58. TGAATTAGTA AAGTGTGTTG TGTTCCTTAG AAGTTAGAAA AGTACTAAGT
  59. ATAAGGTCTT TGAGTTGTCG TCTTTATCTT AACAGATCCC AACAGTGAGA
  60. AGCCCAGTGA TTTTGTTTAC CTTCCGAGAG ATGAAGCATT TGGTCACTTG
  61. AAGTCATCAG ATTTTCTCGT TTATGGAATC AAATCAGTGG CTCAAGACGT
  62. CTTGCCCGTG TTGACTGATG CGTTTGATGG CAATCTTTTG AGCCTTGAGT
  63. TTGATAACTT TGCTGAAGTG CGCAAACTCT ATGAAGGTGG AGTTACACTA
  64. CCTACAAACT TTCTTAGCAA GATCGCCCCT ATACCAGTGG TCAAGGAAAT
  65. TTTTCGAACT GATGGCGAAC AGTTCCTCAA GTATCCACCA CCTAAAGTGA
  66. TGCAGGGTAT GCTACATATT TTGAATATGT AGAATATTAT CAATATACTC
  67. CTGTTTTTAT TCAACATATT TAATCACATG GATGAATTTT TGAACTGTTA';
  68. $form['example_sequence']['nucleotide_example'] = array(
  69. '#type' => 'textarea',
  70. '#title' => 'Nucleotide Example',
  71. '#description' => t('Enter a complete nucleotide FASTA record including the header. More information: <a href="@fasta-format-url" target="_blank">FASTA format</a>.',
  72. array('@fasta-format-url' => 'http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')),
  73. '#default_value' => variable_get(
  74. 'blast_ui_nucleotide_example_sequence',
  75. $nucleotide_default
  76. )
  77. );
  78. $protein_default = '>gi|166477|gb|AAA96434.1| resveratrol synthase [Arachis hypogaea]
  79. MVSVSGIRKVQRAEGPATVLAIGTANPPNCIDQSTYADYYFRVTNSEHMTDLKKKFQRICERTQIKNRHM
  80. YLTEEILKENPNMCAYKAPSLDAREDMMIREVPRVGKEAATKAIKEWGQPMSKITHLIFCTTSGVALPGV
  81. DYELIVLLGLDPCVKRYMMYHQGCFAGGTVLRLAKDLAENNKDARVLIVCSENTAVTFRGPSETDMDSLV
  82. GQALFADGAAAIIIGSDPVPEVEKPIFELVSTDQKLVPGSHGAIGGLLREVGLTFYLNKSVPDIISQNIN
  83. DALNKAFDPLGISDYNSIFWIAHPGGRAILDQVEQKVNLKPEKMKATRDVLSNYGNMSSACVFFIMDLMR
  84. KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
  85. $form['example_sequence']['protein_example'] = array(
  86. '#type' => 'textarea',
  87. '#title' => 'Protein Example',
  88. '#description' => t('Enter a complete protein FASTA record including the header. More information: <a href="@fasta-format-url" target="_blank">FASTA format</a>.',
  89. array('@fasta-format-url' => 'http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml')),
  90. '#default_value' => variable_get(
  91. 'blast_ui_protein_example_sequence',
  92. $protein_default
  93. )
  94. );
  95. $form['submit'] = array(
  96. '#type' => 'submit',
  97. '#value' => 'Save Configuration'
  98. );
  99. return $form;
  100. }
  101. /**
  102. * Form validator for the blastdb node
  103. */
  104. function blast_ui_admin_form_validate($form, &$form_state) {
  105. $blast_path = $form_state['values']['blast_path'];
  106. $blast_path .= 'blastn';
  107. if(!empty($blast_path)) {
  108. if(file_exists($blast_path) ) {
  109. variable_set('blast_path', $form_state['values']['blast_path']);
  110. }
  111. else {
  112. form_set_error('blast_path', t('Please enter a valid path or you can leave it blank'));
  113. }
  114. }
  115. }
  116. /**
  117. *
  118. */
  119. function blast_ui_admin_form_submit($form, $form_state) {
  120. variable_set('blast_ui_allow_target_upload', $form_state['values']['target_upload']);
  121. variable_set('blast_ui_nucleotide_example_sequence', $form_state['values']['nucleotide_example']);
  122. variable_set('blast_ui_protein_example_sequence', $form_state['values']['protein_example']);
  123. }