Browse Source

Updated theming and updated the blast module to support blast2GO XML files blast results (concatenated)

spficklin 14 years ago
parent
commit
0ff683eca5

+ 1 - 1
theme_tripal/tripal_feature/tripal_feature_base.tpl.php

@@ -35,7 +35,7 @@ $feature  = $variables['node']->feature;
         <th>Organism</th>
         <td>
           <?php if ($feature->organism_id->nid) { 
-      	   print "<a href=\"".url("node/".$feature->organism_id->nid)."\">".$feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name ." )</a>";      	 
+      	   print "<a href=\"".url("node/".$feature->organism_id->nid)."\">".$feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")</a>";      	 
           } else { 
             print $feature->organism_id->genus ." " . $feature->organism_id->species ." (" .$feature->organism_id->common_name .")";
           } ?>

+ 8 - 1
theme_tripal/tripal_feature/tripal_feature_blast_results.tpl.php

@@ -1,6 +1,6 @@
 <?php
 $feature  = $variables['node']->feature;
-$blast_results_list = $variables['tripal_analysis_blast']['blast_results_list'];
+$blast_results_list = $feature->tripal_analysis_blast->blast_results_list;
 
 ?>
 <div id="tripal_ajaxLoading" style="display:none">
@@ -61,6 +61,13 @@ if(count($blast_results_list) > 0){
 		
 		<?php 
       $i = 0; 
+      if(sizeof($hits_array)==0){?>
+        <tr>
+          <td colspan="5">    
+            <div class="tripal-no-results">There are no matches against <?php print $db->name?> for this <?php print $feature->type_id->name?>.</div> 
+          </td>
+        </tr><?php
+      }
 		foreach($hits_array AS $hit) { 
          $class = 'tripal-table-odd-row tripal_analysis_blast-table-odd-row';
          if($i % 2 == 0 ){

+ 1 - 2
theme_tripal/tripal_feature/tripal_feature_go_terms.tpl.php

@@ -1,7 +1,6 @@
 <?php
-$terms = $variables['tripal_analysis_go']['terms'];
 $feature = $variables['node']->feature;
-
+$terms = $feature->tripal_analysis_go->terms;
 ?>
 <div id="tripal_feature-go_terms-box" class="tripal_feature-info-box tripal-info-box">
   <div class="tripal_feature-info-box-title tripal-info-box-title">GO Assignments</div>

+ 2 - 2
theme_tripal/tripal_feature/tripal_feature_interpro_results.tpl.php

@@ -1,7 +1,7 @@
 <?php
-$results = $variables['tripal_analysis_interpro']['results']['xml'];
-$resultsHTML = $variables['tripal_analysis_interpro']['results']['html'];
 $feature  = $variables['node']->feature;
+$results = $feature->tripal_analysis_interpro->results->xml;
+$resultsHTML = $feature->tripal_analysis_interpro->results->html;
 
 if(count($results) > 0){ 
    $i = 0;

+ 3 - 1
theme_tripal/tripal_feature/tripal_feature_kegg_terms.tpl.php

@@ -1,6 +1,8 @@
 <?php
-$results = $variables['tripal_analysis_kegg']['results'];
+
 $feature  = $variables['node']->feature;
+$results = $feature->tripal_analysis_kegg->results;
+
 if($feature->cvname != 'gene' and count($results) > 0){ 
    $i = 0;
    foreach($results as $analysis_id => $analysisprops){ 

+ 2 - 2
theme_tripal/tripal_organism/tripal_organism_kegg_summary.tpl.php

@@ -1,6 +1,6 @@
 <?php
-  $form = $variables['tripal_analysis_kegg']['select_form']['form'];
-  $has_results = $variables['tripal_analysis_kegg']['select_form']['has_results'];
+  $form = $organism->tripal_analysis_kegg->select_form->form;
+  $has_results = $organism->tripal_analysis_kegg->select_form->has_results;
 ?>
 <div id="tripal_organism-kegg_summary-box" class="tripal_organism-info-box tripal-info-box">
   <div  class="tripal_organism-info-box-title tripal-info-box-title">KEGG Analysis Reports</div>

+ 45 - 4
tripal_analysis_blast/parse_blast_XML.inc

@@ -94,7 +94,8 @@ function parse_NCBI_Blast_XML_index_version($xml_string,$db,$feature_id) {
  * Parse Blast XML Output file into analysisfeatureprop table
  */
 function tripal_analysis_blast_parseXMLFile ($analysis_id, $blastdb, $blastfile, 
-   $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,$job_id) {
+   $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
+   $is_concat,$job_id,$is_concat) {
 
 	// Prepare log
 	$filename = preg_replace("/.*\/(.*)/", "$1", $blastfile);
@@ -105,7 +106,7 @@ function tripal_analysis_blast_parseXMLFile ($analysis_id, $blastdb, $blastfile,
 	if (is_file($blastfile)) {
       tripal_analysis_blast_parseXML($analysis_id, $blastdb, $blastfile, 
          $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-         $job_id,1,$log);
+         $job_id,1,$log,$is_concat);
 	} 
    // Otherwise, $blastfile is a directory. Iterate through all xml files in it
    else {
@@ -150,7 +151,7 @@ function tripal_analysis_blast_parseXMLFile ($analysis_id, $blastdb, $blastfile,
  */
 function tripal_analysis_blast_parseXML($analysis_id, $blastdb, $blastfile, 
    $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-  $job_id,$set_progress,$log){
+  $job_id,$set_progress,$log,$is_concat){
 
 	// Parsing started
 	print "Parsing File:".$blastfile." ...\n";
@@ -171,9 +172,49 @@ function tripal_analysis_blast_parseXML($analysis_id, $blastdb, $blastfile,
 	$type_id = db_result(db_query($sql));
 
 	// Load the XML file.
+   if (!is_readable($blastfile)) {
+      exit("Could not open the XML file '$blastfile'.  Check that file exists and that permissions are correct.\n");
+   }
+   
+   // if the file is a set of concatenated files then we want to split it up
+   // and run each one individually
+   if($is_concat){
+
+      // generate a temporary file name
+      $temp = tempnam(sys_get_temp_dir(),'blast_');
+      print "Blast XML file is concatenated.  Breaking apart and parsing each individually: $temp\n";
+      $out_fh = fopen($temp,"w");
+
+      // run through the lines of the XML file
+      $in_fh = fopen($blastfile,"r");
+      while(!feof($in_fh)){
+         $line = fgets($in_fh);
+         $line = trim($line);
+         if(!$line){
+            continue;
+         }
+         fwrite($out_fh,"$line\n");
+         // if the line begins a set of blast output XML then parse the
+         // preceeding set.
+         if(preg_match("/<\/BlastOutput>/",$line)){
+            // close the temp file
+            fclose($out_fh);
+            // now parse this new temp file
+            tripal_analysis_blast_parseXML($analysis_id, $blastdb, $temp, 
+               $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
+               $job_id,$set_progress,$log,0);
+            // reopen the file for the next set of results
+            $out_fh = fopen($temp,"w");
+         }
+      }
+      fclose($in_fh);
+
+      return;
+   } 
+
 	$blastoutput = simplexml_load_file($blastfile);
    if(!$blastoutput){
-      exit("Failed to open file '$blastfile'\n");
+      exit("Could not read the XML file '$blastfile'.  Check that the XML file is not corrupted.\n");
    }
 	$no_iterations = 0;
 	foreach($blastoutput->children() as $tmp) {

+ 1 - 0
tripal_analysis_blast/tripal_analysis_blast.install

@@ -170,6 +170,7 @@ function tripal_analysis_blast_add_cvterms () {
    tripal_add_cvterms('analysis_blast_query_type','The feature type (e.g. mRNA, polypeptide) of the query input file. This type is used to identify the query feature when multiple features have the same name');
    tripal_add_cvterms('analysis_blast_query_uniquename','Indicates if the matched name in the query definition line of the blast results is feature uniquename');
    tripal_add_cvterms('analysis_blast_blastfile_ext','Indicates the extension of the blast files. This is required if the blastfile setting is a directory.');
+   tripal_add_cvterms('analysis_blast_is_concat','Indicates if the blast results XML file is a series of concatenated XML results.  Such is the case, for example, if Blast2GO was used to perform the analysis.');
 
    // Add cvterm 'analysis_blast_output_iteration_hits' for inserting into featureprop table
    tripal_add_cvterms('analysis_blast_output_iteration_hits', 'Hits of a blast '.

+ 66 - 10
tripal_analysis_blast/tripal_analysis_blast.module

@@ -134,7 +134,7 @@ function tripal_analysis_blast_preprocess_tripal_feature_blast_results(&$variabl
    }
 
    $blast_results = tripal_get_feature_blast_results($feature->feature_id, $db_id, $max);
-   $variables['tripal_analysis_blast']['blast_results_list'] = $blast_results;
+   $feature->tripal_analysis_blast->blast_results_list = $blast_results;
 }
 /*******************************************************************************
  * Prepare blast result for the feature shown on the page
@@ -422,6 +422,7 @@ function chado_analysis_blast_form ($node){
    $query_re = $blast->query_re;
    $query_type = $blast->query_type;
    $query_uniquename = $blast->query_uniquename;
+   $is_concat = $blast->is_concat;
 
 		
 	$form['blast'] = array(
@@ -465,6 +466,13 @@ function chado_analysis_blast_form ($node){
       '#type' => 'textfield',
       '#description' => t('If a directory is provide for the blast file setting above, then a file extension can be provided here. Files with this extension in the directory will be parsed.  If no extension is provided then files with a .xml extension will be parsed within the directory. Please provide the extension without the preceeding period (e.g. "out" rather than ".out"'),
       '#default_value' => $blastfile_ext,
+	);
+	$form['blast']['is_concat'] = array(
+      '#title' => t('Is the XML file concatenated?'),
+      '#type' => 'checkbox',
+      '#description' => t('Is the XML file a set of concatenated XML results?  Such is the case, for instance, if
+                          <a href="http://www.blast2go.org/">Blast2GO</a> was used to generate the blast results.'),
+      '#default_value' => $is_concat,
 	);
 	$form['blast']['no_parsed'] = array(
 	  '#title' => t('Number of hits to be parsed'),
@@ -511,7 +519,7 @@ function chado_analysis_blast_form ($node){
 	
 	$form['blast']['blastjob'] = array(
       '#type' => 'checkbox',
-      '#title' => t('Submit a job to parse the xml output into analysisfeatureprop table'),
+      '#title' => t('Submit a job to parse the xml output into Chado'),
       '#description' => t('Note: features associated with the blast results must '.
                           'exist in chado before parsing the file. Otherwise, blast '.
                           'results that cannot be linked to a feature will be '.
@@ -519,12 +527,12 @@ function chado_analysis_blast_form ($node){
       '#default_value' => $blastjob
 	);
 	
-	$form['blast']['blastbesthit'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Submit a job to generate a "best hits" report.'),
-      '#description' => t('Note: the checkbox above must also be selected.'),
-      '#default_value' => $blastbesthit
-	);
+//	$form['blast']['blastbesthit'] = array(
+//      '#type' => 'checkbox',
+//      '#title' => t('Submit a job to generate a "best hits" report.'),
+//      '#description' => t('Note: the checkbox above must also be selected.'),
+//      '#default_value' => $blastbesthit
+//	);
 	
 	return $form;
 }
@@ -558,6 +566,7 @@ function chado_analysis_blast_load($node){
    $query_type      = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_query_type');	
    $query_uniquename= tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_query_uniquename');	
    $blastfile_ext   = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_blastfile_ext');	
+   $is_concat       = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_is_concat');	
 
    $analysis->tripal_analysis_blast->blastdb         = $blastdb->value;
    $analysis->tripal_analysis_blast->blastfile       = $blastfile->value;	
@@ -567,6 +576,7 @@ function chado_analysis_blast_load($node){
    $analysis->tripal_analysis_blast->query_type      = $query_type->value;	
    $analysis->tripal_analysis_blast->query_uniquename= $query_uniquename->value;	
    $analysis->tripal_analysis_blast->blastfile_ext   = $blastfile_ext->value;	
+   $analysis->tripal_analysis_blast->is_concat       = $is_concat->value;	
 
    // get the database information so that we don't have to require callers
    // to do the lookup
@@ -624,6 +634,7 @@ function chado_analysis_blast_insert($node){
    tripal_analysis_insert_property($node->analysis_id,'analysis_blast_query_type',$node->query_type);	
    tripal_analysis_insert_property($node->analysis_id,'analysis_blast_query_uniquename',$node->query_uniquename);	
    tripal_analysis_insert_property($node->analysis_id,'analysis_blast_blastfile_ext',$node->blastfile_ext);	
+   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_is_concat',$node->is_concat);	
   
    // submit the parsing jobs
    chado_analysis_blast_submit_jobs($node);
@@ -646,6 +657,7 @@ function chado_analysis_blast_update($node){
    tripal_analysis_update_property($node->analysis_id,'analysis_blast_query_type',$node->query_type,1);	
    tripal_analysis_update_property($node->analysis_id,'analysis_blast_query_uniquename',$node->query_uniquename,1);	
    tripal_analysis_update_property($node->analysis_id,'analysis_blast_blastfile_ext',$node->blastfile_ext,1);	
+   tripal_analysis_update_property($node->analysis_id,'analysis_blast_is_concat',$node->is_concat,1);	
 
    // if this analysis uses the old style blast settings cvterm then remove that term
    $old = tripal_analysis_get_property($node->analysis_id,'analysis_blast_settings');
@@ -672,14 +684,17 @@ function chado_analysis_blast_submit_jobs($node){
           $node->blastfile_ext,
           $node->query_re,
 		    $node->query_type, 
-          $node->query_uniquename
+          $node->query_uniquename,
+          $node->is_concat
       );
 
 		if (is_readable($node->blastfile)) {
 			tripal_add_job("Parse blast: $node->blastfile",'tripal_analysis_blast',
                           'tripal_analysis_blast_parseXMLFile', $job_args, $user->uid);
 		} else {
-			drupal_set_message("Can not open blast output file. Job not scheduled.");
+			drupal_set_message("Blast output file, $node->blastfile, is not readable 
+           by the server.  Check existence of file and file permissions. 
+           Job not scheduled.");
 		}
 	}
    // add a job if the user wants to create a best hits report.
@@ -769,4 +784,45 @@ function chado_analysis_blast_access($op, $node, $account){
 	return FALSE;
 }
 
+/**
+ *
+ *
+ * @ingroup tripal_feature
+ */
+function tripal_analysis_blast_job_describe_args($callback,$args){
+
+   $new_args = array();
+   if($callback == 'tripal_analysis_blast_parseXMLFile'){
+
+      // add in the analysis 
+      if($args[0]){
+         $analysis = tripal_core_chado_select('analysis',array('name'),array('analysis_id' => $args[0]));
+      }
+      $new_args['Analysis'] = $analysis[0]->name;
+
+      // add in the database 
+      if($args[1]){
+         $db = tripal_core_chado_select('db',array('name'),array('db_id' => $args[1]));
+      }
+      $new_args['Database'] = $db[0]->name;
+
+      $new_args['File or Directory Name'] = $args[2];
+      if($args[7] == 1){
+        $new_args['Is XML file concatenated'] = 'Yes';
+      } else {
+        $new_args['Is XML file concatenated'] = 'No';
+      }
+      $new_args['File Extension (if directory)'] = $args[4];
+      $new_args['Number matches parsed per query'] = $args[3];
+      $new_args['Query name regular expression'] = $args[5];
+      $new_args['Query type'] = $args[6];
+      if($args[7] == 1){
+        $new_args['Feature identifier'] = 'feature unique name';
+      } else {
+        $new_args['Feature identifier'] = 'feature name';
+      }
+      
 
+   }
+   return $new_args;
+}

+ 3 - 2
tripal_analysis_go/tripal_analysis_go.module

@@ -189,13 +189,14 @@ function theme_tripal_analysis_go_search_result($node){
 */
 function tripal_analysis_go_preprocess_tripal_feature_go_terms(&$variables){
    $feature = $variables['node']->feature;
-   $variables['tripal_analysis_go']['terms'] = tripal_analysis_go_load_feature_terms($feature);
+   $feature->tripal_analysis_go->terms = tripal_analysis_go_load_feature_terms($feature);
 }
 /************************************************************************
 */
 function tripal_analysis_go_preprocess_tripal_organism_go_summary(&$variables){
    $node = $variables['node'];
-   $variables['tripal_analysis_go']['select_form'] = tripal_analysis_go_load_organism_go_summary($node);
+   $organism = $node->organism;
+   $organism->tripal_analysis_go->select_form = tripal_analysis_go_load_organism_go_summary($node);
 }
 /************************************************************************
 */

+ 2 - 2
tripal_analysis_interpro/tripal_analysis_interpro.module

@@ -391,8 +391,8 @@ function tripal_analysis_interpro_preprocess_tripal_feature_interpro_results(&$v
 
    // we don't know how many analysis are the old style HTML version and how many are the newer
    // XML format.  So, to be backwards compatible we should get both.
-   $variables['tripal_analysis_interpro']['results']['html'] = tripal_get_interpro_HTML_results($feature->feature_id);
-	$variables['tripal_analysis_interpro']['results']['xml'] = tripal_get_interpro_XML_results($feature->feature_id);
+   $feature->tripal_analysis_interpro->results->html = tripal_get_interpro_HTML_results($feature->feature_id);
+	$feature->tripal_analysis_interpro->results->xml = tripal_get_interpro_XML_results($feature->feature_id);
 }
 
 /*******************************************************************************

+ 3 - 2
tripal_analysis_kegg/tripal_analysis_kegg.module

@@ -853,7 +853,8 @@ function tripal_analysis_kegg_preprocess(&$variables){
  */
 function tripal_analysis_kegg_preprocess_tripal_organism_kegg_summary(&$variables){
    $node = $variables['node'];
-   $variables['tripal_analysis_kegg']['select_form'] = tripal_analysis_kegg_load_organism_kegg_summary($node);
+   $organism = $node->organism;
+   $organism->tripal_analysis_kegg->select_form = tripal_analysis_kegg_load_organism_kegg_summary($node);
 }
 /**
 *
@@ -861,7 +862,7 @@ function tripal_analysis_kegg_preprocess_tripal_organism_kegg_summary(&$variable
 function tripal_analysis_kegg_preprocess_tripal_feature_kegg_terms(&$variables){
    $node = $variables['node'];
    $feature = $node->feature;
-   $variables['tripal_analysis_kegg']['results'] = tripal_analysis_kegg_load_feature_terms($feature);
+   $feature->tripal_analysis_kegg->results = tripal_analysis_kegg_load_feature_terms($feature);
 }
 /************************************************************************
  */

+ 2 - 2
tripal_core/jobs.php

@@ -103,9 +103,9 @@ function tripal_jobs_report () {
 
       $cancel_link = '';
       if($job->start_time == 0 and $job->end_time == 0){
-         $cancel_link = "<a href=\"".url("admin/tripal/tripal_jobs/cancel/".$job->job_id)."\">Cancel</a>";
+         $cancel_link = "<a href=\"".url("admin/tripal/tripal_jobs/cancel/".$job->job_id)."\">Cancel</a><br>";
       }
-      $rerun_link = "<a href=\"".url("admin/tripal/tripal_jobs/rerun/".$job->job_id)."\">Re-run</a>";
+      $rerun_link = "<a href=\"".url("admin/tripal/tripal_jobs/rerun/".$job->job_id)."\">Re-run</a><br>";
       $view_link ="<a href=\"".url("admin/tripal/tripal_jobs/view/".$job->job_id)."\">View</a>";
       $output .= "  <tr class=\"$class\">";
       $output .= "    <td>$job->job_id</td>".

+ 1 - 0
tripal_feature/tripal_feature.module

@@ -1915,6 +1915,7 @@ function tripal_features_set_taxonomy($max_sync = 0,$job_id = NULL){
       if($job_id and $i % $interval == 0){
          tripal_job_set_progress($job_id,intval(($i/$count)*100));
       }
+      print "$i of $count: ";
       $node = db_fetch_object(db_query($nsql,$chado_feature->nid));
       tripal_feature_set_taxonomy($node,$chado_feature->feature_id);