Ver Fonte

Edit-Resubmit and recent jobs funcitonality added. Also, improvements on the output page

Deepak Bitragunta há 10 anos atrás
pai
commit
5dbaac381f

+ 2 - 0
api/blast_ui.api.inc

@@ -124,6 +124,8 @@ function run_BLAST_tripal_job($program, $query, $database, $output_filestub, $op
   // Allow administrators to use an absolute path for these commands.
   // Defaults to using $PATH.
 	$blast_path = variable_get('blast_path', '');
+	$blast_threads = variable_get('blast_threads', '');
+	
 	$program = 	$blast_path . $program;
 	$blast_formatter_command = $blast_path .  'blast_formatter';
 

+ 7 - 1
includes/blast_ui.admin.inc

@@ -38,6 +38,12 @@ function blast_ui_admin_form($form, $form_state) {
         FALSE
       )
   );
+	$form['general']['blast_threads']= array(
+    '#type' => 'textfield',
+    '#title' => t('Enter the number of CPU threads to use in blast search.'),
+    '#description' => t('You can increase the number to reduce the search time. Before you increase, please check your hardware configurations . A value of one(1) can result in a slower search for some programs eg. tblastn.'),
+    '#default_value' => variable_get('blast_threads', 1),
+  );
 
   $form['example_sequence'] = array(
     '#type' => 'fieldset',
@@ -132,7 +138,7 @@ function blast_ui_admin_form_validate($form, &$form_state) {
 function blast_ui_admin_form_submit($form, $form_state) {
 
   variable_set('blast_ui_allow_target_upload', $form_state['values']['target_upload']);
-
+	variable_set('blast_threads', $form_state['values']['blast_threads']);
   variable_set('blast_ui_nucleotide_example_sequence', $form_state['values']['nucleotide_example']);
   variable_set('blast_ui_protein_example_sequence', $form_state['values']['protein_example']);
 }

+ 54 - 3
includes/blast_ui.form_per_program.inc

@@ -19,7 +19,16 @@ function blast_ui_per_blast_program_form($form, $form_state) {
 	$form['#attached']['css'] = array(
 		drupal_get_path('module', 'blast_ui') . '/theme/css/form.css',
 	);
-
+	
+  // @deepaksomanadh - Code added for edit and resubmit funcitonality
+	// 	Approach: persist the form data and read it back using JobID
+	$job_data = variable_get('job_data', '');
+	if(isset($_GET['jid']) && isset($job_data)) {		
+			$jid = base64_decode($_GET['jid']);
+	}	else {
+			$job_data = array();
+			$jid = 0;
+	}
   // Determine the BLAST program.
   $query_type = $form_state['build_info']['args'][0];
   $db_type = $form_state['build_info']['args'][1];
@@ -102,6 +111,7 @@ function blast_ui_per_blast_program_form($form, $form_state) {
     '#type' => 'textarea',
     '#title' => t('Enter FASTA sequence(s)'),
     '#description'=>t('Enter query sequence(s) in the text area.'),
+		'#default_value' => isset($job_data[$jid]['fasta']) ? $job_data[$jid]['fasta'] : '',
     '#prefix' => '<div id="fasta-textarea">',
     '#suffix' => '</div>',
   );
@@ -147,7 +157,7 @@ attempting to submit your BLAST.</strong>',
     '#type' => 'select',
     '#title' => t('%type BLAST Databases:', array('%type' => ucfirst($db_type))),
     '#options' => $options,
-    '#default_value' => 0,
+    '#default_value' => isset($job_data[$jid]['db_option']) ? $job_data[$jid]['db_option'] : 0,
   );
 
   if (variable_get('blast_ui_allow_target_upload', FALSE)) {
@@ -393,7 +403,48 @@ your sequence headers include pipes (i.e.: | ) they adhere to '
       $job_args,
       $user->uid
     );
-		// Encode job ID
+		//@deepaksomanadh Persist the important data for edit and resubmit
+		$job_data = variable_get('job_data', '');
+		$seq_rows = explode(PHP_EOL, $seq_content);
+		foreach($seq_rows as $row) {
+			if(strpos($row, ">") !== FALSE) {
+				$query_def[] = ltrim($row, ">");
+			}
+		}
+	
+		$job_data[$job_id] = 
+			array(
+				'program' => $blast_program,
+				'job_url' => current_path(),
+				'fasta' => $seq_content,
+				'query_def' => $query_def,
+				'db_name' => $blastdb_node->db_name,
+				'db_option' => $selected_db,
+				'options' => $advanced_options,
+			);
+		
+		variable_set('job_data', $job_data);
+		//@deepaksomanadh create session and save the recent jobs in respective session
+		if (session_status() === PHP_SESSION_NONE){
+					session_start();
+			}
+		$sid = session_id();
+		$job_encode_id = base64_encode($job_id);
+		$job_url = "blast/report/$job_encode_id";
+
+		$all_jobs = $_SESSION['all_jobs'];
+		
+		$session_jobs = $all_jobs[$sid];
+		$session_jobs[$job_id] = array(
+															'job_output_url'=> $job_url, 
+															'query_defs' => $query_def,
+															'program' => $blast_program,
+														 );
+		$all_jobs[$sid] = $session_jobs;
+		$_SESSION['all_jobs'] = $all_jobs;
+	
+		tripal_jobs_launch(1, $job_id);
+		//Encode the job_id
 		$job_encode_id = base64_encode($job_id);
     // Redirect to the BLAST results page
     drupal_goto("blast/report/$job_encode_id");

+ 6 - 6
theme/blast_align_image.php

@@ -33,7 +33,7 @@
    $name  = getCGIParamPC('name',    'GP', '');
   */
    // extract hit information from hit param
-function generateImage($acc = '', $scores, $hits, $tsize, $qsize, $name) {
+function generateImage($acc = '', $scores, $hits, $tsize, $qsize, $name, $hit_name) {
    $tok = strtok($hits, ";");
    $b_hits = Array();
    while ($tok !== false) {
@@ -85,7 +85,7 @@ function generateImage($acc = '', $scores, $hits, $tsize, $qsize, $name) {
    $t_center = $t_xstart + ($t_length / 2);
    
    // Target labels
-   $warn = " (not to scale)";
+   $warn = '"'. $hit_name . '"';
    imagestring($img, 5, $t_xstart, $t_ystart-20, $acc.$warn, $black);
    imagestring($img, 3, 5, $t_ystart+2, "Target", $black);
    
@@ -105,8 +105,8 @@ function generateImage($acc = '', $scores, $hits, $tsize, $qsize, $name) {
    $q_xwidth = $q_xend - $q_xstart;
 
    // Query labels
-   imagestring($img, 5, $q_xstart, $q_yend+2, $name.$warn, $black);
-   imagestring($img, 3, 5, $q_ystart+2, 'Query', $black);
+   imagestring($img, 5, $q_xstart, $q_yend+2, $name, $black);
+   imagestring($img, 3, $q_xstart, $q_ystart+2, 'Query', $black);
    
    // Draw bar representing query
    imagefilledrectangle($img, $q_xstart, $q_ystart, $q_xend, $q_yend, $gray);
@@ -169,7 +169,7 @@ function generateImage($acc = '', $scores, $hits, $tsize, $qsize, $name) {
 
       // show HSP
       
- 		imagestring($img, 3, 2, $hsp_bary, ($acc ."Hit" . $ii), $black);
+ 		imagestring($img, 3, 2, $hsp_bary, ($acc ."HSP" . ($ii + 1)), $black);
 
    	$cur_score = intval($b_scores[$ii]);
    	
@@ -201,7 +201,7 @@ function generateImage($acc = '', $scores, $hits, $tsize, $qsize, $name) {
    $ywidth = 7;
    $xinc = 10;
    
-   imagestring($img, 5, $xchart, $ychart - 5, "Scores", $black);
+   imagestring($img, 5, $xchart, $ychart - 5, "Bit Scores", $black);
    
    imagestring($img, $fontsize, $xchart + $yinc + $xinc,$ychart + ($yinc * 1) + $ywidth, ">= 200" , $black);
    imagestring($img, $fontsize, $xchart + $yinc + $xinc,$ychart + ($yinc * 2) + $ywidth, "80 - 200" , $black);

+ 68 - 8
theme/blast_report.tpl.php

@@ -5,6 +5,7 @@
  *
  * Variables Available in this template:
  *   $xml_filename: The full path & filename of XML file containing the BLAST results
+ *		@deepaksomanadh: $job_data = meta data related to the current job
  */
 
 // Set ourselves up to do link-out if our blast database is configured to do so.
@@ -70,9 +71,45 @@ $no_hits = TRUE;
   <a href="<?php print '../../' . $tsv_filename; ?>">Tab-Delimited</a>,
   <a href="<?php print '../../' . $xml_filename; ?>">XML</a>
 </p>
+<!--	@deepaksomanadh: For displaying BLAST command details -->
+<table>
+<tr>
+	<th>Input query sequence(s) </th>
+	<th>Target Database selected </th>
+	<th>BLAST command executed </th>
+<tr>
+<tr>
+<?php 
+	// get input sequences from job_data variable
+
+	$query_def = $job_id_data['query_def'];
+	echo "<td>";
+	echo "<ol>";
+	foreach($query_def as $row) {
+		echo "<li>";		
+		echo  $row . "</li>";
+	}
+	echo "</ol></td>";
+	echo "<td>" . 	$job_id_data['db_name'] . "</td>"
+ ?> 
 
-<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>
+
+<?php
+	include_once("blast_align_image.php");
+ 
+	//display the BLAST command without revealing the internal path
+	$blast_cmd = $job_id_data['program'];
+	
+	foreach($job_id_data['options'] as $key => $value) {
+			$blast_cmd .= ' -' . $key. ' ' . $value ;
+	}
+	print "<td>" . $blast_cmd . "</td>";	
+ ?>
+</table>
+
+<p>The following table summarizes the results of your BLAST. 
+Click on a <strong>triangle </strong> on the left to see the alignment and a visualization of the hit, 
+and click the <strong>target name </strong> to open a new window with a genome browser around this hit.</p>
 
 <?php
 include_once("blast_align_image.php");
@@ -87,11 +124,11 @@ $xml = simplexml_load_file($xml_filename);
 if ($xml) {
   // Specify the header of the table
   $header = array(
+		'arrow-col' =>  array('data' => '', 'class' => array('arrow-col')),
     'number' =>  array('data' => '#', 'class' => array('number')),
     'query' =>  array('data' => 'Query Name  (Click for alignment & visualization)', 'class' => array('query')),
-    'hit' =>  array('data' => 'Hit Name', 'class' => array('hit')),
+    'hit' =>  array('data' => 'Target Name', 'class' => array('hit')),
     'evalue' =>  array('data' => 'E-Value', 'class' => array('evalue')),
-    'arrow-col' =>  array('data' => '', 'class' => array('arrow-col'))
   );
 
   $rows = array();
@@ -140,7 +177,9 @@ if ($xml) {
 					// hits=4263001_4262263_1_742;4260037_4259524_895_1411;&scores=722;473;
 					$HSPs = array();
 					$hit_hsps = '';
-					$hit_hsp_score = '';		
+					$hit_hsp_score = '';
+					$target_size = $hit->{'Hit_len'};
+		
 					foreach ($hit->{'Hit_hsps'}->children() as $hsp_xml) {
 						$HSPs[] = (array) $hsp_xml;
 		
@@ -188,7 +227,7 @@ if ($xml) {
 
 					//@deepaksomanadh: Code added for BLAST visualization
 					// get the image and display
-					$hit_img = generateImage($target_name, $Hsp_bit_score, $hit_hsps, $target_size, $query_size, $q_name);
+				  $hit_img = generateImage($target_name, $Hsp_bit_score, $hit_hsps, $target_size, $query_size, $q_name, $hit_name);
 				
 					ob_start(); // Start buffering the output
 					imagepng($hit_img, null, 0, PNG_NO_FILTER);
@@ -197,10 +236,11 @@ if ($xml) {
 					ob_end_clean();
 
 					// Print the HTML tag with the image embedded
-					$hit_img = '<h3> Hit Visualization </h3> <br><img src="data:image/png;base64,'.$b64.'"/>';
+					$hit_img = '<h4><strong> Hit Visualization </strong></h4> <br><img src="data:image/png;base64,'.$b64.'"/>';
 					
           $row = array(
             'data' => array(
+							'arrow-col' => array('data' => '<div class="arrow"></div>', 'class' => array('arrow-col')),
               'number' => array('data' => $count, 'class' => array('number')),
               'query' => array('data' => $query_name, 'class' => array('query')),
               'hit' => array('data' => $hit_name, 'class' => array('hit')),
@@ -216,9 +256,11 @@ if ($xml) {
 
           $row = array(
             'data' => array(
+							'arrow' => '',
               'number' => '',
               'query' => array(
                 'data' => theme('blast_report_alignment_row', array('HSPs' => $HSPs)),
+              //  'colspan' => 4,
               ),
 							'hit' => array(
                 'data' => $hit_img,
@@ -240,7 +282,7 @@ if ($xml) {
       $query_with_no_hits[] = $query_name;
 
 		} // end of else
-  }
+  }	//end of foreach - BlastOutput_iterations
 
   if ($no_hits) {
     print '<p class="no-hits-message">No results found.</p>';
@@ -268,3 +310,21 @@ else {
   print '<p>We encountered an error and are unable to load your BLAST results.</p>';
 }
 ?>
+<p> <!--	@deepaksomanadh: Building the edit and resubmit URL --> 
+	 <a style ="align:center" href="<?php print '../../'. $job_id_data['job_url'] . '?jid=' . base64_encode($job_id) ?>">Edit this query and re-submit</a>	
+</p>
+<strong> Recent Jobs </strong>
+	<ol>
+	<?php
+			$sid = session_id();	
+			$jobs = $_SESSION['all_jobs'][$sid];
+	
+			foreach ( $jobs as $job) {
+				echo "<li>";
+				$q_def = !isset($job['query_defs'][0]) ? "Query" : $job['query_defs'][0];
+				echo "<a href='" . "../../" . $job['job_output_url'] ."' >"  
+								. $q_def ."->". $job['program'] . "</a>";
+				echo "</li>";
+			}
+	?>
+	</ol>

+ 1 - 1
theme/blast_report_alignment_row.tpl.php

@@ -87,7 +87,7 @@
             <span class="alignment-residues"><?php print str_replace(' ', '&nbsp', $matches[$k]); ?></span>
           </div>
           <div class="hit">
-            <span class="alignment-title">Hit:</span>&nbsp;&nbsp;&nbsp;&nbsp;
+            <span class="alignment-title">Sbjct:</span>&nbsp;&nbsp;&nbsp;&nbsp;
             <span class="alignment-start-coord"><?php print $coord['hstart']; ?></span>
             <span class="alignment-residues"><?php print $hit[$k]; ?></span>
             <span class="alignment-stop-coord"><?php print $coord['hstop']; ?></span>

+ 4 - 0
theme/blast_ui.theme.inc

@@ -31,6 +31,10 @@ function blast_ui_preprocess_show_blast_report(&$vars) {
   // Add the blast database node.
   // This is needed for link-out functionality.
   $vars['blastdb'] = get_blast_database(array('path' => $job_args['database']));
+	//@deepaksomanadh: code added to use the persisted data in the template file.
+	$job_id = $vars['job_id'];
+	$job_data = variable_get('job_data', '');
+	$vars['job_id_data'] = $job_data[$job_id];
 }
 
 /**

+ 3 - 0
theme/css/blast_report.css

@@ -18,6 +18,9 @@
 #blast_report th {
   text-align: left;
 }
+#blast_report tr td {
+	vertical-align : top;
+}
 #blast_report tr.odd td {
   cursor:pointer;
 	vertical-align : top;