123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- /**
- * @file
- * Contains all functions for the blast module
- */
- require_once 'includes/blast_ui.blastn.inc';
- require_once 'includes/blast_ui.blastp.inc';
- require_once 'includes/blast_ui.node.inc';
- require_once 'theme/blast_ui.theme.inc';
- /**
- *
- * Implements hook_theme()
- *
- */
- function blast_ui_theme() {
- $items = array();
- $path = drupal_get_path('module', 'blast_ui');
- $items['show_blast_report'] = array(
- 'template' => 'blast_report',
- 'path' => "$path/theme",
- );
- $items['blast_report_alignment_row'] = array(
- 'template' => 'blast_report_alignment_row',
- 'variables' => array('hsps' => NULL),
- 'path' => "$path/theme",
- );
- return $items;
- }
- /**
- *
- * Implements hook_menu()
- *
- */
- function blast_ui_menu() {
- $items['blast'] = array(
- 'title' => 'BLAST',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_nucleotide_form'),
- 'access arguments' => array('access content'),
- 'type' => MENU_NORMAL_ITEM,
- 'expanded' => TRUE,
- );
- $items['blast/report/%'] = array(
- 'title' => 'BLAST result:',
- 'page callback' => 'show_blast_output',
- 'page arguments' => array(2),
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- $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
- );
- $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
- );
- return $items;
- }
- /**
- * Facilitate presenting the result of the blast search
- *
- * @param $args
- * A string containing name of the blast output file.
- *
- * @return $result
- * Return a string containing the blast search output. A link is also provided to let users download the output file.
- *
- */
- function show_blast_output($args = 'all') {
- 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;
- if (file_exists($full_path_filename)) {
- // $result = t('<br /><h3>BLAST Results: <a href="@url" target="_blank">HTML</a></h3>', array('@url' => url('sites/default/files/' . $args)));
- // $result .= check_markup(file_get_contents($full_path_filename), 'full_html');
- // $result = str_replace('<script src="blastResult.js"></script>','',$result);
- $result = theme('show_blast_report');
- }
- else {
- tripal_report_error(
- 'blast_ui',
- TRIPAL_ERROR,
- 'Unable to open blast results file (%file)',
- array('%file' => $full_path_filename)
- );
- $result = '<p>An error was encountered while trying to process your blast results</p>';
- }
- }
- else {
- $result = '<p>An error was encountered while trying to process your blast results</p>';
- }
- return $result;
- }
|