1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?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';
- /**
- *
- * 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' => 'Nucleotide 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)) {
- $full_path_filename = '/var/www/kp-amir/sites/default/files/' . $args;
- if (file_exists($full_path_filename)) {
- $result = t('<a href="@url" target="_blank">Download your BLAST result</a>', 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);
- }
- 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;
- }
|