blast_ui.module 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * @file
  4. * Contains all functions for the blast module
  5. */
  6. require_once 'includes/blast_ui.blastn.inc';
  7. require_once 'includes/blast_ui.blastp.inc';
  8. require_once 'includes/blast_ui.node.inc';
  9. /**
  10. *
  11. * Implements hook_menu()
  12. *
  13. */
  14. function blast_ui_menu() {
  15. $items['blast'] = array(
  16. 'title' => 'BLAST',
  17. 'page callback' => 'drupal_get_form',
  18. 'page arguments' => array('blast_nucleotide_form'),
  19. 'access arguments' => array('access content'),
  20. 'type' => MENU_NORMAL_ITEM,
  21. 'expanded' => TRUE,
  22. );
  23. $items['blast/report/%'] = array(
  24. 'title' => 'Nucleotide BLAST result:',
  25. 'page callback' => 'show_blast_output',
  26. 'page arguments' => array(2),
  27. 'access arguments' => array('access content'),
  28. 'type' => MENU_CALLBACK,
  29. );
  30. $items['blast/blastn'] = array(
  31. 'title' => 'Nucleotide BLAST',
  32. 'page callback' => 'drupal_get_form',
  33. 'page arguments' => array('blast_nucleotide_form'),
  34. 'access arguments' => array('access content'),
  35. 'type' => MENU_NORMAL_ITEM
  36. );
  37. // $items['blast/blastp'] = array(
  38. // 'title' => 'Protein BLAST',
  39. // 'page callback' => 'drupal_get_form',
  40. // 'page arguments' => array('blast_protein_form'),
  41. // 'access arguments' => array('access content'),
  42. // 'type' => MENU_NORMAL_ITEM
  43. // );
  44. return $items;
  45. }
  46. /**
  47. * Facilitate presenting the result of the blast search
  48. *
  49. * @param $args
  50. * A string containing name of the blast output file.
  51. *
  52. * @return $result
  53. * Return a string containing the blast search output. A link is also provided to let users download the output file.
  54. *
  55. */
  56. function show_blast_output($args = 'all') {
  57. if (preg_match('/^[^\/]*/',$args)) {
  58. $full_path_filename = '/var/www/kp-amir/sites/default/files/' . $args;
  59. if (file_exists($full_path_filename)) {
  60. $result = t('<a href="@url" target="_blank">Download your BLAST result</a>', array('@url' => url('sites/default/files/' . $args)));
  61. $result .= check_markup(file_get_contents($full_path_filename), 'full_html');
  62. $result = str_replace('<script src="blastResult.js"></script>','',$result);
  63. }
  64. else {
  65. tripal_report_error(
  66. 'blast_ui',
  67. TRIPAL_ERROR,
  68. 'Unable to open blast results file (%file)',
  69. array('%file' => $full_path_filename)
  70. );
  71. $result = '<p>An error was encountered while trying to process your blast results</p>';
  72. }
  73. }
  74. else {
  75. $result = '<p>An error was encountered while trying to process your blast results</p>';
  76. }
  77. return $result;
  78. }