'BLAST', 'page callback' => 'drupal_get_form', 'page arguments' => array('blast_nucleotide_form'), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM, 'expanded' => TRUE, ); // Nucleotide BLAST submission form $items['blast/blastn'] = array( 'title' => 'Nucleotide BLAST', 'page callback' => 'drupal_get_form', 'page arguments' => array('blast_nucleotide_form'), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM ); // Protein BLAST submission form $items['blast/blastp'] = array( 'title' => 'Protein BLAST', 'page callback' => 'drupal_get_form', 'page arguments' => array('blast_protein_form'), 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM ); // BLAST Results page $items['blast/report/%'] = array( 'title' => 'BLAST result:', 'page callback' => 'show_blast_output', 'page arguments' => array(2), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_theme(). */ function blast_ui_theme() { $items = array(); $path = drupal_get_path('module', 'blast_ui'); // Displays the BLAST results for each job $items['show_blast_report'] = array( 'template' => 'blast_report', 'path' => "$path/theme", ); // Themes the alignments in a BLAST result display $items['blast_report_alignment_row'] = array( 'template' => 'blast_report_alignment_row', 'variables' => array('hsps' => NULL), 'path' => "$path/theme", ); return $items; } /** * Facilitate presenting the result of the blast search * * @param $args * A string containing name of the blast output file. * * @return $result * Return HTML output of the BLAST results to be displayed to the user * */ function show_blast_output($args = 'all') { // Double-check that there are no directory slashes in the path since this could be used // present a security risk (ie: if the path contained ../../../etc/someconfig.file this // we don't want to process or display anything. if (preg_match('/^[^\/]*$/',$args)) { // Since the blast results are in the files directory // we can use public:// to get around hard-coding the full path $full_path_filename = 'public://'.$args; // check that the XML file exists before trying to display results if (file_exists($full_path_filename)) { // Use the show_blast_output.tpl.php to generate the HTML $result = theme('show_blast_report'); } else { // If the file doesn't exist then throw a tripal error // as well as displaying an error to the user tripal_report_error( 'blast_ui', TRIPAL_ERROR, 'Unable to open blast results file (%file)', array('%file' => $full_path_filename) ); $result = '
An error was encountered while trying to process your blast results
'; } } else { // If there are directory slashes in the path then just display an error to the user // rather than risk the security of the server $result = 'An error was encountered while trying to process your blast results
'; } return $result; }