Browse Source

Fixed the hard-coded path in result display, set the title based on the database name, changed the blast command to use full path of database and sorted the blast databases by name

Lacey Sanderson 11 years ago
parent
commit
82938536b4
3 changed files with 15 additions and 11 deletions
  1. 3 2
      blast_ui.module
  2. 4 2
      includes/blast_ui.blastn.inc
  3. 8 7
      includes/blast_ui.node.inc

+ 3 - 2
blast_ui.module

@@ -66,10 +66,11 @@ function blast_ui_menu() {
 function show_blast_output($args = 'all') { 
 
   if (preg_match('/^[^\/]*/',$args)) {
-    $full_path_filename = '/var/www/kp-amir/sites/default/files/' . $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('<a href="@url" target="_blank">Download your BLAST result</a>', array('@url' => url('sites/default/files/' . $args)));
+      $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);

+ 4 - 2
includes/blast_ui.blastn.inc

@@ -330,8 +330,8 @@ function blast_nucleotide_form_submit($form, &$form_state) {
      $blastdb_node = node_load($selected_db);
      $blastdb_path = $blastdb_node->db_path;     
      $blastdb_human_name = $form['DB']['SELECT_DB']['#options'][$selected_db];
-     $subSeqOut = $blastdb_human_name . rand(0, 10000);
-     $blast_db_cmd = "blastn -task blastn -query $query -db sites/default/files/$blastdb_path -out sites/default/files/$subSeqOut.blastn.html -evalue $eVal -word_size $wordSize -gapopen $gapOpen -gapextend $gapExtend -penalty $penalty -reward $reward -num_alignments 100 -html";
+     $subSeqOut = str_replace(' ','_', $blastdb_human_name) . rand(0, 10000);
+     $blast_db_cmd = "blastn -task blastn -query $query -db $blastdb_path -out sites/default/files/$subSeqOut.blastn.html -evalue $eVal -word_size $wordSize -gapopen $gapOpen -gapextend $gapExtend -penalty $penalty -reward $reward -num_alignments 100 -html";
      system($blast_db_cmd,$input);
   }
 
@@ -383,5 +383,7 @@ function _DB_options() {
          $options[$node->nid] = $node->db_name;
       }     
    }
+
+   asort($options);
    return $options;
 }

+ 8 - 7
includes/blast_ui.node.inc

@@ -1,4 +1,4 @@
-x<?php
+<?php
 
 /**
  * @file
@@ -74,7 +74,8 @@ function blastdb_form($node, &$form_state) {
   );
   $form['db_path']= array(
     '#type' => 'textfield',
-    '#title' => t('File Name'),
+    '#title' => t('File Prefix including Full Path'),
+    '#description' => t('The full path to your blast database including the file name but not the file type suffix. For example, /var/www/website/sites/default/files/myblastdb'),
     '#required' => TRUE,
     '#default_value' => isset($node->db_path) ? $node->db_path : '',
   );
@@ -101,8 +102,9 @@ function blastdb_insert($node) {
  * Implements hook_node_insert().
  * This function acts on ALL NODES
  */
-function blastdb_node_insert($node) {
+function blast_ui_node_insert($node) {
   if ($node->type == 'blastdb') {
+    $node->title = $node->db_name;
   }
 }
 
@@ -112,7 +114,6 @@ function blastdb_node_insert($node) {
 *                                                                                                            
 */
 function blastdb_update($node) {
-dpm($node, 'node in module-specific insert');
     db_update('blastdb')->fields(array(
     'name' => $node->db_name,
     'path' => $node->db_path,
@@ -123,9 +124,9 @@ dpm($node, 'node in module-specific insert');
  * Implements hook_node_update().
  * This	function acts on ALL NODES
  */
-function blastdb_node_update($node) {
-  if ($node->type == 'blastdb')	    {
-
+function blast_ui_node_update($node) {
+  if ($node->type == 'blastdb')	{
+    $node->title = $node->db_name;
   }
 }