blast_ui.admin.inc 5.5 KB

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