Sfoglia il codice sorgente

Re-introducted Deepak's changes

Lacey Sanderson 10 anni fa
parent
commit
a506426f65
2 ha cambiato i file con 40 aggiunte e 7 eliminazioni
  1. 15 7
      api/blast_ui.api.inc
  2. 25 0
      includes/blast_ui.admin.inc

+ 15 - 7
api/blast_ui.api.inc

@@ -108,10 +108,11 @@ function get_blast_database_options($type) {
  */
 function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $options, $job_id = NULL) {
 
-  $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';
+ $output_file = file_directory_temp() .  DIRECTORY_SEPARATOR . $output_filestub . '.blast.asn';
+ $output_file_xml = variable_get('file_public_path', conf_path() . '/files') . DIRECTORY_SEPARATOR . $output_filestub . '.blast.xml';
+ $output_file_tsv = variable_get('file_public_path', conf_path() . '/files') . DIRECTORY_SEPARATOR . $output_filestub . '.blast.tsv';
+ $output_file_html = variable_get('file_public_path', conf_path() . '/files') . DIRECTORY_SEPARATOR . $output_filestub . '.blast.html';
+
 
   print "\nExecuting $program\n\n";
   print "Query: $query\n";
@@ -120,6 +121,13 @@ function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $op
 
   print "Options:\n";
 
+	$blast_formatter_command = 'blast_formatter';
+	$blast_path = variable_get('blast_path');
+	if(!empty($blast_path)){
+		$program = 	$blast_path . $program;
+		$blast_formatter_command = $blast_path .  $blast_formatter_command;
+	}
+
   $blast_cmd = "$program -query $query -db $database -out $output_file -outfmt=11";
   if (!empty($options)) {
     foreach ($options as $opt => $val) {
@@ -146,7 +154,7 @@ function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $op
   print "\nGenerating additional download formats...\n";
 
   print "\tXML\n";
-  system("blast_formatter -archive $output_file -outfmt 5 -out $output_file_xml");
+  system("$blast_formatter_command -archive $output_file -outfmt 5 -out $output_file_xml");
   if(!file_exists($output_file_xml)) {
     tripal_report_error(
       'blast_ui',
@@ -158,7 +166,7 @@ function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $op
   }
 
   print "\tTab-delimited\n";
-  system("blast_formatter -archive $output_file -outfmt 7 -out $output_file_tsv");
+  system("$blast_formatter_command -archive $output_file -outfmt 7 -out $output_file_tsv");
   if(!file_exists($output_file_tsv)) {
     tripal_report_error(
       'blast_ui',
@@ -170,7 +178,7 @@ function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $op
   }
 
   print "\tHTML (includes alignments)\n";
-  system("blast_formatter -archive $output_file -outfmt 0 -out $output_file_html -html");
+  system("$blast_formatter_command -archive $output_file -outfmt 0 -out $output_file_html -html");
   if(!file_exists($output_file_tsv)) {
     tripal_report_error(
       'blast_ui',

+ 25 - 0
includes/blast_ui.admin.inc

@@ -94,6 +94,14 @@ KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
       )
   );
 
+$form['blast_path']= array(
+    '#type' => 'textfield',
+    '#title' => t('Enter the path of the BLAST program '),
+    '#required' => TRUE,
+    '#description' => t('You can ignore if your $PATH variable is set. Otherwise, enter the absoulte path to bin folder. For example,  /opt/blast/2.2.29+/bin/'),
+    '#default_value' => variable_get('blast_path', ''),
+  );
+
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => 'Save Configuration'
@@ -102,6 +110,23 @@ KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
   return $form;
 }
 
+/**
+ * Form validator for the blastdb node
+ */
+function blast_ui_validate($form, &$form_state) {
+	$blast_path = $form_state['values']['blast_path'];
+	$blast_path .= 'blastn';
+	if(!empty($blast_path)) {
+		if(file_exists($blast_path) ) {
+			variable_set('blast_path', $form_state['values']['blast_path']);
+		}
+		else {
+			form_set_error('blast_path', t('Please enter a valid path or you can leave it blank'));	
+		}
+	}
+
+}
+
 /**
  *
  */