Browse Source

Added additional download formats including HTML and TSV

Lacey Sanderson 10 years ago
parent
commit
698e6182c2

+ 20 - 5
api/blast_ui.api.inc

@@ -44,16 +44,19 @@ function get_blast_database_options($type) {
  *   The full path and filename of the query FASTA file
  * @param $database
  *   The full path and filename prefix (excluding .nhr, .nin, .nsq, etc.)
- * @param $output_filename
- *   The filename (not including path) to give the results
+ * @param $output_filestub
+ *   The filename (not including path) to give the results. Should not include file type suffix
  * @param $options
  *   An array of additional option where the key is the name of the option used by
  *   BLAST (ie: 'num_alignments') and the value is relates to this particular
  *   BLAST job (ie: 250)
  */
-function run_BLAST_tripal_job($program, $query, $database, $output_file, $options, $job_id = NULL) {
+function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $options, $job_id = NULL) {
 
-  $output_file = 'sites/default/files/' . $output_file;
+  $output_file = 'sites/default/files/' . $output_filestub . '.blast.asn';
+  $output_file_xml = 'sites/default/files/' . $output_filestub . '.blast.xml';
+  $output_file_tsv = 'sites/default/files/' . $output_filestub . '.blast.tsv';
+  $output_file_html = 'sites/default/files/' . $output_filestub . '.blast.html';
 
   print "\nExecuting $program\n\n";
   print "Query: $query\n";
@@ -62,7 +65,7 @@ function run_BLAST_tripal_job($program, $query, $database, $output_file, $option
 
   print "Options:\n";
 
-  $blast_cmd = "$program -query $query -db $database -out $output_file -outfmt=5";
+  $blast_cmd = "$program -query $query -db $database -out $output_file -outfmt=11";
   if (!empty($options)) {
     foreach ($options as $opt => $val) {
       print "\t$opt: $val\n";
@@ -74,5 +77,17 @@ function run_BLAST_tripal_job($program, $query, $database, $output_file, $option
 
   system($blast_cmd);
 
+  print "\nGenerating additional download formats...\n";
+
+  print "\tXML\n";
+  system("blast_formatter -archive $output_file -outfmt 5 -out $output_file_xml");
+
+  print "\tTab-delimited\n";
+  system("blast_formatter -archive $output_file -outfmt 7 -out $output_file_tsv");
+
+  print "\tHTML (includes alignments)\n";
+  system("blast_formatter -archive $output_file -outfmt 0 -out $output_file_html -html");
+
+
   print "\nDone!\n";
 }

+ 1 - 1
includes/blast_ui.blastn.inc

@@ -370,7 +370,7 @@ function blast_nucleotide_form_submit($form, &$form_state) {
       'program' => 'blastn',
       'query' => $query,
       'database' => $blastdb_with_path,
-      'output_filename' => $output_filestub . ".blast.xml",
+      'output_filename' => $output_filestub,
       'options' => array(
         'evalue' => $eVal,
         'word_size' => $wordSize,

+ 1 - 1
includes/blast_ui.blastp.inc

@@ -667,7 +667,7 @@ function blast_protein_form_submit($form, &$form_state) {
       'program' => 'blastp',
       'query' => $query,
       'database' => $blastdb_with_path,
-      'output_filename' => $output_filestub . ".blast.xml",
+      'output_filename' => $output_filestub,
       'options' => array(
         'evalue' => $eVal,
         'word_size' => $wordSize,

+ 6 - 0
theme/blast_report.tpl.php

@@ -27,6 +27,12 @@
   });
 </script>
 
+<p><strong>Download</strong>:
+  <a href="<?php print '../../' . $html_filename; ?>">HTML</a>,
+  <a href="<?php print '../../' . $tsv_filename; ?>">Tab-Delimited</a>,
+  <a href="<?php print '../../' . $xml_filename; ?>">XML</a>
+</p>
+
 <p>The following table summarizes the results of your BLAST. To see additional information
 about each hit including the alignment, click on that row in the table to expand it.</p>
 

+ 3 - 1
theme/blast_ui.theme.inc

@@ -24,6 +24,8 @@ function blast_ui_preprocess_show_blast_report(&$vars) {
   // Get the filename of the BLAST results
   $job = tripal_get_job($vars['job_id']);
   $job_args = unserialize($job->arguments);
-  $vars['xml_filename'] = 'public://' . $job_args['output_filename'];
+  $vars['xml_filename'] = variable_get('file_public_path', conf_path() . '/files') . '/' . $job_args['output_filename'] . '.blast.xml';
+  $vars['tsv_filename'] = variable_get('file_public_path', conf_path() . '/files') . '/' . $job_args['output_filename'] . '.blast.tsv';
+  $vars['html_filename'] = variable_get('file_public_path', conf_path() . '/files') . '/' . $job_args['output_filename'] . '.blast.html';
 
 }