Browse Source

Moved most extensions out. Moved base modules out of 'base' directory

spficklin 13 years ago
parent
commit
af2ff151e6
100 changed files with 0 additions and 9721 deletions
  1. 0 14
      extensions/mainlab_search/mainlab_search.info
  2. 0 0
      extensions/mainlab_search/mainlab_search.install
  3. 0 0
      extensions/mainlab_search/mainlab_search.module
  4. 0 924
      extensions/tripal_analysis_blast/includes/parse_blast_XML.inc
  5. 0 102
      extensions/tripal_analysis_blast/node-chado_analysis_blast.tpl.php
  6. 0 33
      extensions/tripal_analysis_blast/theme/css/tripal_analysis_blast.css
  7. 0 183
      extensions/tripal_analysis_blast/theme/js/tripal_analysis_blast.js
  8. 0 78
      extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_base.tpl.php
  9. 0 123
      extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_report.tpl.php
  10. 0 53
      extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_teaser.tpl.php
  11. 0 115
      extensions/tripal_analysis_blast/theme/tripal_feature/tripal_feature_blast_results.tpl.php
  12. 0 9
      extensions/tripal_analysis_blast/tripal_analysis_blast.info
  13. 0 198
      extensions/tripal_analysis_blast/tripal_analysis_blast.install
  14. 0 909
      extensions/tripal_analysis_blast/tripal_analysis_blast.module
  15. 0 208
      extensions/tripal_analysis_blast/tripal_analysis_blast_htmlreport.inc
  16. 0 23
      extensions/tripal_analysis_go/go_path_counts
  17. 0 466
      extensions/tripal_analysis_go/includes/gaf_loader.inc
  18. 0 17
      extensions/tripal_analysis_go/theme/css/tripal_analysis_go.css
  19. 0 52
      extensions/tripal_analysis_go/theme/js/tripal_analysis_go.js
  20. 0 35
      extensions/tripal_analysis_go/theme/tripal_feature/tripal_feature_go_terms.tpl.php
  21. 0 35
      extensions/tripal_analysis_go/theme/tripal_organism/tripal_organism_go_summary.tpl.php
  22. 0 10
      extensions/tripal_analysis_go/tripal_analysis_go.info
  23. 0 133
      extensions/tripal_analysis_go/tripal_analysis_go.install
  24. 0 608
      extensions/tripal_analysis_go/tripal_analysis_go.module
  25. 0 584
      extensions/tripal_analysis_interpro/includes/parseInterpro.inc
  26. 0 100
      extensions/tripal_analysis_interpro/node-chado_analysis_interpro.tpl.php
  27. 0 44
      extensions/tripal_analysis_interpro/theme/css/tripal_analysis_interpro.css
  28. 0 29
      extensions/tripal_analysis_interpro/theme/js/tripal_analysis_interpro.js
  29. 0 56
      extensions/tripal_analysis_interpro/theme/tripal_analysis_interpro/tripal_analysis_interpro_base.tpl.php
  30. 0 53
      extensions/tripal_analysis_interpro/theme/tripal_analysis_interpro/tripal_analysis_interpro_teaser.tpl.php
  31. 0 128
      extensions/tripal_analysis_interpro/theme/tripal_feature/tripal_feature_interpro_results.tpl.php
  32. 0 10
      extensions/tripal_analysis_interpro/tripal_analysis_interpro.info
  33. 0 90
      extensions/tripal_analysis_interpro/tripal_analysis_interpro.install
  34. 0 795
      extensions/tripal_analysis_interpro/tripal_analysis_interpro.module
  35. 0 101
      extensions/tripal_analysis_kegg/node-chado_analysis_kegg.tpl.php
  36. 0 46
      extensions/tripal_analysis_kegg/theme/css/tripal_analysis_kegg.css
  37. BIN
      extensions/tripal_analysis_kegg/theme/images/kegg.gif
  38. 0 162
      extensions/tripal_analysis_kegg/theme/js/tripal_analysis_kegg.js
  39. 0 53
      extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_base.tpl.php
  40. 0 11
      extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_report.tpl.php
  41. 0 53
      extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_teaser.tpl.php
  42. 0 46
      extensions/tripal_analysis_kegg/theme/tripal_feature/tripal_feature_kegg_terms.tpl.php
  43. 0 22
      extensions/tripal_analysis_kegg/theme/tripal_organism/tripal_organism_kegg_summary.tpl.php
  44. 0 10
      extensions/tripal_analysis_kegg/tripal_analysis_kegg.info
  45. 0 106
      extensions/tripal_analysis_kegg/tripal_analysis_kegg.install
  46. 0 1302
      extensions/tripal_analysis_kegg/tripal_analysis_kegg.module
  47. 0 103
      extensions/tripal_analysis_unigene/node-chado_analysis_unigene.tpl.php
  48. 0 16
      extensions/tripal_analysis_unigene/theme/css/tripal_analysis_unigene.css
  49. 0 86
      extensions/tripal_analysis_unigene/theme/tripal_analysis_unigene/tripal_analysis_unigene_base.tpl.php
  50. 0 53
      extensions/tripal_analysis_unigene/theme/tripal_analysis_unigene/tripal_analysis_unigene_teaser.tpl.php
  51. 0 61
      extensions/tripal_analysis_unigene/theme/tripal_feature/tripal_feature_unigenes.tpl.php
  52. 0 52
      extensions/tripal_analysis_unigene/theme/tripal_organism/tripal_organism_unigenes.tpl.php
  53. 0 9
      extensions/tripal_analysis_unigene/tripal_analysis_unigene.info
  54. 0 290
      extensions/tripal_analysis_unigene/tripal_analysis_unigene.install
  55. 0 922
      extensions/tripal_analysis_unigene/tripal_analysis_unigene.module
  56. 0 0
      tripal_analysis/tripal_analysis.admin.inc
  57. 0 0
      tripal_analysis/tripal_analysis.api.inc
  58. 0 0
      tripal_analysis/tripal_analysis.info
  59. 0 0
      tripal_analysis/tripal_analysis.install
  60. 0 0
      tripal_analysis/tripal_analysis.module
  61. 0 0
      tripal_analysis/tripal_analysis.views.inc
  62. 0 0
      tripal_analysis/tripal_analysis_privacy.inc
  63. 0 0
      tripal_analysis/views/README
  64. 0 0
      tripal_analysis/views/analysis.views.inc
  65. 0 0
      tripal_analysis/views/chado_analysis.views.inc
  66. 0 0
      tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc
  67. 0 0
      tripal_analysis/views/misc_tables.views.inc
  68. 0 0
      tripal_analysis/views/template.node_join.views.inc
  69. 0 0
      tripal_analysis/views/template.table_defn.views.inc
  70. 0 0
      tripal_bulk_loader/tripal_bulk_loader.admin.inc
  71. 0 0
      tripal_bulk_loader/tripal_bulk_loader.constants.inc
  72. 0 0
      tripal_bulk_loader/tripal_bulk_loader.info
  73. 0 0
      tripal_bulk_loader/tripal_bulk_loader.install
  74. 0 0
      tripal_bulk_loader/tripal_bulk_loader.loader.inc
  75. 0 0
      tripal_bulk_loader/tripal_bulk_loader.module
  76. 0 0
      tripal_contact/tripal_contact.api.inc
  77. 0 0
      tripal_contact/tripal_contact.info
  78. 0 0
      tripal_contact/tripal_contact.module
  79. 0 0
      tripal_contact/tripal_contact.views.inc
  80. 0 0
      tripal_contact/views/README
  81. 0 0
      tripal_contact/views/template.node_join.views.inc
  82. 0 0
      tripal_contact/views/template.table_defn.views.inc
  83. 0 0
      tripal_core/chado_install.php
  84. 0 0
      tripal_core/cvterms.php
  85. 0 0
      tripal_core/default_schema.sql
  86. 0 0
      tripal_core/initialize.sql
  87. 0 0
      tripal_core/jobs.php
  88. 0 0
      tripal_core/mviews.php
  89. 0 0
      tripal_core/tripal_core.api.inc
  90. 0 0
      tripal_core/tripal_core.info
  91. 0 0
      tripal_core/tripal_core.install
  92. 0 0
      tripal_core/tripal_core.module
  93. 0 0
      tripal_core/tripal_core.schema.api.inc
  94. 0 0
      tripal_core/tripal_core_job_view.tpl.php
  95. 0 0
      tripal_core/tripal_launch_jobs.php
  96. 0 0
      tripal_core/tripal_launch_jobs_multi.php
  97. 0 0
      tripal_cv/charts.php
  98. 0 0
      tripal_cv/feature_property.obo
  99. 0 0
      tripal_cv/obo_loader.php
  100. 0 0
      tripal_cv/trees.php

+ 0 - 14
extensions/mainlab_search/mainlab_search.info

@@ -1,14 +0,0 @@
-name = Mainlab Searches
-description = Provides basic searching tools for a whole genome website. Allows for searching by gene (mRNA, unigene contig), homology, GO termrs, KEGG terms and InterPro terms.  This module was develoepd at the Main Bioinformatics Lab at Washington State University.
-core = 6.x
-project = mainlab_search
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis
-dependencies[] = tripal_organism
-dependencies[] = tripal_analysis_go
-dependencies[] = tripal_analysis_blast
-dependencies[] = tripal_analysis_interpro
-dependencies[] = tripal_analysis_kegg
-dependencies[] = tripal_views

+ 0 - 0
extensions/mainlab_search/mainlab_search.install


+ 0 - 0
extensions/mainlab_search/mainlab_search.module


+ 0 - 924
extensions/tripal_analysis_blast/includes/parse_blast_XML.inc

@@ -1,924 +0,0 @@
-<?php
-
-/*******************************************************************************
- * Parse NCBI Blast results for indexing so that user can use blast results to
- * find corresponding features
- */
-function parse_NCBI_Blast_XML_index_version($xml_string,$db,$feature_id) {
-	// Get the parser using db_id
-	$sql = "SELECT * FROM {tripal_analysis_blast} WHERE db_id = %d";
-	$parser = db_fetch_object(db_query($sql, $db->db_id));
-	$db_name = $parser->displayname;
-	$is_genbank = $parser->genbank_style;
-	$regex_hit_id = $parser->regex_hit_id;
-	$regex_hit_def = $parser->regex_hit_def;
-	$regex_hit_accession = $parser->regex_hit_accession;
-
-	// set default if regular expressions have not been specified
-	if(!$regex_hit_id){
-		$regex_hit_id = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_id = '/'.$regex_hit_id.'/';
-	}
-	if(!$regex_hit_def){
-		$regex_hit_def = '/^.*?\s(.*)$/';
-	} else {
-		$regex_hit_def = '/'.$regex_hit_def.'/';
-	}
-	if(!$regex_hit_accession){
-		$regex_hit_accession = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_accession = '/'.$regex_hit_accession.'/';
-	}
-
-	$html_out .= "<h3>$db_name</h3>";
-
-	// Load the file.  This XML file should be an extract
-	// of the original XML file with only a single iteration.
-	// An iteration is essentially all the hits for a single
-	// query sequence.
-	$xml_output = simplexml_load_string($xml_string);
-	$iteration = '';
-	// new XML file parser has added the feature name within <Iteration_query-def> tags.
-	if ($xml_output->getName() == 'Iteration') {
-		foreach ($xml_output->children() as $xml_tag) {
-			if ($xml_tag->getName() == 'Iteration_query-def') {
-				// Here we show the feature name again to check if we pull the correct data
-				$html_out .= "Query: $xml_tag<br>";
-			} else if ($xml_tag->getName() == 'Iteration_hits') {
-				$iteration = $xml_tag;
-			}
-		}
-		// This is for the file parsed by the old parser
-	} else {
-		$iteration = $xml_output;
-	}
-
-	// now run through the blast hits/hsps of this iteration
-	// and generate the rows of the table
-	foreach($iteration->children() as $hits){
-		$best_evalue = 0;
-		foreach($hits->children() as $hit){
-			$best_evalue = 0;
-			$element_name = $hit->getName();
-			if($element_name == 'Hit_id'){
-				// if parsing "name, acc, desc" from three tags (1/3)
-				if ($is_genbank) {
-					$hit_name = $hit;
-				}
-			} else if($element_name == 'Hit_def'){
-				if($is_genbank){
-					$description = $hit;
-				} else {
-					$accession = preg_replace($regex_hit_accession,"$1",$hit);
-					$hit_name = preg_replace($regex_hit_id,"$1",$hit);
-					$description = preg_replace($regex_hit_def,"$1",$hit);
-				}
-			} else if($element_name == 'Hit_accession'){
-				// if parsing "name, acc, desc" from three tags (3/3)
-				if ($is_genbank){
-					$accession = $hit;
-				}
-				// now run through each HSP for this hit
-			}
-		}
-		$html_out .= "<p>$hit_name<br>";
-		$html_out .= "$accession<br>";
-		$html_out .= "<b>$description</b></br>";
-		$hsp_html_out = '';
-	}
-	return $html_out;
-}
-
-/*******************************************************************************
- * 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,
-   $is_concat,$job_id,$is_concat) {
-
-	// Prepare log
-	$filename = preg_replace("/.*\/(.*)/", "$1", $blastfile);
-	$logfile = file_directory_path() . "/tripal/tripal_analysis_blast/load_$filename.log";
-        $logfile = tempnam(sys_get_temp_dir(),"tripal_analysis_blast_import");
-	$log = fopen($logfile, 'a'); // append parsing results to log file
-        if(!$log){
-           print "ERROR: cannot open log file: $logfile\n";
-           exit;
-        }
-
-	// If user input a file (e.g. blast.xml)
-	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,$is_concat);
-	} 
-   // Otherwise, $blastfile is a directory. Iterate through all xml files in it
-   else {
-      if(!$blastfile_ext){
-         $blastfile_ext = 'xml';
-      }
-
-		$dir_handle = @opendir($blastfile) or die("Unable to open $blastfile");
-		$pattern = sql_regcase($blastfile . "/*.$blastfile_ext");
-		$total_files = count(glob($pattern));
-		print "$total_files file(s) to be parsed.\n";
-		
-		$interval = intval($total_files * 0.01);
-		$no_file = 0;
-			
-		// Parsing all files in the directory
-		while ($file = readdir($dir_handle)) {
-			if(preg_match("/^.*\.$blastfile_ext/i",$file)){
-
-            tripal_analysis_blast_parseXML($analysis_id, $blastdb, "$blastfile/$file", 
-              $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-              $job_id,0,$log);
-
-			   // Set job status
-			   if ($no_file % $interval == 0) {
-			      $percentage = (int) (($no_file / $total_files) * 100);
-				   tripal_job_set_progress($job_id, $percentage);
-				   print $percentage."%\r";
-			   }				
-         }
-   	   $no_file ++;
-		}
-	}
-
-	print "Done.\nSuccessful and failed entries have been saved in the log file:\n $logfile\n";
-	fwrite($log, "\n");
-	fclose($log);
-	return;
-}
-/********************************************************************************
- * 
- */
-function tripal_analysis_blast_parseXML($analysis_id, $blastdb, $blastfile, 
-   $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-  $job_id,$set_progress,$log,$is_concat){
-
-	// Parsing started
-	print "Parsing File:".$blastfile." ...\n";
-	fwrite($log, date("D M j G:i:s Y").". Loading $blastfile\n");
-	if ($no_parsed == 'all') {
-		print "Parsing all hits...\n";
-	} else {
-		print "Parsing top $no_parsed hits...\n";
-	}
-	
-	// Get cvterm_id for 'analysis_blast_output_iteration_hits' which is required
-	// for inserting into the analysisfeatureprop table
-	$previous_db = tripal_db_set_active('chado'); // use chado database
-	$sql = "SELECT CVT.cvterm_id ".
-          "FROM {cvterm} CVT ".
-          "   INNER JOIN {cv} ON cv.cv_id = CVT.cv_id ".
-          "WHERE CVT.name = 'analysis_blast_output_iteration_hits' ".
-          "   AND CV.name = 'tripal'";
-	$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("Could not read the XML file '$blastfile'.  Check that the XML file is not corrupted.\n");
-   }
-	$no_iterations = 0;
-	foreach($blastoutput->children() as $tmp) {
-		if ($tmp->getName() == 'BlastOutput_iterations') {
-			foreach($tmp->children() as $itr) {
-				if ($itr->getName() == 'Iteration') {
-					$no_iterations ++;
-				}
-			}
-		}
-	}
-	print "$no_iterations iterations to be processed.\n";
-		
-	$interval = intval($no_iterations * 0.01);
-	$idx_iterations = 0;
-	foreach ($blastoutput->children() as $blastoutput_tags) {
-
-		if ($blastoutput_tags->getName() == 'BlastOutput_iterations') {
-			foreach($blastoutput_tags->children() as $iterations) {
-				if ($iterations->getName() == 'Iteration') {
-
-					// Set job status
-					$idx_iterations ++;
-					if ($set_progress and $idx_iterations % $interval == 0) {
-						$percentage = (int) (($idx_iterations / $no_iterations) * 100);
-						tripal_job_set_progress($job_id, $percentage);
-						print $percentage."%\r";
-					}
-					// now run through the blast hits/hsps of this iteration
-					// and generate the rows of the table
-					$feature_id = 0;
-					foreach($iterations->children() as $iteration_tags) {
-
-						// Match chado feature uniquename with <Iteration_query-def>
-						// and get the feature_id
-						$featurenaem_xml = '';
-						if($iteration_tags->getName() == 'Iteration_query-def'){
-
-							// If the Iteration_query-def in the format provided by the 
-                     // user's regular expression 
-							if ($query_re and preg_match("/$query_re/", $iteration_tags, $matches)) {
-								$feature = $matches[1];
-							} 
-                     // If not in above format then pull up to the first space
-                     else {
-								if (preg_match('/^(.*?)\s.*$/', $iteration_tags, $matches)) {
-   								$feature = $matches[1];
-                        } 
-                        // if no match up to the first space then just use the entire string
-                        else {
-                           $feature = $iteration_tags;
-                        }
-                     }   
-
-                     if(!$feature and $query_re){
-                        print "ERROR: cannot find feature for $iteration_tags using the regular expression: $query_re\n";
-                        exit;
-                     }
-
-                     // now find the feature in chado
-                     $select = array();
-                     if($query_uniquename){
-                        $select['uniquename'] = $feature;
-                     } else {
-                        $select['name'] = $feature;
-                     }
-                     if($query_type){
-                        $select['type_id'] = array(
-                          'cv_id' => array(
-                             'name' => 'sequence'
-                          ),
-                          'name' => $query_type,
-                        );
-                     }
-
-                     $feature_arr = tripal_core_chado_select('feature',array('feature_id'),$select);
-                     if(count($feature_arr) > 1){
-  							   fwrite($log, "Ambiguous: '$feature' matches more than one feature and is being skipped.\n");
-								continue;
-                     }
-                     if(count($feature_arr) == 0){
-								fwrite($log, "Failed: '$feature' cannot find a matching feature in the database.\n");
-                        continue;
-                     }
-                     $feature_id = $feature_arr[0]->feature_id;
-
-    						fwrite($log, "Matched: '$feature' => feature id:".$feature_id);
-							$featurename_xml = $iteration_tags->asXML();
-						} 
-                  // Insert Iteration_hits into analysisfeatureprop and analysisfeature tables
-                  else if($iteration_tags->getName() == 'Iteration_hits'){
-							if ($feature_id) {
-								// Make sure this iteration doesn't exist in analysisfeatureprop. If it does, update but not insert
-								$sql = "SELECT analysisfeatureprop_id FROM {analysisfeatureprop} AFP ".
-                               "INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id ".       
-                               "WHERE feature_id=%d ".
-                            "AND analysis_id=%d ".
-                            "AND type_id=%d ";
-
-								$result = db_query($sql, $feature_id, $analysis_id, $type_id);
-								$analysisfeatureprop = db_fetch_object($result);
-								$xml_content =  "<Iteration>\n".$featurename_xml."\n";
-								// parse all hits
-								if ($no_parsed == 'all') {
-									$xml_content .= $iteration_tags->asXML();
-								// parse only top hits
-								} else {
-									$counter = 0;
-									$xml_content .= "<Iteration_hits>\n";
-									foreach ($iteration_tags->children() As $hit) {
-										if ($counter < $no_parsed) {
-											$xml_content .= $hit->asXML();
-										} else {
-											break;
-										}
-										$counter ++;
-									}
-									$xml_content .= "</Iteration_hits>";
-								}
-								$xml_content .= "\n</Iteration>";
-
-								// If this Iteration_hits already exists, update it
-								if ($analysisfeatureprop) {
-
-									$sql = "UPDATE {analysisfeatureprop} ".
-                               "SET value = '%s' ".
-                               "WHERE analysisfeatureprop_id = %d ";
-										
-									db_query($sql, $xml_content, $analysisfeatureprop->analysisfeatureprop_id);
-									fwrite($log, " (Update)\n"); // write to log
-
-									// Otherwise, insert the Iteration_hits into analysisfeature and analysisfeatureprop tables
-								} else {
-									//------------------------------------------------------
-									// Insert into analysisfeature table
-									//------------------------------------------------------
-									$sql = "INSERT INTO {analysisfeature} (feature_id, analysis_id) ".
-                               "VALUES (%d, %d)";
-									db_query ($sql, $feature_id, $analysis_id);
-									// Get the newly inserted analysisfeature_id
-									$sql = "SELECT analysisfeature_id FROM {analysisfeature} WHERE feature_id = %d AND analysis_id = %d";
-									$analysisfeature_id = db_result(db_query($sql, $feature_id, $analysis_id));
-									//------------------------------------------------------
-									// Insert into analysisfeatureprop table
-									//------------------------------------------------------
-									$sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank)".
-                               "VALUES (%d, %d, '%s', %d)";
-									db_query($sql, $analysisfeature_id, $type_id, $xml_content, '0');
-									fwrite($log, " (Insert)\n"); // write to log
-								}
-							}
-						}	
-					}
-				}
-			}
-		}
-	}
-	tripal_db_set_active ($previous_db); // Use drupal database
-}
-/********************************************************************************
- * 
- */
-function tripal_analysis_blast_get_result_object($xml_string,$db,$max,$feature_id, $analysis) {
-	$blast_object = new stdClass();
-
-	// Get the parser using db_id
-	$sql = "SELECT * FROM {tripal_analysis_blast} WHERE db_id = %d";
-	$parser = db_fetch_object(db_query($sql, $db->db_id));
-	$db_name = $parser->displayname;
-	$is_genbank = $parser->genbank_style;
-	$regex_hit_id = $parser->regex_hit_id;
-	$regex_hit_def = $parser->regex_hit_def;
-	$regex_hit_accession = $parser->regex_hit_accession;
-
-	// set default if regular expressions have not been specified
-	if(!$regex_hit_id){
-		$regex_hit_id = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_id = '/'.$regex_hit_id.'/';
-	}
-	if(!$regex_hit_def){
-		$regex_hit_def = '/^.*?\s(.*)$/';
-	} else {
-		$regex_hit_def = '/'.$regex_hit_def.'/';
-	}
-	if(!$regex_hit_accession){
-		$regex_hit_accession = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_accession = '/'.$regex_hit_accession.'/';
-	}
-
-	// Get analysis information
-	$blast_object->analysis = $analysis;
-	$db->displayname = $db_name;
-	$blast_object->db = $db;
-	if (!$db_name) {
-		$blast_object->title = $analysis->name;
-	} else {
-		$blast_object->title = $db_name;
-	}
-
-	// Find node id for the analysis
-	$ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %d", $analysis->analysis_id));
-   $analysis->nid = $ana_nid;
-
-
-	// Load the file.  This XML file should be an extract
-	// of the original XML file with only a single iteration.
-	// An iteration is essentially all the hits for a single
-	// query sequence.
-	$xml_output = simplexml_load_string($xml_string);
-	$iteration = '';
-	// new XML file parser has added the feature name within <Iteration_query-def> tags.
-	if ($xml_output->getName() == 'Iteration') {
-		foreach ($xml_output->children() as $xml_tag) {
-			if ($xml_tag->getName() == 'Iteration_query-def') {
-				// Here we show the feature name again to check if we pull the correct data
-				$blast_object->xml_tag = $xml_tag;
-			} else if ($xml_tag->getName() == 'Iteration_hits') {
-				$iteration = $xml_tag;
-			}
-		}
-		// This is for the file parsed by the old parser
-	} else {
-		$iteration = $xml_output;
-	}
-
-	$number_hits = 0;
-	foreach($iteration->children() as $hits){
-		$number_hits ++;
-	}
-
-	// add the links for updating blast info using Ajax
-	$blast_object->max = $max;
-	$blast_object->number_hits = $number_hits;
-	$blast_object->feature_id = $feature_id;
-	
-	$hits_array = array();
-	$hit_count = 0;
-
-	foreach($iteration->children() as $hits){
-		$hsp_array = array();
-		$counter = 0;
-		foreach($hits->children() as $hit){
-			$best_evalue = 0;
-			$best_identity = 0;
-			$best_len = 0;
-			$element_name = $hit->getName();
-			if($element_name == 'Hit_id'){
-				// if parsing "name, acc, desc" from three tags (1/3)
-				if ($is_genbank) {
-					$hit_name = $hit;
-				}
-			} else if($element_name == 'Hit_def'){
-				if($is_genbank){
-					$description = $hit;
-				} else {
-					$accession = preg_replace($regex_hit_accession,"$1",$hit);
-					$hit_name = preg_replace($regex_hit_id,"$1",$hit);
-					$description = preg_replace($regex_hit_def,"$1",$hit);
-				}
-			} else if($element_name == 'Hit_accession'){
-				// if parsing "name, acc, desc" from three tags (3/3)
-				if ($is_genbank){
-					$accession = $hit;
-				}
-				// now run through each HSP for this hit
-			} else if($element_name == 'Hit_hsps'){		
-				foreach($hit->children() as $hsp){
-					foreach($hsp->children() as $hsp_info){
-						$element_name = $hsp_info->getName();
-						if($element_name == 'Hsp_num'){
-							$hsp_num = $hsp_info;
-						}
-						if($element_name == 'Hsp_bit-score'){
-							$hsp_bit_score = $hsp_info;
-						}
-						if($element_name == 'Hsp_score'){
-							$hsp_score = $hsp_info;
-						}
-						if($element_name == 'Hsp_evalue'){
-							$hsp_evalue = $hsp_info;
-							// use the first evalue for this set of HSPs
-							// as the best evalue. This get's shown as
-							// info for the overall match.
-							if(!$best_evalue){
-								$best_evalue = $hsp_evalue;
-							}
-						}
-						if($element_name == 'Hsp_query-from'){
-							$hsp_query_from = $hsp_info;
-						}
-						if($element_name == 'Hsp_query-to'){
-							$hsp_query_to = $hsp_info;
-						}
-						if($element_name == 'Hsp_hit-from'){
-							$hsp_hit_from = $hsp_info;
-						}
-						if($element_name == 'Hsp_hit-to'){
-							$hsp_hit_to = $hsp_info;
-						}
-						if($element_name == 'Hsp_query-frame'){
-							$hsp_query_frame = $hsp_info;
-						}
-						if($element_name == 'Hsp_identity'){
-							$hsp_identity = $hsp_info;
-							// use the first evalue for this set of HSPs
-							// as the best evalue. This get's shown as
-							// info for the overall match.
-							if(!$best_identity){
-								$best_identity = $hsp_identity;
-							}
-						}
-						if($element_name == 'Hsp_positive'){
-							$hsp_positive = $hsp_info;
-						}
-						if($element_name == 'Hsp_align-len'){
-							$hsp_align_len = $hsp_info;
-							// use the first evalue for this set of HSPs
-							// as the best evalue. This get's shown as
-							// info for the overall match.
-							if(!$best_len){
-								$best_len = $hsp_align_len;
-							}
-						}
-						if($element_name == 'Hsp_qseq'){
-							$hsp_qseq = $hsp_info;
-						}
-						if($element_name == 'Hsp_hseq'){
-							$hsp_hseq = $hsp_info;
-						}
-						if($element_name == 'Hsp_midline'){
-							$hsp_midline = $hsp_info;
-						}
-					}
-
-					$hsp_content = array();
-					$hsp_content['hsp_num'] = $hsp_num;
-					$hsp_content['bit_score'] = $hsp_bit_score;
-					$hsp_content['score'] = $hsp_score;
-					$hsp_content['evalue'] = $hsp_evalue;
-					$hsp_content['query_frame'] = $hsp_query_frame;
-					$hsp_content['qseq'] = $hsp_qseq;
-					$hsp_content['midline'] = $hsp_midline;
-					$hsp_content['hseq'] = $hsp_hseq;
-					$hsp_content['hit_from'] = $hsp_hit_from;
-					$hsp_content['hit_to'] = $hsp_hit_to;
-					$hsp_content['identity'] = $hsp_identity;
-					$hsp_content['align_len'] = $hsp_align_len;
-					$hsp_content['positive'] = $hsp_positive;
-					$hsp_content['query_from'] = $hsp_query_from;
-					$hsp_content['query_to'] = $hsp_query_to;
-					$hsp_array[$counter] = $hsp_content;
-					$counter ++;
-				}
-			}
-		}
-      $arrowr_url = url(drupal_get_path('theme', 'tripal')."/images/arrow_r.png");
-		$hits_array[$hit_count]['arrowr_url'] = $arrowr_url;
-		$hits_array[$hit_count]['accession'] = $accession;
-		$hits_array[$hit_count]['hit_name'] = $hit_name;
-		
-		if($accession && $db->urlprefix){
-			$hits_array[$hit_count]['hit_url'] = "$db->urlprefix$accession";
-		} else {
-			// Test if this is another feature in the database
-			$sql = "SELECT feature_id FROM {feature} WHERE uniquename = '%s'";
-			$previous_db = db_set_active('chado');
-			$hit_feature_id = db_result(db_query($sql, $hit_name));
-			db_set_active($previous_db);
-			// If it is, add link to that feature
-			if ($hit_feature_id) {
-				$hits_array[$hit_count]['hit_url'] = "ID$hit_feature_id";
-			}
-		}
-		
-		$hits_array[$hit_count]['best_evalue'] = $best_evalue;
-		
-		if (!empty($best_len)) {
-			$percent_identity = number_format($best_identity/$best_len*100, 2);
-			$hits_array[$hit_count]['percent_identity'] = $percent_identity;
-		}
-
-		$hits_array[$hit_count]['description'] = $description;
-		
-		// if there is at least one HSP
-		if (!empty($hsp_array[0]['query_frame'])) {
-		  $hits_array[$hit_count]['hsp'] = $hsp_array;
-		} else {
-		  $hits_array[$hit_count]['hsp'] = array();
-		}
-		
-		$hit_count ++;
-		
-		// if we've hit the maximum number of hits then return
-		if($max > 0 && $hit_count >= $max){
-			break;
-		}
-	}
-	$blast_object->hits_array = $hits_array;
-	return $blast_object;
-}
-
-/********************************************************************************
- * Parse the best hit to generate the best hit homology report 
- */
-function tripal_analysis_blast_parse_best_hit ($analysis_id) {
-
-	// Select all features for this blast analysis, and save them to the 'featureSet' array
-	$sql = "SELECT feature_id
-	             FROM {analysisfeature} AF  
-	             WHERE analysis_id = %d";
-	$previous_db = tripal_db_set_active('chado');
-	$result = db_query($sql, $analysis_id);
-	$featureSet = array ();
-	$counter = 0;
-	while ($feature = db_fetch_object($result)) {
-		$featureSet [$counter] = $feature->feature_id;
-		$counter ++;
-	}
-
-	// Get analysis information including 'Time', 'Name', and 'DB Settings'
-	$sql = "SELECT value, name, to_char(timeexecuted, 'MM-DD-YYYY') AS time
-                FROM {analysis}  A
-                INNER JOIN {analysisprop} AP ON  A.analysis_id = AP.analysis_id 
-                WHERE A.analysis_id = %d
-                AND type_id= (SELECT cvterm_id 
-                                           FROM {cvterm} 
-                                           WHERE name = 'analysis_blast_settings')";
-	$analysis = db_fetch_object(db_query($sql, $analysis_id));
-	
-	// Parse the blast settings
-	$blastsettings = explode("|", $analysis->value);
-	$db_id = $blastsettings [0];
-	
-	// Get the xml description parser using db_id
-	tripal_db_set_active($previous_db);
-	$sql = "SELECT * FROM {tripal_analysis_blast} WHERE db_id = %d";
-	$parser = db_fetch_object(db_query($sql, $db_id));
-
-	$db_name = $parser->displayname;
-	$is_genbank = $parser->genbank_style;
-	$regex_hit_id = $parser->regex_hit_id;
-	$regex_hit_def = $parser->regex_hit_def;
-	$regex_hit_accession = $parser->regex_hit_accession;
-
-	// set default description parser  if regular expressions have not been specified
-	if(!$regex_hit_id){
-		$regex_hit_id = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_id = '/'.$regex_hit_id.'/';
-	}
-	if(!$regex_hit_def){
-		$regex_hit_def = '/^.*?\s(.*)$/';
-	} else {
-		$regex_hit_def = '/'.$regex_hit_def.'/';
-	}
-	if(!$regex_hit_accession){
-		$regex_hit_accession = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_accession = '/'.$regex_hit_accession.'/';
-	}
-	
-   $interval = intval($counter * 0.01);
-	for ($i = 0; $i < $counter; $i ++) {
-		
-		if ($i !=0 && $i % $interval == 0) {
-			$percentage = (int) ($i / $counter * 100);
-			tripal_job_set_progress($job_id, $percentage);	
-			print $percentage."%\r";
-		}
-
-		$sql = "SELECT value
-		             FROM {analysisfeatureprop} AFP 
-		             INNER JOIN {analysisfeature} AF ON AFP.analysisfeature_id = AF.analysisfeature_id 
-		             WHERE analysis_id = %d 
-		             AND feature_id = %d
-		             AND type_id = (SELECT cvterm_id FROM cvterm WHERE name='analysis_blast_output_iteration_hits' AND cv_id = (SELECT cv_id FROM cv WHERE name='tripal'))";
-		$previous_db = tripal_db_set_active('chado');
-		$xml_output = simplexml_load_string(db_result(db_query($sql, $analysis_id, $featureSet[$i])));
-		
-		$iteration = '';
-		// new XML file parser has added the feature name within <Iteration_query-def> tags.
-		if ($xml_output->getName() == 'Iteration') {
-			$query = "";
-			foreach ($xml_output->children() as $xml_tag) {
-				if ($xml_tag->getName() == 'Iteration_query-def') {
-					// Here we show the feature name again to check if we pull the correct data
-					$query = $xml_tag;
-				} else if ($xml_tag->getName() == 'Iteration_hits') {
-					$iteration = $xml_tag;
-				}
-			}
-	   // This is for the file parsed by the old parser
-		} else {
-			$iteration = $xml_output;
-		}
-
-		$number_hits = 0;
-		foreach($iteration->children() as $hits){
-			$number_hits ++;
-		}
-
-		$query = explode(" ", $query) ;
-		$query = $query [0];
-		if ($number_hits == 0) {
-			continue;
-		} 
-
-		// now run through the blast hits/hsps of this iteration
-		// and generate the rows of the table
-
-		foreach($iteration->children() as $hits){
-			$hit_count++;
-			foreach($hits->children() as $hit){
-				$best_evalue = 0;
-				$best_identity = 0;
-				$best_len = 0;
-				$element_name = $hit->getName();
-				if($element_name == 'Hit_id'){
-					// if parsing "name, acc, desc" from three tags (1/3)
-					if ($is_genbank) {
-						$hit_name = $hit;
-					}
-				} else if($element_name == 'Hit_def'){
-					if($is_genbank){
-						$description = $hit;
-					} else {
-						$accession = preg_replace($regex_hit_accession,"$1",$hit);
-						$hit_name = preg_replace($regex_hit_id,"$1",$hit);
-						$description = preg_replace($regex_hit_def,"$1",$hit);
-					}
-				} else if($element_name == 'Hit_accession'){
-					// if parsing "name, acc, desc" from three tags (3/3)
-					if ($is_genbank){
-						$accession = $hit;
-					}
-					// now run through each HSP for this hit
-				} else if($element_name == 'Hit_hsps'){
-					foreach($hit->children() as $hsp){
-						foreach($hsp->children() as $hsp_info){
-							$element_name = $hsp_info->getName();
-							if($element_name == 'Hsp_num'){
-								$hsp_num = $hsp_info;
-							}
-							if($element_name == 'Hsp_bit-score'){
-								$hsp_bit_score = $hsp_info;
-							}
-							if($element_name == 'Hsp_score'){
-								$hsp_score = $hsp_info;
-							}
-							if($element_name == 'Hsp_evalue'){
-								$hsp_evalue = $hsp_info;
-								// use the first evalue for this set of HSPs
-								// as the best evalue. This get's shown as
-								// info for the overall match.
-								if(!$best_evalue){
-									$best_evalue = $hsp_evalue;
-								}
-							}
-							if($element_name == 'Hsp_query-from'){
-								$hsp_query_from = $hsp_info;
-							}
-							if($element_name == 'Hsp_query-to'){
-								$hsp_query_to = $hsp_info;
-							}
-							if($element_name == 'Hsp_hit-from'){
-								$hsp_hit_from = $hsp_info;
-							}
-							if($element_name == 'Hsp_hit-to'){
-								$hsp_hit_to = $hsp_info;
-							}
-							if($element_name == 'Hsp_query-frame'){
-								$hsp_query_frame = $hsp_info;
-							}
-							if($element_name == 'Hsp_identity'){
-								$hsp_identity = $hsp_info;
-								// use the first evalue for this set of HSPs
-								// as the best evalue. This get's shown as
-								// info for the overall match.
-								if(!$best_identity){
-									$best_identity = $hsp_identity;
-								}
-							}
-							if($element_name == 'Hsp_positive'){
-								$hsp_positive = $hsp_info;
-							}
-							if($element_name == 'Hsp_align-len'){
-								$hsp_align_len = $hsp_info;
-								// use the first evalue for this set of HSPs
-								// as the best evalue. This get's shown as
-								// info for the overall match.
-								if(!$best_len){
-									$best_len = $hsp_align_len;
-								}
-							}
-							if($element_name == 'Hsp_qseq'){
-								$hsp_qseq = $hsp_info;
-							}
-							if($element_name == 'Hsp_hseq'){
-								$hsp_hseq = $hsp_info;
-							}
-							if($element_name == 'Hsp_midline'){
-								$hsp_midline = $hsp_info;
-							}
-						}
-					}
-				}
-			}
-			
-			// Get analysisfeature_id
-			$sql = "SELECT analysisfeature_id FROM {analysisfeature} WHERE analysis_id = %d AND feature_id = %d";
-			$af_id = db_result(db_query($sql, $analysis_id, $featureSet[$i]));
-			
-			// Get type_id
-			$sql = "SELECT cvterm_id FROM {cvterm} WHERE name = '%s' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal')"; 
-			$type_id = db_result(db_query($sql, 'analysis_blast_besthit_query'));
-			
-			$sql_test ="SELECT analysisfeatureprop_id FROM {analysisfeatureprop} WHERE analysisfeature_id = $af_id AND type_id = %d";
-			$test_afpid = db_result(db_query($sql_test, $type_id));
-			
-			//Insert only if this blast query not exists. 
-			if (!$test_afpid) {
-				$afp_sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank) VALUES (%d, %d, '%s', 0)";
-				
-				//$query;
-				db_query($afp_sql, $af_id, $type_id, $query);
-
-				//$hit_name;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_match'));
-				db_query($afp_sql, $af_id, $type_id, $hit_name);
-					
-				//$description;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_description'));
-				db_query($afp_sql, $af_id, $type_id, $description);
-					
-				//$best_evalue;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_evalue'));
-				$e_digit = explode("e-", $best_evalue);
-				if (count($e_digit) == 2) {
-					$evalue_shown = number_format($e_digit [0],1);
-					$best_evalue = $evalue_shown."e-".$e_digit[1];
-				} 
-				db_query($afp_sql, $af_id, $type_id, $best_evalue);
-					
-				//$best_identity;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_identity'));
-				$percent_identity = number_format($best_identity/$best_len*100, 1);
-				db_query($afp_sql, $af_id, $type_id, $percent_identity);
-					
-				//$best_len;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_length'));
-				db_query($afp_sql, $af_id, $type_id, $best_len);
-				
-			// Otherwise, update all instead
-			} else {
-				$afp_sql = "UPDATE {analysisfeatureprop} SET analysisfeature_id = %d, type_id = %d, value = '%s', rank = 0 WHERE analysisfeatureprop_id = %d";
-
-				//$query;
-				db_query($afp_sql, $af_id, $type_id, $query, $test_afpid);
-				
-				//$hit_name;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_match'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				db_query($afp_sql, $af_id, $type_id, $hit_name, $test_afpid);
-
-				//$description;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_description'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				db_query($afp_sql, $af_id, $type_id, $description, $test_afpid);
-					
-				//$best_evalue;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_evalue'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				$e_digit = explode("e-", $best_evalue);
-				if (count($e_digit) == 2) {
-					$evalue_shown = number_format($e_digit [0],1);
-					$best_evalue = $evalue_shown."e-".$e_digit[1];
-				} 
-				db_query($afp_sql, $af_id, $type_id, $best_evalue, $test_afpid);
-					
-				//$best_identity;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_identity'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				$percent_identity = number_format($best_identity/$best_len*100, 1);
-				db_query($afp_sql, $af_id, $type_id, $percent_identity, $test_afpid);
-					
-				//$best_len;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_length'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				db_query($afp_sql, $af_id, $type_id, $best_len, $test_afpid);
-				
-			}
-			tripal_db_set_active($previous_db);
-			
-			break;
-		}
-	}
-   print "100%\n";
-	return;
-}

+ 0 - 102
extensions/tripal_analysis_blast/node-chado_analysis_blast.tpl.php

@@ -1,102 +0,0 @@
-<?php
-// Purpose: This template provides the layout of the organism node (page)
-//   using the same templates used for the various feature content blocks.
-//
-// To Customize the Featture Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//   - Block Templates: customize the content/layout of each block of stock 
-//       content. These templates are found in the tripal_stock subdirectory
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, type, title, taxonomy. It also includes stock
-//       specific fields such as stock_name, uniquename, stock_type, synonyms,
-//       properties, db_references, object_relationships, subject_relationships,
-//       organism, etc.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($variables,TRUE).'</pre>';
- //drupal_add_css('./tripal-node-templates.css');
-drupal_add_css(drupal_get_path('theme', 'tripal') . '/tripal-node-templates.css');
-//this makes tripal required as theme-------^  !!!
-                                          
-$node = $variables['node'];
-$organism = $variables['node']->organism;
-?>
-
-<?php if ($teaser) { 
-	include(drupal_get_path('module' , 'tripal_analysis_blast') . '/theme/tripal_analysis_blast/tripal_analysis_blast_teaser.tpl.php');
-} else { ?>
-
-<script type="text/javascript">
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_analysis_blast_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_blast_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show the corresponding item in the details box
-      $(".tripal_analysis_blast_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // we want to make sure our table of contents and the details
-         // box stay the same height
-         $("#tripal_analysis_blast_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // we want the base details to show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-      if(block == null){
-         block = window.location.href.match(/[\?|\&]block=(.+)/)
-      }
-      if(block != null){
-         $("#tripal_analysis_blast-"+block[1]+"-box").show();
-      } else {
-         $("#tripal_analysis_blast-base-box").show();
-      }
-
-      $("#tripal_analysis_blast_toc").height($("#tripal_analysis_blast-base-box").parent().height());
-      
-   });
-}
-</script>
-
-
-<div id="tripal_analysis_blast_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php include('theme/tripal_analysis_blast/tripal_analysis_blast_base.tpl.php');?>
-
-   <?php print $content ?>
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_analysis_blast_toc" class="tripal_toc">
-   <div id="tripal_analysis_blast_toc_title" class="tripal_toc_title">Resources</i></div>
-   <span id="tripal_analysis_blast_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_analysis_blast_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-
-<?php } ?>

+ 0 - 33
extensions/tripal_analysis_blast/theme/css/tripal_analysis_blast.css

@@ -1,33 +0,0 @@
-#tripal_analysis_blast-table {
-   width: 100%;
-	overflow:auto;
-}
-#tripal_analysis_blast-table td {
-  text-align: left;
-}
-#tripal_analysis_blast-table .tripal-table-even-row {
-   border-top: 0px solid #CCCCCC;
-   border-bottom: 0px solid #CCCCCC;
-}
-#tripal_analysis_blast-table .tripal-table-odd-row {
-   border-top: 0px solid #CCCCCC;
-   border-bottom: 0px solid #CCCCCC;
-}
-#tripal_analysis_blast-table .tripal_analysis_blast-result-first-row {
-   border-top: 1px solid #CCCCCC;
-}
-#tripal_analysis_blast-table .tripal_analysis_blast-result-last-row {
-   border-bottom: 1px solid #CCCCCC;
-}
-
-.tripal_analysis_blast-info-hsp-desc {
-	background-color: #FFFFFF;
-	border:0px solid #CCC5AE;
-	display:none;
-	overflow:auto;
-   width: 100%;
-}
-.tripal_analysis_blast-info-hsp-desc pre{
-	background-color: #FFFFFF;
-   border:none;
-}

+ 0 - 183
extensions/tripal_analysis_blast/theme/js/tripal_analysis_blast.js

@@ -1,183 +0,0 @@
-
-if (Drupal.jsEnabled) {
-   
-   $(document).ready(function(){
-	   // If Anlaysis admin page is shown, get the settings for selected database
-	   if ($("#edit-blastdb")[0]) {
-		   tripal_update_regex($("#edit-blastdb")[0]);
-		   tripal_set_genbank_style();
-	   }
-      // hide the alignment information on the blast results box
-      $(".tripal_analysis_blast-info-hsp-desc").hide();
-
-   });
-  
-   //------------------------------------------------------------
-   // Update the blast results based on the user selection
-   function tripal_update_blast(link,db_id){
-      tripal_startAjax();
-      $.ajax({
-         url: link.href,
-         dataType: 'json',
-         type: 'POST',
-         success: function(data){         
-            $("#blast_db_" + db_id).html(data.update);
-            $(".tripal_analysis_blast-info-hsp-desc").hide();
-            tripal_stopAjax();
-         }
-      });
-      return false;
-   }
-
-   //------------------------------------------------------------
-   // Update the blast results based on the user selection
-   function tripal_blast_toggle_alignment(analysis_id,hit_id){
-      var alignment_box = $("#tripal_analysis_blast-info-hsp-desc-"+analysis_id+"-"+hit_id);
-      var toggle_img = $("#tripal_analysis_blast-info-toggle-image-"+analysis_id+"-"+hit_id);
-	   var icon_url = toggle_img.attr("src");
-
-
-      if (alignment_box.is(':visible')) {
-         alignment_box.fadeOut('fast');
-	      var changed_icon_url = icon_url.replace(/arrow_d.png/,"arrow_r.png");
-	      toggle_img.attr("src", changed_icon_url);
-	   } else {
-         var width = alignment_box.parent().width();
-         alignment_box.css("width", width+'px');
-         alignment_box.fadeIn('slow');
-	      var icon_url = icon_url.replace(/arrow_r.png/,"arrow_d.png");
-	      toggle_img.attr("src", icon_url);
-	   }
-      return false;
-   }
-   
-   //------------------------------------------------------------
-   // Update regular expression for selected database
-   function tripal_update_regex(options){
-	   // Get the dbname from DOM
-	   var index = options.selectedIndex;
-	   var dbid = options[index].value;
-
-	   // Form the link for the following ajax call	   
-      var baseurl = tripal_get_base_url();
-      var link = baseurl + '/tripal_blast_regex/' + dbid;
-	   
-	   // Make ajax call to retrieve regular expressions
-	   $.ajax( {
-			url : link,
-			dataType : 'json',
-			type : 'POST',
-			success : tripal_set_parser,
-		});
-	}
-   
-   // Set parser for the admin page
-   function tripal_set_parser(data) {
-	   // Set title if it exists
-	   if (data.name) {
-			$("#edit-displayname").val(data.name);
-	   } else {
-			$("#edit-displayname").val("");
-	   }
-		
-	   // If genbank_style is TRUE, check the Genbank style box, clear all regular expressions, and disable
-	   // the text fields
-	   if (data.genbank_style == 1) {
-		   $("#edit-gb-style-parser").attr("checked", true);
-		   $("#edit-hit-id").val("");
-		   $("#edit-hit-def").val("");
-		   $("#edit-hit-accession").val("");
-		
-	   // Otherwise, uncheck the Genbank style box and set the regular expressions
-	   } else {
-			$("#edit-gb-style-parser").attr("checked", false);
-			if (data.reg1) {
-				$("#edit-hit-id").val(data.reg1);			
-			// Show default hit-id parser if it's not set
-			} else {
-				$("#edit-hit-id").val("^(.*?)\s.*$");
-			}
-			if (data.reg2) {
-				$("#edit-hit-def").val(data.reg2);
-			// Show default hit-def parser if it's not set
-			} else {
-				$("#edit-hit-def").val("^.*?\s(.*)$");
-			}
-			if (data.reg3) {
-				$("#edit-hit-accession").val(data.reg3);			
-			// Show default hit-accession parser if it's not set
-			} else {
-				$("#edit-hit-accession").val("^(.*?)\s.*$");
-			}
-		}
-		tripal_set_genbank_style();  
-   }
-   // ------------------------------------------------------------
-   // Use genbank style parser. Hide regular expression text feilds
-   function tripal_set_genbank_style (){
-	  // Disable regular expressions if genbank style parser is used (checked)
-	  if ($("#edit-gb-style-parser").is(":checked")) {
-		  $("#edit-hit-id-wrapper > label").css("color", "grey");
-		  $("#edit-hit-def-wrapper > label").css("color", "grey");
-		  $("#edit-hit-accession-wrapper > label").css("color", "grey");
-		  $("#edit-hit-id").attr('disabled', 'disabled');
-		  $("#edit-hit-def").attr('disabled', 'disabled');
-		  $("#edit-hit-accession").attr('disabled', 'disabled');
-	  } else {
-		  $("#edit-hit-id-wrapper > label").css("color", "black");
-		  $("#edit-hit-def-wrapper > label").css("color", "black");
-		  $("#edit-hit-accession-wrapper > label").css("color", "black");
-		  $("#edit-hit-id").removeAttr('disabled');
-		  $("#edit-hit-def").removeAttr('disabled');
-		  $("#edit-hit-accession").removeAttr('disabled');
-	  }
-   }
-   // -------------------------------------------------------------
-   // Function that toggles the blast droppable subbox content
-   function tripal_set_blast_subbox(db_id){
-	  
-	  $('.blast-hit-arrow-icon').hover(
-	     function() {
-	        $(this).css("cursor", "pointer");
-	     },
-	     function() {
-	        $(this).css("cursor", "pointer");
-	     }
-	  );
-     $('.blast-hit-arrow-icon').click(function() {
-	        
-     });
-   }
-   
-   	//------------------------------------------------------------
-	// Update the blast best hit report for selected page and sorting
-	function tripal_update_best_hit_report(obj, analysis_id, sort, descending, per_page){
-		var page = obj.selectedIndex + 1;
-		var baseurl = location.href.substring(0,location.href.lastIndexOf('/tripal_blast_report/'));
-		var link = baseurl + '/tripal_blast_report/' + analysis_id + "/" + page + "/" + sort + "/" + descending + "/" + per_page;
-
-		tripal_startAjax();
-		$.ajax({
-			url: link,
-			dataType: 'html',
-			type: 'POST',
-			success: function(data){
-				var d = document.createElement('div');
-				d.innerHTML = data;
-				var divs = d.getElementsByTagName("div");
-				for (var i = 0; i < divs.length; i ++) {
-					if (divs[i].getAttribute('id') == 'blast-hits-report') {	
-						var report_table = document.getElementById('blast-hits-report');
-						report_table.innerHTML = divs[i].innerHTML;
-						var table_breport = document.getElementById('tripal_blast_report_table');
-						var sel = document.getElementById('tripal_blast_report_page_selector');
-						sel.options[page - 1].selected = true;
-						tripal_stopAjax();
-					}
-				}
-			}
-		});
-		
-		return false;
-	}
-}

+ 0 - 78
extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_base.tpl.php

@@ -1,78 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-// get the blast data 
-$blast = $node->analysis->tripal_analysis_blast;
-
-//dpm($analysis);
-
-?>
-<div id="tripal_analysis_blast-base-box" class="tripal_analysis_blast-info-box tripal-info-box">
-  <div class="tripal_analysis_blast-info-box-title tripal-info-box-title">Blast Analysis Details</div>
-  <div class="tripal_analysis_blast-info-box-desc tripal-info-box-desc"></div>
-   <table id="tripal_analysis_blast-table-base" class="tripal_analysis_blast-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr> 
-      <tr class="tripal_analysis_blast-table-even-row tripal-table-odd-row">
-        <th nowrap>Database</th>
-        <td><?php print $blast->db->name ?></td>
-      </tr> 
-      <tr class="tripal_analysis_blast-table-even-row tripal-table-even-row">
-        <th nowrap>Blast Arguments</th>
-        <td><?php print $blast->blastparameters ?></td>
-      </tr>  
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-odd-row">
-        <th>Report</th>
-        <td>
-        	<?php 
-        		if ($analysis->blast_report) {					
-        			print "<a href=$analysis->blast_report>View the best hit report</a>";
-        		} else {
-        			print "not available";
-        		}
-        	?>
-        	</td>
-      </tr>       	                                
-   </table>   
-</div>

+ 0 - 123
extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_report.tpl.php

@@ -1,123 +0,0 @@
-<?php
-$report  = $variables['report_object'];
-$hits = $report->hits;
-?>
-
-<style type="text/css">
-#tripal_blast_report_current_page {
-	float: right;
-	margin-bottom: 5px;
-	margin-right: 20px;
-}
-#tripal_blast_report_pager {
-	float: right;
-	margin-bottom: 10px;
-	margin-right: 20px;
-}
-#tripal_blast_report_per_page {
-	float: left;
-	margin-bottom: 10px;
-}
-</style>
-
-<div id="tripal_ajaxLoading" style="display:none">
-	<div id="loadingText">Loading...</div>
-	<img src="<?php print url(drupal_get_path('theme', 'tripal') . '/images/ajax-loader.gif') ?>">
-</div>
-
-<div id="blast-hits-report">
-	<strong>Analysis Date: </strong><?php print $report->time?> (<a href=<?php print $report->url ?>><?php print $report->name ?></a>)<br>
-	There are <strong><?php print $report->counter ?></strong> records. 
-	<div id=tripal_blast_report_current_page>page <strong><?php print $report->currentpage ?></strong> of <strong><?php print $report->no_page ?></strong>
-	</div>
-	
-	<table id="tripal_analysi_blast-report-table" class="tripal_analysis_blast-table tripal-table tripal-table-horz">
-		<tr class="tripal_analysis_blast-table-odd-row tripal-table-odd-row">
-			<th nowrap><?php if ($report->sort == 0) {print $report->symbol;} ?>
-				<a href=<?php print $report->byQuery ?>>Query</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 1) {print $report->symbol;} ?>
-				<a href=<?php print $report->byMatchName ?>>Match Name</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 2) {print $report->symbol;} ?>
-				<a href=<?php print $report->byDescription ?>>Description</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 3) {print $report->symbol;} ?>
-				<a href=<?php print $report->byEvalue ?>>E-value</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 4) {print $report->symbol;} ?>
-				<a href=<?php print $report->byIdentity ?>>%Identity</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 5) {print $report->symbol;} ?>
-				<a href=<?php print $report->byLength ?>>Length</a>
-			</th>
-		</tr>
-		
-		<?php foreach($hits AS $hit) {?>
-		<tr class="<?php print $hit->class ?>">
-		                           <td nowrap><a href=<?php print $hit->q_url ?>><?php print $hit->query ?></a></td>
-		                           <td nowrap><a href=<?php print $hit->urlprefix.$hit->match ?> target=_blank><?php print $hit->match ?></td>
-		                           <td><?php print $hit->desc ?></td>
-		                           <td nowrap><?php print $hit->evalue ?></td>
-		                           <td nowrap><?php print $hit->identity ?></td>
-		                           <td nowrap><?php print $hit->length ?></td>
-		                         </tr>
-		<?php } ?>	
-			
-	</table>
-			<div id="tripal_blast_report_per_page">Show	
-				<?php 
-				$per_page = $report->per_page;
-				$path = $report->path;
-				if ($per_page == 10) {?>
-					<strong>10</strong> | 
-				<?php } else { 
-					$url_path = url($path."10");
-				?>	
-					<a href=<?php print $url_path ?>>10</a> | 
-				<?php } 
-				if ($per_page == 20) {
-				?>
-					<strong>20</strong> | 
-				<?php } else {
-					$url_path = url($path."20");
-				?>
-					<a href=<?php print $url_path ?>>20</a> | 
-				<?php } 
-				if ($per_page == 50) {
-				?>
-					<strong>50</strong> | 
-				<?php } else {
-					$url_path = url($path."50");
-				?>
-					<a href=<?php print $url_path ?>>50</a> | 
-				<?php }
-				if ($per_page == 100) {
-				?>
-					<strong>100</strong> | 
-				<?php } else {
-					$url_path = url($path."100");
-				?>
-					<a href=<?php print $url_path ?>>100</a> | 
-				<?php }
-				if ($per_page == 200) {
-				?>
-					<strong>200</strong> | 
-				<?php } else {
-					$url_path = url($path."200");
-				?>
-			   	<a href=<?php print $url_path ?>>200</a>
-				<?php } ?>
-				
-				records per page
-		</div>
-		<div id=tripal_blast_report_pager>page
-			<select id=tripal_blast_report_page_selector onChange="tripal_update_best_hit_report(this, <?php print $report->analysis_id ?>,<?php print $report->sort ?>, <?php print $report->descending ?>, <?php print $report->per_page ?>)">
-			<?php  for ($i = 1; $i <= $report->no_page; $i ++) { ?>
-				<option value=<?php print $i ?>><?php print $i ?></option>
-			<?php } ?>	                           
-			</select>
-		</div>
-</div>
-			
-	

+ 0 - 53
extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_teaser.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 115
extensions/tripal_analysis_blast/theme/tripal_feature/tripal_feature_blast_results.tpl.php

@@ -1,115 +0,0 @@
-<?php
-$feature  = $variables['node']->feature;
-$blast_results_list = $feature->tripal_analysis_blast->blast_results_list;
-
-?>
-<div id="tripal_ajaxLoading" style="display:none">
-	<div id="loadingText">Loading...</div>
-	<img src="<?php print drupal_get_path('theme', 'tripal') . '/images/ajax-loader.gif';?>">
-</div>
-
-<?php 
-if(count($blast_results_list) > 0){
-   foreach ($blast_results_list as $blast_result) {
-	  $hits_array = $blast_result->hits_array;
-	  $db = $blast_result->db;
-     $analysis = $blast_result->analysis;
-?>
-<div id="blast_db_<?php print $db->db_id ?>">
-<div id="tripal_analysis_blast-results-<?php print "$db->db_id" ?>-box" class="tripal_analysis_blast-box tripal-info-box">
-	<div class="tripal-info-box-title tripal_analysis_blast-info-box-title"><?php if ($db->displayname) {print $db->displayname;} else {print $db->name . "Homologs";} ?></div>
-	<div class="tripal-info-box-desc tripal_analysis_blast-info-box-desc">
-	<strong>Analysis Date: </strong><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted) . " (<a href=".url("node/$analysis->nid").">$analysis->name</a>)"?><br>
-	<!--Query: <?php print "$blast_result->xml_tag"?><br>-->
-	
-	<?php 
-   if($blast_result->max != 10){    
-      $url = url("tripal_top_blast/$feature->feature_id/$db->db_id/10");
-		?><span><a onclick="return tripal_update_blast(this,<?php print $db->db_id?>)" href="<?php print $url ?>">Show Best 10 Hits</a></span><?php
-	} else { 
-		?><span>Best 10 Hits Shown</span><?php
-	} 
-	
-	if($blast_result->number_hits <= 10){ 
-	} 
-   else if ($blast_result->max != 25) { 
-  	   $url = url("tripal_top_blast/$feature->feature_id/$db->db_id/25"); 	
-		?><span> | <a onclick="return tripal_update_blast(this,<?php print"$db->db_id"?>)" href="<?php print $url ?>">Show Best 25 Hits</a></span><?php
-	}else {
-		?><span> | Best 25 Hits Shown</span><?php
-	} 
-	
-	if($blast_result->number_hits <= 25){
-	} 
-   else if ($blast_result->max != 0) {
-	   $url = url("tripal_top_blast/$feature->feature_id/$db->db_id/all"); 		
-		?><span> | <a onclick="return tripal_update_blast(this, <?php print $db->db_id ?>)" href="<?php print $url ?>">Show All Hits</a> </span><?php
-	} else {
-		?><span> | All Hits Shown</span><?php
-	} 
-   ?>
-	<br><br><span>Click a description for more details</span>
-   </div>
-	<table id="tripal_analysis_blast-table" class="tripal-table tripal-table-horz tripal_analysis_blast-table">
-		<tr>
-         <th>&nbsp;</th>
-			<th nowrap>Match Name</th>
-			<th nowrap>E value</th>
-			<th nowrap>Identity</th>
-			<th nowrap>Description</th>
-		</tr>
-		
-		<?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 ){
-            $class = 'tripal-table-even-row tripal_analysis_blast-table-even-row';
-         }?>
-         <tr class="<?php print $class ?> tripal_analysis_blast-result-first-row">
-            <td><?php print $i+1 ?>.</td>
-		      <?php if ($hit['hit_url']) { ?>
-			      <td><a href="<?php print $hit['hit_url']?>" target="_blank"><?php print $hit['hit_name']?></a></td>
-		      <?php } else {?>
-			      <td><?php print $hit['hit_name'] ?></td>
-		      <?php } ?>
-			   <td nowrap><?php print $hit['best_evalue']?></td>
-			   <td nowrap><?php  if (!empty($hit['percent_identity'])) { print $hit['percent_identity']; } ?></td>
-			   <td><?php print $hit['description']?></td>
-		   </tr>
-   
-		   <!-- If there is alignment information for at least one HSP -->
-		   <?php if (!empty($hit['hsp'][0]['query_frame'])) { ?>
-	      <tr class="<?php print $class ?>">
-		      <td colspan=5>
-			      <a class="blast-hit-arrow-icon" onclick="return tripal_blast_toggle_alignment(<?php print $analysis->analysis_id ?>,<?php print $i?>)"><img id="tripal_analysis_blast-info-toggle-image-<?php print $analysis->analysis_id ?>-<?php print $i?>" src=<?php print $hit['arrowr_url']?> align="top"> View Alignment</a>
-			      <div class="tripal_analysis_blast-info-hsp-title"></div>
-		      </td>
-	      </tr>
-	      <tr class="<?php print $class ?> tripal_analysis_blast-result-last-row">
-		      <td colspan=5>
-		      <?php 
-		      $hsps_array = $hit['hsp'];
-		      foreach ($hsps_array AS $hsp) { ?>
-			      <div class="tripal_analysis_blast-info-hsp-desc" id="tripal_analysis_blast-info-hsp-desc-<?php print $analysis->analysis_id ?>-<?php print $i?>">
-				      &nbsp;HSP <?php  print $hsp['hsp_num'] ?>
-				      <pre>Score: <?php print $hsp['bit_score'] ?> bits (<?php print $hsp['score'] ?>), Expect = <?php print $hsp['evalue'] ?><br>Identity = <?php print sprintf("%d/%d (%.2f%%)", $hsp['identity'], $hsp['align_len'], $hsp['identity']/$hsp['align_len']*100) ?>, Postives = <?php print sprintf("%d/%d (%.2f%%)", $hsp['positive'], $hsp['align_len'], $hsp['positive']/$hsp['align_len']*100)?>, Query Frame = <?php print $hsp['query_frame']?></a><br><br></a>Query: <?php print sprintf("%4d", $hsp['query_from'])?> <?php print $hsp['qseq'] ?> <?php print sprintf("%d", $hsp['query_to']); ?><br>            <?php print $hsp['midline'] ?><br>Sbjct: <?php print sprintf("%4d", $hsp['hit_from']) ?> <?php print $hsp['hseq']?> <?php print sprintf("%d",$hsp['hit_to']) ?></pre><br>
-			      </div>
-		      <?php } //end of foreach hsp ?>
-		      </td>
-	      </tr>		
-         <?php } //end of if there is query sequence for at least one hsp
-         $i++;  
-     } //end of foreach hit ?>
-	</table>
-</div>
-</div>
-  <?php } // end of foreach blast result ?>
-<?php } //end of if there are blast results ?>

+ 0 - 9
extensions/tripal_analysis_blast/tripal_analysis_blast.info

@@ -1,9 +0,0 @@
-; $Id:
-name = Tripal Blast
-description = An analysis sub-module for adding, editing, and displaying blast analysis results.
-core = 6.x
-project = tripal_analysis_blast
-package = Tripal Extensions 
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis

+ 0 - 198
extensions/tripal_analysis_blast/tripal_analysis_blast.install

@@ -1,198 +0,0 @@
-<?php
-//$Id:
-
-/*******************************************************************************
- * Implementation of hook_install().
- */
-function tripal_analysis_blast_install() {
-   // create the module's data directory
-   tripal_create_moddir('tripal_analysis_blast');
-
-   // We need to register to tripal_analysis module so it can provide a control
-   // for our blast result. Basically the registration is done by inserting
-   // modulename into the drupal {tripal_analysis} table AND inserting required
-   // information to the chado Analysis table. Also in tripal_analysis_blast.module,
-   // we need to define HOOK_get_settings() for the module to work properly.   
-   // Register the analysis type
-   tripal_analysis_register_child('tripal_analysis_blast');
-   
-   // Add cvterms
-   tripal_analysis_blast_add_cvterms();
-   
-   // Create a tripal_analysis_blast table to store parsers
-   drupal_install_schema('tripal_analysis_blast');
-   
-   // Create default parser for swissprot, DB:genbank, and go-seqdb
-   $sql_db = "SELECT db_id, name FROM {db} WHERE name like '%s'";
-   $sql_parser = "INSERT INTO {tripal_analysis_blast} ".
-                 "  (db_id, displayname, regex_hit_id, regex_hit_def, regex_hit_accession, genbank_style) ".
-                 "VALUES (%d, '%s', '%s', '%s', '%s', %d)";
-   
-   // Add swissprot parser
-   $previous_db = tripal_db_set_active ('chado');
-   $results = db_query($sql_db, "%swissprot%");
-   tripal_db_set_active($previous_db);
-   while ($db = db_fetch_object($results)) {
-      db_query($sql_parser, $db->db_id, 'ExPASy Swissprot', '^sp\|.*?\|(.*?)\s.*?$', '^sp\|.*?\|.*?\s(.*)$', 'sp\|(.*?)\|.*?\s.*?$', 0);
-   }
-   
-   // Add trembl parser
-   $previous_db = tripal_db_set_active ('chado');
-   $results = db_query($sql_db, "%trembl%");
-   tripal_db_set_active($previous_db);
-   while ($db = db_fetch_object($results)) {
-      db_query($sql_parser, $db->db_id, 'ExPASy TrEMBL', '^.*?\|(.*?)\s.*?$', '^.*?\|.*?\s(.*)$', '^(.*?)\|.*?\s.*?$', 0);
-   }
-   
-   // Add NCBI genbank parser
-   $previous_db = tripal_db_set_active ('chado');
-   $results = db_query($sql_db, "%genbank%");
-   tripal_db_set_active($previous_db);
-   while ($db = db_fetch_object($results)) {
-      db_query($sql_parser, $db->db_id, 'Genbank', '', '', '', 1);
-   }
-}
-
-/*******************************************************************************
- * Implementation of hook_uninstall().
- */
-function tripal_analysis_blast_uninstall() {
-   
-   // Delete all information associate with the module
-   // Drupal complains when the user tries to uninstall tripal_analysis 
-   // and tripal_analysis_blast at the same time. This is because Drupal drops
-   // the {tripal_analysis} table before we can delete anything from it. Thus,
-   // we perform a db_table_exists() check before the deletion
-   
-   //Delete the settings from {tripal_analysis} table
-   tripal_analysis_unregister_child('tripal_analysis_blast');
-
-   // Delete module's variables from variables table.
-   db_query("DELETE FROM {variable} WHERE name='%s'",
-            'tripal_analysis_blast_setting');
-            
-   // Delete a tripal_analysis_blast table
-   drupal_uninstall_schema('tripal_analysis_blast');
-}
-
-/*******************************************************************************
-* Implementation of hook_schema(). This table stores the parsers for blast xml
-* xml results.
-*/
-function tripal_analysis_blast_schema() {
-   $schema = array();
-   $schema['tripal_analysis_blast'] = array(
-      'fields' => array(
-         'db_id' => array(
-            'type' => 'int',
-            'unsigned' => TRUE,
-            'not null' => TRUE,
-            'default' => 0
-         ),
-         'displayname' => array(
-            'type' => 'varchar',
-            'length' => 100,
-            'not null' => TRUE,
-         ),
-         'regex_hit_id' => array(
-            'type' => 'varchar',
-            'length' => 30,
-         ),
-         'regex_hit_def' => array(
-            'type' => 'varchar',
-            'length' => 30,
-         ),
-         'regex_hit_accession' => array(
-            'type' => 'varchar',
-            'length' => 30,
-         ),
-         'genbank_style' => array(
-            'type' => 'int',
-            'unsigned' => TRUE,
-            'default' => 0
-         ),
-      ),
-      'indexes' => array(
-         'db_id' => array('db_id')
-      ),
-      'primary key' => array('db_id'),
-  );
-  return $schema;
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_blast_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_blast'] = array(
-            'title' => "tripal_analysis_blast",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}
-
-/*******************************************************************************
- * Provide update script for adding new cvterms
- */
-function tripal_analysis_blast_update_6000(){
-
-   // we have some new cvterms to add
-   tripal_analysis_blast_add_cvterms();
-
-   $ret = array(
-      '#finished' => 1,
-   );
-   
-   return $ret;
-}
-
-/*******************************************************************************
- * Function for adding cvterms
- */
-function tripal_analysis_blast_add_cvterms () {
-	
-   // Add the cvterms for the anlysisprop table
-   tripal_add_cvterms('analysis_blast_settings', 'Settings of a blast analysis, '.
-      'including db_id, output file, and run parameters separated by a bar |');
-   tripal_add_cvterms('analysis_blast_blastdb','The database used for blasting');
-   tripal_add_cvterms('analysis_blast_blastfile','The input file or directory that contains the XML blast output');
-   tripal_add_cvterms('analysis_blast_blastparameters','The parameters used when performing blast.');
-   tripal_add_cvterms('analysis_blast_no_parsed','Indicates if the input file should be parsed to map results to features');
-   tripal_add_cvterms('analysis_blast_query_re','The regular expression for finding the feature name in the query definition line of the blast results');
-   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 '.
-      'output iteration. Each iteration corresponds to a chado feature, and is '.
-      'the content between <iteration> and </iteration> tags in the blast xml '.
-      'output file. This cvterm represents all hits in the iteration');
-   
-   tripal_add_cvterms('analysis_blast_besthit_query', 'query name of the best hit 
-   associated with a feature and a blast analysis ');
-
-   tripal_add_cvterms('analysis_blast_besthit_match', 'match name of the best hit 
-   associated with a feature and a blast analysis ');
-    
-   tripal_add_cvterms('analysis_blast_besthit_description', 'description of the best hit 
-   associated with a feature and a blast analysis ');
-   
-   tripal_add_cvterms('analysis_blast_besthit_evalue', 'evalue of the best hit 
-   associated with a feature and a blast analysis ');
-    
-   tripal_add_cvterms('analysis_blast_besthit_identity', 'identity (%) of the best hit 
-   associated with a feature and a blast analysis ');
-   
-   tripal_add_cvterms('analysis_blast_besthit_length', 'length of the best hit 
-   associated with a feature and a blast analysis ');
-   
-}

+ 0 - 909
extensions/tripal_analysis_blast/tripal_analysis_blast.module

@@ -1,909 +0,0 @@
-<?php
-
-require_once "includes/parse_blast_XML.inc";
-
-
-/*******************************************************************************
- * Tripal Blast Result lets users show/hide blast results associated
- * with a tripal feature
- ******************************************************************************/
-function tripal_analysis_blast_init(){
-	// Add javascript and style sheet
-	drupal_add_css(drupal_get_path('module', 'tripal_analysis_blast') .'/theme/css/tripal_analysis_blast.css', 'theme');
-	drupal_add_js(drupal_get_path('module', 'tripal_analysis_blast') .'/theme/js/tripal_analysis_blast.js');
-}
-
-/*******************************************************************************
- * tripal_analysis_blast_menu()
- * HOOK: Implementation of hook_menu()
- * Entry points and paths of the module
- */
-function tripal_analysis_blast_menu() {
-	// Show top 10/25/all blast results for ajax calls
-	$items['tripal_top_blast'] = array(
-      'path' => 'top_blast',
-      'title' => t('Blast Hits'),
-      'page callback' => 'tripal_get_feature_blast_results_ajax',
-      'page arguments' => array(1,2,3),
-      'access arguments' => array('access content'),
-      'type' => MENU_CALLBACK
-	);
-	// Show regular expressions for selected database in Blast admin page
-	$items['admin/tripal/tripal_analysis/tripal_blast_regex/%'] = array(
-      'title' => t('Blast Regex'),
-      'page callback' => 'tripal_get_blast_regex',
-      'page arguments' => array(4),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK
-	);
-	$items['tripal_blast_report'] = array(
-      'title' => t('Homology Report'),
-      'page callback' => 'tripal_get_blast_report',
-      'page arguments' => array(1,2,3,4,5),
-      'access arguments' => array('access chado_analysis_blast content'),
-      'type' => MENU_CALLBACK,
-	   'file' => 'tripal_analysis_blast_htmlreport.inc'
-	);
-	
-	return $items;
-}
-/**
- *
- *
- * @ingroup tripal_analysis_blast
- */
-function tripal_analysis_blast_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['blast_base']['info'] = t('Analysis: Blast Details');
-         $blocks['blast_base']['cache'] = BLOCK_NO_CACHE;
-
-
-         $blocks['featureblast']['info'] = t('Tripal Feature Blast Results');
-         $blocks['featureblast']['cache'] = BLOCK_NO_CACHE;
-
-         
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_blast content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-               case 'blast_base':
-                  $block['subject'] = t('Blast Details');
-                  $block['content'] = theme('tripal_analysis_blast_base',$node);
-                  break;
-               case 'featureblast':
-                  $block['subject'] = t('Homology');
-                  $block['content'] = theme('tripal_feature_blast_results',$node);
-                  break;  
-               default :
-            }
-
-            return $block;
-         }
-   }
-}
-
-/*******************************************************************************
- * tripal_analysis_blast_nodeapi()
- * HOOK: Implementation of hook_nodeapi()
- * Display blast results for allowed node types
- */
-function tripal_analysis_blast_nodeapi(&$node, $op, $teaser, $page) {
-
-	switch ($op) {
-		case 'view':
-
-         if($teaser){
-            return '';
-         }
-			// Find out which node types for showing the blast
-			$types_to_show = variable_get('tripal_analysis_blast_setting',
-			array('chado_feature'));
-
-			// Abort if this node is not one of the types we should show.
-			if (!in_array($node->type, $types_to_show, TRUE)) {
-				break;
-			}
-
-         if(strcmp($node->type,'chado_feature')==0){
-				if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-					$node->content['tripal_analysis_blast_index_version'] = array(
-                  '#value' => theme('tripal_analysis_blast_results_index_version',$node),
-                  '#weight' => 8,
-					);
-				} else {
-				   // Show blast result if not at teaser view
-				   $node->content['tripal_feature_blast_results'] = array(
-                  '#value' => theme('tripal_feature_blast_results', $node),
-                  '#weight' => 8
-				   );
-				}
-			}
-         break;
-	}
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-
-function tripal_analysis_blast_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_analysis_blast')));
-}
-
-
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_blast_theme () {
-	$path = drupal_get_path('module', 'tripal_analysis_blast') . '/theme';
-	$theme = array(
-      'tripal_analysis_blast_results_index_version' => array (
-         'arguments' => array('node'),
-		),
-		'tripal_feature_blast_results' => array(
-			'template' => 'tripal_feature_blast_results',
-			'arguments' =>  array('node'=> null),
-			'path' => $path . '/tripal_feature',
-		),
-		'tripal_analysis_blast_report' => array(
-			'template' => 'tripal_analysis_blast_report',
-			'arguments' =>  array('report_object'=> null),
-			'path' => $path . '/tripal_analysis_blast',
-		),
-		'tripal_analysis_blast_base' => array(
-			'template' => 'tripal_analysis_blast_base',
-			'arguments' =>  array('report_object'=> null),
-			'path' => $path . '/tripal_analysis_blast',
-		)
-	);
-	return $theme;
-}
-/*******************************************************************************
- *  
- */
-function tripal_get_feature_blast_results_ajax($feature_id, $db_id, $max){
-   $sql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
-   $nid = db_fetch_object(db_query($sql,$feature_id));
-   $node = node_load($nid->nid);
-
-   // add the additional variables that the theme needs to generate the output
-   $node->db_id = $db_id;
-   $node->max = $max;
-   // call the theme to rebuild the blast results
-   drupal_json(array('update' => theme('tripal_feature_blast_results',$node)));
-}
-/*******************************************************************************
- *  
- */
-function tripal_analysis_blast_preprocess_tripal_feature_blast_results(&$variables){
-   $feature = $variables['node']->feature;
-   $db_id = $variables['node']->db_id; // this value only gets set on an ajax call
-  
-   $max = 10;
-   if(isset($variables['node']->max)){
-      $max = $variables['node']->max;
-   }
-
-   $blast_results = tripal_get_feature_blast_results($feature->feature_id, $db_id, $max);
-   $feature->tripal_analysis_blast->blast_results_list = $blast_results;
-	 
-	 
-}
-/*******************************************************************************
- * Prepare blast result for the feature shown on the page
- */
-function theme_tripal_analysis_blast_results_index_version ($node) {
-	$feature = $node->feature;
-	$content = tripal_get_blast_results_index_version($feature->feature_id);
-	return $content;
-}
-
-/*******************************************************************************
- * tripal_get_feature_blast_results()
- * Get blast result from featureprop table for the feature
- */
-function tripal_get_feature_blast_results($feature_id, $db_id, $max){
-
-	// Get the blast results stored as XML from the analysisfeatureprop table
-   // the type for the property is named 'analysis_blast_output_iteration_hits'
-   // and is found in the 'tripal' controlled vocabulary.  This CV term was
-   // added by this module.
-   $select = array(
-      'analysisfeature_id' => array(
-         'feature_id' => $feature_id,
-      ), 
-      'type_id' => array(
-         'name' => 'analysis_blast_output_iteration_hits',
-         'cv_id' => array(
-            'name' => 'tripal'
-         ),
-      ),         
-   );
-   $blast_results = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
-   if (!$blast_results){
-      return;
-   }
-
-	// get the HTML content for viewing each of the XML file
-	$blast_obj_array = array ();
-	$blast_obj_counter = 0;
-	foreach ($blast_results as $index => $analysisfeatureprop) {
-      // get the blast XML for this feature
-      $blast_xml = $analysisfeatureprop->value;
-
-      // get the analysis record
-      $analysisfeature_arr = tripal_core_chado_select('analysisfeature',array('analysis_id'),
-         array('analysisfeature_id' => $analysisfeatureprop->analysisfeature_id));
-      $analysis_arr = tripal_core_chado_select('analysis',array('*'),
-         array('analysis_id' => $analysisfeature_arr[0]->analysis_id));
-      $analysis = $analysis_arr[0];
-      $analysis_id = $analysis->analysis_id;
-
-      // the old style was to store all parameters in a single CV term in the analysisprop 
-      // table. However now each property has it's own CV term in that table. But,
-      // we still need to support the old method for backwards compatibility.
-      // so, first get the old style variable and see if it has values. In
-      // particular we need the database setting
-      $blast_settings  = tripal_analysis_get_property($analysis_id,'analysis_blast_settings');	
-      if($blast_settings){
-		   $blastsettings = explode("|", $blast_settings->value);
-         // if we don't have the proper number of fields in the value column then
-         // skip this entry
-         if(count($blastsettings) != 3){
-           continue;
-         }
-		   $adb_id = $blastsettings[0];
-      }
-      // if we're not using the old style then try the new method to get the 
-      // database id
-      else {
-         $blastdb = tripal_analysis_get_property($analysis_id,'analysis_blast_blastdb');
-         $adb_id = $blastdb->value;
-      }
-      // if the callee specified a database to show then we want to check that
-      // with the database id of the analysis we're looking at.  If they
-      // don't match then skip this blast.  If a database id was not specified
-      // then continue
-      if($db_id and $adb_id != $db_id){
-         continue;
-      } 
-
-      // get the database
-      if($adb_id){
-        $db_arr = tripal_core_chado_select('db',array('*'),array('db_id' => $adb_id)); 
-        $db = $db_arr[0];
-      }
-
-      // parse the XML and add it to the array of blast results to be returned
-		$blast_obj = tripal_analysis_blast_get_result_object($blast_xml,$db,$max,$feature_id, $analysis);
-      $blast_obj->analysis = $analysis;
-		$blast_obj_array [$blast_obj_counter] = $blast_obj;
-		$blast_obj_counter ++;
-	}
-
-   return $blast_obj_array;
-}
-/*******************************************************************************
- * Scanning the file folder for blast results and prepare content for indexing
- */
-function tripal_get_blast_results_index_version ($feature_id){
-
-	// Get cvterm_id for 'analysis_blast_output_iteration_hits' which is required
-	// for inserting into the analysisfeatureprop table
-	$previous_db = tripal_db_set_active('chado');
-	$sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT ".
-          "INNER JOIN cv ON cv.cv_id = CVT.cv_id ".
-          "WHERE CVT.name = 'analysis_blast_output_iteration_hits' ".
-          "AND CV.name = 'tripal'";
-	$type_id = db_result(db_query($sql));
-
-	// Get xml string from analysisfeatureprop value column, get db_id from analysisprop value column
-	// , and get analysis_id from analysisfeature table
-	$sql = "SELECT AP.value AS apvalue, AFP.value AS afpvalue, AF.analysis_id AS aid
-           FROM {analysisfeatureprop} AFP
-           INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id
-           INNER JOIN analysisprop AP ON AP.analysis_id = AF.analysis_id
-           WHERE feature_id = %d
-           AND AFP.type_id = %d ";
-	$result = db_query($sql, $feature_id, $type_id);
-	tripal_db_set_active($previous_db);
-
-	// get the HTML content for viewing each of the XML file
-	while ($analysisfeatureprop = db_fetch_object($result)) {
-		// get analysis name and date
-		$previous_db = tripal_db_set_active('chado');
-		$sql = "SELECT analysis_id AS aid, name, to_char(timeexecuted, 'MM-DD-YYYY') AS time
-              FROM {analysis}               WHERE analysis_id = %d";
-		$analysis = db_fetch_object(db_query($sql, $analysisfeatureprop->aid));
-		tripal_db_set_active($previous_db);
-
-		$blastsettings = explode("|", $analysisfeatureprop->apvalue);
-		$att_db_id = $blastsettings [0];
-
-		// Get db object using the db_id
-		$previous_db = tripal_db_set_active('chado');
-		$sql = "SELECT * FROM {db} WHERE db_id=%d";
-		$db = db_fetch_object(db_query($sql, $att_db_id));
-		tripal_db_set_active($previous_db);
-		// Only index best 10 hits because the default page only shows 10 blast results
-		$max = 10;
-		$content .= parse_NCBI_Blast_XML_index_version($analysisfeatureprop->afpvalue,$db,$max,$feature_id,$ajax, $analysis);
-			
-	}
-	return $content;
-
-}
-
-
-/*******************************************************************************
- * Tripal Blast administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_blast_get_settings() {
-	// Get an array of node types with internal names as keys
-	$options = node_get_types('names');
-	// Add 'chado_feature' to allowed content types for showing blast results
-	$allowedoptions ['chado_feature'] = "Show blast results on feature pages";
-
-	$form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("Most chado features were analyzed by blast against major sequence databases. This option allows user to display the blast analysis results. Please read user manual for storage and display of blast files. Check the box to enable the analysis results. Uncheck to disable it."),
-		 '#weight' => 0,
-	);
-
-	$form['tripal_analysis_blast_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value' => variable_get('tripal_analysis_blast_setting',
-	array('chado_feature')),
-	);
-	$form['blast_parser'] = array(
-      '#title' => t('Blast Parser Settings'),
-      '#type' => 'fieldset',
-      '#description' => t('Configure parsers for showing blast results. Each database is '.
-                          'allowed to have one xml parser.'),
-      '#weight' => 10
-	);
-
-	$previous_db = tripal_db_set_active('chado');  // use chado database
-	// get a list of db from chado for user to choose
-	$sql = 'SELECT db_id, name FROM {db} ORDER BY lower(name)';
-	$results = db_query ($sql);
-	$blastdbs = array();
-	while ($db = db_fetch_object($results)){
-		$blastdbs[$db->db_id] = $db->name;
-	}
-	$form['db_options'] = array(
-      '#type' => 'value',
-      '#value' => $blastdbs
-	);
-	$form['blast_parser']['blastdb'] = array(
-      '#title' => t('Database'),
-      '#type' => 'select',
-      '#description' => t('The database used for the blast analysis.'),
-      '#options' => $form['db_options']['#value'],
-      '#attributes' => array(
-         'onChange' => "return tripal_update_regex(this)",
-	    )
-	);
-	$form['blast_parser']['displayname'] = array(
-      '#title' => t('Title for the blast analysis'),
-      '#type' => 'textfield',
-	);
-	$form['blast_parser']['gb_style_parser'] = array(
-      '#title' => t('Use Genebank style parser. This will clear all regular expression settings for the selected database.'),
-	   '#type' => 'checkbox',
-	   '#attributes' => array(
-         'onClick' => "return tripal_set_genbank_style(this)",
-	    )
-	);
-	$form['blast_parser']['hit_id'] = array(
-      '#title' => t('Regular expression for Hit Name'),
-      '#type' => 'textfield',
-	);
-	$form['blast_parser']['hit_def'] = array(
-      '#title' => t('Regular expression for Hit Description'),
-      '#type' => 'textfield',
-	);
-	$form['blast_parser']['hit_accession'] = array(
-      '#title' => t('Regular expression for Hit Accession'),
-      '#type' => 'textfield',
-	);
-	$form['blast_parser']['button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Save settings')
-	);
-	tripal_db_set_active($previous_db); // use drupal database
-
-	$settings->form = $form;
-	$settings->title = "Tripal Blast";
-	return $settings;
-}
-
-
-
-/*******************************************************************************
- * This function is only called by ajax to get regular expressions for blast
- * admin page
- */
-function tripal_get_blast_regex ($db_id) {
-	$sql = "SELECT * FROM {tripal_analysis_blast} WHERE db_id = %d";
-	$blast_regexs = db_fetch_object(db_query($sql, $db_id));
-	drupal_json(array(
-	     'name' => $blast_regexs->displayname,
-	     'genbank_style' => $blast_regexs->genbank_style,
-	     'reg1' => $blast_regexs->regex_hit_id,
-	     'reg2' => $blast_regexs->regex_hit_def,
-	     'reg3' => $blast_regexs->regex_hit_accession)
-	);
-}
-
-/*******************************************************************************
- *  Provide information to drupal about the node types that we're creating
- *  in this module
- */
-function tripal_analysis_blast_node_info() {
-	$nodes = array();
-	$nodes['chado_analysis_blast'] = array(
-      'name' => t('Analysis: Blast'),
-      'module' => 'chado_analysis_blast',
-      'description' => t('A blast analysis from the chado database'),
-      'has_title' => FALSE,
-      'title_label' => t('Analysis: Blast'),
-      'has_body' => FALSE,
-      'body_label' => t('Blast Analysis Description'),
-      'locked' => TRUE
-	);
-	return $nodes;
-}
-
-
-/*******************************************************************************
- *  Provide a Blast Analysis form
- */
-function chado_analysis_blast_form ($node){
-
-   // add in the default fields
-   $form = chado_analysis_form($node);
-
-   // set the default values
-   $blast = $node->analysis->tripal_analysis_blast;
-   $blastdb = $blast->blastdb;
-   $blastfile    = $blast->blastfile;
-   $blastfile_ext    = $blast->blastfile_ext;
-   $blastparameters = $blast->blastparameters;
-
-   $query_re = $blast->query_re;
-   $query_type = $blast->query_type;
-   $query_uniquename = $blast->query_uniquename;
-   $is_concat = $blast->is_concat;
-
-		
-	$form['blast'] = array(
-      '#title' => t('Blast Settings'),
-      '#type' => 'fieldset',
-      '#description' => t('Specific Settings for Blast Analysis.'),
-      '#collapsible' => TRUE,
-      '#attributes' => array('id' => 'blast-extra-settings'),
-      '#weight' => 11
-	);
-
-	$previous_db = tripal_db_set_active('chado');  // use chado database
-	// get a list of db from chado for user to choose
-	$sql = 'SELECT db_id, name FROM {db} ORDER BY lower(name)';
-	$results = db_query ($sql);
-	tripal_db_set_active($previous_db);
-	$blastdbs = array();
-	while ($db = db_fetch_object($results)){
-		$blastdbs[$db->db_id] = $db->name;
-	}
-	$form['db_options'] = array(
-      '#type' => 'value',
-      '#value' => $blastdbs
-	);
-	$form['blast']['blastdb'] = array(
-      '#title' => t('Database'),
-      '#type' => 'select',
-      '#description' => t('The database used for the blast analysis. If the database does not appear in this list, please add it.'),
-      '#options' => $form['db_options']['#value'],
-      '#default_value' => $blastdb,
-	);
-
-	$form['blast']['blastfile'] = array(
-      '#title' => t('Blast XML File/Directory: (if you input a directory without the tailing slash, all xml files in the directory will be loaded)'),
-      '#type' => 'textfield',
-      '#description' => t('The xml output file generated by blast in full path.'),
-      '#default_value' => $blastfile,
-	); 
-   $form['blast']['blastfile_ext'] = array(
-      '#title' => t('Blast XML file extension'),
-      '#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'),
-      '#type' => 'textfield',
-      '#description' => t("The number of hits to be parsed. Tripal will parse only top 10 hits if you input '10'' in this field."),
-      '#default_value' => 'all',
-	);
-
-	$form['blast']['query_re'] = array(
-      '#title' => t('Query Name RE'),
-      '#type' => 'textfield',
-      '#description' => t('Enter the regular expression that will extract the '.
-         'feature name from the query line in the blast results. This should be '.
-         'the same as the definition line in the query FASTA file.  This option is '.
-         'is only required when the query does not identically match a feature '.
-         'in the database.'),
-      '#default_value' => $query_re,
-	);
-
-	$form['blast']['query_type'] = array(
-      '#title' => t('Query Type'),
-      '#type' => 'textfield',
-      '#description' => t('Please enter the Sequence Ontology term that describes '.
-         'the query sequences used for blasting.  This is only necessary if two '.
-         'or more sequences have the same name.'),
-      '#default_value' => $query_type,
-	);
-
-	$form['blast']['query_uniquename'] = array(
-      '#title' => t('Use Unique Name'),
-      '#type' => 'checkbox',
-      '#description' => t('Select this checboxk if the query name in the blast file '.
-        'matches the uniquename of the feature.  By default, the blast results will '.
-        'mapped to the "name" of the feature.'),
-      '#default_value' => $query_uniquename,
-	);
-
-	$form['blast']['blastparameters'] = array(
-      '#title' => t('Parameters'),
-      '#type' => 'textfield',
-      '#description' => t('The parameters for running the blast analysis.'),
-      '#default_value' => $blastparameters,
-	);
-	
-	$form['blast']['blastjob'] = array(
-      '#type' => 'checkbox',
-      '#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 '.
-                          'discarded. '),
-      '#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
-	);
-*/	
-	return $form;
-}
-/**
-*
-*/
-function chado_analysis_blast_validate($node, &$form){
-   // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form); 
-}
-
-/*******************************************************************************
- *  When a node is requested by the user this function is called to allow us
- *  to add auxiliary data to the node object.
- */
-function chado_analysis_blast_load($node){
-
-   // load the default set of analysis fields
-	$additions = chado_analysis_load($node);
-
-   // create some variables for easier lookup
-   $analysis = $additions->analysis;
-   $analysis_id = $analysis->analysis_id;
-
-   $blast_settings  = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_settings');	
-   $blastdb         = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_blastdb');
-   $blastfile       = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_blastfile');	
-   $blastparameters = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_blastparameters');
-   $no_parsed       = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_no_parsed');	
-   $query_re        = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_query_re');	
-   $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;	
-   $analysis->tripal_analysis_blast->blastparameters = $blastparameters->value;
-   $analysis->tripal_analysis_blast->no_parsed       = $no_parsed->value;	
-   $analysis->tripal_analysis_blast->query_re        = $query_re->value;	
-   $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
-   $select = array('db_id' => $blastdb->value);
-   $analysis->tripal_analysis_blast->db = tripal_core_generate_chado_var('db',$select);
-
-   // if there is an old style 'blast_settings' array, then break these out for
-   // use in the new format
-   if(count($blast_settings)>0){
-	   $prop_values = explode ("|", $blast_settings->value);
-      $analysis->tripal_analysis_blast->blastdb = $prop_values[0];
-      $analysis->tripal_analysis_blast->blastfile = $prop_values[1];
-      $analysis->tripal_analysis_blast->blastparameters = $prop_values[2];
-   }
-
-   /* check if there exists a best hit report. if yes, reuturn the report url
-   $select = array(
-      'analysisfeature_id' => array(
-         'analysis_id' => $analysis_id,
-      ), 
-      'type_id' => array(
-         'name' => 'analysis_blast_besthit_query',
-         'cv_id' => array(
-            'name' => 'tripal'
-         ),
-      ),         
-   );
-   $blast_report = tripal_core_chado_select('analysisfeatureprop',array('analysisfeatureprop_id'),$select);
-   */
-   $sql = "SELECT AFP.analysisfeature_id
-	             FROM {analysisfeature} AF 
-	             INNER JOIN {analysisfeatureprop} AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
-	             WHERE analysis_id = %d
-	             AND AFP.type_id = (
-	                SELECT cvterm_id 
-	                FROM {cvterm} 
-	                WHERE name = '%s' 
-	                AND cv_id = (
-	                   SELECT cv_id 
-	                   FROM {cv} 
-	                   WHERE name = 'tripal'
-	                )
-	             ) LIMIT 1 OFFSET 0";
-   $blast_report = db_result(chado_query($sql, $analysis_id, 'analysis_blast_besthit_query'));
-	if ($blast_report) {
-		$report_url = url("tripal_blast_report/".$analysis->analysis_id."/1/0/0/20");
-		$analysis->blast_report = $report_url;
-	}
-
-	return $additions;
-}
-/**
-*
-*/
-function chado_analysis_blast_insert($node){
-
-   // insert the analysistripal_core_generate_chado_var
-   chado_analysis_insert($node);
-
-   // set the type for this analysis
-   tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_blast');
-
-   // now add in the remaining settings as a single property but separated by bars
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_blastdb',$node->blastdb);
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_blastfile',$node->blastfile);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_blastparameters',$node->blastparameters);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_no_parsed',$node->no_parsed);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_query_re',$node->query_re);	
-   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);
-}
-/**
- * 
- */
-function chado_analysis_blast_update($node){
-
-   // update the anlaysis
-   chado_analysis_update($node); 
-
-   // add the blast settings
-   tripal_analysis_update_property($node->analysis_id,'analysis_type','tripal_analysis_blast',1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_blastdb',$node->blastdb,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_blastfile',$node->blastfile,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_blastparameters',$node->blastparameters,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_no_parsed',$node->no_parsed,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_query_re',$node->query_re,1);	
-   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');
-   if(count($old) > 0){
-      tripal_analysis_delete_property($node->analysis_id,'analysis_blast_settings');
-   }
-
-   // submit the parsing jobs
-   chado_analysis_blast_submit_jobs($node);
-}
-/**
-*
-*/
-function chado_analysis_blast_submit_jobs($node){
-   global $user;
-
-   // add a job if the user wants to parse the XML	    	
-	if($node->blastjob) {
-      $job_args = array(
-          $node->analysis_id,
-          $node->blastdb,
-          $node->blastfile,
-          $node->no_parsed,
-          $node->blastfile_ext,
-          $node->query_re,
-		    $node->query_type, 
-          $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("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.
-	if($node->blastbesthit) {
-      $j_args[0] = $node->analysis_id;	
-		tripal_add_job("Parse best hit: $node->blastfile",'tripal_analysis_blast',
-                     'tripal_analysis_blast_parse_best_hit', $j_args, $user->uid);			
-   }
-		
-}
-/*******************************************************************************
- * Delete blast anlysis
- */
-function chado_analysis_blast_delete($node){
-	chado_analysis_delete($node);
-}
-
-/*******************************************************************************
- *  This function customizes the view of the chado_analysis node.  It allows
- *  us to generate the markup.
- */
-function chado_analysis_blast_view ($node, $teaser = FALSE, $page = FALSE) {
-	// use drupal's default node view:
-    //dprint_r($node);
-	if (!$teaser) {
-		$node = node_prepare($node, $teaser);
-		// When previewing a node submitting form, it shows 'Array' instead of
-		// correct date format. We need to format the date here
-		$time = $node->timeexecuted;
-		if(is_array($time)){
-			$month = $time['month'];
-			$day = $time['day'];
-			$year = $time['year'];
-			$timestamp = $year.'-'.$month.'-'.$day;
-			$node->timeexecuted = $timestamp;
-		}
-		// When viewing a node, we need to reformat the analysisprop since we
-		// separate each value with a bar |
-		if (preg_match("/.*\|.*\|.*/",$node->blastdb)) {
-			$prop_values = explode("|", $node->blastdb);
-			$node->blastdb = $prop_values[0];
-			$node->blastfile = $prop_values[1];
-			$node->blastparameters = $prop_values[2];
-		}
-	}
-	return $node;
-}
-
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_blast_perm(){
-	return array(
-      'access chado_analysis_blast content',
-      'create chado_analysis_blast content',
-      'delete chado_analysis_blast content',
-      'edit chado_analysis_blast content',
-	);
-}
-
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_blast_access($op, $node, $account){
-	if ($op == 'create') {
-		if(!user_access('create chado_analysis_blast content', $account)){
-			return FALSE;
-      }
-	}
-	if ($op == 'update') {
-		if (!user_access('edit chado_analysis_blast content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'delete') {
-		if (!user_access('delete chado_analysis_blast content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'view') {
-		if(!user_access('access chado_analysis_blast content', $account)){
-         return FALSE;
-      }
-	}
-   return NULL;
-}
-
-/**
- *
- *
- * @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;
-}

+ 0 - 208
extensions/tripal_analysis_blast/tripal_analysis_blast_htmlreport.inc

@@ -1,208 +0,0 @@
-<?php
-
-function tripal_get_blast_report ($analysis_id, $currentpage, $sort, $descending, $per_page) {
-	if (!tripal_analysis_check_permission($analysis_id)) {
-		$html_out = "Access denied. You are not authorized to access this report.";
-		return $html_out;
-	}
-	$report_object = new stdClass;
-	
-	$symbol = "&and;";
-	$sort_key = "ASC";
-	if ($descending == 1) {
-		$symbol = "&or;";
-		$sort_key = "DESC";
-	}
-	$header = 'analysis_blast_besthit_query';
-	$convert = 0;
-	if ($sort == 1) {
-		$header = 'analysis_blast_besthit_match';
-	} else if ($sort == 2) {
-		$header = 'analysis_blast_besthit_description';
-	} else if ($sort == 3) {
-		$header = 'analysis_blast_besthit_evalue';
-		$convert = 1;
-	} else if ($sort == 4) {
-		$header = 'analysis_blast_besthit_identity';
-		$convert = 1;
-	} else if ($sort == 5) {
-		$header = 'analysis_blast_besthit_length';
-		$convert = 1;
-	}
-
-	$previous_db = tripal_db_set_active('chado');
-	// Get analysis information including 'Time', 'Name', and 'DB Settings'
-	$sql = "SELECT value, name, to_char(timeexecuted, 'MM-DD-YYYY') AS time
-                FROM {analysis}  A
-                INNER JOIN {analysisprop} AP ON  A.analysis_id = AP.analysis_id 
-                WHERE A.analysis_id = %d
-                AND type_id= (SELECT cvterm_id 
-                                           FROM {cvterm} 
-                                           WHERE name = 'analysis_blast_blastdb')";
-	$analysis = db_fetch_object(db_query($sql, $analysis_id));
-	$db_id = $analysis->value;
-	
-	// Get db 'urlprefix'
-	$sql = "SELECT urlprefix FROM {db} WHERE db_id=%d";
-	$urlprefix = db_result(db_query($sql, $db_id));
-	
-	// Get all analysisfeature_id's sorted by the selected header for this blast analysis
-	$sql = "SELECT AFP.analysisfeature_id
-	             FROM {analysisfeature} AF 
-	             INNER JOIN {analysisfeatureprop} AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
-	             WHERE analysis_id = %d
-	             AND AFP.type_id = (SELECT cvterm_id FROM {cvterm} WHERE name = '%s' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal'))
-	             ORDER BY value ";
-	// Convert string to number for evalue, %identity, and length before SQL sorting
-	if ($convert == 1) {
-		$sql .= "::numeric  ";
-	} 
-	$sql .= "$sort_key";
-
-	$result = db_query($sql, $analysis_id, $header);
-	tripal_db_set_active($previous_db);
-	$analysisfeatureSet = array();
-	// Count how many analysisfeature_id we have and store them in order in $analysisfeatureSet
-	$counter = 0;	
-	while ($feature = db_fetch_object($result)) {
-		$analysisfeatureSet [$counter] = $feature->analysisfeature_id;
-		$counter ++;
-	}
-   
-	// Get analysis node id
-	$ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %d", $analysis_id));
-	$ana_url = url("node/".$ana_nid);
-	
-	// Get pager info
-	$no_page = (int) ($counter / $per_page);
-	if ($counter % $per_page != 0) {
-		$no_page ++;
-	}
-	$first_item = ($currentpage - 1)* $per_page;
-
-	$report_object->time = $analysis->time;
-	$report_object->name = $analysis->name;
-	$report_object->url = $ana_url;
-	$report_object->counter = $counter;
-	$report_object->currentpage = $currentpage;
-	$report_object->no_page = $no_page;
-	$report_object->symbol = $symbol;
-	$report_object->sort = $sort;
-
-	// Construct URL path for different sorting column
-	$path =  "tripal_blast_report/$analysis_id/1/0/";
-	if ($descending == 0 && $sort == 0) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byQuery = $url_path;
-
-	$path =  "tripal_blast_report/$analysis_id/1/1/";
-	if ($descending == 0 && $sort == 1) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byMatchName =$url_path;
-
-	$path =  "tripal_blast_report/$analysis_id/1/2/";
-	if ($descending == 0 && $sort == 2) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byDescription = $url_path;
-
-	$path =  "tripal_blast_report/$analysis_id/1/3/";
-	if ($descending == 0 && $sort == 3) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byEvalue = $url_path;
-	
-	$path =  "tripal_blast_report/$analysis_id/1/4/";
-	if ($descending == 0 && $sort == 4) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byIdentity = $url_path;
-
-	$path =  "tripal_blast_report/$analysis_id/1/5/";
-	if ($descending == 0 && $sort == 5) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byLength = $url_path;
-
-	// Get table content
-	$sql = "SELECT value
-	             FROM {analysisfeatureprop} 
-	             WHERE analysisfeature_id = %d 
-	             AND type_id = (SELECT cvterm_id FROM {cvterm} WHERE name = '%s' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal'))";
-	$j = 0;
-	$hits = array ();
-	for ($i = $first_item; $i < $first_item +$per_page; $i ++) {
-		$previous_db = tripal_db_set_active('chado');
-		$query = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_query'));
-		$match = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_match'));
-		$desc = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_description'));
-		$evalue = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_evalue'));
-		$identity = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_identity'));
-		$length = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_length'));
-		
-		$sql_fid = "SELECT feature_id FROM analysisfeature WHERE analysisfeature_id = %d";
-		$fid = db_result(db_query($sql_fid, $analysisfeatureSet[$i]));
-		tripal_db_set_active($previous_db);
-		
-		$q_url = url("ID$fid");
-		$class = 'tripal_analysis_blast-table-odd-row tripal-table-odd-row';
-	 	if($j % 2 == 0 ){
-         $class = 'tripal_analysis_blast-table-even-row tripal-table-even-row';
-      }
-      $hit = new stdClass();
-		if ($query) {
-			$hit->class = $class;
-			$hit->q_url = $q_url;
-			$hit->query = $query;
-			$hit->urlprefix = $urlprefix;
-			$hit->match = $match;
-			$hit->desc = $desc;
-			$hit->evalue = $evalue;
-			$hit->identity = $identity;
-			$hit->length = $length;
-			$hits [$j] = $hit;
-		}
-		$j ++;
-	}
-	$report_object->hits = $hits;
-	
-	// The number of items to show on the page
-	$path =  "tripal_blast_report/$analysis_id/1/$sort/$descending/";
-	$report_object->path = $path;
-	$report_object->per_page = $per_page;
-
-	// Make AJAX call to update the  page which user selected 
-	$report_object->analysis_id = $analysis_id;
-	$report_object->sort = $sort;
-	$report_object->descending = $descending;
-	$report_object->per_page = $per_page;
-	$report_object->no_page = $no_page;
-
-    return theme('tripal_analysis_blast_report',$report_object);
-}

+ 0 - 23
extensions/tripal_analysis_go/go_path_counts

@@ -1,23 +0,0 @@
-SELECT  CVTP.subject_id, CVT.name, CVT2.name, CVTP.object_id, CVT3.name, CVTP.pathdistance, count(F.name)
-FROM {cvtermpath} CVTP
-   INNER JOIN CVTerm CVT ON CVTP.subject_id = CVT.cvterm_id
-   INNER JOIN CVTerm CVT2 on CVTP.type_id = CVT2.cvterm_id
-   INNER JOIN CVTerm CVT3 on CVTP.object_id = CVT3.cvterm_id
-   INNER JOIN Feature_cvterm FCVT on FCVT.cvterm_id = CVT.cvterm_id
-   INNER JOIN Feature F on FCVT.feature_id = F.feature_id
-WHERE object_id = 7438
-GROUP BY CVTP.subject_id, CVT.name, CVT2.name, CVTP.object_id, CVT3.name, CVTP.pathdistance
-ORDER BY pathdistance
-
-
-// THE MATERIALIZED VIEW!!!
-SELECT  CVT3.name, CVTP.object_id, count(F.name)
-FROM {cvtermpath} CVTP
-   INNER JOIN CVTerm CVT ON CVTP.subject_id = CVT.cvterm_id
-   INNER JOIN CVTerm CVT2 on CVTP.type_id = CVT2.cvterm_id
-   INNER JOIN CVTerm CVT3 on CVTP.object_id = CVT3.cvterm_id
-   INNER JOIN Feature_cvterm FCVT on FCVT.cvterm_id = CVT.cvterm_id
-   INNER JOIN Feature F on FCVT.feature_id = F.feature_id
-   INNER JOIN CV on CV.cv_id = CVT.cv_id
-WHERE CV.name = 'biological_process' or CV.name = 'molecular_function' or CV.name = 'cellular_component'
-GROUP BY CVT3.name, CVTP.object_id

+ 0 - 466
extensions/tripal_analysis_go/includes/gaf_loader.inc

@@ -1,466 +0,0 @@
-<?php
-
-function tripal_analysis_go_gaf_load_form (){
-
-   $form['notice']= array(
-      '#type' => 'item',
-      '#value' => t('Note: currently, the GAF loader only uses column 2 (Object ID) and 5 (GO ID) 
-          from the GAF file, and simply imports GO terms for the features. 
-          Further support for this file format will be provided later.'),
-   );
-
-   $form['gaf_file']= array(
-      '#type'          => 'textfield',
-      '#title'         => t('GAF File'),
-      '#description'   => t('Please enter the full system path for the GAF file, or a path within the Drupal
-                             installation (e.g. /sites/default/files/xyz.txt).  The path must be accessible to the
-                             server on which this Drupal instance is running.'),
-      '#required' => TRUE,
-   );
-   // get the list of organisms
-   $sql = "SELECT * FROM {organism} ORDER BY genus, species";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $org_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $organisms = array();
-   $organisms[''] = '';
-   while($organism = db_fetch_object($org_rset)){
-      $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
-   }
-   $form['organism_id'] = array (
-     '#title'       => t('Organism'),
-     '#type'        => t('select'),
-     '#description' => t("Choose the organism to which these sequences are associated "),
-     '#required'    => TRUE,
-     '#options'     => $organisms,
-   );
-   $form['seq_type']= array(
-      '#type' => 'textfield',
-      '#title' => t('Sequence Type'),
-      '#required' => TRUE,
-      '#description' => t('Please enter the Sequence Ontology term that describes the sequences in the GAF file.'),
-   );
-	$form['query_uniquename'] = array(
-      '#title' => t('Use Unique Name'),
-      '#type' => 'checkbox',
-      '#description' => t('Select this checboxk if the feature name in the GAF file '.
-        'matches the uniquename in the database.  By default, the feature will '.
-        'be mapped to the "name" of the feature.'),
-      '#default_value' => $query_uniquename,
-	);
-   $form['import_options'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Import Options'),
-      '#collapsed' => TRUE
-   );
-   $form['import_options']['add_only']= array(
-      '#type' => 'checkbox',
-      '#title' => t('Add GO terms'),
-      '#required' => FALSE,
-      '#description' => t('GO terms in the GAF file will be added to each feature.'),
-   );
-//   $form['import_options']['replace']= array(
-//      '#type' => 'checkbox',
-//      '#title' => t('Replace GO terms'),
-//      '#required' => FALSE,
-//      '#description' => t('All GO terms for features in the GAF file will be replaced with terms in the GAF file.'),
-//   );
-   $form['import_options']['remove']= array(
-      '#type' => 'checkbox',
-      '#title' => t('Delete GO terms'),
-      '#required' => FALSE,
-      '#description' => t('GO terms for features in the GAF file will be removed. Other terms will remain.'),
-   );
-
-   $form['analysis'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Analysis Used to Derive GO terms'),
-      '#collapsed' => TRUE
-   ); 
-
-   // get the list of organisms
-   $sql = "SELECT * FROM {analysis} ORDER BY name";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $org_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $analyses = array();
-   $analyses[''] = '';
-   while($analysis = db_fetch_object($org_rset)){
-      $analyses[$analysis->analysis_id] = "$analysis->name ($analysis->program $analysis->programversion, $analysis->sourcename)";
-   }
-   $form['analysis']['analysis_id'] = array (
-     '#title'       => t('Analysis'),
-     '#type'        => t('select'),
-     '#description' => t("Choose the analysis that defines how the GO annotations in the GAF file were created. "),
-     '#required'    => TRUE,
-     '#options'     => $analyses,
-   );
-
-
-  // Advanced Options
-   $form['advanced'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Advanced Options'),
-      '#collapsed' => TRUE
-   );
-   $form['advanced']['re_help']= array(
-      '#type' => 'item',
-      '#value' => t('A regular expression is an advanced method for extracting information from a string of text.  
-                     By default, this loader will use the first word in the second column of the GAF file 
-                     as the uniquename for the sequences.  If this is not desired, you may use the following regular 
-                     expressions to define the location of the name or unique name within the text of column 2.'),
-   );
-
-   $form['advanced']['re_name']= array(
-      '#type' => 'textfield',
-      '#title' => t('Regular expression for the name'),
-      '#required' => FALSE,
-      '#description' => t('Enter the regular expression that will extract the '.
-         'feature name from the GAF file. This option is '.
-         'is only required when the feature identifier does not identically match a feature '.
-         'in the database.'),
-   );   
- 
-
-   $form['button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Import GAF file'),
-   );
-   return $form;
-}
-/**
- *
- *
- * @ingroup gff3_loader
- */
-function tripal_analysis_go_gaf_load_form_validate ($form, &$form_state){
-
-   $gaf_file = $form_state['values']['gaf_file'];
-   $organism_id = $form_state['values']['organism_id'];
-   $add_only = $form_state['values']['add_only'];
-   $remove   = $form_state['values']['remove'];
-   $replace  = $form_state['values']['replace'];
-   $analysis_id = $form_state['values']['analysis_id'];
-   $type      = trim($form_state['values']['seq_type']);
-   $re_name      = trim($form_state['values']['re_name']);
-   $query_uniquename = $form_state['values']['query_uniquename'];
-
-
-   // check to see if the file is located local to Drupal
-   $dfile = $_SERVER['DOCUMENT_ROOT'] . base_path() . $gaf_file; 
-   if(!file_exists($dfile)){
-      // if not local to Drupal, the file must be someplace else, just use
-      // the full path provided
-      $dfile = $gaf_file;
-   }
-   if(!file_exists($dfile)){
-      form_set_error('gff_file',t("Cannot find the file on the system. Check that the file exists or that the web server has permissions to read the file."));
-   }
-
-   if (($add_only and ($remove or $replace)) or 
-       ($replace and ($add_only or $remove)) or
-       ($remove and ($replace or $add_only))){
-       form_set_error('add_only',t("Please select only one checkbox from the import options section"));
-   }
-
-   // check to make sure the types exists
-   $cvtermsql = "SELECT CVT.cvterm_id
-                 FROM {cvterm} CVT
-                    INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
-                    LEFT JOIN {cvtermsynonym} CVTS on CVTS.cvterm_id = CVT.cvterm_id
-                 WHERE cv.name = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
-   $cvterm = db_fetch_object(db_query($cvtermsql,'sequence',$type,$type));
-   if(!$cvterm){
-      form_set_error('type',t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
-   }
-   if($rel_type){
-      $cvterm = db_fetch_object(db_query($cvtermsql,'sequence',$parent_type,$parent_type));
-      if(!$cvterm){
-         form_set_error('parent_type',t("The Sequence Ontology (SO) term selected for the parent relationship is not available in the database. Please check spelling or select another."));
-      }
-   }
-}
-
-/**
- *
- * @ingroup gff3_loader
- */
-function tripal_analysis_go_gaf_load_form_submit ($form, &$form_state){
-   global $user;
-
-   $gaf_file = $form_state['values']['gaf_file'];
-   $organism_id = $form_state['values']['organism_id'];
-   $add_only = $form_state['values']['add_only'];
-   $remove   = $form_state['values']['remove'];
-   $replace  = $form_state['values']['replace'];
-   $analysis_id = $form_state['values']['analysis_id'];
-   $type      = trim($form_state['values']['seq_type']);
-   $re_name      = trim($form_state['values']['re_name']);
-   $query_uniquename = $form_state['values']['query_uniquename'];
-
-   $args = array($gaf_file,$organism_id,$analysis_id,$add_only,$replace,
-      $remove,$re_name,$type,$query_uniquename);
-   if($add_only){
-     $type = 'add GO terms';
-   }
-   if($replace){
-     $type = 'replace and add GO terms';
-   }
-   if($remove){
-     $type = 'remove GO terms';
-   }
-   tripal_add_job("Import GAF 2.0 file $gaf_file and $type",'tripal_analysis_go',
-      'tripal_analysis_go_load_gaf',$args,$user->uid);
-
-   return '';
-}
-
-/**
- *
- *
- * @ingroup gff3_loader
- */
-function tripal_analysis_go_load_gaf($gaf_file, $organism_id,$analysis_id,$add_only =0, 
-   $replace = 0, $remove = 0, $re_name, $type, $query_uniquename,
-   $job = NULL)
-{
-   print "Opening GAF file $gaf_file\n";
-
-    
-   $lines = file($gaf_file,FILE_SKIP_EMPTY_LINES);
-   $i = 0;
-
-   $name = '';
-   $residues = '';
-   $num_lines = sizeof($lines);
-   $interval = intval($num_lines * 0.01);
-   if($interval == 0){
-      $interval = 1;
-   }
-
-   foreach ($lines as $line_num => $line) {
-      $i++;  // update the line count     
-
-      // skip comments
-      if(preg_match('/^\!/',$line)){
-         continue; 
-      }
-
-      // update the job status every 1% features
-      if($job and $i % $interval == 0){
-         tripal_job_set_progress($job,intval(($i/$num_lines)*100));
-      }
-
-      // split the line into it's columns
-      $cols = explode("\t",$line);
-      if(sizeof($cols) < 15){
-         print "ERROR: improper number of columns on line $i\n";
-         print_r($cols);
-         return '';
-      }
-      $db        = $cols[0];
-      $object    = $cols[1];
-      $symbol    = $cols[2];
-      $qualifier = $cols[3];
-      $go_id     = $cols[4];
-      $dbxref    = $cols[5];
-      $ecode     = $cols[6];
-      $with      = $cols[7];
-      $aspect    = $cols[8];
-      $obj_name  = $cols[9];
-      $obj_syn   = $cols[10];
-      $obj_type  = $cols[11];
-      $taxon     = $cols[12];
-      $date      = $cols[13];
-      $assigned  = $cols[14];
-      $exten     = $cols[15];
-      $product   = $cols[16];
-
-      // get the name or uniquename for the feature
-      $name = $object;
-      if($re_name){
-         if(!preg_match("/$re_name/",$object,$matches)){
-            print "Regular expression for the feature name finds nothing\n";
-         } else {
-            $name = trim($matches[1]);
-         }
-      } else {
-         if(preg_match("/^\s*(.*?)[\s\|].*$/",$object,$matches)){
-            $name = trim($matches[1]);
-         }
-      }
-      
-
-      // get the feature
-      $values = array(
-         'type_id' => array(
-            'cv_id' => array(
-               'name' => 'sequence'
-            ),
-            'name' => $type,
-         ),
-         'organism_id' => $organism_id,
-      );
-      if(!$query_uniquename){
-        $values['name'] = $name;
-      } else {
-        $values['uniquename'] = $name;
-      } 
-      $feature = tripal_core_chado_select('feature',array('*'),$values);
-      if(count($feature) == 0){
-         print "WARNING: Cannot find the feature: '$name'\n";         
-      } else {
-         // add the GO term to the feature
-         tripal_analysis_go_load_gaff_go_term($feature[0],$go_id,$remove,$analysis_id);
-      }
-   }
-   return 1;
-}
-/**
-*
-*/
-function tripal_analysis_go_load_gaff_go_term($feature,$dbxref,$remove,$analysis_id){
-
-   // get the database name from the reference.  If it doesn't exist then create one.
-   $ref = explode(":",$dbxref);
-   $dbname = $ref[0];
-   $accession = $ref[1];
-
-   // first look for the database name 
-   $db = tripal_core_chado_select('db',array('db_id'),array('name' => "DB:$dbname"));  
-   if(sizeof($db) == 0){
-      $db = tripal_core_chado_select('db',array('db_id'),array('name' => "$dbname"));      
-   }        
-   if(sizeof($db) == 0){
-      print "ERROR: Database, $dbname is missing for reference: $dbname:$accession\n";
-      return 0;
-   } 
-   $db = $db[0];
-    
-   // now check to see if the accession exists
-   $dbxref = tripal_core_chado_select('dbxref',array('dbxref_id'),array(
-      'accession' => $accession,'db_id' => $db->db_id));
-   if(sizeof($dbxref) == 0){
-      print "ERROR: Accession, $accession is missing for reference: $dbname:$accession\n";
-      return 0;
-   }
-   $dbxref = $dbxref[0];
-
-   // now check to see if the cvterm exists
-   $cvterm = tripal_core_chado_select('cvterm',array('cvterm_id'),array(
-      'dbxref_id' => $dbxref->dbxref_id));
-   // if it doesn't exist in the cvterm table, look for an alternate id
-   if(sizeof($cvterm) == 0){
-      $cvterm = tripal_core_chado_select('cvterm_dbxref',array('cvterm_id'),array(
-         'dbxref_id' => $dbxref->dbxref_id));
-   }
-   if(sizeof($cvterm) == 0){
-      print "ERROR: CVTerm is missing for reference: $dbname:$accession\n";
-      return 0;
-   }
-   $cvterm = $cvterm[0];
-   
-
-   // check to see if this feature cvterm already exists
-   $fcvt = tripal_core_chado_select('feature_cvterm',array('feature_cvterm_id'),
-      array('cvterm_id' => $cvterm->cvterm_id,'feature_id' => $feature->feature_id));
-
-   // now associate this feature with the cvterm if it doesn't already exist
-   if(sizeof($fcvt)==0){
-      $values = array(
-         'feature_id' => $feature->feature_id,
-         'cvterm_id' => $cvterm->cvterm_id,
-         'pub_id' => array(
-            'uniquename' => 'null',
-         ),
-      );
-      $ret = tripal_core_chado_insert('feature_cvterm',$values);
-
-      if($ret){
-         print "   Added ontology term $dbname:$accession to feature $feature->uniquename\n";
-      } else {
-         print "ERROR: failed to insert ontology term '$dbname:$accession' for feature: $feature\n";
-         return 0;
-      }
-   } else {
-      if($remove){
-         $status = tripal_core_chado_delete('feature_cvterm',
-            array('cvterm_id' => $cvterm->cvterm_id,
-                 'feature_id' => $feature->feature_id));
-         if(!$status){
-            print "ERROR: Failed to delete ontology term $dbname:$accession from feature $feature->uniquename\n";
-         } else {
-            print "   Deleted ontology term $dbname:$accession from feature $feature->uniquename\n";
-         }
-      } else {
-         print "   Ontology term already associated to feature $feature->uniquename, skipping $dbname:$accession\n";
-      }
-   }
-
-   if(!$remove){
-      print "   Associating feature $feature->name to analysis\n";
-      // Insert into analysisfeature table only if it doesn't already exist
-      $values = array('feature_id' => $feature->feature_id, 'analysis_id' => $analysis_id);
-      $analysisfeature = tripal_core_chado_select('analysisfeature',array('*'),$values);
-      if(sizeof($analysisfeature) == 0){
-         $analysisfeature = tripal_core_chado_insert('analysisfeature',$values);
-         $analysisfeature_id = $analysisfeature['analysisfeature_id'];
-      } else {
-         $analysisfeature_id = $analysisfeature[0]->analysisfeature_id;
-      }
-
-      // Insert GO terms into analysisfeatureprop table
-      $values = array('analysisfeature_id' => $analysisfeature_id,
-                      'type_id' => $cvterm->cvterm_id,
-                      'rank' => 0);
-      $analysisfeatureprop = tripal_core_chado_select('analysisfeatureprop',array('*'),$values);
-      if(sizeof($analysisfeatureprop) == 0){
-         $values['value'] = $matches[1];
-         $analysisfeatureprop = tripal_core_chado_insert('analysisfeatureprop',$values);
-      }
-   }
-   return 1;
-}
-/**
-*
-*/
-function tripal_analysis_go_load_gaff_insert_analysisfeatureprop ($feature_id, $analysis_id,
-   $brite_id,$keggterm)
-{
-
-   // add the analysisfeature record if it doesn't already exist.
-   $values = array('feature_id' => $feature_id,'analysis_id' => $analysis_id);
-   $analysisfeature_arr = tripal_core_chado_select('analysisfeature',
-      array('analysisfeature_id'),$values);
-   if(count($analysisfeature_arr) == 0){
-      tripal_core_chado_insert('analysisfeature',$values);
-      $analysisfeature_arr = tripal_core_chado_select('analysisfeature',
-         array('analysisfeature_id'),$values);
-   }
-   $analysisfeature_id = $analysisfeature_arr[0]->analysisfeature_id;            
-   // Insert into analysisfeatureprop if the value doesn't already exist
-   // KEGG heir results sometimes have the same record more than once.
-   if($analysisfeature_id){
-      // Get the highest rank for this feature_id in analysisfeatureprop table
-      $sql = "SELECT rank FROM analysisfeatureprop WHERE analysisfeature_id = %d and type_id = %d ORDER BY rank DESC";
-      $previous_db = tripal_db_set_active('chado');
-      $result = db_fetch_object(db_query($sql,$analysisfeature_id,$brite_id));
-      tripal_db_set_active($previous);
-      $rank = 0;
-      if ($result and $result->rank > 0) {
-         $rank = $result->rank + 1;
-      }
-
-      $values = array(
-         'analysisfeature_id' => $analysisfeature_id, 
-         'type_id' => $brite_id,
-         'value' => $keggterm,
-         'rank' => $rank,
-      );
-
-      return tripal_core_chado_insert('analysisfeatureprop',$values);
-   }
-   else {
-      return 0;
-   }
-}

+ 0 - 17
extensions/tripal_analysis_go/theme/css/tripal_analysis_go.css

@@ -1,17 +0,0 @@
-
-.tripal_go-info-box, .tripal_go_summary-info-box {
-   margin-top: 10px;
-   margin-left: 0px;
-   margin-right: 0px;
-   margin-bottom: 0px;
-   padding-top: 0px;
-   padding-left: 0px;
-   padding-bottom: 0px;
-   padding-right: 0px;
-   border-collapse: collapse;
-   z-index: 10;
-}
-
-.tripal_go_summary-info-box .tripal_cv_tree {
-   border-collapse: separate;
-}

+ 0 - 52
extensions/tripal_analysis_go/theme/js/tripal_analysis_go.js

@@ -1,52 +0,0 @@
-
-
-if (Drupal.jsEnabled) {
-
-
-   $(document).ready(function() {
-       // Select default GO analysis when available
-       var selectbox = $('#edit-tripal-analysis-go-select');
-       if(selectbox.length > 0){ 
-    	   var option = document.getElementById("analysis_id_for_go_report");
-    	   if (option) {
-    		   var options = document.getElementsByTagName('option');
-    		   var index = 0;
-    		   for (index = 0; index < options.length; index ++) {
-    			   if (options[index].value == option.value) {
-    				   break;
-    			   }
-    		   }
-    		   selectbox[0].selectedIndex = index;
-    		   tripal_analysis_go_org_charts(option.value);
-    	// Otherwise, show the first option by default
-    	   } else {
-    		   selectbox[0].selectedIndex = 1;
-    		   tripal_analysis_go_org_charts(selectbox.val());
-    	   }
-       }
-   });
-
-
-   function tripal_analysis_go_org_charts(item){
-      if(!item){
-         $("#tripal_analysis_go_org_charts").html('');
-         return false;
-      }
-      // Form the link for the following ajax call 
-      baseurl = tripal_get_base_url();      
-      var link = baseurl + '?q=tripal_analysis_go_org_charts/' + item;
-      tripal_startAjax();
-      $.ajax({
-           url: link,
-           dataType: 'json',
-           type: 'POST',
-           success: function(data){
-             $("#tripal_analysis_go_org_charts").html(data[0]);
-             tripal_cv_init_chart();
-             tripal_cv_init_tree();
-             tripal_stopAjax();
-           }
-      });
-      return false;
-   }
-}

+ 0 - 35
extensions/tripal_analysis_go/theme/tripal_feature/tripal_feature_go_terms.tpl.php

@@ -1,35 +0,0 @@
-<?php
-$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>
-  <div class="tripal_feature-info-box-desc tripal-info-box-desc">This <?php print $feature->type_id->name ?> is annotated with the following GO terms.</div>
-  <?php if(count($terms) > 0){ ?>
-  <table id="tripal_feature-go_terms-table" class="tripal_feature-table tripal-table tripal-table-horz">
-    <tr>
-      <th>Category</th>
-      <th>Term Accession</th>
-      <th>Term Name</th>
-    </tr>
-    <?php
-    $i = 0; 
-    foreach ($terms as $term){
-      $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
-      if($i % 2 == 0 ){
-         $class = 'tripal_feature-table-odd-row tripal-table-even-row';
-      }
-      ?>
-      <tr class="<?php print $class ?>">
-        <td><?php print $term->cvname ?></td>
-        <td><a href="http://amigo.geneontology.org/cgi-bin/amigo/term_details?term=GO:<?php print $term->accession ?>"  target="_go">GO:<?php print $term->accession?></a></td>
-        <td><span title="<?php print $term->definition ?>"><?php print $term->goterm ?></span></td>
-      </tr>
-      <?php
-      $i++;  
-    } ?>
-  </table>
-  <?php } else { ?>
-    <div class="tripal-no-results">There are no GO terms for this feature</div> 
-  <?php }?>
-</div>

+ 0 - 35
extensions/tripal_analysis_go/theme/tripal_organism/tripal_organism_go_summary.tpl.php

@@ -1,35 +0,0 @@
-<?php
-  $organism = $node->organism;
-  $form = $organism->tripal_analysis_go->select_form['form'];
-  $has_results = $organism->tripal_analysis_go->select_form['has_results'];
-?>
-<div id="tripal_organism-go_summary-box" class="tripal_organism-info-box tripal-info-box">
-  <div  class="tripal_organism-info-box-title tripal-info-box-title">GO Analysis Reports</div>
-  <?php 
-     if($has_results){
-        print $form;
-     } else {
-       ?><div class="tripal-no-results">
-           There are no GO reports available
-           <?php if(user_access('access administration pages')){ ?>
-              <p><br>Administrators, to view a GO report you must:
-              <ul>
-                 <li>load GO assignments and associate them to features and a corresponding analysis</li>
-                 <li>Set the <a href="<?php print url('admin/tripal/tripal_cv/cvtermpath');?>">cvtermpath</a> for the 'biological process', 'molecular_function' and 'cellular_component' vocabularies.</li>
-                 <li>Populate the <a href="<?php print url('admin/tripal/tripal_mviews');?>">go_count_analysis</a> materialized view</li>
-              </ul> </p>
-           <?php }?>
-         </div><?php
-     }
-  ?>
-  <div id="tripal_analysis_go_org_charts"></div>    
-  <div id="tripal_cv_cvterm_info_box">
-      <a href="#" onclick="$('#tripal_cv_cvterm_info_box').hide()" style="float: right">Close [X]</a>
-      <div>Term Information</div>
-      <div id="tripal_cv_cvterm_info"></div>
-   </div>
-   <div id="tripal_ajaxLoading" style="display:none">
-     <div id="loadingText">Loading...</div>
-   </div>
-</div>
-

+ 0 - 10
extensions/tripal_analysis_go/tripal_analysis_go.info

@@ -1,10 +0,0 @@
-; $Id: tripal_analysis_go.info,v 1.2 2009/10/23 02:12:16 ccheng Exp $
-name = Tripal GO
-description = An analysis sub-module for displaying GO analysis and GO assignments to features.
-core = 6.x
-project = tripal_analysis_go
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis
-dependencies[] = tripal_organism

+ 0 - 133
extensions/tripal_analysis_go/tripal_analysis_go.install

@@ -1,133 +0,0 @@
-<?php
-
-/*******************************************************************************
-*  Implementation of hook_install();
-*/
-function tripal_analysis_go_install(){
-  
-   tripal_analysis_register_child('tripal_analysis_go');
-   
-   // The following view will create counts of features that are assigned
-   // either directly or by ancestry each GO term. The count is organized by
-   // organisms.
-   $previous_db = tripal_db_set_active('chado');
-   if (db_table_exists('go_count_organism')) {
-      $sql = "DROP TABLE go_count_organism";
-      db_query($sql);
-   }
-   if (db_table_exists('go_count_analysis')) {
-      $sql = "DROP TABLE go_count_analysis";
-      db_query($sql);
-   }
-   tripal_db_set_active($previous_db);
-   
-   tripal_add_mview(
-      // view name
-      'go_count_organism',
-      // tripal module name
-      'tripal_analysis_go',
-      // table name
-      'go_count_organism',
-      // table schema definition
-      'cvname character varying(255),
-       cvterm_id integer,
-       organism_id integer,
-       feature_count integer',
-      // columns for indexing
-      'cvterm_id,organism_id',
-      // SQL statement to populate the view
-      "SELECT T1.cvname, T1.object_id, T1.organism_id, count(T1.feature_id)
-       FROM
-         (SELECT DISTINCT CVT3.name as cvname, CVTP.object_id, 
-            O.organism_id, F.feature_id
-          FROM {cvtermpath} CVTP
-            INNER JOIN CVTerm CVT          ON CVTP.subject_id = CVT.cvterm_id
-            INNER JOIN CVTerm CVT2         ON CVTP.type_id = CVT2.cvterm_id
-            INNER JOIN CVTerm CVT3         ON CVTP.object_id = CVT3.cvterm_id
-            INNER JOIN Feature_cvterm FCVT ON FCVT.cvterm_id = CVT.cvterm_id
-            INNER JOIN Feature F           ON FCVT.feature_id = F.feature_id
-            INNER JOIN CV                  ON CV.cv_id = CVT.cv_id
-            INNER JOIN Organism O          ON O.organism_id = F.organism_id
-          WHERE (CV.name = 'biological_process' or 
-                 CV.name = 'molecular_function' or 
-                 CV.name = 'cellular_component')
-         ) as T1
-       GROUP BY T1.cvname,T1.object_id,T1.organism_id",
-      // special index
-      ''
-   );
-
-   // The following view will create counts of features that are assigned
-   // either directly or by ancestry each GO term. The count is organized by
-   // tripal_go_analysis analyses.
-   tripal_add_mview(
-      // view name
-      'go_count_analysis',
-      // tripal module name
-      'tripal_analysis_go',
-      // table name
-      'go_count_analysis',
-      // table schema definition
-      'cvname character varying(255),
-       cvterm_id integer,
-       analysis_id integer,
-       organism_id integer,
-       feature_count integer',
-      // columns for indexing
-      'cvterm_id,analysis_id,organism_id',
-      // SQL statement to populate the view
-      "SELECT T1.cvname,T1.cvterm_id,T1.analysis_id,T1.organism_id,count(*) as feature_count 
-       FROM
-        (SELECT DISTINCT AF.analysis_id, AF.feature_id,CVT.name as cvname,
-           CVT.cvterm_id,CVTP.object_id,CV.name, F.organism_id 
-         FROM {analysisfeatureprop} AFP
-           INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id
-           INNER JOIN feature F          ON AF.feature_id = F.feature_id
-           INNER JOIN cvtermpath CVTP    ON CVTP.subject_id = AFP.type_id
-           INNER JOIN cvterm CVT         ON CVTP.object_id = CVT.cvterm_id
-           INNER JOIN CV                 ON CV.cv_id = CVT.cv_id
-
-         WHERE  
-           (CV.name = 'biological_process' or 
-            CV.name = 'molecular_function' or 
-            CV.name = 'cellular_component')) as T1
-       GROUP BY T1.cvname,T1.cvterm_id,T1.analysis_id,T1.organism_id",
-      // special index
-      ''
-   );
-}
-
-/*******************************************************************************
-* Implementation of hook_uninstall()
-*/
-function tripal_analysis_go_uninstall(){
-
-   $mview = tripal_mviews_get_mview_id('go_count_organism');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   $mview = tripal_mviews_get_mview_id('go_count_analysis');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   tripal_analysis_unregister_child('tripal_analysis_go');
-
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_go_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_go'] = array(
-            'title' => "tripal_analysis_go",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}

+ 0 - 608
extensions/tripal_analysis_go/tripal_analysis_go.module

@@ -1,608 +0,0 @@
-<?php
-
-require_once "includes/gaf_loader.inc";
-
-function tripal_analysis_go_init(){
-   // Add style sheet
-   drupal_add_css(drupal_get_path('module', 'tripal_analysis_go').'/theme/css/tripal_analysis_go.css', 'theme');
-
-   drupal_add_js(drupal_get_path('module', 'tripal_analysis_go').'/theme/js/tripal_analysis_go.js');
-}
-
-/*******************************************************************************
- * Menu items are automatically added for the new node types created
- * by this module to the 'Create Content' Navigation menu item.  This function
- * adds more menu items needed for this module.
- */
-function tripal_analysis_go_menu() {
-   $items = array();
-
-   $items['download_goterm_features'] = array(
-      'path' => 'download_goterm_features',
-      'title' => t('Get GO Term Features'),
-      'page callback' => 'tripal_analysis_go_get_goterm_features',
-      'page arguments' => array(1,2),
-      'access arguments' => array('access chado_analysis_go content'),
-      'type' => MENU_CALLBACK
-   );
-   $items['tripal_analysis_go_org_charts'] = array(
-      'path' => 'tripal_analysis_go_org_charts',
-      'title' => t('Analysis GO Charts'),
-      'page callback' => 'tripal_analysis_go_org_charts',
-      'page arguments' => array(1),
-      'access arguments' => array('access chado_analysis_go content'),
-      'type' => MENU_CALLBACK
-   );
-   $items['admin/tripal/tripal_analysis_go'] = array(
-     'title' => 'Gene Ontology',
-     'description' => 'Administrative tools for managing Gene Ontology data.',
-     'page callback' => 'tripal_analysis_go_module_description_page',
-     'access arguments' => array('administer site configuration'),
-     'type' => MENU_NORMAL_ITEM,
-   );
-   $items['admin/tripal/tripal_analysis_go/gaf_load'] = array(
-     'title' => t('Import GO terms with GAF file'),
-     'description' => t("Import GO terms into Chado using the Gene Ontology's GAF 2.0 file format"),
-     'page callback' => 'drupal_get_form',
-     'page arguments' => array('tripal_analysis_go_gaf_load_form'),
-     'access arguments' => array('access administration pages'),
-     'type' => MENU_NORMAL_ITEM,
-   );
-
-   return $items;
-}
-/*************************************************************************
- * Purpose: Provide Guidance to new Tripal Admin
- *
- * @return HTML Formatted text
- */
-function tripal_analysis_go_module_description_page() {
-  $text = '';
-  
-  $text .= '<h3>Description:</h3>';
-  $text .= '<p>TODO: Basic Description of this module including mention/link to the chado module</p>';
-
-  $text .= '<h3>Post Installation Instructions:</h3>';
-  $text .= '<p>TODO: Describe any post installation intructions here. You shouldalways include setting user permissions.</p>';
-  
-  
-  $text .= '<h3>Features of this Module:</h3>';
-  $text .= '<p>TODO: Discuss the Features of this module including links. Some features to consider are creating content, details pages/node content, editing/deleteing, basic listings and vies integration. See admin/tripal/tripal_stock for an example.</p>';
-  
-  return $text;
-}
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_go_perm(){
-   return array(
-      'access chado_analysis_go content',
-      'create chado_analysis_go content',
-      'delete chado_analysis_go content',
-      'edit chado_analysis_go content',
-   );
-}
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_go_access($op, $node, $account){
-   if ($op == 'create') {
-      if(!user_access('create chado_analysis_go content', $account)){
-         return FALSE;
-      }
-   }
-   if ($op == 'update') {
-      if (!user_access('edit chado_analysis_go content', $account)) {
-         return FALSE;
-      }
-   }
-   if ($op == 'delete') {
-      if (!user_access('delete chado_analysis_go content', $account)) {
-         return FALSE;
-      }
-   }
-   if ($op == 'view') {
-      if (!user_access('access chado_analysis_go content', $account)) {
-         return FALSE;
-      }
-   }
-   return NULL;
-}
-/*******************************************************************************
- *
- */
-function tripal_analysis_go_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['tago_org_sum']['info'] = t('Tripal Organism GO Analysis Report');
-         $blocks['tago_org_sum']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['featurego']['info'] = t('Tripal Feature GO Terms');
-         $blocks['featurego']['cache'] = BLOCK_NO_CACHE;
-
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_go content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-                 case 'tago_org_sum':
-                  $block['subject'] = t('GO Summary');
-                  $block['content'] = theme('tripal_organism_go_summary',$node);
-                  break;
-               case 'featurego':
-                  $block['subject'] = t('GO Terms');
-                  $block['content'] = theme('tripal_feature_go_terms',$node);
-                  break;
-               default :
-            }
-            return $block;
-         }
-
-   }
-}
-/*******************************************************************************
- * HOOK: Implementation of hook_nodeapi()
- * Display library information for associated features or organisms
- * This function also provides contents for indexing
- */
-function tripal_analysis_go_nodeapi(&$node, $op, $teaser, $page) {
-
-   switch ($op) {
-      case 'view':
-     
-         if ($teaser) {
-            return;
-         }
-         // add the library to the organism/feature search indexing
-         if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-            $node->content['tripal_analysis_go_search_index'] = array(
-					'#value' => theme('tripal_analysis_go_search_index',$node),
-					'#weight' => 5,
-            );
-         } else if ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
-            $node->content['tripal_analysis_go_search_result'] = array(
-					'#value' => theme('tripal_analysis_go_search_result',$node),
-					'#weight' => 5,
-            );
-         } else {
-            // Show go terms if the organism/feature is not at teaser view
-            switch($node->type){
-               case 'chado_organism':    
-                  $node->content['tripal_organism_go_summary'] = array(
-   				      '#value' => theme('tripal_organism_go_summary',$node),
-		      			'#weight' => 5,
-                  );
-                  break;
-               case 'chado_feature':
-                  $node->content['tripal_feature_go_terms'] = array(
-				         '#value' => theme('tripal_feature_go_terms',$node),
-      					'#weight' => 5,
-                  );
-                  break;
-            }
-         }
-         break;
-   }
-}
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_go_theme () {
-	$path = drupal_get_path('module', 'tripal_analysis_go') . '/theme';
-   return array(
-      'tripal_analysis_go_search_index' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_analysis_go_search_result' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_organism_go_summary' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_organism_go_summary',
-         'path' => $path . '/tripal_organism',
-      ),
-      'tripal_feature_go_terms' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_feature_go_terms',
-         'path' => $path . '/tripal_feature',
-      )
-   );
-}
-/************************************************************************
-*/
-function theme_tripal_analysis_go_search_index($node){
-
-}
-
-/************************************************************************
-*/
-function theme_tripal_analysis_go_search_result($node){
-
-}
-/************************************************************************
-*/
-function tripal_analysis_go_preprocess_tripal_feature_go_terms(&$variables){
-   $feature = $variables['node']->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'];
-   $organism = $node->organism;
-   $organism->tripal_analysis_go->select_form = tripal_analysis_go_load_organism_go_summary($node);
-}
-/************************************************************************
-*/
-function tripal_analysis_go_select_form(&$form_state = NULL,$node){
-
-   $form = array();
-   // find analyses that have GO terms
-   $sql = "
-     SELECT DISTINCT A.analysis_id, A.name, GCA.organism_id
-     FROM {go_count_analysis} GCA
-       INNER JOIN Analysis A on GCA.analysis_id = A.analysis_id
-     WHERE organism_id = %d
-     ORDER BY analysis_id DESC
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$node->organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-   $analyses = array();
-   $analyses[''] = '';
-   while($analysis = db_fetch_object($results)){
-      # check to see if the user has permission to see this analysis
-      $anode = tripal_analysis_get_node($analysis->analysis_id);
-      if(node_access("view",$anode)){
-         $analyses[$analysis->analysis_id."-".$analysis->organism_id] = "$analysis->name";
-      }
-   }
-  
-   # create the select box
-   $form['tripal_analysis_go_select'] = array(
-      '#title' => t('Select a GO report to view'),
-      '#description' => t('Any analysis with GO results related to this organism are available for viewing. For further information, see the analysis information page.'),
-      '#type'  => 'select',
-      '#options' => $analyses,
-      '#attributes' => array (
-         'onchange' => 'tripal_analysis_go_org_charts(this.options[this.selectedIndex].value)'
-      ),
-   );
-   return $form;
-}
-/************************************************************************
-*/
-function tripal_analysis_go_org_charts ($element) {
-   $analysis_id = preg_replace("/^(\d+)-(\d+)$/","$1",$element);
-   $organism_id = preg_replace("/^(\d+)-(\d+)$/","$2",$element);
-   $content = '';
-
-   if($analysis_id and $organism_id){
-      $content = "
-
-        <b>Biological Process</b>
-        <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
-        <div class=\"tripal_cv_tree\"  id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_bp\"></div>
-	<br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_bp\" src=\"\" border=\"0\">	   
-	<br><br><br><br>
-
-        <b>Cellular Component</b>
-        <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
-        <div class=\"tripal_cv_tree\"  id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_cc\"></div>
-        <br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_cc\" src=\"\" border=\"0\">
-
-        <br><br><br><br>
-        <b>Molecular Function</b>       
-        <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
-        <div class=\"tripal_cv_tree\"  id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_mf\"></div>      
-        <br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_mf\" src=\"\" border=\"0\">
-      ";
-   }
-   $opt = array($content);
-   return drupal_json($opt);
-}
-/************************************************************************
-*/
-function tripal_analysis_go_load_organism_go_summary($node) {
-  $organism = $node->organism;
-	
-   // check to see if we have any analyses
-   $sql = "
-     SELECT A.analysis_id
-     FROM {go_count_analysis} GCA
-       INNER JOIN Analysis A on GCA.analysis_id = A.analysis_id
-     WHERE organism_id = %d
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-   # check to ensure we have access to at least one of the GO analyses
-   $has_results = 0;
-   while($analysis = db_fetch_object($results)){
-      $anode = tripal_analysis_get_node($analysis->analysis_id);
-      if(node_access("view",$anode)){
-         $has_results = 1;
-      }
-   }
-   return array (
-      'has_results' => $has_results,
-      'form' => drupal_get_form('tripal_analysis_go_select_form',$node),
-   );
-}
-/************************************************************************
- *
- */
-function tripal_analysis_go_cv_chart($chart_id){
-
-  // The CV module will create the JSON array necessary for buillding a
-  // pie chart using jgChart and Google Charts.  We have to pass to it
-  // a table that contains count information, tell it which column 
-  // contains the cvterm_id and provide a filter for getting the
-  // results we want from the table.
-  $organism_id = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$chart_id);
-  $analysis_id = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$chart_id);
-  $type        = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$3",$chart_id);
-
-  $sql = "SELECT * FROM {Analysis} WHERE analysis_id = %d";
-  $previous_db = tripal_db_set_active('chado');  // use chado database
-  $analysis = db_fetch_object(db_query($sql,$analysis_id));
-  tripal_db_set_active($previous_db);  // now use drupal database  
- 
-  if(strcmp($type,'mf')==0){
-     $class = 'molecular_function';
-     $title = "Number of Molecular Function Terms From $analysis->name Analysis";
-  }
-  if(strcmp($type,'cc')==0){
-     $class = 'cellular_component';
-     $title = "Number of Cellular Component Terms From $analysis->name Analysis";
-  }
-  if(strcmp($type,'bp')==0){
-     $class = 'biological_process';
-     $title = "Number of Biological Process Terms From $analysis->name Analysis";
-  }
-  $options = array(
-     count_mview      => 'go_count_analysis',
-     cvterm_id_column => 'cvterm_id',
-     count_column     => 'feature_count',
-     filter           => "
-        CNT.organism_id = $organism_id AND 
-        CNT.analysis_id = $analysis_id AND 
-        CNT.cvterm_id IN ( 
-          SELECT CVTR.subject_id 
-          FROM {CVTerm_relationship} CVTR 
-            INNER JOIN CVTerm CVT on CVTR.object_id = CVT.cvterm_id
-            INNER JOIN CV on CVT.cv_id = CV.cv_id
-          WHERE CVT.name = '$class' AND  
-                 CV.name = '$class'
-        )
-     ",
-     type             => 'p',
-     size             => '650x260',
-     title            => $title,
-  );
-  return $options;
-}
-/************************************************************************
- *
- */
-function tripal_analysis_go_cv_tree($tree_id){
-
-  $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
-  $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
-  $type        = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$3",$tree_id);
-
-  if(strcmp($type,'mf')==0){
-     $class = 'molecular_function';
-  }
-  if(strcmp($type,'cc')==0){
-     $class = 'cellular_component';
-  }
-  if(strcmp($type,'bp')==0){
-     $class = 'biological_process';
-  }
-
-  $options = array(
-     cv_id            => tripal_cv_get_cv_id($class),
-     count_mview      => 'go_count_analysis',
-     cvterm_id_column => 'cvterm_id',
-     count_column     => 'feature_count',
-     filter           => "CNT.organism_id = $organism_id AND CNT.analysis_id = $analysis_id",
-     label            => 'Features',
-  );
-  return $options;
-}
-/************************************************************************
-*/
-function tripal_analysis_go_cvterm_add($cvterm_id,$tree_id){
-  $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
-  $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
-
-  $sql = "
-     SELECT DBX.accession
-     FROM {cvterm} CVT
-       INNER JOIN dbxref DBX on DBX.dbxref_id = CVT.dbxref_id
-     WHERE cvterm_id = %d
-  ";
-  $previous_db = tripal_db_set_active('chado');
-  $xref = db_fetch_object(db_query($sql,$cvterm_id));
-  tripal_db_set_active($previous_db);
-
-  $link = url("download_goterm_features/$cvterm_id/$tree_id");
-  $options = array(
-     'Download sequences' => "<a href=\"$link\">GO_".$xref->accession.".fasta</a>",
-  );
-  return $options;
-}
-/************************************************************************
-*/
-function tripal_analysis_go_get_goterm_features($cvterm_id,$tree_id){
-
-   // get hte accession number for this cvterm and use it in naming the download
-   $sql = "
-      SELECT DBX.accession
-      FROM {cvterm} CVT
-        INNER JOIN dbxref DBX on DBX.dbxref_id = CVT.dbxref_id
-      WHERE cvterm_id = %d
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $xref = db_fetch_object(db_query($sql,$cvterm_id));
-   tripal_db_set_active($previous_db);
-
-   drupal_set_header('Content-Type: text');
-   drupal_set_header('Content-Disposition: attachment; filename="GO_'.$xref->accession.'.fasta"');
-
-   $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
-   $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
-   $sql = "
-      SELECT DISTINCT F.name,F.residues,F.feature_id
-      FROM {cvtermpath} CVTP
-         INNER JOIN CVTerm CVT1 on CVTP.subject_id = CVT1.cvterm_id
-         INNER JOIN CVTerm CVT2 on CVTP.object_id = CVT2.cvterm_id
-         INNER JOIN AnalysisFeatureProp AFP on AFP.type_id = CVTP.subject_id 
-         INNER JOIN AnalysisFeature AF on AF.analysisfeature_id = AFP.analysisfeature_id
-         INNER JOIN Feature F on AF.feature_id = F.feature_id
-      WHERE CVTP.object_id = %d and F.organism_id = %d and AF.analysis_id = %d
-      ORDER BY F.name
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$cvterm_id,$organism_id,$analysis_id);
-   tripal_db_set_active($previous_db);
-   while($feature = db_fetch_object($results)){
-      // get the go term information for each sequence
-      $sql = "
-         SELECT CVT.name,DBX.accession 
-         FROM {Feature_CVTerm} FCVT 
-           INNER JOIN CVTerm CVT on FCVT.cvterm_id = CVT.cvterm_id
-           INNER JOIN DBXref DBX on CVT.dbxref_id = DBX.dbxref_id
-         WHERE FCVT.feature_id = %d
-      ";
-
-      $previous_db = tripal_db_set_active('chado');
-      $terms = db_query($sql,$feature->feature_id);
-      tripal_db_set_active($previous_db);
-      $desc = '[';
-      while($term = db_fetch_object($terms)){
-         $desc .= "GO:$term->accession $term->name; ";
-      }
-      $desc = chop($desc);
-      $desc = chop($desc,';');
-      $desc .= ']';
-      print tripal_feature_return_fasta($feature, $desc);   
-   }
-   return;
-}
-/************************************************************************
-*/
-function tripal_analysis_go_load_feature_terms($feature) {
-   $sql = "
-       SELECT DISTINCT FCVT.feature_id,DBX.accession,CVT.name as goterm, 
-          CVT.cvterm_id as go_id, CV.name as cvname, CVT.definition
-       FROM {Feature_Cvterm} FCVT  
-          INNER JOIN Cvterm CVT           ON CVT.cvterm_ID = FCVT.cvterm_ID
-          INNER JOIN CV                   ON CV.cv_id = CVT.cv_id  
-          INNER JOIN dbxref DBX           ON DBX.dbxref_id = CVT.dbxref_id
-        WHERE      
-          (CV.name = 'biological_process' OR 
-           CV.name = 'cellular_component' OR 
-           CV.name = 'molecular_function') AND 
-          FCVT.feature_id = %d
-        ORDER BY CV.name, CVT.name
-   ";
-
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$feature->feature_id);
-   tripal_db_set_active($previous_db);
-   $i=0;
-   $terms = array();
-   while($term = db_fetch_object($results)){
-
-      $terms[$i++] = $term;
-   }
-   return $terms;
-}
-
-/*******************************************************************************
- * Tripal GO administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_go_get_settings() {
-   // Get an array of node types with internal names as keys
-   $options = node_get_types('names');
-   // Add 'chado_feature' to allowed content types for showing unigene results
-   $allowedoptions ['chado_feature'] = "Show GO terms on feature pages";
-   $allowedoptions ['chado_organism'] = "Show GO analysis on organism pages";
-
-   $form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("This option allows user to display the Gene Ontology (GO) ".
-          "information. For features, this would include all GO terms assigned to a feature ".
-          "and for organisms this would be statistical pie charts of GO terms for a organism. Check the box to ".
-          "enable the display of GO information. Uncheck to disable."),
-       '#weight' => 0,
-   );
-
-   $form['tripal_analysis_go_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value'=>variable_get('tripal_analysis_go_setting',array('chado_feature', 'chado_organism')),
-   );
-   $settings->form = $form;
-   $settings->title = "Tripal GO";
-   return $settings;
-}
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_analysis_go_job_describe_args($callback,$args){
-
-   $new_args = array();
-   if($callback == 'tripal_analysis_go_load_gaf'){
-      
-      $new_args['GAF 2.0 file'] = $args[0];
-
-      $organism = tripal_core_chado_select('organism',array('genus','species'),array('organism_id' => $args[1]));
-      $new_args['Organism'] = $organism[0]->genus." ". $organism[0]->species;
-      $new_args['Sequence Type'] = $args[7];
-      if(!$args[8]){
-        $new_args['Use Unique Name'] = 'No';
-      } else {
-        $new_args['Use Unique Name'] = 'Yes';
-      }
-
-      // add in the analysis 
-      if($args[2]){
-         $analysis = tripal_core_chado_select('analysis',array('name'),array('analysis_id' => $args[2]));
-      }
-      $new_args['Analysis'] = $analysis[0]->name;
-
-      if($args[3]){
-        $new_args['Function to perform'] = 'Add GO terms';
-      }
-      if($args[4]){
-        $new_args['Function to perform'] = 'Replace GO terms';
-      }
-      if($args[5]){
-        $new_args['Function to perform'] = 'Delete GO terms';
-      }
-
-      $new_args['Regular expression for the feature name'] = $args[6];
-
-
-   }
-   return $new_args;
-}

+ 0 - 584
extensions/tripal_analysis_interpro/includes/parseInterpro.inc

@@ -1,584 +0,0 @@
-<?php
-
-/*******************************************************************************
- * Parse Interpro HTML Output file into analysisfeatureprop table
- */
-function tripal_analysis_interpro_parseHTMLFile ($analysis_id, $interprofile, $parsego, $job_id) {
-
-	// Prepare log
-	$filename = preg_replace("/.*\/(.*)/", "$1", $interprofile);
-        $logfile = tempnam(sys_get_temp_dir(),"tripal_analysis_interpro_import");
-        $log = fopen($logfile, 'a'); // append parsing results to log file
-        if(!$log){
-           print "ERROR: cannot open log file: $logfile\n";
-           exit;
-        }
-
-	// Parsing started
-	print "Parsing File:".$interprofile." ...\n";
-	fwrite($log, date("D M j G:i:s Y").". Loading $interprofile\n");
-
-	// Get cvterm_id for 'analysis_interpro_output_iteration_hits' which is required
-	// for inserting into the analysisfeatureprop table
-	$previous_db = tripal_db_set_active('chado'); // use chado database
-	$sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT ".
-          "INNER JOIN cv ON cv.cv_id = CVT.cv_id ".
-          "WHERE CVT.name = 'analysis_interpro_output_hit' ".
-          "AND CV.name = 'tripal'";
-	$type_id = db_result(db_query($sql));
-	print "cvterm_id for analysis_interpro_output_iteration_hits is $type_id\n";
-
-	// Load the HTML file and convert it into XML for loading
-	$dom = new domDocument;
-	$dom->loadHTMLFile($interprofile);
-	$xml = $dom->saveXML();
-	$interproput = simplexml_load_string($xml);
-
-	// Get html tables for parsing
-	$tables = $interproput->children()->children();
-
-	// Count the number of tables to be processed
-	$no_iterations = 0;
-	foreach($tables as $tmp) {
-		if ($tmp->getName() == 'table') {
-			$no_iterations ++;
-		}
-	}
-	print "$no_iterations html tables to be processed.\n";
-	$interval = intval($no_iterations * 0.01);
-	$idx_iterations = 0;
-
-	// Processed the tables
-	foreach ($tables as $table) {
-        //if (preg_match('/No hits reported/', $table->asXML()) ) {
-            //print "skipping this table b/c no hits are reported\n";
-        //}
-        // make sure we are looking at a table and its not an empty table
-        if ($table->getName() == 'table' && !preg_match('/No hits reported/', $table->asXML()) ) {
-            $idx_iterations ++;
-            if ($idx_iterations % $interval == 0) {
-                    $percentage = (int) ($idx_iterations / $no_iterations * 100);
-                    tripal_db_set_active($previous_db);
-                    tripal_job_set_progress($job_id, $percentage);
-                    $previous_db = tripal_db_set_active('chado');
-                    print $percentage."% ";
-            }
-
-            // Set job status
-            // Get the first row and match its name with the feature name
-            $firsttd = $table->children()->children()->children();
-            $feature_id = 0;
-            foreach($firsttd as $b) {
-                foreach($b->children() as $a) {
-                    if ($a->getName() == 'a') {
-                        // Remove _ORF from the sequence name
-                        $seqname = preg_replace('/^(.+?)_\d_.+/', "$1", $a);
-                        print "seqname is $seqname\n";
-    
-                        // Find out how many features match this uniquename
-                        $sql = "SELECT count(feature_id) FROM {feature} ".
-                        "WHERE uniquename = '%s' ";
-                        $no_features = db_result(db_query($sql, $seqname));
-						    
-                        // If there is only one match, get the feature_id
-                        if ($no_features == 1) {
-                            $sql = "SELECT feature_id FROM {feature} ".
-                                    "WHERE uniquename = '%s' ";
-                            $feature_id = db_result(db_query($sql, $seqname));
-                            print "\tfeature id is $feature_id\n";
-    
-                            // If the uniquename matches more than one features then skip and print 'Ambiguous'
-                        } else if ($no_features > 1) {
-                            fwrite($log, "Ambiguous: ".$seqname." matches more than one feature and is not processed.\n");
-                            continue;
-    
-                        // If the uniquename did not match, skip and print 'Failed'
-                        } else {
-                            fwrite($log, "Failed: ".$seqname."\n");
-                        }
-    
-                    }
-                }
-            }
-
-            // Successfully matched. print 'Succeeded'. Add analysis_id and
-            // feature_id to analysisfeature. Add the table as XML to analysisfeatureprop
-            if ($feature_id) {
-
-                //------------------------------------
-                // Clease unwanted rows from the table
-                //------------------------------------
-
-                $parent_row =   "/<tr><td valign=\"top\"><b>Parent<\/b><\/td>\s*<td valign=\"top\">\s*no.*?parent<\/td>\s*<\/tr>/";
-                $children_row = "/<tr><td valign=\"top\"><b>Children<\/b><\/td>\s*<td valign=\"top\">\s*no.*?children<\/td>\s*<\/tr>/";
-                $found_row    = "/<tr><td valign=\"top\"><b>Found.*?in<\/b><\/td>\s*<td valign=\"top\">\s*no.*?entries<\/td>\s*<\/tr>/";
-                $contains_row = "/<tr><td valign=\"top\"><b>Contains<\/b><\/td>\s*<td valign=\"top\">\s*no.*?entries<\/td>\s*<\/tr>/";
-                $go_row       = "/<tr><td valign=\"top\"><b>GO.*?terms<\/b><\/td>\s*<td valign=\"top\">\s*none<\/td>\s*<\/tr>/";
-    
-                $table_txt = $table->asXML();
-                $table_txt = preg_replace($parent_row, "", $table_txt);
-                $table_txt = preg_replace($children_row, "", $table_txt);
-                $table_txt = preg_replace($found_row, "", $table_txt);
-                $table_txt = preg_replace($contains_row, "", $table_txt);
-                $table_txt = preg_replace($go_row, "", $table_txt);
-
-                //------------------------------------
-                // Clease unwanted ORF link from table 
-                //------------------------------------
-                $orf_link = "/<b><a href=\"\/iprscan\/wget.*?\">(.*?)<\/a><\/b>/";
-                $table_txt = preg_replace($orf_link, "$1", $table_txt);
-
-                //print "----------------------------\n";
-                //print "old: ".$table->asXML()."\n\n\n";
-                //print "----------------------------\n";
-                //print "Fixed: $table_txt\n";
-                //print "----------------------------\n";
-
-                //------------------------------------
-                // If this feature has already been associated with this analysis, do not reinsert
-                // Otherwise, Insert into analysisfeature table
-                //------------------------------------
-                $sql = "Select analysisfeature_id as id from {analysisfeature} where feature_id = %d and analysis_id = %d";
-                $analysisfeature =  db_fetch_object(db_query($sql, $feature_id, $analysis_id));
-                if($analysisfeature){ $analysisfeature_id = $analysisfeature->id; }
-                if(!$analysisfeature_id){
-                    print "inserting analysisfeature\n";
-                   $sql = "INSERT INTO {analysisfeature} (feature_id, analysis_id) ".
-                        "VALUES (%d, %d)";
-                   db_query ($sql, $feature_id, $analysis_id);
-                   $sql = "Select analysisfeature_id from {analysisfeature} where feature_id = %d and analysis_id = %d";
-                   $analysisfeature =  db_fetch_object(db_query($sql, $feature_id, $analysis_id));
-                   $analysisfeature_id = $analysisfeature->id;
-                }
-
-                print "analysisfeature_id is $analysisfeature_id (analysis_id = $analysis_id; feature_id = $feature_id)\n";
-
-
-                // Get the higest rank for this feature_id in analysisfeatureprop table.
-                // If the value of the inserting content is not duplicate, add it to  
-                // analysisfeaturepro with 'higest_rank + 1'
-                $sql = "SELECT MAX(rank) FROM {analysisfeatureprop} AFP ".
-                        "INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id ".       
-                        "WHERE feature_id=%d ".
-                        "AND analysis_id=%d ".
-                        "AND type_id=%d ";
-
-                $afp =  db_fetch_object(db_query($sql, $feature_id, $analysis_id, $type_id));
-                $hi_rank = 0;
-                if ($afp) {
-                    $hi_rank = $afp->max + 1;
-                }
-            
-				//------------------------------------------------------------
-				// Insert interpro html tags into analysisfeatureprop table
-				//------------------------------------------------------------
-				// Before inserting, make sure it's not a duplicate
-				$sql = "SELECT value FROM {analysisfeatureprop} WHERE analysisfeature_id = %d AND type_id = %d";
-				$result = db_query($sql, $analysisfeature_id, $type_id);
-				$duplicate = 0;
-				while ($afp_value = db_fetch_object($result)) {
-				    if ($table_txt == $afp_value->value) {
-                        $duplicate = 1;
-				    }
-				}
-				if (!$duplicate) {
-				    $sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank)".
-                            "VALUES (%d, %d, '%s', %d)";
-				    db_query($sql, $analysisfeature_id, $type_id, $table_txt, $hi_rank);
-				    fwrite($log, " (Insert)\n"); // write to log
-                    print "\twriting table\n";
-				} else {
-				   fwrite($log, " (Skipped)\n");
-                    print "\tskipping table - dup\n";
-				}
-				
-                // Parse GO terms. Make sure GO database schema is installed in chado
-                $go_db_id = db_result(db_query("SELECT db_id FROM {db} WHERE name='GO'"));
-                if (!$go_db_id) {
-                    print 'GO schema not installed in chado. GO terms are not processed.';
-                }
-                if ($go_db_id && $parsego) {
-                    $trs = $table->children();
-                    foreach ($trs as $tr) {
-                        $tds = $tr->children();
-                        foreach($tds as $td) {
-                            $gotags = $td->children();
-                            foreach ($gotags as $gotag) {
-                                // Look for 'GO:accession#'
-                                if (preg_match("/^.*?GO:(\d+).*$/", $gotag, $matches)) {
-                        	
-                                    // Find cvterm_id for the matched GO term
-                                    $sql = "SELECT cvterm_id FROM {cvterm} CVT 
-                                            INNER JOIN dbxref DBX ON CVT.dbxref_id = DBX.dbxref_id
-                                            WHERE DBX.accession = '%s' AND DBX.db_id = %d";
-                                    $goterm_id = db_result(db_query($sql, $matches[1], $go_db_id));
-                           
-                                    //-------------------------------------------
-                                    // Insert GO terms into feature_cvterm table
-                                    //-------------------------------------------
-                                    // Default pub_id = 1 (NULL) was used
-                                    $sql = "INSERT INTO {feature_cvterm} (feature_id, cvterm_id, pub_id)
-                                            VALUES (%d, %d, 1)";
-                                    db_query($sql, $feature_id, $goterm_id);
-
-                                    //------------------------------------------------
-                                    // Insert GO terms into analysisfeatureprop table
-                                    //------------------------------------------------
-                                    $sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank) ".
-                                            "VALUES (%d, %d, '%s', 0)";
-                                    db_query($sql, $analysisfeature_id, $goterm_id, $matches[1]);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    tripal_db_set_active ($previous_db); // Use drupal database
-    print "Done.\nSuccessful and failed entries have been saved in the log file:\n $logfile\n";
-	
-    fwrite($log, "\n");
-    fclose($log);
-    return;
-}
-/**
-*
-*/
-function tripal_analysis_interpro_parseXMLFile ($analysis_id, $interproxmlfile, 
-   $parsego, $query_re, $query_type, $query_uniquename, $job_id) 
-{
-   // clear out the anslysisfeature table for this analysis before getting started
-   tripal_core_chado_delete('analysisfeature',array('analysis_id' => $analysis_id));
-
-   // If user input a file (e.g. blast.xml)
-	if (is_file($interproxmlfile)) {
-      tripal_analysis_interpro_parseSingleXMLFile ($analysis_id, $interproxmlfile, 
-         $parsego, $query_re, $query_type, $query_uniquename, $job_id);
-   } 
-   else {
-		$dir_handle = @opendir($interproxmlfile) or die("Unable to open $interproxmlfile");
-		$pattern = sql_regcase($interproxmlfile . "/*.xml");
-		$total_files = count(glob($pattern));
-		print "$total_files file(s) to be parsed.\n";
-		
-		$interval = intval($total_files * 0.01);
-      if($interval == 0){
-         $interval = 1;
-      }
-		$no_file = 0;
-			
-		// Parsing all files in the directory
-		while ($file = readdir($dir_handle)) {
-			if(preg_match("/^.*\.xml/i",$file)){
-
-            tripal_analysis_interpro_parseSingleXMLFile ($analysis_id, "$interproxmlfile/$file", 
-               $parsego, $query_re, $query_type, $query_uniquename, $job_id,0);
-
-			   // Set job status
-			   if ($no_file % $interval == 0) {
-			      $percentage = (int) (($no_file / $total_files) * 100);
-				   tripal_job_set_progress($job_id, $percentage);
-				   print $percentage."% ";
-			   }				
-         }
-   	   $no_file ++;
-		}
-	}
-
-	print "Done.";
-}
-/**
-*
-*/
-function tripal_analysis_interpro_parseSingleXMLFile ($analysis_id, $interproxmlfile, 
-   $parsego, $query_re, $query_type, $query_uniquename, $job_id,$uptate_status = 1) 
-{
-
-   // Parsing started
-   print "Parsing File:".$interproxmlfile." ...\n";
-
-
-   // Get cvterm_id for 'analysis_interpro_xmloutput_hits' which is required
-   // for inserting into the analysisfeatureprop table
-   $previous_db = db_set_active('chado'); // use chado database
-   $sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT ".
-          "   INNER JOIN cv ON cv.cv_id = CVT.cv_id ".
-          "WHERE CVT.name = 'analysis_interpro_xmloutput_hit' ".
-          "   AND CV.name = 'tripal'";
-   $type_id = db_result(db_query($sql));
-
-   // Load the XML file
-   $xml =  simplexml_load_file($interproxmlfile);
-
-   // If there is an EBI header then we need to skip that
-   // and set our proteins array to be the second element of the array. This
-   // occurs if results were generated with the online InterProScan tool.
-   // if the XML starts in with the results then this happens when InterProScan
-   // is used command-line and we can just use the object as is
-   if(preg_match('/^EBIInterProScanResults/',$xml->getname())){
-      $children = $xml->children();
-      $header = $children[0];
-      $proteins = $children[1];
-   } 
-   // if the XML starts with the <interpro_matches> tag
-   elseif(preg_match('/^interpro_matches/',$xml->getname())) {
-      $proteins = $xml;
-   }
-   else {
-      print "ERROR: cannot parse XML file format is not recognized\n";
-      return;
-   }
-
-   // Count the number of entires to be processed
-   $no_iterations = 0;
-   foreach($proteins as $protein) {
-      $no_iterations ++;
-   }
-   print "  Found results for $no_iterations sequences\n";
-   $interval = intval($no_iterations * 0.01);
-   if($interval == 0){
-      $interval = 1;
-   }
-   $idx_iterations = 0;
-
-   // get the DB id for the GO database
-   $parsego = tripal_analysis_get_property($analysis_id,'analysis_interpro_parsego');
-   $go_db_id = db_result(db_query("SELECT db_id FROM {db} WHERE name='GO'"));
-   if ($parsego and !$go_db_id) {
-     print 'GO schema not installed in chado. GO terms are not processed.';;
-   }
-
-   // Processed each protein
-   foreach ($proteins as $protein) {
-
-      // Set job status
-      $idx_iterations ++;
-      if ($idx_iterations % $interval == 0 and $update_status) {
-         $percentage = (int) ($idx_iterations / $no_iterations * 100);
-         db_set_active($previous_db);
-         tripal_job_set_progress($job_id, $percentage);
-         $previous_db = db_set_active('chado');
-         print $percentage."% ";
-      }
-
-      // match the protein id with the feature name
-      $feature_id = 0;
-      $attr = $protein->attributes();
-      $seqname =$attr ['id'];
-
-      // is the sequence name a generic name (i.e. 'Sequence_1') then the 
-      // blast results do not contain the original sequence names.  The only
-      // option we have is to use the filename.  This will work in the case of
-      // Blast2GO which stores the XML for each sequence in a file with the
-      // the filename the name of the sequence
-      if(preg_match('/Sequence_\d+/',$seqname)){
-         $filename = preg_replace('/^.*\/(.*).xml$/', '$1', $interproxmlfile);
-         print "  Sequence name is not specific, using filename: $filename\n";
-         $seqname = $filename;   
-      }
-
-      // Remove _ORF from the sequence name
-      $seqname = preg_replace('/^(.+)_\d+_ORF\d+.*/', '$1', $seqname);
-     
-      // if a regular expression is provided then pick out the portion requested
-		if ($query_re and preg_match("/$query_re/", $seqname, $matches)) {
-			$feature = $matches[1];
-		} 
-      // If no match by the regular expression then get everything up to the first space
-      else {
-			if (preg_match('/^(.*?)\s.*$/',  $seqname, $matches)) {
-				$feature = $matches[1];
-         } 
-         // if no match up to the first space then just use the entire string
-         else {
-            $feature =  $seqname;
-         }
-      }   
-
-      if(!$feature and $query_re){
-         print "Failed: Cannot find feature for '$seqname' using the regular expression: $query_re\n";
-         continue;
-      }
-
-      // now find the feature in chado
-      $select = array();
-      if($query_uniquename){
-         $select['uniquename'] = $feature;
-      } else {
-         $select['name'] = $feature;
-      }
-      if($query_type){
-         $select['type_id'] = array(
-           'cv_id' => array(
-              'name' => 'sequence'
-           ),
-           'name' => $query_type,
-         );
-      }
-
-      $feature_arr = tripal_core_chado_select('feature',array('feature_id'),$select);
-      if(count($feature_arr) > 1){
-		   print "Ambiguous: '$feature' matches more than one feature and is being skipped.\n";
-			continue;
-      }
-      if(count($feature_arr) == 0){
-			print "Failed: cannot find a matching feature for '$feature' in the database.\n";
-         continue;
-      }
-      $feature_id = $feature_arr[0]->feature_id;
-
-     
-      // Successfully matched. print 'Succeeded'. Add analysis_id and
-      // feature_id to analysisfeature. Add the table as XML to analysisfeatureprop
-      if ($feature_id) {
-
-         print "  Adding InterPro results for feature '$seqname' ($feature_id)\n";
-
-         // Insert into analysisfeature table only if it doesn't already exist
-         $values = array('feature_id' => $feature_id, 'analysis_id' => $analysis_id);
-         $analysisfeature = tripal_core_chado_select('analysisfeature',array('*'),$values);
-         if(sizeof($analysisfeature) == 0){
-            $analysisfeature = tripal_core_chado_insert('analysisfeature',$values);
-            $analysisfeature_id = $analysisfeature['analysisfeature_id'];
-         } else {
-            $analysisfeature_id = $analysisfeature[0]->analysisfeature_id;
-         }
-
-         // Insert interpro xml results into analysisfeatureprop table
-         // Check to see if we have an existing entry
-         $sql = "SELECT analysisfeatureprop_id,rank 
-                 FROM {analysisfeatureprop} 
-                 WHERE analysisfeature_id = %d AND type_id = %d 
-                 ORDER BY rank DESC";
-         $result = db_fetch_object(db_query($sql, $analysisfeature_id, $type_id));
-         $rank = 0;
-         if($result){
-            $afp_id = $result->analysisfeatureprop_id; 
-            $rank = $result->rank + 1; 
-         }
-         $sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank)".
-                "VALUES (%d, %d, '%s', %d)";
-         db_query($sql, $analysisfeature_id, $type_id, $protein->asXML(), $rank);
-
-         // parse the XML for each protein if GO terms are requested
-         if($parsego and $go_db_id){		
-
-            $protein = tripal_analysis_interpro_get_result_object($protein->asXML(),$feature_id); 
-            $goterms = $protein['goterms'];                 
-
-            // cycle through the GO terms and add them to the database
-            foreach($goterms as $goterm){ 
-                   
-               // seperate the 'GO:' from the term
-               if (preg_match("/^.*?GO:(\d+).*$/", $goterm, $matches)) {
-
-                  // Find cvterm_id for the matched GO term
-                  $sql = "SELECT cvterm_id FROM {cvterm} CVT 
-                          INNER JOIN dbxref DBX ON CVT.dbxref_id = DBX.dbxref_id
-                          WHERE DBX.accession = '%s' AND DBX.db_id = %d";
-                  $goterm_id = db_result(db_query($sql, $matches[1], $go_db_id));
-
-                  // Insert GO terms into feature_cvterm table
-                  // Default pub_id = 1 (NULL) was used
-                  $values = array('feature_id' => $feature_id, 'cvterm_id' => $goterm_id, 'pub_id' => 1);
-                  $feature_cvterm = tripal_core_chado_select('feature_cvterm',array('*'),$values);
-                  if(sizeof($feature_cvterm) == 0){
-                     $feature_cvterm = tripal_core_chado_insert('feature_cvterm',$values);
-                  }
-
-                  // Insert GO terms into analysisfeatureprop table
-                  $values = array('analysisfeature_id' => $analysisfeature_id,
-                                  'type_id' => $goterm_id,
-                                  'rank' => 0);
-                  $analysisfeatureprop = tripal_core_chado_select('analysisfeatureprop',array('*'),$values);
-                  if(sizeof($analysisfeatureprop) == 0){
-                     $values['value'] = $matches[1];
-                     $analysisfeatureprop = tripal_core_chado_insert('analysisfeatureprop',$values);
-                  }
-               } // end if preg_match
-            } // end for each goterm
-         } // end if($parsego and $go_db_id)
-      } // end if($feature_id)            
-   } // end foreach ($proteins as $protein)
-   db_set_active ($previous_db); // Use drupal database
-
-   return;
-}
-/********************************************************************************
- * 
- */
-function tripal_analysis_interpro_get_result_object($interpro_xml,$feature_id){
-
-	// Load the XML into an object
-	$xmlObj = simplexml_load_string($interpro_xml);
-
-   // iterate through each interpro results for this protein
-   $results = array();
-   $terms = array();
-   $protein = array();
-   $iprterms = array();
-   $goterms = array();
-
-   $term_count = 0;
-   $match_count = 0;
-   
-   // get the properties of this result
-   $attr = $xmlObj->attributes();
-   $protein['orf_id'] = (string) $attr["id"];
-   $protein['orf_length'] = (string) $attr["length"];
-   $protein['orf_crc64'] = (string) $attr["crc64"];
-   
-	foreach($xmlObj->children() as $intepro){
-      // get the interpro term for this match
-      $attr = $intepro->attributes();
-	   $terms[$term_count]['ipr_id'] = (string) $attr["id"];
-	   $terms[$term_count]['ipr_name'] = (string) $attr["name"];
-	   $terms[$term_count]['ipr_type'] = (string) $attr["type"];
-      $iprterms[] = array($terms[$term_count]['ipr_id'],$terms[$term_count]['ipr_name']);
- 
-      // iterate through the elements of the interpro result
-      $matches[$term_count]['matches'] = array();
-      $match_count = 0;
-  	   foreach($intepro->children() as $level1){
-			$element_name = $level1->getName();
-			if($element_name == 'match'){
-            // get the match name for this match
-            $attr = $level1->attributes();
-	         $terms[$term_count]['matches'][$match_count]['match_id'] = (string) $attr["id"];
-	         $terms[$term_count]['matches'][$match_count]['match_name'] = (string) $attr["name"];
-	         $terms[$term_count]['matches'][$match_count]['match_dbname'] = (string) $attr["dbname"];
-            
-            // get the location information for this match     
-            $loc_count = 0;
-            foreach($level1->children() as $level2){
-			      $element_name = $level2->getName();
-			      if($element_name == 'location'){
-                  $attr = $level2->attributes();
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_start'] = (string) $attr["start"];
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_end'] = (string) $attr["end"];
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_score'] = (string) $attr["score"];
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_status'] = (string) $attr["status"];
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_evidence'] = (string) $attr["evidence"];
-                  $loc_count++;
-               }
-            }
-            $match_count++;
-         }
-
-			if($element_name == 'classification'){
-            $attr = $level1->attributes();
-            if($attr['class_type'] == 'GO'){
-               $terms[$term_count]['matches'][$match_count]['go_terms'][] = (string) $attr['id'];
-               $goterms[] = (string) $attr['id'];
-            }
-         }
-      }
-      $term_count++;
-	}
-   $results['terms'] = $terms;
-   $results['orf'] = $protein;
-   $results['iprterms'] = $iprterms;
-   $results['goterms'] = $goterms;
-	return $results;
-}

+ 0 - 100
extensions/tripal_analysis_interpro/node-chado_analysis_interpro.tpl.php

@@ -1,100 +0,0 @@
-<?php
-// Purpose: This template provides the layout of the organism node (page)
-//   using the same templates used for the various feature content blocks.
-//
-// To Customize the Featture Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//   - Block Templates: customize the content/layout of each block of stock 
-//       content. These templates are found in the tripal_stock subdirectory
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, type, title, taxonomy. It also includes stock
-//       specific fields such as stock_name, uniquename, stock_type, synonyms,
-//       properties, db_references, object_relationships, subject_relationships,
-//       organism, etc.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($variables,TRUE).'</pre>';
-drupal_add_css('./tripal-node-templates.css');
-
-$node = $variables['node'];
-$organism = $variables['node']->organism;
-?>
-
-<?php if ($teaser) { 
-  include(drupal_get_path('module' , 'tripal_analysis_interpro') . '/theme/tripal_analysis_interpro/tripal_analysis_interpro_teaser.tpl.php'); 
-} else { ?>
-
-<script type="text/javascript">
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_analysis_interpro_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_interpro_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show the corresponding item in the details box
-      $(".tripal_analysis_interpro_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // we want to make sure our table of contents and the details
-         // box stay the same height
-         $("#tripal_analysis_interpro_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // we want the base details to show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-      if(block == null){
-         block = window.location.href.match(/[\?|\&]block=(.+)/)
-      }
-      if(block != null){
-         $("#tripal_analysis_interpro-"+block[1]+"-box").show();
-      } else {
-         $("#tripal_analysis_interpro-base-box").show();
-      }
-
-      $("#tripal_analysis_interpro_toc").height($("#tripal_analysis_interpro-base-box").parent().height());
-      
-   });
-}
-</script>
-
-
-<div id="tripal_analysis_interpro_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php include('theme/tripal_analysis_interpro/tripal_analysis_interpro_base.tpl.php'); ?>
-
-   <?php print $content ?>
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_analysis_interpro_toc" class="tripal_toc">
-   <div id="tripal_analysis_interpro_toc_title" class="tripal_toc_title">Resources</i></div>
-   <span id="tripal_analysis_interpro_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_analysis_interpro_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-
-<?php } ?>

+ 0 - 44
extensions/tripal_analysis_interpro/theme/css/tripal_analysis_interpro.css

@@ -1,44 +0,0 @@
-
-.tripal_interpro-info-box {
-   margin-top: 10px;
-   margin-left: 0px;
-   margin-right: 0px;
-   margin-bottom: 0px;
-   padding-top: 0px;
-   padding-left: 0px;
-   padding-bottom: 0px;
-   padding-right: 0px;
-   border-collapse: collapse;
-   z-index: 10;
-}
-
-.tripal_interpro_results_table {
-   margin-left: auto;
-   margin-right: auto;
-}
-
-.tripal_interpro_results_table tbody {
-    border-top: none;
-}
-
-.tripal_interpro_results_table tbody tr td table{
-   background: #FFFFFF;
-}
-
-.tripal_interpro_results_table tbody tr td table tr{
-   background: #FFFFFF;
-}
-
-.tripal_interpro_results_table tbody tr td table tr td{
-   background: #FFFFFF;
-}
-/* feature node sepcific template */
-.tripal_feature_interpro-results-table {
-   padding-top: 10px;
-   padding-bottom: 10px;
-}
-.tripal_feature-interpro_results_subtitle{
-   padding-top: 10px;
-   padding-bottom: 10px;
-   font-weight: bold;
-}

+ 0 - 29
extensions/tripal_analysis_interpro/theme/js/tripal_analysis_interpro.js

@@ -1,29 +0,0 @@
-if (Drupal.jsEnabled) {
-   
-   $(document).ready(function(){
-	   var fontcolor = $(".interpro_results_table tbody tr td table tbody tr td b a").parent().prev().css('color');
-	   // Disable the hyperlink for sequences in the interpro box
-	   $(".tripal_interpro_results_table tbody tr td table tbody tr td b a").removeAttr('href');
-	   $(".tripal_interpro_results_table tbody tr td table tbody tr td b a").css('font-weight','normal');
-	   $(".tripal_interpro_results_table tbody tr td table tbody tr td b a").css('text-decoration','none');
-	   $(".tripal_interpro_results_table tbody tr td table tbody tr td b a").css('color',fontcolor);
-	   
-	   // Allow selection of "Load GO term to the database" only when the submitting job to parse
-	   // html output is enabled
-	   isSubmittingJob ();
-   });
-   
-   // Disable parse GO checkbox if no interpro job is submitted
-   function isSubmittingJob () {
-	   if ($('#edit-interprojob').is(":checked")) {
-		   var fontcolor = $("#edit-parsego").parent().parent().prev().children().css('color');
-		   $("#edit-parsego").attr('disabled', false);
-		   $("#edit-parsego-wrapper").css("color", fontcolor);
-		   
-	   } else {
-		   $("#edit-parsego").attr('checked', false);
-		   $("#edit-parsego").attr('disabled', true);
-		   $("#edit-parsego-wrapper").css("color", "grey");
-	   }
-   }
-}

+ 0 - 56
extensions/tripal_analysis_interpro/theme/tripal_analysis_interpro/tripal_analysis_interpro_base.tpl.php

@@ -1,56 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-$interpro = $node->analysis->tripal_analysis_interpro;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-?>
-<div id="tripal_analysis_interpro-base-box" class="tripal_analysis_interpro-info-box tripal-info-box">
-  <div class="tripal_analysis_interpro-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis_interpro-table-base" class="tripal_analysis_interpro-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis_interpro-table-even-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_interpro-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis_interpro-table-even-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis_interpro-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis_interpro-table-even-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>      
-      <tr class="tripal_analysis_interpro-table-odd-row tripal-table-odd-row">
-        <th nowrap>InterProScan Arguments</th>
-        <td><?php print $interpro->interproparameters ?></td>
-      </tr>        	                                
-   </table>   
-</div>

+ 0 - 53
extensions/tripal_analysis_interpro/theme/tripal_analysis_interpro/tripal_analysis_interpro_teaser.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 128
extensions/tripal_analysis_interpro/theme/tripal_feature/tripal_feature_interpro_results.tpl.php

@@ -1,128 +0,0 @@
-<?php
-$feature  = $variables['node']->feature;
-$results = $feature->tripal_analysis_interpro->results->xml;
-$resultsHTML = $feature->tripal_analysis_interpro->results->html;
-
-if(count($results) > 0){ 
-   $i = 0;
-   foreach($results as $analysis_id => $analysisprops){ 
-     $analysis = $analysisprops['analysis'];
-     $protein_ORFs = $analysisprops['protein_ORFs']; 
-     $terms = $analysisprops['allterms']; 
-     ?>
-     <div id="tripal_feature-interpro_results_<?php print $i?>-box" class="tripal_analysis_interpro-box tripal-info-box">
-        <div class="tripal_feature-info-box-title tripal-info-box-title">InterPro Report <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></div>
-        <div class="tripal_feature-info-box-desc tripal-info-box-desc"><?php 
-            if($analysis->nid){ ?>
-               Analysis name: <a href="<?php print url('node/'.$analysis->nid) ?>"><?php print $analysis->name?></a><?php
-            } else { ?>
-               Analysis name: <?php print $analysis->name;
-            } ?><br>
-            Date Performed: <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?>
-        </div>
-
-     <div class="tripal_feature-interpro_results_subtitle">Summary of Annotated IPR terms</div>
-     <table id="tripal_feature-interpro_summary-<?php $i ?>-table" class="tripal_analysis_interpro-summary-table tripal-table tripal-table-horz">
-      <tr>
-        <th>Term</td>
-        <th>Name</td>
-      </tr>
-     <?php 
-     $j=0;
-     foreach($terms as $term){ 
-       $ipr_id = $term[0];
-       $ipr_name = $term[1];
-       if(strcmp($ipr_id,'noIPR')==0){
-          continue;
-       }
-       $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
-       if($j % 2 == 0 ){
-         $class = 'tripal_feature-table-even-row tripal-table-even-row';
-       }?>
-       <tr class="<?php print $class ?>">
-         <td><a href="http://www.ebi.ac.uk/interpro/IEntry?ac=<?php print $ipr_id ?>" target="_ipr"><?php print $ipr_id ?></a></td>
-         <td><?php print $ipr_name ?></td>         
-       </tr>
-       <?php
-       $j++;
-     } ?>
-     </table>
-     <br><br>
-     <div class="tripal_feature-interpro_results_subtitle">Analysis Details</div>
-     <table id="tripal_feature-interpro_results-<?php $i ?>-table" class="tripal-table tripal_feature_interpro-results-table tripal-table-horz" style="border-top: 0px; border-bottom: 0px">
-     <?php
-     foreach($protein_ORFs as $orf){  
-        $terms = $orf['terms'];
-        $orf = $orf['orf'];  
-        ?>
-        <?php foreach($terms as $term){ 
-          $matches = $term['matches'];
-          $ipr_id = $term['ipr_id'];
-          $ipr_name = $term['ipr_name'];
-          $ipr_type = $term['ipr_type']; 
-          if(strcmp($ipr_id,'noIPR')==0){
-             continue;
-          } 
-          ?>          
-            <tr>
-              <td colspan="4" style="padding-left: 0px">ORF: <?php print $orf['orf_id'] ?>, Length: <?php print $orf['orf_length'] ?> <br>
-                              IPR Term: <a href="http://www.ebi.ac.uk/interpro/IEntry?ac=<?php print $ipr_id ?>" target="_ipr"><?php print $ipr_id ?></a> <?php print " $ipr_name ($ipr_type)"; ?></th>
-            </tr>
-            <tr style="border-top: solid 1px;">
-              <th>Method</th>
-              <th>Identifier</th>
-              <th>Description</th>
-              <th>Matches<sup>*</sup></th>
-            </tr>
-            <?php $j = 0; 
-            foreach ($matches as $match){
-               $match_id = $match['match_id'];
-               $match_name = $match['match_name'];
-               $match_dbname = $match['match_dbname'];
-
-
-               $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
-               if($j % 2 == 0 ){
-                  $class = 'tripal_feature-table-even-row tripal-table-even-row';
-               }?>
-               <tr class="<?php print $class ?>">
-                 <td><?php print $match_dbname ?></td>
-                 <td><?php print $match_id ?></td>
-                 <td><?php print $match_name ?></td>
-                 <td nowrap><?php
-                    $locations = $match['locations'];
-                    foreach($locations as $location){
-                      print $location['match_score']." [".$location['match_start']."-".$location['match_end']."] " . $location['match_status'] ."<br>";
-                      #$match_evidence =  $location['match_evidence'];
-                    } ?>
-                 </td>
-               </tr>
-               <?php
-               $j++;  
-            } // end foreach matches ?>
-            <tr><td colspan="4"><sup>* score [start-end] status</sup></td></tr> <?php
-        } // end foreach terms
-        $i++;
-     } // end foreach orfs ?>
-     </table>
-     </div> <?php
-   } // end for each analysis 
-} // end if
-if($resultsHTML){  ?>
-   <div id="tripal_feature-interpro_results_<?php print $i?>-box" class="tripal_analysis_interpro-box tripal-info-box">
-     <div class="tripal_feature-info-box-title tripal-info-box-title">InterPro Report <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></div>
-     <div class="tripal_feature-info-box-desc tripal-info-box-desc"><?php 
-         if($analysis->nid){ ?>
-            Analysis name: <a href="<?php print url('node/'.$analysis->nid) ?>"><?php print $analysis->name?></a><?php
-         } else { ?>
-            Analysis name: <?php print $analysis->name;
-         } ?><br>
-         Date Performed: <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?>
-     </div>
-
-   <div class="tripal_feature-interpro_results_subtitle">Summary of Annotated IPR terms</div> <?php 
-   print $resultsHTML;?>
-   </div> <?php
-}
-?>
-

+ 0 - 10
extensions/tripal_analysis_interpro/tripal_analysis_interpro.info

@@ -1,10 +0,0 @@
-; $Id:
-name = Tripal Interpro
-description = An analysis sub-module for adding, editing, and displaying InterProScan analysis results.
-core = 6.x
-project = tripal_analysis_interpro
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis
-dependencies[] = tripal_analysis_go

+ 0 - 90
extensions/tripal_analysis_interpro/tripal_analysis_interpro.install

@@ -1,90 +0,0 @@
-<?php
-//$Id:
-
-/*******************************************************************************
- * Implementation of hook_install().
- */
-function tripal_analysis_interpro_install() {
-   // create the module's data directory
-   tripal_create_moddir('tripal_analysis_interpro');
-
-   // We need to register to tripal_analysis module so it can provide a control
-   // for our interpro result. Basically the registration is done by inserting
-   // modulename into the drupal {tripal_analysis} table AND inserting required
-   // information to the chado Analysis table. Also in tripal_analysis_interpro.module,
-   // we need to define HOOK_get_settings() for the module to work properly.
-   
-   // Inert into drupal's {tripal_analysis}
-   tripal_analysis_register_child('tripal_analysis_interpro');
-   
-   // add the CVterms needed for this module
-   tripal_analysis_interpro_add_cvterms();
-}
-
-/*******************************************************************************
- * Implementation of hook_uninstall().
- */
-function tripal_analysis_interpro_uninstall() {
-   
-   // Delete all information associate with the module
-   // Drupal complains when the user tries to uninstall tripal_analysis 
-   // and tripal_analysis_interpro at the same time. This is because Drupal drops
-   // the {tripal_analysis} table before we can delete anything from it. Thus,
-   // we perform a db_table_exists() check before the deletion
-   
-   //Delete the settings from {tripal_analysis} table
-   tripal_analysis_unregister_child('tripal_analysis_interpro');
-   
-   // Delete module's variables from variables table.
-   db_query("DELETE FROM {variable} WHERE name='%s'",
-            'tripal_analysis_interpro_setting');
-
-}
-/**
-*
-*/
-function tripal_analysis_interpro_add_cvterms(){
-   // Add cvterm 'analysis_interpro_output_iteration_hits' for inserting into featureprop table
-   tripal_add_cvterms('analysis_interpro_xmloutput_hit', 'Hit in the interpro XML output. Each hit belongs to a chado feature. This cvterm represents a hit in the output');
-   tripal_add_cvterms('analysis_interpro_output_hit', 'Hit in the interpro HTML output. Each hit belongs to a chado feature. This cvterm represents a hit in the output');
-   tripal_add_cvterms('analysis_interpro_settings', 'Settings of an interpro analysis, including output file and run parameters separated by a bar |');
-   tripal_add_cvterms('analysis_interpro_interproparameters','The parameters used when executing an InterProScan job');
-   tripal_add_cvterms('analysis_interpro_interprofile','Used to hold the name of the XML file containing the InterProScan results');
-   tripal_add_cvterms('analysis_interpro_parsego','Indicates whether or not the GO terms should be extracted when parsing the InterProScan XML file');
-   tripal_add_cvterms('analysis_interpro_parseHTML','Indicates that the input file is in HTML format. This functionality is deprecated and may not work, but is provided for backwards compatability.');
-   tripal_add_cvterms('analysis_interpro_query_re','The regular expression for finding the feature name in the query definition line of the InterPro results');
-   tripal_add_cvterms('analysis_interpro_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_interpro_query_uniquename','Indicates if the matched name in the query definition line of the blast results is feature uniquename');
-   tripal_add_cvterms('analysis_interpro_output_keywords', 'Selected keywords for interpro html output which are indexed for search.');
-}
-/**
- * 
- */
-function tripal_analysis_interpro_update_6000(){
-
-   // we have some new cvterms to add
-   tripal_analysis_interpro_add_cvterms();
-
-   $ret = array(
-      '#finished' => 1,
-   );
-   
-   return $ret;
-}
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_interpro_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_interpro'] = array(
-            'title' => "tripal_analysis_interpro",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}

+ 0 - 795
extensions/tripal_analysis_interpro/tripal_analysis_interpro.module

@@ -1,795 +0,0 @@
-<?php
-
-require_once "includes/parseInterpro.inc";
-
-/*******************************************************************************
- * Tripal Interpro lets users show/hide iprscan results associated with a tripal
- * feature
- ******************************************************************************/
-function tripal_analysis_interpro_init(){
-
-	// Add javascript and style sheet
-   drupal_add_css(drupal_get_path('module', 'tripal_analysis_interpro').'/theme/css/tripal_analysis_interpro.css', 'theme');
-   drupal_add_js( drupal_get_path('module', 'tripal_analysis_interpro').'/theme/js/tripal_analysis_interpro.js');
-}
-/*******************************************************************************
- *  Provide information to drupal about the node types that we're creating
- *  in this module
- */
-function tripal_analysis_interpro_node_info() {
-	$nodes = array();
-	$nodes['chado_analysis_interpro'] = array(
-      'name' => t('Analysis: Interpro'),
-      'module' => 'chado_analysis_interpro',
-      'description' => t('An interpro analysis from the chado database'),
-      'has_title' => FALSE,
-      'title_label' => t('Analysis: Interpro'),
-      'has_body' => FALSE,
-      'body_label' => t('Interpro Analysis Description'),
-      'locked' => TRUE
-	);
-	return $nodes;
-}
-/*******************************************************************************
- *  Provide a Interpro Analysis form
- */
-function chado_analysis_interpro_form ($node){
-
-   // add in the default fields for the analysis
-   $form = chado_analysis_form($node);
-
-   $analysis = $node->analysis;
-
-   $interprofile = $analysis->tripal_analysis_interpro->interprofile;
-   $interproparameters = $analysis->tripal_analysis_interpro->interproparameters;
-   $parsego = $analysis->tripal_analysis_interpro->parsego;
-   $parseHTML = $analysis->tripal_analysis_interpro->parseHTML;
-   $query_re = $analysis->tripal_analysis_interpro->query_re;
-   $query_type = $analysis->tripal_analysis_interpro->query_type;
-   $query_uniquename = $analysis->tripal_analysis_interpro->query_uniquename;
-
-
-	$moreSettings ['interpro'] = 'Interpro Settings';
-	$form['interpro'] = array(
-      '#title' => t('Interpro Settings'),
-      '#type' => 'fieldset',
-      '#description' => t('Specific Settings for Interpro Analysis.'),
-      '#collapsible' => TRUE,
-      '#attributes' => array('id' => 'interpro-extra-settings'),
-      '#weight' => 11
-	);
-	$form['interpro']['interprofile'] = array(
-      '#title' => t('InterProScan XML File/Directory: (if you input a directory without the tailing slash, all xml files in the directory will be loaded)'),
-      '#type' => 'textfield',
-      '#description' => t('Please provide the full path to the XML output file generated by InterProScan or a directory containing multiple XML files.'),
-      '#default_value' => $interprofile,
-	);
-	$form['interpro']['interprojob'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Submit a job to parse the InterProScan XML file(s)'),
-      '#description' => t('Note: features associated with the interpro results must '.
-                             'exist in chado before parsing the file. Otherwise, interpro '.
-                             'results that cannot be linked to a feature will not '.
-                             'be imported.  The feature name must be unique'),
-      '#default_value' => $interprojob,
-	   '#attributes' => array(
-        'onclick' => 'return isSubmittingJob(this)'
-      )
-	);
-	$form['interpro']['parseHTML'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('The input file is in HTML format (deprecated, only provided for backwards compatibility)'),
-      '#description' => t('Check the box to use the HTML parser.'),
-      '#default_value' => $parseHTML
-   );
-	$form['interpro']['parsego'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Load GO terms to the database'),
-      '#description' => t('Check the box to load GO terms to chado database'),
-      '#default_value' => $parsego
-   );
-//   $form['interpro']['interprokeywordjob'] = array(
-//      '#type' => 'checkbox',
-//      '#title' => t('Submit a job to extract keywords from the Interpro html output'),
-//      '#description' => t('Note: Interpro results are only searchable after keywords are extracted.'),/
-//	);
-	$form['interpro']['interproparameters'] = array(
-      '#title' => t('Parameters'),
-      '#type' => 'textfield',
-      '#description' => t('The parameters used when running the InterProScan analysis.'),
-      '#default_value' => $interproparameters,
-	);
-
-	$form['interpro']['query_re'] = array(
-      '#title' => t('Query Name RE'),
-      '#type' => 'textfield',
-      '#description' => t('Enter the regular expression that will extract the '.
-         'feature name from the query line in the interpro results. This option is '.
-         'is only required when the query does not identically match a feature '.
-         'in the database. By default, the parser will try to match results to '.
-         'a feature in Chado using the feature name.  Select the check box below'.
-         'to match against the unique name if needed.'),
-      '#default_value' => $query_re,
-	);
-
-	$form['interpro']['query_uniquename'] = array(
-      '#title' => t('Use Unique Name'),
-      '#type' => 'checkbox',
-      '#description' => t('Select this checboxk if the query name in the results file '.
-        'matches the unique name of the feature. '),
-      '#default_value' => $query_uniquename,
-	);
-
-	$form['interpro']['query_type'] = array(
-      '#title' => t('Query Type'),
-      '#type' => 'textfield',
-      '#description' => t('Please enter the Sequence Ontology term (e.g. contig, polypeptide, mRNA) that describes '.
-         'the query sequences in the interproscan XML results file(s).  This is only necessary if two '.
-         'or more sequences have the same name.'),
-      '#default_value' => $query_type,
-	);
-	return $form;
-}
-/**
-*
-*/
-function chado_analysis_interpro_validate($node, &$form){
-   // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form); 
-}
-/**
- * 
- * 
- */
-function chado_analysis_interpro_load($node){
-
-   // load the default set of analysis fields
-	$additions = chado_analysis_load($node);
-
-   // create some variables for easier lookup
-   $analysis = $additions->analysis;
-   $analysis_id = $analysis->analysis_id;
-
-   $intepro_settings  = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_settings');	
-   $interprofile      = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_interprofile');
-   $interproparameters= tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_interproparameters');
-   $parsego           = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_parsego');		
-   $parseHTML         = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_parseHTML');		
-   $query_re          = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_re');	
-   $query_type        = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_type');	
-   $query_uniquename  = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_uniquename');	
-
-   $analysis->tripal_analysis_interpro->interprofile      = $interprofile->value;
-   $analysis->tripal_analysis_interpro->interproparameters= $interproparameters->value;
-   $analysis->tripal_analysis_interpro->parsego           = $parsego->value;
-   $analysis->tripal_analysis_interpro->parseHTML         = $parseHTML->value;
-   $analysis->tripal_analysis_interpro->query_re          = $query_re->value;
-   $analysis->tripal_analysis_interpro->query_type        = $query_type->value;
-   $analysis->tripal_analysis_interpro->query_uniquename  = $query_uniquename->value;
-
-   // if there is an old style 'interpro_settings' array, then break these out for
-   // use in the new format
-   if(count($interpro_settings)>0){
-	   $prop_values = explode ("|", $interpro_settings->value);
-      $analysis->tripal_analysis_interpro->interprofile       = $prop_values[0];
-      $analysis->tripal_analysis_interpro->interproparameters = $prop_values[1];
-   }
-	return $additions;
-}
-/**
- *  
- */
-function chado_analysis_interpro_insert($node){
-   // insert the analysistripal_core_generate_chado_var
-   chado_analysis_insert($node);
-
-   // set the type for this analysis
-   tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_interpro');
-
-   // now add in the remaining settings as a single property but separated by bars
-   tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_interprofile',$node->interprofile);
-   tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_interproparameters',$node->interproparameters);
-   tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_parsego',$node->parsego);		
-   tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_parseHTML',$node->parseHTML);		
-   tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_re',$node->query_re);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_type',$node->query_type);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_uniquename',$node->query_uniquename);	
-  
-   // submit the parsing jobs
-   chado_analysis_interpro_submit_job($node);
-
-}
-/**
- * 
- */
-function chado_analysis_interpro_update($node){
-  // insert the analysistripal_core_generate_chado_var
-   chado_analysis_update($node);
-
-   // set the type for this analysis
-   tripal_analysis_update_property($node->analysis_id,'analysis_type','tripal_analysis_interpro',1);
-
-   // now add in the remaining settings as a single property but separated by bars
-   tripal_analysis_update_property($node->analysis_id,'analysis_interpro_interprofile',$node->interprofile,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_interpro_interproparameters',$node->interproparameters,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_interpro_parsego',$node->parsego,1);		
-   tripal_analysis_update_property($node->analysis_id,'analysis_interpro_parseHTML',$node->parseHTML,1);		
-   tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_re',$node->query_re,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_type',$node->query_type,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_uniquename',$node->query_uniquename,1);	
-
-   // if this analysis uses the old style settings cvterm then remove that term
-   $old = tripal_analysis_get_property($node->analysis_id,'analysis_interpro_settings');
-   if(count($old) > 0){
-      tripal_analysis_delete_property($node->analysis_id,'analysis_interpro_settings');
-   }
-  
-   // submit the parsing jobs
-   chado_analysis_interpro_submit_job($node);
-}
-/*******************************************************************************
- * Delete interpro anlysis
- */
-function chado_analysis_interpro_delete($node){
-	chado_analysis_delete($node);
-}
-
-/**
-*
-*/
-function chado_analysis_interpro_submit_job($node){
-   global $user;
-
-	// Add a job if the user wants to parse the html output
-	if($node->interprojob) {
-		$job_args[0] = $node->analysis_id;
-		$job_args[1] = $node->interprofile;
-		if ($node->parsego) {
-		   $job_args[2] = 1;
-		} else {
-         $job_args[2] = 0;
-      }
-
-
-		if (is_readable($node->interprofile)) {
-			$fname = preg_replace("/.*\/(.*)/", "$1", $node->interprofile);
-         if($node->parseHTML){
-			   tripal_add_job("Parse HTML interpro: $fname",'tripal_analysis_interpro',
-                           'tripal_analysis_interpro_parseHTMLFile', $job_args, $user->uid);
-         } else {
-		      $job_args[3] = $node->query_re;
-		      $job_args[4] = $node->query_type;
-		      $job_args[5] = $node->query_uniquename;;
-			   tripal_add_job("Parse XML interpro: $fname",'tripal_analysis_interpro',
-                           'tripal_analysis_interpro_parseXMLFile', $job_args, $user->uid);
-         }
-		} else {
-			drupal_set_message("Can not open interpro output file. Job not scheduled.");
-		}
-	}
-	
-	// Add a job if the user wants to the keywords from the HTML output
-	if ($node->interprokeywordjob) {
-		$analysis_id = chado_get_id_for_node('analysis', $node);
-		$job_args[0] = $analysis_id;
-		tripal_add_job("Extract keywords for search: $node->analysisname",'tripal_analysis_interpro',
-                           'tripal_analysis_interpro_extract_keywords', $job_args, $user->uid);
-	}
-}
-
-
-/*******************************************************************************
- *  This function customizes the view of the chado_analysis node.  It allows
- *  us to generate the markup.
- */
-function chado_analysis_interpro_view ($node, $teaser = FALSE, $page = FALSE) {
-	// use drupal's default node view:
-	if (!$teaser) {
-		$node = node_prepare($node, $teaser);
-		// When previewing a node submitting form, it shows 'Array' instead of
-		// correct date format. We need to format the date here
-		$time = $node->timeexecuted;
-		if(is_array($time)){
-			$month = $time['month'];
-			$day = $time['day'];
-			$year = $time['year'];
-			$timestamp = $year.'-'.$month.'-'.$day;
-			$node->timeexecuted = $timestamp;
-		}
-		// When viewing a node, we need to reformat the analysisprop since we
-		// separate each value with a bar |
-		if (preg_match("/.*\|.*/",$node->interprofile)) {
-			$prop_values = explode("|", $node->interprofile);
-			$node->interprofile = $prop_values[0];
-			$node->interproparameters = $prop_values[1];
-		}
-	}
-	return $node;
-}
-/**
- *
- *
- * @ingroup tripal_analysis_interpro
- */
-function tripal_analysis_interpro_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['ipr_base']['info'] = t('Analysis: Interpro Details');
-         $blocks['ipr_base']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['featureipr']['info'] = t('Tripal Feature Interpro Results');
-         $blocks['featureipr']['cache'] = BLOCK_NO_CACHE;
-
-         
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_interpro content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-               case 'ipr_base':
-                  $block['subject'] = t('Interpro Details');
-                  $block['content'] = theme('tripal_analysis_interpro_base',$node);
-                  break;
-               case 'featureipr':
-                  $block['subject'] = t('Interpro Results');
-                  $block['content'] = theme('tripal_feature_interpro_results',$node);
-                  break;
-              
-               default :
-            }
-            return $block;
-         }
-   }
-}
-
-/*******************************************************************************
- * tripal_analysis_interpro_nodeapi()
- * HOOK: Implementation of hook_nodeapi()
- * Display interpro results for allowed node types
- */
-function tripal_analysis_interpro_nodeapi(&$node, $op, $teaser, $page) {
-
-	switch ($op) {
-		case 'view':
-			// Find out which node types for showing the interpro
-			$types_to_show = variable_get('tripal_analysis_interpro_setting',
-			array('chado_feature'));
-
-			// Abort if this node is not one of the types we should show.
-			if (!in_array($node->type, $types_to_show, TRUE)) {
-				break;
-			}
-			// Add interpro to the content item if it's not a teaser
-			if (!$teaser && $node->feature->feature_id) {
-				if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-					$node->content['tripal_analysis_interpro_index_version'] = array(
-                  '#value' => theme('parse_EBI_Interpro_XML_index_version',$node),
-                  '#weight' => 7,
-					);
-				} else {
-					// Show interpro result if not at teaser view
-					$node->content['tripal_feature_interpro_results'] = array(
-                  '#value' => theme('tripal_feature_interpro_results', $node),
-                  '#weight' => 7
-					);
-				}
-			}
-	}
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-function tripal_analysis_interpro_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_analysis_interpro')));
-}
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_interpro_theme () {
-	$path = drupal_get_path('module' , 'tripal_analysis_interpro') . '/theme';
-	return array(
-      'parse_EBI_Interpro_XML_index_version' => array (
-         'arguments' => array('node'),
-	   ),
-      'tripal_feature_interpro_results' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_feature_interpro_results',
-         'path' => $path . '/tripal_feature',
-	   ),
-      'tripal_analysis_interpro_base' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_analysis_interpro_base',
-         'path' => $path . '/tripal_analysis_interpro',
-	   )
-	);
-}
-/*******************************************************************************
- * Prepare interpro result for the feature shown on the page
- */
-//function theme_tripal_analysis_interpro_results ($node) {
-//	$feature = $node->feature;
-//	$content = tripal_get_interpro_results($feature->feature_id);
-//	return $content;
-//}
-
-function tripal_analysis_interpro_preprocess_tripal_feature_interpro_results(&$variables){
-   $feature = $variables['node']->feature;
-
-   // 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.
-  // $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);
-}
-
-/*******************************************************************************
- * Prepare interpro result for the feature shown on the page
- */
-function theme_parse_EBI_Interpro_XML_index_version ($node) {
-	$feature = $node->feature;
-	$content = tripal_get_interpro_results_index_version($feature->feature_id);
-	return $content;
-}
-/**
- * 
- */
-function tripal_get_interpro_XML_results($feature_id){
-
-	// Get the blast results stored as XML from the analysisfeatureprop table
-   // the type for the property is named 'analysis_blast_output_iteration_hits'
-   // and is found in the 'tripal' controlled vocabulary.  This CV term was
-   // added by this module.
-   $select = array(
-      'analysisfeature_id' => array(
-         'feature_id' => $feature_id,
-      ), 
-      'type_id' => array(
-         'name' => 'analysis_interpro_xmloutput_hit',
-         'cv_id' => array(
-            'name' => 'tripal'
-         ),
-      ),         
-   );
-   $afeatureprops = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
-
-   // iterate through all of the interpro XML properties for this feature
-	$results = array ();
-   if($afeatureprops){
-	   foreach ($afeatureprops as $index => $afeatureprop) {
-
-         // get the analysis feature record
-         $analysisfeature_arr = tripal_core_chado_select('analysisfeature',array('analysis_id'),
-            array('analysisfeature_id' => $afeatureprop->analysisfeature_id));
-         $analysisfeature = $analysisfeature_arr[0];
-
-         // get the analysis record and the analysis_id
-         $analysis = tripal_core_generate_chado_var('analysis',
-            array('analysis_id' => $analysisfeature->analysis_id));
-         $analysis_id = $analysis->analysis_id;
-
-         // parse the XML and add it to the array of blast results to be returned
-         $interpro_xml = $afeatureprop->value;
-         $orf = tripal_analysis_interpro_get_result_object($interpro_xml,$feature_id);
-		   $results[$analysis->analysis_id]['protein_ORFs'][] = $orf;
-         $results[$analysis->analysis_id]['analysis'] = $analysis;
-
-         // iterate through all of the protein ORFs and combine the terms into one large list
-         if(!is_array($results[$analysis->analysis_id]['allterms'])){
-           $results[$analysis->analysis_id]['allterms'] = array();
-         }
-         if(!is_array($results[$analysis->analysis_id]['goterms'])){
-           $results[$analysis->analysis_id]['goterms'] = array();
-         }
-         $results[$analysis->analysis_id]['allterms'] = array_merge($results[$analysis->analysis_id]['allterms'],$orf['iprterms']);
-         $results[$analysis->analysis_id]['goterms'] = array_merge($results[$analysis->analysis_id]['goterms'],$orf['goterms']);
-         $i++;
-	   }
-   }
-   return $results;
-}
-/*******************************************************************************
- * tripal_get_interpro_results()
- * Get interpro result from featureprop table for the feature
- */
-function tripal_get_interpro_HTML_results($feature_id){
-	// Get cvterm_id for 'analysis_interpro_output_hit' which is required
-	// for inserting into the analysisfeatureprop table
-	$previous_db = tripal_db_set_active('chado');
-	$sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT 
-	        INNER JOIN cv ON cv.cv_id = CVT.cv_id
-	        WHERE CVT.name = 'analysis_interpro_output_hit'
-	        AND CV.name = 'tripal'";
-	$type_id = db_result(db_query($sql));
-   
-   // Get analysis times for the feature
-	$sql = "SELECT A.analysis_id AS aid 
-	        FROM {analysis} A
-	        INNER JOIN analysisfeature AF ON A.analysis_id = AF.analysis_id 
-	        INNER JOIN analysisfeatureprop AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
-	        WHERE feature_id = %d
-	        AND AFP.type_id = %d
-	        AND AFP.value NOT like '%No hits reported.%' 
-           AND AFP.value NOT like '%parent%' 
-           AND AFP.value NOT like '%children%' 
-	        GROUP BY A.analysis_id
-	       ";
-   $hasResult = db_result(db_query($sql, $feature_id, $type_id));
-   $result = db_query($sql, $feature_id, $type_id);
-
-   // Show interpro result ORDER BY time
-   if ($hasResult) { // If there is any result, show expandable box
-      $content .= "<table class=\"tripal_interpro_results_table\">
-                         <tr><td>";
-
-      while ($ana = db_fetch_object($result)) {
-         // Show analysis date
-         $sql = "SELECT name, to_char(timeexecuted, 'MM-DD-YYYY') AS time 
-         		  FROM {analysis} 
-         		  WHERE analysis_id = %d";
-         $ana_details = db_fetch_object(db_query($sql, $ana->aid));
-         // Find node id for the analysis
-         tripal_db_set_active($previous_db);
-         $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %d", $ana->aid));
-         $ana_url = url("node/".$ana_nid);
-         $previous_db = tripal_db_set_active('chado');
-       
-         // Show content
-         $content .= "<strong>Analysis Date:</strong> $ana_details->time
-                        (<a href=$ana_url>$ana_details->name</a>)";
-         
-         // Show interpro results
-         $sql = "SELECT AFP.value AS afpvalue
-                 FROM {analysisfeatureprop} AFP
-                 INNER JOIN analysisfeature AF on AF.analysisfeature_id = AFP.analysisfeature_id
-                 WHERE AF.analysis_id = %d
-                 AND AF.feature_id = %d
-                 AND AFP.type_id = %d
-                 AND AFP.value NOT like '%No hits reported.%' 
-                 AND AFP.value NOT like '%parent%' 
-                 AND AFP.value NOT like '%children%' 
-                ";
-         $interpro_results = db_query($sql, $ana->aid, $feature_id, $type_id);
-      	 while ($afp = db_fetch_object($interpro_results)) {
-      	 	$content .= $afp->afpvalue;
-      	 }
-      }   
-      $content .= '</td></tr></table>';
-   }
-     
-   tripal_db_set_active($previous_db);
-	return $content;
-}
-
-/*******************************************************************************
- * tripal_get_interpro_results()
- * Get interpro result from featureprop table for the feature
- */
-function tripal_get_interpro_results_index_version($feature_id){
-   // Get cvterm_id for 'analysis_interpro_output_hit' which is required
-   // for inserting into the analysisfeatureprop table
-   $previous_db = tripal_db_set_active('chado');
-   $sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT ".
-          "INNER JOIN cv ON cv.cv_id = CVT.cv_id ".
-          "WHERE CVT.name = 'analysis_interpro_output_hit' ".
-          "AND CV.name = 'tripal'";
-   $type_id = db_result(db_query($sql));
-
-   // Get xml string from analysisfeatureprop value column
-   $sql = "SELECT AFP.value AS afpvalue FROM {analysisfeatureprop} AFP ".
-          "INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id ".
-          "INNER JOIN analysisprop AP ON AP.analysis_id = AF.analysis_id ".
-          "WHERE feature_id = %d ".
-          "AND AFP.type_id = %d ";
-   $result = db_query($sql, $feature_id, $type_id);
-   tripal_db_set_active($previous_db);
-   if (db_result($result)) {
-      // get the HTML content for viewing each of the XML file
-      while ($analysisfeatureprop = db_fetch_object($result)) {
-         $content .= $analysisfeatureprop->afpvalue;
-      }
-   }
-   return $content;
-}
-
-/*******************************************************************************
- * Tripal Interpro administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_interpro_get_settings() {
-	// Get an array of node types with internal names as keys
-	$options = node_get_types('names');
-	// Add 'chado_feature' to allowed content types for showing interpro results
-	$allowedoptions ['chado_feature'] = "Show Interpro results on feature pages";
-
-	$form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("Some chado features were analyzed using InterProScan. This option allows user to display the interpro analysis results. Please read user manual for storage and display of interpro files. Check the box to enable the analysis results. Uncheck to disable it."),
-       '#weight' => 0,
-	);
-
-	$form['tripal_analysis_interpro_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value' => variable_get('tripal_analysis_interpro_setting',
-	   array('chado_feature')),
-	);
-
-	$settings->form = $form;
-	$settings->title = "Tripal Interpro";
-	return $settings;
-}
-
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_interpro_perm(){
-   return array(
-      'access chado_analysis_interpro content',
-      'create chado_analysis_interpro content',
-      'delete chado_analysis_interpro content',
-      'edit chado_analysis_interpro content',
-   );
-}
-
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_interpro_access($op, $node, $account){
-	if ($op == 'create') {
-		if(!user_access('create chado_analysis_interpro content', $account)){
-			return FALSE;
-      }
-	}
-	if ($op == 'update') {
-		if (!user_access('edit chado_analysis_interpro content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'delete') {
-		if (!user_access('delete chado_analysis_interpro content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'view') {
-		if(!user_access('access chado_analysis_interpro content', $account)){
-         return FALSE;
-      }
-	}
-   return NULL;
-}
-
-/**
- *
- *
- * @ingroup tripal_analysis_interpro
- */
-function tripal_analysis_interpro_job_describe_args($callback,$args){
-
-
-   $new_args = array();
-   if($callback == 'tripal_analysis_interpro_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;
-
-      $new_args['File or Directory Name'] = $args[1];
-
-      if($args[2]){
-         $new_args['Parse GO terms'] = 'Yes';
-      } else {
-         $new_args['Parse GO terms'] = 'No';
-      }
-
-      $new_args['Query name regular expression'] = $args[3];
-      $new_args['Query type'] = $args[4];
-      if($args[5] == 1){
-        $new_args['Feature identifier'] = 'feature unique name';
-      } else {
-        $new_args['Feature identifier'] = 'feature name';
-      }      
-   }
-   return $new_args;
-}
-
-
-/*******************************************************************************
- * Parsing Interpro HTML results that are stored in analysisfeatureprop for 
- * searching 
- * */
-function tripal_analysis_interpro_extract_keywords ($analysis_id) {	
-	
-	// Remove previously stored interpro keywords for this analysis
-	print "Remove keywords previously stored...\n";
-	$output_type_id = tripal_get_cvterm_id('analysis_interpro_output_hit');
-	$sql = "SELECT distinct AFP.analysisfeature_id FROM {analysisfeatureprop} AFP 
-					 INNER JOIN {analysisfeature} AF ON AF.analysisfeature_id = AFP.analysisfeature_id
-					 WHERE type_id = $output_type_id 
-					 AND AF.analysis_id = $analysis_id";
-	$results_remove = chado_query($sql);
-	$keyword_type_id = tripal_get_cvterm_id('analysis_interpro_output_keywords');
-
-	while ($record = db_fetch_object($results_remove)) {
-		$af_id = $record->analysisfeature_id;
-		$sql = "DELETE FROM {analysisfeatureprop} WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id";
-		chado_query($sql);
-	}
-	
-	print "Extracting keywords...\n";
-	$sql = "SELECT AFP.analysisfeature_id, AFP.value FROM {analysisfeatureprop} AFP 
-					 INNER JOIN {analysisfeature} AF ON AF.analysisfeature_id = AFP.analysisfeature_id
-					 WHERE type_id = $output_type_id 
-					 AND AF.analysis_id = $analysis_id
-					 AND value NOT like '%No hits reported.%' 
-           		 AND value NOT like '%parent%' 
-           		 AND value NOT like '%children%'";
-	$results = chado_query($sql);
-	// Define what to be extracted in the array
-	$search = array (
-							"'SEQUENCE:.*'",
-							"'CRC64:.*'",
-							"'LENGTH:.*'",
-							"'unintegrated'",
-							"'noIPR'",
-							"'<td>seg</td>'",
-							"'<b>InterPro<br/>'",
-							"'<br/>Domain|Family\n'",
-							"'<td>no description</td>'",
-                 		"'<[/!]*?[^<>]*?>'si",          // replace HTML tags with a space
-							"'\n'", // replace newlines with a space
-	);
-	$replace = array (
-								"",
-								"",
-								"",
-								"",
-								"",
-								"",
-								"",
-								"", 
-								"",
-					  			" ",
-                 			" ",
-	);
-	while ($record = db_fetch_object($results)) {
-		$af_id = $record->analysisfeature_id;
-		$value = $record->value;
-
-		// Retrive keywords for this analysisfeature_id if there is any
-		$sql = "SELECT value FROM {analysisfeatureprop} WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id";
-		$keywords = db_result(chado_query($sql));
-		
-		// Extract new keywords from the interpro html output
-		$text = preg_replace($search, $replace, $value); 
-		$new_keywords = trim(ereg_replace(' +', ' ', $text)); // remove extra spaces
-		
-		// Append the new keywords 
-		if ($keywords) {
-			$new_keywords = "$keywords $new_keywords";
-			$sql = "UPDATE {analysisfeatureprop} SET value = '$new_keywords' WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id ";
-		} else {
-			// Insert the keyword into the analysisfeatureprop table
-			$sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank) VALUES ($af_id, $keyword_type_id, '$new_keywords', 0)";
-		}
-		chado_query($sql);
-
-	}
-	
-	print "Finished.\n";
-	
-}

+ 0 - 101
extensions/tripal_analysis_kegg/node-chado_analysis_kegg.tpl.php

@@ -1,101 +0,0 @@
-<?php
-// Purpose: This template provides the layout of the organism node (page)
-//   using the same templates used for the various feature content blocks.
-//
-// To Customize the Featture Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//   - Block Templates: customize the content/layout of each block of stock 
-//       content. These templates are found in the tripal_stock subdirectory
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, type, title, taxonomy. It also includes stock
-//       specific fields such as stock_name, uniquename, stock_type, synonyms,
-//       properties, db_references, object_relationships, subject_relationships,
-//       organism, etc.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($variables,TRUE).'</pre>';
-drupal_add_css('./tripal-node-templates.css');
-$node = $variables['node'];
-$organism = $variables['node']->organism;
-?>
-
-<?php if ($teaser) { 
-  include(drupal_get_path('module', 'tripal_analysis_kegg') . '/theme/tripal_analysis_kegg/tripal_analysis_kegg_teaser.tpl.php'); 
-} else { ?>
-
-<script type="text/javascript">
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_analysis_kegg_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_kegg_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show the corresponding item in the details box
-      $(".tripal_analysis_kegg_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // we want to make sure our table of contents and the details
-         // box stay the same height
-         $("#tripal_analysis_kegg_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // we want the base details to show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-      if(block == null){
-         block = window.location.href.match(/[\?|\&]block=(.+)/)
-      }
-      if(block != null){
-         $("#tripal_analysis_kegg-"+block[1]+"-box").show();
-      } else {
-         $("#tripal_analysis_kegg-base-box").show();
-      }
-      
-      // make the height of the table of contents match the height of the details box
-      $("#tripal_analysis_kegg_toc").height($("#tripal_analysis_kegg-base-box").parent().height());
-      
-   });
-}
-</script>
-
-
-<div id="tripal_analysis_kegg_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php include(drupal_get_path('module', 'tripal_analysis_kegg') . '/theme/tripal_analysis_kegg/tripal_analysis_kegg_base.tpl.php'); ?>
-   <?php include(drupal_get_path('module', 'tripal_analysis_kegg') . '/theme/tripal_analysis_kegg/tripal_analysis_kegg_report.tpl.php'); ?>
-
-   <?php print $content ?>
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_analysis_kegg_toc" class="tripal_toc">
-   <div id="tripal_analysis_kegg_toc_title" class="tripal_toc_title">Resources</i></div>
-   <span id="tripal_analysis_kegg_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_analysis_kegg_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-
-<?php } ?>

+ 0 - 46
extensions/tripal_analysis_kegg/theme/css/tripal_analysis_kegg.css

@@ -1,46 +0,0 @@
-/*
- Copyright 2009 Clemson University
-*/
-
-.tripal_kegg-info-box, .tripal_kegg_summary-info-box {
-   margin-top: 10px;
-   margin-left: 0px;
-   margin-right: 0px;
-   margin-bottom: 0px;
-   padding-top: 0px;
-   padding-left: 0px;
-   padding-bottom: 0px;
-   padding-right: 0px;
-   border-collapse: collapse;
-   z-index: 10;
-}
-
-.tripal_kegg_brite_terms {
-   line-height: 170%;
-   text-align: left;
-}
-
-#tripal_kegg_brite_hierarchy {
-   border-collapse: separate;
-}
-
-#tripal_kegg_brite_links {
-   background-image:url("../images/kegg.gif");/*TODO: figure out what to do about images in tripal extensions*/
-   background-repeat: no-repeat;
-   padding-left:20px;
-}
-
-#tripal_kegg_feature_links {
-   background-image:none;
-   background-repeat: no-repeat;
-   padding:0px 0px 0px 0px;
-}
-
-.tripal_kegg_results_table #tripal_kegg_brite_links {
-   padding: 0px 0px 0px 22px;
-}
-
-#tripal_kegg_brite_results {
-   height: 600px;
-   overflow: auto;   
-}

BIN
extensions/tripal_analysis_kegg/theme/images/kegg.gif


+ 0 - 162
extensions/tripal_analysis_kegg/theme/js/tripal_analysis_kegg.js

@@ -1,162 +0,0 @@
-
-
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-
-       // Select default KEGG analysis when available
-       var selectbox = $('#edit-tripal-analysis-kegg-select');
-       if(selectbox.length > 0){ 
-    	   var option = document.getElementById("analysis_id_for_kegg_report");
-    	   if (option) {
-    		   var options = document.getElementsByTagName('option');
-    		   var index = 0;
-    		   for (index = 0; index < options.length; index ++) {
-    			   if (options[index].value == option.value) {
-    				   break;
-    			   }
-    		   }
-    		   selectbox[0].selectedIndex = index;
-    		   var baseurl = tripal_get_base_url();
-    		   tripal_analysis_kegg_org_report(option.value, baseurl);
-    		// Otherwise, show the first option by default
-    	   } else {
-    		   selectbox[0].selectedIndex = 1;
-    		   selectbox.change();
-    	   }
-       }
-
-   });
-
-   //------------------------------------------------------------
-   function tripal_analysis_kegg_org_report(item,baseurl,themedir){
-      if(!item){
-         $("#tripal_analysis_kegg_org_report").html('');
-         return false;
-      }
-      // Form the link for the following ajax call  
-      var link = baseurl + "/";
-      if(!isClean){
-         link += "?q=";
-      }
-      link += 'tripal_analysis_kegg_org_report/' + item;
-
-      tripal_startAjax();
-      $.ajax({
-           url: link,
-           dataType: 'json',
-           type: 'POST',
-           success: function(data){
-             $("#tripal_analysis_kegg_org_report").html(data[0]);
-             $(".tripal_kegg_brite_tree").attr("id", function(){
-                init_kegg_tree($(this).attr("id"));    
-             });
-             tripal_stopAjax();
-           }
-      });
-      return false;
-   }
-   
-   //------------------------------------------------------------
-   // Update the BRITE hierarchy based on the user selection
-   function tripal_update_brite(link,type_id){
-      tripal_startAjax();
-      $.ajax({
-         url: link.href,
-         dataType: 'json',
-         type: 'POST',
-         success: function(data){
-            $("#tripal_kegg_brite_hierarchy").html(data.update);
-            $("#tripal_kegg_brite_header").html(data.brite_term);
-            tripal_stopAjax();
-            init_kegg_tree(data.id);
-         }
-      });
-      return false;
-   }
-
-   //------------------------------------------------------------
-   // This function initializes a KEGG term tree
-   function init_kegg_tree(id){
-
-      // Form the link for the following ajax call
-      var theme_path = baseurl + '/' + themedir + "/js/jsTree/source/themes/";
-	   
-      $("#" + id).tree ({
-	    data    : {
-	        type    : "predefined", // ENUM [json, xml_flat, xml_nested, predefined]
-	        method  : "GET",        // HOW TO REQUEST FILES
-	        async   : false,        // BOOL - async loading onopen
-	        async_data : function (NODE) { return { id : $(NODE).attr("id") || 0 } }, // PARAMETERS PASSED TO SERVER
-	        url     : false,        // FALSE or STRING - url to document to be used (async or not)
-	        json    : false,        // FALSE or OBJECT if type is JSON and async is false - the tree dump as json
-	        xml     : false         // FALSE or STRING
-	    },
-        ui      : {
-           dots        : true,     // BOOL - dots or no dots
-           rtl         : false,    // BOOL - is the tree right-to-left
-           animation   : 0,        // INT - duration of open/close animations in miliseconds
-           hover_mode  : true,     // SHOULD get_* functions chage focus or change hovered item
-           scroll_spd  : 4,
-           theme_path  : theme_path,    // Path to themes
-           theme_name  : "classic",// Name of theme
-        },
-
-        rules   : {
-           multiple    : false,    // FALSE | CTRL | ON - multiple selection off/ with or without holding Ctrl
-           metadata    : false,    // FALSE or STRING - attribute name (use metadata plugin)
-           type_attr   : "rel",    // STRING attribute name (where is the type stored if no metadata)
-           multitree   : false,    // BOOL - is drag n drop between trees allowed
-           createat    : "bottom", // STRING (top or bottom) new nodes get inserted at top or bottom
-           use_inline  : false,    // CHECK FOR INLINE RULES - REQUIRES METADATA
-           clickable   : "all",    // which node types can the user select | default - all
-           renameable  : false,    // which node types can the user select | default - all
-           deletable   : false,    // which node types can the user delete | default - all
-           creatable   : false,    // which node types can the user create in | default - all
-           draggable   : "none",   // which node types can the user move | default - none | "all"
-           dragrules   : "all",    // what move operations between nodes are allowed | default - none | "all"
-           drag_copy   : false,    // FALSE | CTRL | ON - drag to copy off/ with or without holding Ctrl
-           droppable   : [],
-           drag_button : "left"
-        },
-
-        callback    : {             // various callbacks to attach custom logic to
-           // before focus  - should return true | false
-           beforechange: function(NODE,TREE_OBJ) { return true },
-           beforeopen  : function(NODE,TREE_OBJ) { return true },
-           beforeclose : function(NODE,TREE_OBJ) { return true },
-           // before move   - should return true | false
-           beforemove  : function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true }, 
-           // before create - should return true | false
-           beforecreate: function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true }, 
-           // before rename - should return true | false
-           beforerename: function(NODE,LANG,TREE_OBJ) { return true }, 
-           // before delete - should return true | false
-           beforedelete: function(NODE,TREE_OBJ) { return true }, 
-
-           onJSONdata  : function(DATA,TREE_OBJ) { return DATA; },
-           onselect    : function(NODE,TREE_OBJ) {        	   
-               window.onerror = function(){return true;};
-        	   throw 'exit';
-        	},                  // node selected
-           ondeselect  : function(NODE,TREE_OBJ) { },                  // node deselected
-           onchange    : function(NODE,TREE_OBJ) { },                  // focus changed
-           onrename    : function(NODE,LANG,TREE_OBJ,RB) { },              // node renamed ISNEW - TRUE|FALSE, current language
-           onmove      : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // move completed (TYPE is BELOW|ABOVE|INSIDE)
-           oncopy      : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // copy completed (TYPE is BELOW|ABOVE|INSIDE)
-           oncreate    : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // node created, parent node (TYPE is createat)
-           ondelete    : function(NODE, TREE_OBJ,RB) { },                  // node deleted
-           onopen      : function(NODE, TREE_OBJ) { },                 // node opened
-           onopen_all  : function(TREE_OBJ) { },                       // all nodes opened
-           onclose     : function(NODE, TREE_OBJ) { },                 // node closed
-           error       : function(TEXT, TREE_OBJ) { },                 // error occured
-           // double click on node - defaults to open/close & select
-           ondblclk    : function(NODE, TREE_OBJ) { TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); },
-           // right click - to prevent use: EV.preventDefault(); EV.stopPropagation(); return false
-           onrgtclk    : function(NODE, TREE_OBJ, EV) { },
-           onload      : function(TREE_OBJ) { },
-           onfocus     : function(TREE_OBJ) { },
-           ondrop      : function(NODE,REF_NODE,TYPE,TREE_OBJ) {}
-        }
-      });
-   }
-}

+ 0 - 53
extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_base.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis_kegg-base-box" class="tripal_analysis_kegg-info-box tripal-info-box">
-  <div class="tripal_analysis_kegg-info-box-title tripal-info-box-title">KEGG Analysis Details</div>
-   <table id="tripal_analysis_kegg-table-base" class="tripal_analysis_kegg-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 11
extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_report.tpl.php

@@ -1,11 +0,0 @@
-<?php
-$analysis = $node->analysis;
-$report = $analysis->tripal_analysis_kegg->kegg_report;
-//dpm($analysis);
-?>
-
-<div id="tripal_analysis_kegg-report-box" class="tripal_analysis_kegg-box tripal-info-box">
-  <div class="tripal_analysis_kegg-info-box-title tripal-info-box-title">KEGG Report</div>
-  <div class="tripal_analysis_kegg-info-box-desc tripal-info-box-desc"><?php print $analysis->name ?></div>
-  <?php print $report ?>
-</div>

+ 0 - 53
extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_teaser.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 46
extensions/tripal_analysis_kegg/theme/tripal_feature/tripal_feature_kegg_terms.tpl.php

@@ -1,46 +0,0 @@
-<?php
-
-$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){ 
-     $analysis = $analysisprops['analysis'];
-     $terms = $analysisprops['terms']; 
-     ?>
-     <div id="tripal_feature-kegg_results_<?php print $i?>-box" class="tripal_analysis_kegg-box tripal-info-box">
-        <div class="tripal_feature-info-box-title tripal-info-box-title">KEGG Report <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></div>
-        <div class="tripal_feature-info-box-desc tripal-info-box-desc"><?php 
-            if($analysis->nid){ ?>
-               Analysis name: <a href="<?php print url('node/'.$analysis->nid) ?>"><?php print $analysis->name?></a><?php
-            } else { ?>
-               Analysis name: <?php print $analysis->name;
-            } ?><br>
-            Date Performed: <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?>
-        </div>
-
-     <div class="tripal_feature-kegg_results_subtitle">Annotated Terms</div>
-     <table id="tripal_feature-kegg_summary-<?php $i ?>-table" class="tripal_analysis_kegg-summary-table tripal-table tripal-table-horz">
-     <?php 
-     $j=0;
-     foreach($terms as $term){ 
-       $ipr_id = $term[0];
-       $ipr_name = $term[1];
-       $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
-       if($j % 2 == 0 ){
-         $class = 'tripal_feature-table-even-row tripal-table-even-row';
-       }?>
-       <tr class="<?php print $class ?>">
-         <td><?php print $term ?></td>
-       </tr>
-       <?php
-       $j++;
-     } ?>
-     </table>     
-     </div> <?php
-     $i++;
-   } // end for each analysis 
-} // end if
-?>
-

+ 0 - 22
extensions/tripal_analysis_kegg/theme/tripal_organism/tripal_organism_kegg_summary.tpl.php

@@ -1,22 +0,0 @@
-<?php
-  $organism = $node->organism;
-  $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>
-  <?php 
-     if($has_results){
-        print $form;
-     } else {
-       ?><div class="tripal-no-results">There are no KEGG reports available</div><?php
-     }
-  ?>
-   <div id="tripal_analysis_kegg_org_report"></div>
-   <div id="tripal_ajaxLoading" style="display:none">
-     <div id="loadingText">Loading...</div>
-   </div>   
-</div>
-
-
-

+ 0 - 10
extensions/tripal_analysis_kegg/tripal_analysis_kegg.info

@@ -1,10 +0,0 @@
-; $Id: tripal_analysis_kegg.info,v 1.2 2009/10/23 02:12:27 ccheng Exp $
-name = Tripal Kegg
-description = An analysis sub-module for adding, editing, and displaying KEGG/KAAS analysis results.
-core = 6.x
-project = tripal_analysis_kegg
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis
-

+ 0 - 106
extensions/tripal_analysis_kegg/tripal_analysis_kegg.install

@@ -1,106 +0,0 @@
-<?php
-
-/*******************************************************************************
-*  Implementation of hook_install();
-*/
-function tripal_analysis_kegg_install(){
-   // create the module's data directory
-   tripal_create_moddir('tripal_analysis_kegg');
-   
-   // We need to register to tripal_analysis module so it can provide a control
-   // for our kegg result. Basically the registration is done by inserting
-   // modulename into the drupal {tripal_analysis} table AND inserting required
-   // information to the chado Analysis table. Also in tripal_analysis_interpro.module,
-   // we need to define HOOK_get_settings() for the module to work properly.
-   
-   // Inert into drupal's {tripal_analysis}
-   tripal_analysis_register_child('tripal_analysis_kegg');
-   
-   // add the cvterms needed for this module
-   tripal_analysis_kegg_add_cvterms ();
-
-   // add the db and the cv for the KEGG terms
-   tripal_add_db('KEGG','KEGG: Kyoto Encyclopedia of Genes and Genomes.',
-      'http://www.genome.jp',
-      'http://www.genome.jp/kegg/');
-
-  tripal_add_mview(
-      // view name
-      'kegg_by_organism',
-      // tripal module name
-      'kegg_by_organism',
-      // table name
-      'kegg_by_organism',
-      // table schema definition
-      'analysis_name character varying(255),
-       analysis_id integer,
-       organism_id integer',
-      // columns for indexing
-      'analysis_id,organism_id',
-      // SQL statement to populate the view
-      "SELECT DISTINCT A.name,A.analysis_id,F.organism_id
-       FROM {analysisprop} AP
-          INNER JOIN analysis A on A.analysis_id = AP.analysis_id
-          INNER JOIN cvterm CVT on CVT.cvterm_id = AP.type_id
-          INNER JOIN analysisfeature AF on AF.analysis_id = A.analysis_id
-          INNER JOIN feature F on F.feature_id = AF.feature_id
-       WHERE CVT.name = 'analysis_kegg_settings'",
-      // special index
-      ''
-   );
-}
-/*******************************************************************************
- * Provide update script for adding new cvterms
- */
-function tripal_analysis_kegg_update_6000(){
-
-   // we have some new cvterms to add
-   tripal_analysis_kegg_add_cvterms();
-
-   $ret = array(
-      '#finished' => 1,
-   );
-   
-   return $ret;
-}
-/**
-*
-*/
-function tripal_analysis_kegg_add_cvterms () {
-   tripal_add_cvterms('analysis_kegg_settings', 'Settings of a KEGG analysis, Currently include only the heir.tar.gz file name & path.');
-   tripal_add_cvterms('kegg_brite_data', 'This term is intended for use in the analysisfeatureprop table to store the KAAS results data.');
-   tripal_add_cvterms('analysis_kegg_query_re','The regular expression for finding the feature name in the query definition line of the blast results');
-   tripal_add_cvterms('analysis_kegg_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_kegg_query_uniquename','Indicates if the matched name in the query definition line of the blast results is feature uniquename');
-   tripal_add_cvterms('analysis_kegg_output_keywords', 'Selected keywords for kegg html output which are indexed for search.');
-}
-/*******************************************************************************
-* Implementation of hook_uninstall()
-*/
-function tripal_analysis_kegg_uninstall(){
-//   tripal_delete_db('KEGG');
-   tripal_analysis_unregister_child('tripal_analysis_kegg');
-
-   $mview = tripal_mviews_get_mview_id('kegg_by_organism');
-   if($mview){
-	   tripal_mviews_action('delete',$mview);
-	}
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_kegg_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_kegg'] = array(
-            'title' => "tripal_analysis_kegg",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}

+ 0 - 1302
extensions/tripal_analysis_kegg/tripal_analysis_kegg.module

@@ -1,1302 +0,0 @@
-<?php
-
-
-/*******************************************************************************
- *
- ******************************************************************************/
-
-function tripal_analysis_kegg_init(){
-   // add the tripal_analysis_kegg JS and CSS
-   drupal_add_js(drupal_get_path('module', 'tripal_analysis_kegg').'/theme/js/tripal_analysis_kegg.js');
-   drupal_add_css(drupal_get_path('module', 'tripal_analysis_kegg').'/theme/css/tripal_analysis_kegg.css', 'theme');
-   // add the jsTree JS and CSS
-   drupal_add_css(drupal_get_path('theme', 'tripal').'/js/jsTree/source/tree_component.css', 'theme');
-   drupal_add_js (drupal_get_path('theme', 'tripal').'/js/jsTree/source/_lib.js');
-   drupal_add_js (drupal_get_path('theme', 'tripal').'/js/jsTree/source/tree_component.js');
-}
-/*******************************************************************************
- *  Provide information to drupal about the node types that we're creating
- *  in this module
- */
-function tripal_analysis_kegg_node_info() {
-   $nodes = array();
-   $nodes['chado_analysis_kegg'] = array(
-      'name' => t('Analysis: KEGG'),
-      'module' => 'chado_analysis_kegg',
-      'description' => t('Results from a KEGG/KAAS analysis'),
-      'has_title' => FALSE,
-      'title_label' => t('Analysis: KEGG'),
-      'has_body' => FALSE,
-      'body_label' => t('KEGG Analysis Description'),
-      'locked' => TRUE
-   );
-   return $nodes;
-}
-
-/*******************************************************************************
- * Menu items are automatically added for the new node types created
- * by this module to the 'Create Content' Navigation menu item.  This function
- * adds more menu items needed for this module.
- */
-function tripal_analysis_kegg_menu() {
-   $items['brite/%'] = array(
-     'title' => t('KEGG BRITE'),
-     'page callback' => 'tripal_analysis_kegg_brite',
-     'page arguments' => array(1, 2),
-     'access arguments' => array('access content'),
-     'type' => MENU_CALLBACK
-   );
-   $items['tripal_analysis_kegg_org_report/%'] = array(
-      'path' => 'tripal_analysis_kegg_org_report',
-      'title' => t('Analysis KEGG report'),
-      'page callback' => 'tripal_analysis_kegg_org_report',
-      'page arguments' => array(1),
-      'access arguments' => array('access chado_analysis_kegg content'),
-      'type' => MENU_CALLBACK
-   );
-   return $items;
-}
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_kegg_perm(){
-   return array(
-      'access chado_analysis_kegg content',
-      'create chado_analysis_kegg content',
-      'delete chado_analysis_kegg content',
-      'edit chado_analysis_kegg content',
-   );
-}
-
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_kegg_access($op, $node, $account){
-	if ($op == 'create') {
-		if(!user_access('create chado_analysis_kegg content', $account)){
-			return FALSE;
-      }
-	}
-	if ($op == 'update') {
-		if (!user_access('edit chado_analysis_kegg content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'delete') {
-		if (!user_access('delete chado_analysis_kegg content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'view') {
-		if(!user_access('access chado_analysis_kegg content', $account)){
-         return FALSE;
-      }
-	}
-   return NULL;
-}
-
-/*******************************************************************************
- */
-function tripal_analysis_kegg_brite($analysis_id, $type_id, $ajax){
-   global $base_url;
-   $theme_dir = drupal_get_path('theme','tripal');
-   // If not called by ajax
-   if (!$ajax) {
-      $content .=  
-        "<div id=\"tripal_kegg_brite_results\" class=\"tripal_kegg_brite-info-box\">
-          <table>
-            <tr>
-              <th>KEGG BRITE</th>
-              <th id=\"tripal_kegg_brite_header\">Hierarchy:</th>
-            </tr>
-            <tr>
-              <td nowrap valign=\"top\">
-      ";
-      // List all BRITE terms on the left
-      $sql = "SELECT DISTINCT CVT.name, CVT.cvterm_id
-              FROM {cvterm} CVT 
-                INNER JOIN analysisprop AP ON CVT.cvterm_id = AP.type_id
-              WHERE AP.analysis_id = %d AND CVT.definition LIKE 'KEGG BRITE term: %'
-              ORDER BY CVT.cvterm_id";
-      $previous_db = tripal_db_set_active('chado');
-      $result = db_query($sql, $analysis_id);
-      tripal_db_set_active($previous_db);
-      while ($brite_term = db_fetch_object($result)) {
-         $url = url("brite/$analysis_id/$brite_term->cvterm_id/1");
-         $content .= "<li class=\"tripal_kegg_brite_terms\"><a onclick=\"return tripal_update_brite(".
-                   "this,$brite_term->cvterm_id,'$base_url','$theme_dir')\" href=\"$url\">
-                   $brite_term->name
-                   </a></li>";
-      }
-      // Show the hierarchy tree
-      $content .="</td>
-                  <td nowrap id=\"tripal_kegg_brite_hierarchy\" valign=\"top\">";
-      $content .= "<i>Note:</i> Click a BRITE term for its functional hierarchy";
-      
-   // If called by ajax, generate tree structure
-   } else {
-      // Get BRITE term from cvterm table
-      $previous_db = tripal_db_set_active('chado');
-      $sql = 'SELECT name FROM {cvterm} WHERE cvterm_id=%d';
-      $brite_term = db_result(db_query($sql, $type_id));
-
-      // Get BRITE hierarchy tree
-      $sql = "SELECT value
-           FROM {analysisprop} AP
-             INNER JOIN CVterm CVT on AP.type_id = CVT.cvterm_id
-             INNER JOIN CV on CVT.cv_id = CV.cv_id
-           WHERE CV.name = 'tripal' and CVT.name = '%s' 
-           AND AP.analysis_id = %d";
-
-      $result = db_fetch_object(db_query($sql, $brite_term, $analysis_id));
-      tripal_db_set_active($previous_db);
-      $content .= "<div class=\"tripal_kegg_brite_tree\" id=\"tripal_kegg_brite_tree_$type_id\">$result->value</div>";
-   }
-    
-   if (!$ajax) {
-            $content .= "     </td>
-                            </tr>
-                          </table>
-                      </div>";
-   }
-   // since this function provides output for addition into
-   // an analysis page, as well as an AJAX refresh of content
-   // within the BRITE hierarchy we need to setup the return
-   // different depending on the request type
-   if($ajax){
-      drupal_json(array('update' => $content,
-      					   'id' => "tripal_kegg_brite_tree_$type_id",
-                        'brite_term' => "Hierarchy: $brite_term"));
-   } else {
-      return $content;
-   }
-}
-
-/*******************************************************************************
- *  Provide a KEGG Analysis form
- */
-function chado_analysis_kegg_form ($node){
-   // add in the default fields
-   $form = chado_analysis_form($node);
-
-   // set the defaults
-   $kegg = $node->analysis->tripal_analysis_kegg;
-   $query_re = $kegg->query_re;
-   $query_type = $kegg->query_type;
-   $query_uniquename = $kegg->query_uniquename;
-
-   $hierfile = $kegg->hierfile;
-
-   $moreSettings ['kegg'] = 'KEGG Analysis Settings';
-   $form['kegg'] = array(
-      '#title' => t('KEGG Settings'),
-      '#type' => 'fieldset',
-      '#description' => t('Specific Settings for KEGG Analysis.'),
-      '#collapsible' => TRUE,
-      '#attributes' => array('id' => 'kegg-extra-settings'),
-      '#weight' => 11
-   );
-   $form['kegg']['hierfile'] = array(
-      '#title' => t('KAAS hier.tar.gz Output File'),
-      '#type' => 'textfield',
-      '#description' => t('The full path to the hier.tar.gz file generated by KAAS. 
-                           Alternatively, you can input the full path to the directory
-                           that contains decompressed kegg files.'),
-      '#default_value' => $hierfile,
-   );
-	$form['kegg']['query_re'] = array(
-      '#title' => t('Query Name RE'),
-      '#type' => 'textfield',
-      '#description' => t('Enter the regular expression that will extract the '.
-         'feature name from the results line in the KEGG heir results. This will be '.
-         'the same as the definition line in the query FASTA file used for the analysis.  This option is '.
-         'is only required when the query does not identically match a feature '.
-         'in the database.'),
-      '#default_value' => $query_re,
-	);
-
-	$form['kegg']['query_type'] = array(
-      '#title' => t('Query Type'),
-      '#type' => 'textfield',
-      '#description' => t('Please enter the Sequence Ontology term that describes '.
-         'the query sequences used for KEGG.  This is only necessary if two '.
-         'or more sequences have the same name.'),
-      '#default_value' => $query_type,
-	);
-
-	$form['kegg']['query_uniquename'] = array(
-      '#title' => t('Use Unique Name'),
-      '#type' => 'checkbox',
-      '#description' => t('Select this checboxk if the feature name in the KEGG heir file '.
-        'matches the uniquename in the database.  By default, the feature will '.
-        'be mapped to the "name" of the feature.'),
-      '#default_value' => $query_uniquename,
-	);
-   $form['kegg']['keggjob'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Submit a job to parse the kegg output into Chado'),
-      '#description' => t('Note: features used in the KAAS analysis must '.
-                          'exist in chado before parsing the file. Otherwise, KEGG '.
-                          'results that cannot be linked to a feature will be '.
-                          'discarded.'),
-   );
-/*   $form['kegg']['keggkeywordjob'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Submit a job to extract keywords from the KEGG html output'),
-      '#description' => t('Note: KEGG results are only searchable after keywords are extracted.'),
-	);
-*/
-   return $form;
-}
-/**
-*
-*/
-function chado_analysis_kegg_validate($node, &$form){
-   // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form); 
-}
-/*******************************************************************************
- *
- */
-function chado_analysis_kegg_insert($node){
-   // insert the analysis
-   chado_analysis_insert($node);
-
-   // set the type for this analysis
-   tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_kegg');
-
-   // now add in the remaining settings as a single property but separated by bars
-   tripal_analysis_insert_property($node->analysis_id,'analysis_kegg_settings',$node->hierfile);
-   tripal_analysis_insert_property($node->analysis_id,'analysis_kegg_query_re',$node->query_re);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_kegg_query_type',$node->query_type);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_kegg_query_uniquename',$node->query_uniquename);	
-     
-   // Add a job if the user wants to parse the html output
-   chado_analysis_kegg_submit_job($node);
-}
-/**
-*
-*/
-function chado_analysis_kegg_submit_job($node){
-   global $user;
-   global $base_url;
-
-   if($node->keggjob) {
-      $job_args[0] = $node->analysis_id;
-      $job_args[1] = $node->hierfile;
-      $job_args[2] = $base_url;
-      $job_args[3] = $node->query_re;
-      $job_args[4] = $node->query_type;
-      $job_args[5] = $node->query_uniquename;
-
-      if (is_readable($node->hierfile)) {
-      	$fname = preg_replace("/.*\/(.*)/", "$1", $node->hierfile);
-         tripal_add_job("Parse KAAS output: $fname",'tripal_analysis_kegg',
-                        'tripal_analysis_kegg_parseHierFile', $job_args, $user->uid);
-      } else {
-         drupal_set_message("Can not open KAAS hier.tar.gz output file. Job not scheduled.");
-      }
-   }
-	// Add a job if the user wants to the keywords from the HTML output
-	if ($node->keggkeywordjob) {
-		$analysis_id =chado_get_id_for_node('analysis', $node);
-		$job_args[0] = $analysis_id;
-		tripal_add_job("Extract keywords for search: $node->analysisname",'tripal_analysis_kegg',
-                           'tripal_analysis_kegg_extract_keywords', $job_args, $user->uid);
-	}
-}
-/*******************************************************************************
- * Delete KEGG anlysis
- */
-function chado_analysis_kegg_delete($node){
-   chado_analysis_delete($node);
-}
-
-/*******************************************************************************
- * Update KEGG analysis
- */
-function chado_analysis_kegg_update($node){
-   // insert the analysis
-   chado_analysis_update($node);
-
-   // set the type for this analysis
-   tripal_analysis_update_property($node->analysis_id,'analysis_type','tripal_analysis_kegg',1);
-
-   // now add in the remaining settings as a single property but separated by bars
-   tripal_analysis_update_property($node->analysis_id,'analysis_kegg_settings',$node->hierfile,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_kegg_query_re',$node->query_re,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_kegg_query_type',$node->query_type,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_kegg_query_uniquename',$node->query_uniquename,1);	
-
-     
-   // Add a job if the user wants to parse the output
-   chado_analysis_kegg_submit_job($node);
-}
-/*******************************************************************************
- *  When a node is requested by the user this function is called to allow us
- *  to add auxiliary data to the node object.
- */
-function chado_analysis_kegg_load($node){
-
-   // load the default set of analysis fields
-	$additions = chado_analysis_load($node);
-
-   // create some variables for easier lookup
-   $analysis = $additions->analysis;
-   $analysis_id = $analysis->analysis_id;
-
-   // get the heirfile name
-   $hierfile        = tripal_analysis_get_property($analysis_id,'analysis_kegg_settings');	
-   $query_re        = tripal_analysis_get_property($analysis->analysis_id,'analysis_kegg_query_re');	
-   $query_type      = tripal_analysis_get_property($analysis->analysis_id,'analysis_kegg_query_type');	
-   $query_uniquename= tripal_analysis_get_property($analysis->analysis_id,'analysis_kegg_query_uniquename');	
-
-   $analysis->tripal_analysis_kegg->hierfile = $hierfile->value;
-   $analysis->tripal_analysis_kegg->query_re        = $query_re->value;	
-   $analysis->tripal_analysis_kegg->query_type      = $query_type->value;	
-   $analysis->tripal_analysis_kegg->query_uniquename= $query_uniquename->value;	
-
-   return $additions;
-}
-
-/**
-*
-*/
-function chado_analysis_kegg_view ($node, $teaser = FALSE, $page = FALSE) {
-   // use drupal's default node view:
-   if (!$teaser) {
-      $node = node_prepare($node, $teaser);
-      // When previewing a node submitting form, it shows 'Array' instead of
-      // correct date format. We need to format the date here
-      $time = $node->timeexecuted;
-      if(is_array($time)){
-         $month = $time['month'];
-         $day = $time['day'];
-         $year = $time['year'];
-         $timestamp = $year.'-'.$month.'-'.$day;
-         $node->timeexecuted = $timestamp;
-      }
-   }
-   return $node;
-}
-/********************************************************************************
- */
-function tripal_analysis_kegg_parseHierFile ($analysis_id, $hierfile, $base_path, 
-   $query_re,$query_type,$query_uniquename,$job_id) {
- 
-   // If user input a file (e.g. hier.tar.gz), decompress it first
-   if (is_file($hierfile)) {
-      // generate a unique directory name for extracting and parsing the file
-      $data_dir = sys_get_temp_dir() . "/" . uniqid();
-      mkdir($data_dir);
-      $stderr = shell_exec("cd $data_dir; tar -zxf $hierfile;");
-      print "$stderr\n";
-      $hierdir = $data_dir . "/hier";
-   } 
-   // Otherwise, treat it as a directory
-   else {
-      $hierdir = $hierfile;
-   }
-   $dir_handle = @opendir($hierdir) or die("Unable to open $hierdir");
-   $total_files = count(glob($hierdir . '/*.*'));
-   print "There are $total_files keg file(s).\n";
-   $interval = intval($total_files * 0.01);
-   if($interval > 1){
-      $interval = 1;
-   }
-   $no_file = 0;
-
-   // Remove the analysis features for this analysis
-   // we will rebuild them from just this parsing
-   $select =  array('analysis_id' => $analysis_id);
-   if(!tripal_core_chado_delete('analysisfeature',$select)){
-      print "ERROR: Unable to clear previous results.\n";
-      exit;
-   }
-
-   while ($file = readdir($dir_handle)) {
-
-      if(preg_match("/^.*\.keg/",$file)){
-         // Update the progress
-         if ($no_file % $interval == 0) {
-            $percentage = (int) ($no_file / $total_files * 100);
-            tripal_job_set_progress($job_id, $percentage);
-            print $percentage."%\r";
-         }
-         $no_file ++;
-         
-         # $heirarchy variable will be set in tripal_analysis_kegg_parse_kegg_file()
-         $results = tripal_analysis_kegg_parse_kegg_file("$hierdir/$file",$heirarchy,
-            $analysis_id, $base_path, $query_re,$query_type,$query_uniquename);
-
-         # add the item to the database
-         if(count($results) > 0){
-            print "Loading results for '$heirarchy'\n";
-            // We want to insert the KEGG heirarchy results into the
-            // analysisprop table. We insert a separate record for each 
-            // heirarchy.  But we need to clear out any prevous results first.
-            $sql = "DELETE
-                    FROM {analysisprop}
-                    WHERE analysis_id = %d
-                    AND type_id = (SELECT cvterm_id 
-                                   FROM {cvterm} CVT 
-                                   INNER JOIN CV ON CVT.cv_id = CV.cv_id
-                                   WHERE CV.name = 'tripal' AND CVT.name = '%s'
-                                   )
-                   ";
-
-            $previous_db = tripal_db_set_active('chado');
-            db_result(db_query($sql, $analysis_id, $heirarchy));
-            tripal_db_set_active($previous_db);
-            
-            	
-         	$previous_db = tripal_db_set_active('chado'); // Use chado database
-         	// Get type_id for the BRITE term
-         	$sql = "SELECT cvterm_id 
-                    FROM {cvterm} CVT 
-                    INNER JOIN CV ON CVT.cv_id = CV.cv_id
-                    WHERE CV.name = 'tripal' AND CVT.name = '%s'";
-         	$brite_cvterm_id = db_result(db_query($sql, $heirarchy)); 
-            if(!$brite_cvterm_id){
-               print "ERROR: Cannot find cvterm for '$heirarchy'.\n";
-               exit; 
-            }
-
-            // convert the array to text for saving in the database
-         	// Replace all single quote as HTML code before insert
-            $i = 0;
-            $content = '<ul>';
-            tripal_analysis_kegg_array2list($results,$content,$i);
-            $content .= '</ul>';
-         	$content = preg_replace("/\'/", "&#39;", $content);
-         	
-         	// Insert the value
-            $sql = "INSERT INTO {analysisprop} (analysis_id, type_id, value) 
-                    VALUES (%d, %d,'$content')";   
-            
-            if(!db_query($sql, $analysis_id, $brite_cvterm_id)){
-               print "ERROR: Cannot add '$heirarchy' results to the database.\n";
-               exit;
-            }
-            tripal_db_set_active($previous_db); // Use drupal database
-
-            
-         }
-      }
-   }
-   print "Done.\n";
-   tripal_job_set_progress($job_id,100);
-   closedir($dir_handle);
-
-   // If user input a file, remove decompressed files after parsing
-   if (is_file($hierfile)) {
-      $stderr = shell_exec("rm -r $data_dir;");
-      print "$stderr\n";
-   }
-   return;
-}
-/**
-*
-*/
-function tripal_analysis_kegg_array2list($array,&$content,&$i){
-   foreach($array as $index => $item){
-      if(is_array($item)){
-         if(is_numeric($index)){
-            tripal_analysis_kegg_array2list($item,$content,$i);
-         } else {
-            $content .= "<li id=\"term_$i\"><a></a>$index\n<ul>";
-            $i++;
-            tripal_analysis_kegg_array2list($item,$content,$i);
-            $content .= "</ul>\n</li>\n";
-         }
-      } else {
-         $content .= "<li id=\"term_$i\"><a></a>$item</li>\n";
-         $i++;
-      }
-   }   
-}
-/*******************************************************************************
- * Parse *.keg files. 
- * Each file has a definition line. BRITE term is extracted * from this line 
- * and added to chado as a cvterm. Tree structure for this cvterm is then 
- * generated and saved to analysisfeature and analysisfeatureprop tables.
- */
-function tripal_analysis_kegg_parse_kegg_file ($file, &$heirarchy, $analysis_id, 
-   $base_path, $query_re, $query_type, $query_uniquename)
-{
-
-   print "Parsing $file\n";
-
-   // get the 'kegg_brite_data' cvterm
-   $select = array('name' => 'kegg_brite_data', 
-                   'cv_id' => array('name' => 'tripal'));
-   $bdt_arr = tripal_core_chado_select('cvterm',array('cvterm_id'),$select);
-   $brite_id = $bdt_arr[0]->cvterm_id;
-
-   $filepos = 0;
-
-   // iterate through the lines of the file and recurse through the various levels
-   $handle = fopen($file,'r');
-   while($line = fgets($handle)){
-      $filepos += strlen($line);
-      $line = trim($line);
-
-      // the first line of the file provides the BRITE heirarchy name
-      if(preg_match("/#.*nbsp;\s(.*)<\/h2>$/",$line,$matches)){
-         $heirarchy = $matches[1];
-         // get the CVterm for the heirarchy.  If it doesn't exist then add it
-         $select = array('name' => $heirarchy,'cv_id' => array('name' => 'tripal'));
-         $cvt_arr = tripal_core_chado_select('cvterm',array('cvterm_id'),$select);
-         if (count($cvt_arr) == 0) {
-            tripal_add_cvterms($heirarchy, "KEGG BRITE term: $heirarchy");
-            $cvt_arr = tripal_core_chado_select('cvterm',array('cvterm_id'),$select);
-         }
-         $heirarchy_id = $cvt_arr[0]->cvterm_id;
-
-         // now that we have the file type we can recurse
-         $next = tripal_analysis_kegg_get_next_line($handle,$filepos);
-         $results = tripal_analysis_kegg_recurse_heir($handle,$next,$query_re,
-            $query_type,$query_uniquename,$base_path,$analysis_id,
-            $brite_id,$heirarchy,$filepos);
-      }
-   }
-   fclose($handle);
-   return $results;
-}
-
-/**
-*
-*/
-function tripal_analysis_kegg_recurse_heir($handle, $line,$query_re,
-   $query_type, $query_uniquename, $base_path, $analysis_id, $brite_id, 
-   $heirarchy,&$filepos)
-{
-   $results = array(); 
-
-   // get the current level and the value
-   $level = $line[0];
-   $value = $line[1];
-
-   // now get the next line to see what is coming next.  If the 
-   // next level is greater then recurse immediately. 
-   $prevpos = $filepos;
-   while($next = tripal_analysis_kegg_get_next_line($handle,$filepos)){
-      $next_level = $next[0];
-      $next_value = $next[1];
-
-      // check this line to see if it has a feature we need to keep
-      $ret = tripal_analysis_kegg_check_line_handle_feature($query_re,
-         $query_type, $query_uniquename, $base_path, $analysis_id, $brite_id, 
-         $heirarchy,$value);
-      if($ret){
-         $results[] = $ret;
-      }
-
-      // if we're going up a level then recurse immediately and add results to our array
-      if(ord($next_level) > ord($level)){
-         // now recurse
-         $ret = tripal_analysis_kegg_recurse_heir($handle,$next, 
-            $query_re,$query_type, $query_uniquename, $base_path, $analysis_id,
-            $brite_id,$heirarchy,$filepos);
-         if(count($ret) > 0){
-            $results[][$value] = $ret; 
-         }
-      }
-
-      // if we go down a level on the next line then reset the 
-      // filepointer and return
-      elseif(ord($next_level) < ord($level)){
-          fseek($handle,$prevpos);
-          $filepos = $prevpos;
-          return $results;
-      }
-      else {
-         $line = $next;
-         $level = $next[0];
-         $value = $next[1];
-      }
-      $prevpos = $filepos; 
-   }
-
-   return $results;
-}
-/**
-*
-*/
-
-function tripal_analysis_kegg_get_next_line($handle,&$filepos){
-   $good = 0;
-
-   // get the next line in the file
-   $line = fgets($handle);
-   $filepos += strlen($line);
-
-   // we hit the end of the file, so exit with a null
-   if(!$line){
-      return null;
-   }  
-   while(!$good){
-      $line = trim($line);
-      preg_match("/^([ABCDEFGHIJKLMNOP])\s*(.*)/",$line,$matches);
-      $level = $matches[1];
-      $value = $matches[2];
-
-      // skip lines that aren't data or are empty
-      if($level and $value) {
-
-         // change all relative paths to absolute paths pointing to KEGG (www.genome.jp)
-         // add id to <a> tags so we can link kegg.gif to it in tripal_analysis_kegg.css
-         $value = preg_replace("/<a href=\"\//i","<a href=\"http://www.genome.jp/",$value);     
-         $value = preg_replace("/<a href=\"/i","<a id=\"tripal_kegg_brite_links\" target=\"_blank\" href=\"",$value);
-
-         // this line is good so let's exit out
-         $good = 1;
-      } else {
-         $line = fgets($handle);
-         $filepos += strlen($line);
-         // we hit the end of the file, so exit with a null
-         if(!$line){
-            return null;
-         }         
-      }
-   }
-   return array($level,$value);
-}
-/**
-*
-*/
-function tripal_analysis_kegg_check_line_handle_feature($query_re,
-   $query_type, $query_uniquename, $base_path, $analysis_id, $brite_id, 
-   $heirarchy,$value)
-{
-
-   // extract the features that have been mapped to the KEGG IDs
-   if(preg_match("/^(.*?);\s*(\<a.+)/",$value,$matches)){
-      $has_feature = 1;
-      $fname = $matches[1];
-      $keggterm = $matches[2];
-
-		// get the feature name using the user's regular expression
-		if ($query_re and preg_match("/$query_re/", $fname, $matches)) {
-			$feature = $matches[1];
-		} 
-      // If not in above format then pull up to the first space
-      else {
-			if (preg_match('/^(.*?)\s.*$/', $fname, $matches)) {
-				$feature = $matches[1];
-         } 
-         // if no match up to the first space then just use the entire string
-         else {
-            $feature = $fname;
-         }
-      } 
-
-      // now find the feature in chado
-      $select = array();
-      if($query_uniquename){
-         $select['uniquename'] = $feature;
-      } else {
-         $select['name'] = $feature;
-      }
-      if($query_type){
-         $select['type_id'] = array(
-           'cv_id' => array(
-              'name' => 'sequence'
-           ),
-           'name' => $query_type,
-         );
-      }
-
-      $feature_arr = tripal_core_chado_select('feature',array('feature_id'),$select);
-
-      if(count($feature_arr) > 1){
-		   print "Ambiguous: '$feature' matches more than one feature and is being skipped.\n";
-			return;
-      }
-      if(count($feature_arr) == 0){
-			print "Failed: '$feature' cannot find a matching feature in the databasef.  RE: $query_re; LINE: $fname\n";
-         return;
-      }
-      $feature_id = $feature_arr[0]->feature_id;
-
-      if($feature_id){
-         print "Adding KEGG term for $feature ($feature_id,$analysis_id). $heirarchy\n";
-
-         // add this term to the analysis feature properties
-         tripal_analysis_kegg_insert_featureprop($feature_id,$analysis_id,
-            $brite_id,$keggterm);
-
-         // get the node ID of the feature if one exists
-         $sql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
-         $nid = db_result(db_query($sql, $feature_id)); 
-
-         // Add link to each matched feature
-         if($nid){
-            $value = preg_replace("/^(.*?)(;\s*\<a)/","<a id=\"tripal_kegg_feature_links\" target=\"_blank\" href=\"$base_path/node/$nid\">"."$1"."</a>"."$2",$value);
-         }
-         // if we have a feature match then add this to our results array
-         return $value;  
-      }       
-   }
-   return null;
-}
-/**
-*
-*/
-function tripal_analysis_kegg_insert_featureprop ($feature_id, $analysis_id,
-   $brite_id,$keggterm)
-{
-
-   // add the analysisfeature record if it doesn't already exist.
-   $values = array('feature_id' => $feature_id,'analysis_id' => $analysis_id);
-   $analysisfeature_arr = tripal_core_chado_select('analysisfeature',
-      array('analysisfeature_id'),$values);
-   if(count($analysisfeature_arr) == 0){
-      tripal_core_chado_insert('analysisfeature',$values);
-      $analysisfeature_arr = tripal_core_chado_select('analysisfeature',
-         array('analysisfeature_id'),$values);
-   }
-   $analysisfeature_id = $analysisfeature_arr[0]->analysisfeature_id;            
-   // Insert into analysisfeatureprop if the value doesn't already exist
-   // KEGG heir results sometimes have the same record more than once.
-   if($analysisfeature_id){
-      // Get the highest rank for this feature_id in analysisfeatureprop table
-      $sql = "SELECT rank FROM analysisfeatureprop WHERE analysisfeature_id = %d and type_id = %d ORDER BY rank DESC";
-      $previous_db = tripal_db_set_active('chado');
-      $result = db_fetch_object(db_query($sql,$analysisfeature_id,$brite_id));
-      tripal_db_set_active($previous);
-      $rank = 0;
-      if ($result and $result->rank > 0) {
-         $rank = $result->rank + 1;
-      }
-
-      $values = array(
-         'analysisfeature_id' => $analysisfeature_id, 
-         'type_id' => $brite_id,
-         'value' => $keggterm,
-         'rank' => $rank,
-      );
-
-      return tripal_core_chado_insert('analysisfeatureprop',$values);
-   }
-   else {
-      return 0;
-   }
-}
-/**
- *
- *
- * @ingroup tripal_analysis_kegg
- */
-function tripal_analysis_kegg_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['featurekegg']['info'] = t('Tripal Feature KEGG Terms');
-         $blocks['featurekegg']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['orgkegg']['info'] = t('Organism KEGG Summary');
-         $blocks['orgkegg']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['kegg_base']['info'] = t('Analsyis: KEGG Details');
-         $blocks['kegg_base']['cache'] = BLOCK_NO_CACHE;
-
-         
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_kegg content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-               case 'featurekegg':
-                  $block['subject'] = t('KEGG Terms');
-                  $block['content'] = theme('tripal_feature_kegg_terms',$node);
-                  break;
-
-               case 'orgkegg':
-                  $block['subject'] = t('KEGG Terms');
-                  $block['content'] = theme('tripal_organism_kegg_summary',$node);
-                  break;
-
-               case 'kegg_base':
-                  $block['subject'] = t('KEGG Terms');
-                  $block['content'] = theme('tripal_analysis_kegg_report',$node);
-                  break;
-              
-               default :
-            }
-            return $block;
-         }
-   }
-}
-/*******************************************************************************
- * HOOK: Implementation of hook_nodeapi()
- * Display library information for associated features or organisms
- * This function also provides contents for indexing
- */
-function tripal_analysis_kegg_nodeapi(&$node, $op, $teaser, $page) {
-   switch ($op) {
-      case 'view':
-              
-         // add the library to the organism/feature search indexing
-         if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-            $node->content['tripal_analysis_kegg_search_index'] = array(
-               '#value' => theme('tripal_analysis_kegg_search_index',$node),
-               '#weight' => 6,
-            );
-         } else if ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
-            $node->content['tripal_analysis_kegg_search_result'] = array(
-               '#value' => theme('tripal_analysis_kegg_search_result',$node),
-               '#weight' => 6,
-            );
-         } else {
-            switch($node->type){
-               case 'chado_organism':
-                  // Show KEGG report on the analysis page
-                  $node->content['tripal_organism_kegg_summary'] = array(
-                     '#value' => theme('tripal_organism_kegg_summary', $node),
-                  );
-                  break;
-               case 'chado_feature':
-                  // Show KEGG terms on a feature page
-                  $node->content['tripal_feature_kegg_terms'] = array(
-                     '#value' => theme('tripal_feature_kegg_terms', $node),
-                  );
-            }
-
-         }
-         break;
-   }
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-function tripal_analysis_kegg_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_analysis_kegg')));
-}
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_kegg_theme () {
-	$path = drupal_get_path('module', 'tripal_analysis_kegg') . '/theme';
-   return array(
-      'tripal_analysis_kegg_search_index' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_analysis_kegg_search_result' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_organism_kegg_summary' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_organism_kegg_summary',
-         'path' => $path . '/tripal_organism',
-      ),
-      'tripal_feature_kegg_terms' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_feature_kegg_terms',
-         'path' => $path . '/tripal_feature',
-      ),
-      'tripal_analysis_kegg_report' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_analysis_kegg_report',
-         'path' => $path . '/tripal_analysis_kegg',
-      ),
-   );
-}
-/**
- *  
- *
- * @ingroup tripal_analysis_kegg
- */
-function tripal_analysis_kegg_preprocess(&$variables){
-
-   // if the template file is the default node template file then we want
-   // to add all of our variables.
-   if($variables['template_files'][0] == 'node-chado_analysis_kegg'){
-      $analysis = $variables['node']->analysis;
-      $report = tripal_analysis_kegg_full_report($analysis->analysis_id);
-      $analysis->tripal_analysis_kegg->kegg_report = $report;
-   }
-}
-/*******************************************************************************
- *  
- */
-function tripal_analysis_kegg_preprocess_tripal_organism_kegg_summary(&$variables){
-   $node = $variables['node'];
-   $organism = $node->organism;
-   $organism->tripal_analysis_kegg->select_form = tripal_analysis_kegg_load_organism_kegg_summary($node);
-}
-/**
-*
-*/
-function tripal_analysis_kegg_preprocess_tripal_feature_kegg_terms(&$variables){
-   $node = $variables['node'];
-   $feature = $node->feature;
-   $feature->tripal_analysis_kegg->results = tripal_analysis_kegg_load_feature_terms($feature);
-}
-/************************************************************************
- */
-function theme_tripal_analysis_kegg_search_index($node){
- if ($node->type == 'chado_feature') {
-      // Find cvterm_id for 'kegg_brite_data'
-      $sql = "SELECT cvterm_id 
-              FROM {cvterm} CVT
-              INNER JOIN cv ON cv.cv_id = CVT.cv_id
-              WHERE cv.name = 'tripal'
-              AND CVT.name = '%s'";
-      $previous_db = tripal_db_set_active('chado');
-      $brite_id = db_result(db_query($sql, 'kegg_brite_data'));
-      
-      // Get analysis id
-      $sql = "SELECT analysis_id AS aid 
-              FROM {analysisfeature} AF 
-              INNER JOIN analysisfeatureprop AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
-              WHERE feature_id = %d
-              AND AFP.type_id = %d
-              GROUP BY analysis_id";
-      $feature = $node->feature;
-      $feature_id = $feature->feature_id;
-      $hasResult = db_result(db_query($sql, $feature_id, $brite_id));
-      $result = db_query($sql, $feature->feature_id, $brite_id);
-
-      // Show kegg result ORDER BY time
-      if ($hasResult) { // If there is any result, show expandable box
-         $content = "";
-
-         while ($ana = db_fetch_object($result)) {
-            // Show analysis date
-            $sql = "SELECT name, to_char(timeexecuted, 'MM-DD-YYYY') AS time 
-                    FROM {analysis} 
-                    WHERE analysis_id = %d";
-            $ana_details = db_fetch_object(db_query($sql, $ana->aid));
-            // Find node id for the analysis
-            tripal_db_set_active($previous_db);
-            $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %d", $ana->aid));
-            $ana_url = url("node/".$ana_nid);
-            $previous_db = tripal_db_set_active('chado');
-       
-            // Show content
-            $content .= "$ana_details->name";
-         
-            // Show Kegg results
-            $sql = "SELECT AFP.value AS afpvalue
-                    FROM {analysisfeatureprop} AFP
-                    INNER JOIN analysisfeature AF on AF.analysisfeature_id = AFP.analysisfeature_id
-                    WHERE AF.analysis_id = %d
-                    AND AF.feature_id = %d
-                   ";
-            $kegg_results = db_query($sql, $ana->aid, $feature_id);
-            while ($afp = db_fetch_object($kegg_results)) {
-               $content .= " $afp->afpvalue";
-            }
-         }
-      }
-      tripal_db_set_active($previous_db);
-      return $content;
-   }
-}
-
-/************************************************************************
- */
-function theme_tripal_analysis_kegg_search_result($node){
- //  $content = theme_tripal_analysis_kegg_node_add($node);
- //  return $content;
-}
-
-
-/************************************************************************
- */
-function tripal_analysis_kegg_load_organism_kegg_summary($node) {
-   $organism = $node->organism;
-
-   // find analyses that have KEGG terms
-   $sql = "
-     SELECT analysis_id
-     FROM {kegg_by_organism} KBO
-     WHERE organism_id = %d
-     ORDER BY analysis_id DESC
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-   # check to ensure we have access to at least one of the GO analyses
-   $has_results = 0;
-   while($analysis = db_fetch_object($results)){
-      $anode = tripal_analysis_get_node($analysis->analysis_id);
-      if(node_access("view",$anode)){
-         $has_results = 1;
-      }
-   }
-   return array (
-      'has_results' => $has_results,
-      'form' => drupal_get_form('tripal_analysis_kegg_select_form',$node),
-   );
-}
-/************************************************************************
- 
-
-   // Show Kegg additional information on a KEGG Analysis page
-   if ($node->type == 'chado_analysis_kegg') {
-      return tripal_analysis_kegg_full_report($node->analysis_id);
-   }   
-   
-   // Show Kegg-info-box on a Feature page
-   else if ($node->type == 'chado_feature') {
-       return tripal_analysis_kegg_feature_add($node);
-   } 
-   
-   return $content;
-}
- */
-
-function tripal_analysis_kegg_org_report($analysis_id){
-   $content = tripal_analysis_kegg_full_report($analysis_id);
-   $opt = array($content);
-   return drupal_json($opt);
-}
-/************************************************************************
- */
-function tripal_analysis_kegg_full_report($analysis_id){
-   // Test if brite data have been parsed into the database
-   $sql = "SELECT CVT.name, CVT.cvterm_id
-           FROM {cvterm} CVT 
-             INNER JOIN analysisprop AP ON CVT.cvterm_id = AP.type_id
-           WHERE AP.analysis_id = %d
-              AND CVT.definition LIKE 'KEGG BRITE term: %'
-           ORDER BY CVT.cvterm_id";
-   $previous_db = tripal_db_set_active('chado');
-   $result = db_query($sql, $analysis_id);
-   tripal_db_set_active($previous_db);
-
-   if (db_result($result)) {
-      $content = tripal_analysis_kegg_brite($analysis_id, $type_id, 0);
-   } else {
-      $content = "<i>Note:</i> Analysis result is not available. Please schedule and run the job to parse the kegg output.";
-   }
-   return $content;
-}
-/*******************************************************************************
- * Tripal Kegg administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_kegg_get_settings() {
-   // Get an array of node types with internal names as keys
-   $options = node_get_types('names');
-   // Add 'chado_feature' to allowed content types for showing kegg results
-   $allowedoptions ['chado_feature'] = "Show KEGG results on feature pages";
-   $allowedoptions ['chado_analysis_kegg'] = "Show KEGG BRITE results on the analysis page.";
-   $allowedoptions ['chado_organism'] = "Show KEGG BRITE results on the organism pages.";
-
-   $form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("Some chado features were analyzed by KEGG automatic annotation server (KAAS). This option allows user to display the kegg analysis results. Please read user manual for storage and display of kegg files. Check the box to enable the analysis results. Uncheck to disable it."),
-       '#weight' => 0,
-   );
-
-   $form['tripal_analysis_kegg_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value' => variable_get('tripal_analysis_kegg_setting',
-      array('chado_feature', 'chado_analysis_kegg')),
-   );
-
-   $settings->form = $form;
-   $settings->title = "Tripal Kegg";
-   return $settings;
-}
-/************************************************************************
-*/
-function tripal_analysis_kegg_organism_results($node) {
-   $node = node_load($node);
-   return tripal_analysis_kegg_organism_add($node);
-}
-/************************************************************************
-*/
-function tripal_analysis_kegg_load_feature_terms($feature) {
-  
-   $feature_id = $feature->feature_id;
-
-	// Get the KEGG results stored using the term 'kegg_brite_data'
-   $select = array(
-      'analysisfeature_id' => array(
-         'feature_id' => $feature_id,
-      ), 
-      'type_id' => array(
-         'name' => 'kegg_brite_data',
-         'cv_id' => array(
-            'name' => 'tripal'
-         ),
-      ),         
-   );
-   $afeatureprops = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
-   if(!$afeatureprops){
-      return;
-   }
-
-   // iterate through all of the KEGG properties for this feature
-   $results = array();
-	foreach ($afeatureprops as $index => $afeatureprop) {
-
-      // get the analysis feature record
-      $analysisfeature_arr = tripal_core_chado_select('analysisfeature',array('analysis_id'),
-         array('analysisfeature_id' => $afeatureprop->analysisfeature_id));
-      $analysisfeature = $analysisfeature_arr[0];
-
-      // get the analysis record and the analysis_id
-      $analysis = tripal_core_generate_chado_var('analysis',
-         array('analysis_id' => $analysisfeature->analysis_id));
-      $analysis_id = $analysis->analysis_id;
-    
-      $results[$analysis_id]['analysis'] = $analysis;
-   }
-
-   // now get all the terms for each analysis
-   foreach($results as $analysis_id => $arr){
-      $select = array(
-         'analysisfeature_id' => array(
-            'analysis_id' => $analysis_id,
-            'feature_id' => $feature_id,
-         ),
-         'type_id' => array(
-            'name' => 'kegg_brite_data',
-            'cv_id' => array(
-               'name' => 'tripal',
-            ),
-         ),
-      );
-      $terms = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
-      foreach ($terms as $term){
-         $results[$analysis_id]['terms'][] = $term->value;
-      }
-   }
-
-   return $results;
-}
-/************************************************************************
-*/
-function tripal_analysis_kegg_select_form(&$form_state = NULL,$node){
-
-   $form = array();
-   // find analyses that have KEGG terms
-   $sql = "
-     SELECT *
-     FROM {kegg_by_organism} KBO
-     WHERE organism_id = %d
-     ORDER BY analysis_id DESC
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$node->organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-   $analyses = array();
-   $analyses[''] = '';
-   while($analysis = db_fetch_object($results)){
-      # check to see if the user has permission to see this analysis
-      $anode = tripal_analysis_get_node($analysis->analysis_id);
-      if(node_access("view",$anode)){
-   		$analyses[$analysis->analysis_id] = "$analysis->analysis_name";
-      }
-   }
-  
-   global $base_url;
-   // we need to set some hidden values for the javascript to use
-   $form['theme_dir'] = array(
-      '#type' => 'hidden',
-      '#value' => drupal_get_path('theme', 'tripal'),
-   );
-   $form['base_url'] = array(
-      '#type' => 'hidden',
-      '#value' => $base_url,
-   );
-   // now generate the select box
-   global $base_url;
-   $theme_dir = drupal_get_path('theme', 'tripal');
-   $form['tripal_analysis_kegg_select'] = array(
-      '#title' => t('Select a KEGG report to view'),
-      '#description' => t('Any analysis with KEGG results related to this organism are available for viewing. For further information, see the analysis information page.'),
-      '#type'  => 'select',
-      '#options' => $analyses,
-      '#attributes' => array (
-         'onchange' => "tripal_analysis_kegg_org_report(this.options[this.selectedIndex].value,'".$base_url. "','".$theme_dir."')"
-      ),
-   );
-   return $form;
-}
-
-/*******************************************************************************
- * Parsing KEGG HTML results that are stored in analysisfeatureprop for 
- * searching 
- * */
-function tripal_analysis_kegg_extract_keywords ($analysis_id) {
-	
-	// Remove kegg keywords previously stored
-	print "Remove keywords previously stored...\n";
-	$output_type_id = tripal_get_cvterm_id('kegg_brite_data');
-	$sql = "SELECT distinct AFP.analysisfeature_id FROM {analysisfeatureprop} AFP 
-					 INNER JOIN {analysisfeature} AF ON AF.analysisfeature_id = AFP.analysisfeature_id
-					 WHERE type_id = $output_type_id 
-					 AND AF.analysis_id = $analysis_id";
-	$results_remove = chado_query($sql);
-	$keyword_type_id = tripal_get_cvterm_id('analysis_kegg_output_keywords');	
-	while ($record = db_fetch_object($results_remove)) {
-		$af_id = $record->analysisfeature_id;
-		$sql = "DELETE FROM {analysisfeatureprop} WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id";
-		chado_query($sql);
-	}
-	
-	print "Extracting keywords...\n";
-	$sql = "SELECT AFP.analysisfeature_id, AFP.value FROM {analysisfeatureprop} AFP 
-					 INNER JOIN {analysisfeature} AF ON AF.analysisfeature_id = AFP.analysisfeature_id
-					 WHERE type_id = $output_type_id 
-					 AND AF.analysis_id = $analysis_id";
-	$results = chado_query($sql);
-	// Define what to be extracted in the array
-	$search = array (
-                 		"'<[/!]*?[^<>]*?>'si",          // replace HTML tags with a space
-							"'\n'", // replace newlines with a space
-	);
-	$replace = array (
-					  			" ",
-                 			" ",
-	);
-	while ($record = db_fetch_object($results)) {
-		$af_id = $record->analysisfeature_id;
-		$value = $record->value;
-
-		// Retrive keywords for this analysisfeature_id if there is any
-		$sql = "SELECT value FROM {analysisfeatureprop} WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id";
-		$keywords = db_result(chado_query($sql));
-		
-		// Extract new keywords from the kegg html output
-		$text = preg_replace($search, $replace, $value); 
-		$new_keywords = trim(ereg_replace(' +', ' ', $text)); // remove extra spaces
-		
-		// Append the new keywords 
-		if ($keywords) {
-			$new_keywords = "$keywords $new_keywords";
-			$sql = "UPDATE {analysisfeatureprop} SET value = '$new_keywords' WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id ";
-		} else {
-			// Insert the keyword into the analysisfeatureprop table
-			$sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank) VALUES ($af_id, $keyword_type_id, '$new_keywords', 0)";
-		}
-		chado_query($sql);
-
-	}
-	
-	print "Finished.\n";
-	
-}
-

+ 0 - 103
extensions/tripal_analysis_unigene/node-chado_analysis_unigene.tpl.php

@@ -1,103 +0,0 @@
-<?php
-// Purpose: This template provides the layout of the organism node (page)
-//   using the same templates used for the various feature content blocks.
-//
-// To Customize the Featture Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//   - Block Templates: customize the content/layout of each block of stock 
-//       content. These templates are found in the tripal_stock subdirectory
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, type, title, taxonomy. It also includes stock
-//       specific fields such as stock_name, uniquename, stock_type, synonyms,
-//       properties, db_references, object_relationships, subject_relationships,
-//       organism, etc.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
-// print '<pre>'.print_r($node,TRUE).'</pre>';
-drupal_add_css('./tripal-node-templates.css');
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-$unigene_name = $analysis->tripal_analysis_unigene->unigene_name;
-
-//dpm($analysis);
-
-// get the unigene name from the properties list
-
-
-?>
-
-<?php if ($teaser) { 
-  include('tripal_analysis_unigene/tripal_analysis_unigene_teaser.tpl.php'); 
-} else { ?>
-
-<script type="text/javascript">
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_analysis_unigene_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_unigene_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show the corresponding item in the details box
-      $(".tripal_analysis_unigene_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // we want to make sure our table of contents and the details
-         // box stay the same height
-         $("#tripal_analysis_unigene_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // we want the base details to show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-      if(block == null){
-         block = window.location.href.match(/[\?|\&]block=(.+)/)
-      }
-      if(block != null){
-         $("#tripal_analysis_unigene-"+block[1]+"-box").show();
-      } else {
-         $("#tripal_analysis_unigene-base-box").show();
-      }
-      $("#tripal_analysis_unigene_toc").height($("#tripal_analysis_unigene-base-box").parent().height());
-   });
-}
-</script>
-
-<div id="tripal_analysis_unigene_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php include('theme/tripal_analysis_unigene/tripal_analysis_unigene_base.tpl.php'); ?>
-
-   <?php print $content ?>
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_analysis_unigene_toc" class="tripal_toc">
-   <div id="tripal_analysis_unigene_toc_title" class="tripal_toc_title">Resources</div>
-   <span id="tripal_analysis_unigene_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_analysis_unigene_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-
-<?php } ?>

+ 0 - 16
extensions/tripal_analysis_unigene/theme/css/tripal_analysis_unigene.css

@@ -1,16 +0,0 @@
-/*
- Copyright 2009 Clemson University
-*/
-
-.tripal_unigene-info-box {
-   margin-top: 10px;
-   margin-left: 0px;
-   margin-right: 0px;
-   margin-bottom: 0px;
-   padding-top: 0px;
-   padding-left: 0px;
-   padding-bottom: 0px;
-   padding-right: 0px;
-   border-collapse: collapse;
-   z-index: 10;
-}

+ 0 - 86
extensions/tripal_analysis_unigene/theme/tripal_analysis_unigene/tripal_analysis_unigene_base.tpl.php

@@ -1,86 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-$unigene = $node->analysis->tripal_analysis_unigene;
-//dpm($node);
-
-?>
-<div id="tripal_analysis_unigene-base-box" class="tripal_analysis_unigene-info-box tripal-info-box">
-  <div class="tripal_analysis_unigene-info-box-title tripal-info-box-title">Unigene Details</div>
-  <div class="tripal_analysis_unigene-info-box-desc tripal-info-box-desc"></div>
-   <table id="tripal_analysis_unigene-table-base" class="tripal_analysis_unigene-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis_unigene-table-even-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-odd-row tripal-table-odd-row">
-        <th>Unigene Name</th>
-        <td><?php print $unigene->unigene_name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-even-row tripal-table-even-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-odd-row tripal-table-odd-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-even-row tripal-table-even-row">
-        <th nowrap>Date constructed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-odd-row tripal-table-odd-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr> 
-      <tr class="tripal_analysis_unigene-table-even-row tripal-table-even-row">
-        <th nowrap>Stats</th>
-        <td>
-             <?php if($unigene->num_reads){print "Number of reads: $unigene->num_reads<br>";} ?>
-             <?php if($unigene->num_clusters){print "Number of clusters: $unigene->num_clusters<br>";} ?>
-             <?php if($unigene->num_contigs){print "Number of contigs: $unigene->num_contigs<br>";} ?>
-             <?php if($unigene->num_singlets){print "Number of singlets: $unigene->num_singlets<br>";} ?>
-        </td>
-      </tr>  
-      <tr class="tripal_analysis_unigene-table-odd-row tripal-table-odd-row">
-        <th>Organisms</th>
-        <td><?php 
-            if($unigene->organisms and is_array($unigene->organisms)){
-               foreach($unigene->organisms as $organism){
-                  if($organism->nid){
-                     print "<i><a href=\"".url("node/$organism->nid")."\">$organism->genus $organism->species</i></a><br>";
-                  } else {
-                     print "<i>$organism->genus $organism->species</i><br>";
-                  }
-               }
-            } else {
-                // add message here with instructions for administrators to make this work.
-            }
-            ?>
-        </td>
-      </tr>       	                                
-   </table>   
-</div>

+ 0 - 53
extensions/tripal_analysis_unigene/theme/tripal_analysis_unigene/tripal_analysis_unigene_teaser.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 61
extensions/tripal_analysis_unigene/theme/tripal_feature/tripal_feature_unigenes.tpl.php

@@ -1,61 +0,0 @@
-<?php
-$node = $variables['node'];
-$feature = $node->feature;
-$unigenes = $feature->tripal_analysis_unigene->unigenes;
-
-// if this feature has a unigene then we want to show the box
-if($unigenes){
-  //dpm($unigenes);
-?>
-<div id="tripal_feature-unigenes-box" class="tripal_feature-info-box tripal-info-box">
-  <div class="tripal_feature-info-box-title tripal-info-box-title">Unigenes</div>
-  <div class="tripal_feature-info-box-desc tripal-info-box-desc">This <?php print $feature->type_id->name ?> is part of the following unigenes:</div>
-  <?php if(count($unigenes) > 0){ ?>
-  <table id="tripal_feature-unigenes-table" class="tripal_feature-table tripal-table tripal-table-horz">
-    <tr>
-      <th>Unigene Name</th>
-      <th>Analysis Name</th>
-      <th>Sequence type in Unigene</th>
-    </tr>
-    <?php
-    $i = 0; 
-    foreach ($unigenes as $unigene){
-      $class = 'tripal-table-odd-row';
-      if($i % 2 == 0 ){
-         $class = 'tripal-table-even-row';
-      }
-      ?>
-      <tr class="<?php print $class ?>">
-        <td><?php 
-           if($unigene->nid){
-              print "<a href=\"".url("node/$unigene->nid")."\">$unigene->unigene_name</a>";
-           } else {
-              print $unigene->unigene_name;
-           }?>
-        </td>
-        <td><?php 
-           if($analysis->nid){
-              print "<a href=\"".url("node/$analysis->nid")."\">$analysis->name</a>";
-           } else {
-              print $analysis->name;
-           }?>
-        </td>
-        <td nowrap><?php 
-           if($unigene->singlet){
-              print "Singlet";
-           } else {
-              print $feature->type_id->name;
-           }?>
-        </td>
-      </tr>
-      <?php
-      $i++;  
-    } ?>
-  </table>
-  <?php } else { ?>
-    <div class="tripal-no-results">There are no unigenes for this feature</div> 
-  <?php }?>
-</div>
-<?php 
-}
-?>

+ 0 - 52
extensions/tripal_analysis_unigene/theme/tripal_organism/tripal_organism_unigenes.tpl.php

@@ -1,52 +0,0 @@
-<?php
-$node = $variables['node'];
-$organism = $node->organism;
-$unigenes = $organism->tripal_analysis_unigene->unigenes;
-
-//dpm($unigenes);
-?>
-<div id="tripal_organism-unigenes-box" class="tripal_feature-info-box tripal-info-box">
-  <div class="tripal_feature-info-box-title tripal-info-box-title">Unigenes</div>
-  <div class="tripal_feature-info-box-desc tripal-info-box-desc">Below is a list of unigenes available for <i><?php print $organism->genus ?> <?php print $organism->species ?></i>. Click the unigene name for further details.</div>
-  <?php if(count($unigenes) > 0){ ?>
-  <table id="tripal_organism-unigenes-table" class="tripal_feature-table tripal-table tripal-table-horz">
-    <tr>
-      <th>Unigene Name</th>
-      <th>Analysis Name</th>
-      <th>Date Constructed</th>
-      <th>Stats</th>
-    </tr>
-    <?php
-    $i = 0; 
-    foreach ($unigenes as $unigene){
-      $class = 'tripal-table-odd-row';
-      if($i % 2 == 0 ){
-         $class = 'tripal-table-even-row';
-      }
-      ?>
-      <tr class="<?php print $class ?>">
-        <td>
-           <?php 
-           if($unigene->nid){
-              print "<a href=\"".url("node/$unigene->nid")."\">$unigene->unigene_name</a>";
-           } else {
-              print $unigene->unigene_name;
-           }?>
-        </td>
-        <td><?php print $unigene->name; ?></td>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$unigene->timeexecuted); ?></td>
-        <td nowrap>
-             <?php if($unigene->num_reads){print "Reads: $unigene->num_reads<br>";} ?>
-             <?php if($unigene->num_clusters){print "Clusters: $unigene->num_clusters<br>";} ?>
-             <?php if($unigene->num_contigs){print "Contigs: $unigene->num_contigs<br>";} ?>
-             <?php if($unigene->num_singlets){print "Singlets: $unigene->num_singlets<br>";} ?>
-        </td>
-      </tr>
-      <?php
-      $i++;  
-    } ?>
-  </table>
-  <?php } else { ?>
-    <div class="tripal-no-results">There are no unigenes for this organism</div> 
-  <?php }?>
-</div>

+ 0 - 9
extensions/tripal_analysis_unigene/tripal_analysis_unigene.info

@@ -1,9 +0,0 @@
-; $Id:
-name = Tripal Unigene
-description = An analysis sub-module for displaying unigene analysis results.
-core = 6.x
-project = tripal_analysis_unigene
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis

+ 0 - 290
extensions/tripal_analysis_unigene/tripal_analysis_unigene.install

@@ -1,290 +0,0 @@
-<?php
-//$Id:
-
-/*******************************************************************************
- * Implementation of hook_install().
- */
-function tripal_analysis_unigene_install() {
-   // create the module's data directory
-   tripal_create_moddir('tripal_analysis_unigene');
-
-   // We need to register to tripal_analysis module so it can provide a control
-   // for our unigene result. Basically the registration is done by inserting
-   // required information into the {tripal_analysis} table.
-   tripal_analysis_register_child('tripal_analysis_unigene');
-
-   $previous_db = tripal_db_set_active('chado');
-   if (db_table_exists('unigene_libraries_mview')) {
-      $sql = "DROP TABLE unigene_libraries_mview";
-      db_query($sql);
-   }
-   if (db_table_exists('unigene_mview')) {
-      $sql = "DROP TABLE unigene_mview";
-      db_query($sql);
-   }
-   tripal_db_set_active($previous_db);
-   
-
-   tripal_analysis_unigene_add_cvterms();
-   tripal_analysis_unigene_add_organism_unigene_mview();
-   
-   tripal_analysis_unigene_add_stat_mview(); // Add statistics mview
-
-}
-
-/**
-*
-*/
-function tripal_analysis_unigene_update_6001(){
-
-   // we have some new cvterms to add
-   tripal_analysis_unigene_add_cvterms();
-
-   // remove the old unigene materialized view and add the new one.
-   $mview = tripal_mviews_get_mview_id('unigene_mview');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   tripal_analysis_unigene_add_organism_unigene_mview();
-   tripal_analysis_unigene_add_stat_mview(); // Add statistics mview
-
-   // next, add the cvterm 'analysis_unigene_name' to all existing 
-   // unigenes that are already in the database. This will allow the 
-   // materialized view to work.
-   $sql = "SELECT N.nid,N.title,CN.analysis_id
-           FROM {node} N
-             INNER JOIN {chado_analysis} CN on CN.nid = N.nid
-           WHERE type = 'chado_analysis_unigene'";
-   $analyses = db_query($sql);
-   while($analysis = db_fetch_object($analyses)){
-      tripal_analysis_insert_property($analysis->analysis_id,'analysis_unigene_name',$analysis->title);	
-   }
-
-   $ret = array(
-      '#finished' => 1,
-   );
-   
-   return $ret;
-}
-/**
-*
-*/
-function tripal_analysis_unigene_add_cvterms(){
-   tripal_add_cvterms('unigene_version','The version number for the unigene ".
-     "(e.g. v1, v2, etc...) ');
-   tripal_add_cvterms('analysis_unigene_name', 'The name for a unigene.');
-   tripal_add_cvterms('analysis_unigene_num_contigs','The number of contigs in the unigene assembly');
-   tripal_add_cvterms('analysis_unigene_num_singlets','The number of singlets remaining in the unigene assembly');
-   tripal_add_cvterms('analysis_unigene_num_clusters','The number of clusters in the unigene assembly');
-   tripal_add_cvterms('analysis_unigene_num_reads','The number of reads, after filtering, used as input for the assembly');
-   tripal_add_cvterms('analysis_unigene_avg_length','The average contig length');
-   tripal_add_cvterms('singlet',"Indicates the feature is a singlet in a ".
-     "specific unigene version (e.g. v1, v2, etc...). The value specified ".
-     "should match that of the unigene_version");
-
-   // Add cveterm 'analysis_unigene_settings' for inserting into analysisprop table   
-   tripal_add_cvterms('analysis_unigene_settings', 'Settings of a unigene analysis');
-   tripal_add_cvterms('singlet_in_analysis', 'Label the feature as a singlet of specified analysis. The value is the name of a unigene analysis. More importantly, the analysis_id of said analysis is inserted to the featureprop table as rank');
-}
-/**
-*
-*/
-function tripal_analysis_unigene_add_organism_unigene_mview(){
-
-   $view_name = 'organism_unigene_mview';
-
-   // Drop the MView table if it exists
-   $mview_id = tripal_mviews_get_mview_id($view_name);
-   if($mview_id){
-      tripal_mviews_action("delete",$mview_id);
-   }
-
-   tripal_add_mview(
-      // view name
-      $view_name,
-      // tripal module name
-      'tripal_analysis_unigene',
-      // table name
-      $view_name,
-      // table schema definition
-      'analysis_id integer, organism_id integer',
-      // columns for indexing
-      'analysis_id, organism_id',
-      // SQL statement to populate the view
-	   "SELECT DISTINCT A.analysis_id, O.organism_id ".
-      "FROM {Analysis} A ".
-      "  INNER JOIN analysisprop AP    ON AP.analysis_id = A.analysis_id ".
-      "  INNER JOIN cvterm CVT         ON AP.type_id = CVT.cvterm_id ".
-      "  INNER JOIN cv CV              ON CV.cv_id = CVT.cv_id ".
-      "  INNER JOIN analysisfeature AF ON A.analysis_id = AF.analysis_id ".
-      "  INNER JOIN feature F          ON AF.feature_id = F.feature_id ".
-      "  INNER JOIN organism O         ON F.organism_id = O.organism_id ".
-      "WHERE CV.name = 'tripal' AND CVT.name='analysis_unigene_name'",
-      // special index 
-	   ''
-   );
-
-   // add a job to the job queue so this view gets updated automatically next
-   // time the job facility is run
-   $mview_id = tripal_mviews_get_mview_id($view_name);
-   if($mview_id){
-      tripal_mviews_action('update',$mview_id);
-   }
-}
-/*******************************************************************************
- * Implementation of hook_uninstall().
- */
-function tripal_analysis_unigene_uninstall() {
-   $mview = tripal_mviews_get_mview_id('unigene_mview');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   $mview = tripal_mviews_get_mview_id('unigene_libraries_mview');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   // Delete the settings from {tripal_analysis} table
-   // Drupal complains when the user tries to uninstall tripal_analysis 
-   // and tripal_analysis_unigene at the same time. This is because Drupal drops
-   // the {tripal_analysis} table before we can delete anything from it. Thus,
-   // we perform a db_table_exists() check before the deletion
-   tripal_analysis_unregister_child('tripal_analysis_unigene');
-
-   // Delete module's variables from variables table.
-   db_query("DELETE FROM {variable} WHERE name='%s'",
-            'tripal_analysis_unigene_setting');
-   
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_unigene_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_unigene'] = array(
-            'title' => "tripal_analysis_unigene",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}
-
-/********************************************************************************
-* Add a materialized view for unigene basic stat
-*/
-function tripal_analysis_unigene_add_stat_mview() {
-	$view_name = 'unigene_basic_stats';
-	// Drop the MView table if it exists
-	$mview_id = tripal_mviews_get_mview_id($view_name);
-	if($mview_id){
-		tripal_mviews_action("delete",$mview_id);
-	}
-
-	$schema = " analysis_id integer,
-   							  name character varying(255),
-   							  unigene_no integer,
-   							  unigene_min_length integer,
-   							  unigene_max_length integer,
-   							  unigene_avg_length integer,
-   							  contig_no integer,
-   							  contig_min_length integer,
-   							  contig_max_length integer,
-   							  contig_avg_length integer,
-   							  singlet_no integer,
-   							  singlet_min_length integer,
-   							  singlet_max_length integer,
-   							  singlet_avg_length integer
-   							  ";
-	 
-	$index = "analysis_id";
-	 
-	$ana_type = tripal_get_cvterm_id('analysis_type');
-	$singlet_type_id = tripal_get_cvterm_id('singlet_in_analysis');
-	$contig_type = db_result(chado_query("SELECT cvterm_id FROM {cvterm} WHERE name = 'contig' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'sequence')")); //P.S. 'contig' is not a tripal term
-	$EST_type = db_result(chado_query("SELECT cvterm_id FROM {cvterm} WHERE name = 'EST' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'sequence')")); //P.S. 'EST' is not a tripal term
-	$sql = "SELECT
-						A.analysis_id, name, 
-						coalesce(unigene_no, 0), 
-						coalesce(unigene_min, 0), 
-						coalesce(unigene_max, 0), 
-						coalesce(unigene_avg, 0), 
-						coalesce(contig_no, 0), 
-						coalesce(contig_min, 0), 
-						coalesce(contig_max, 0), 
-						coalesce(contig_avg, 0), 
-						coalesce(singlet_no, 0), 
-						coalesce(singlet_min, 0), 
-						coalesce(singlet_max, 0), 
-						coalesce(singlet_avg, 0)
-
-					FROM analysis A 
-					INNER JOIN analysisprop AP ON A.analysis_id = AP.analysis_id
-
-					LEFT JOIN (SELECT count (F.feature_id) AS unigene_no, 
-												min(F.seqlen) AS unigene_min, 
-												max(F.seqlen) AS unigene_max, 
-												round(avg(F.seqlen),0) AS unigene_avg, 
-												analysis_id 
-												FROM feature F
-						         			INNER JOIN analysisfeature AF ON F.feature_id = AF.feature_id
-												LEFT JOIN featureprop FP on F.feature_id = FP.feature_id
-            								WHERE F.type_id = $contig_type
-            								AND ((FP.type_id = $singlet_type_id AND FP.rank != AF.analysis_id) OR FP.type_id IS NULL)
-												OR (FP.type_id = $singlet_type_id AND FP.rank = AF.analysis_id)
-												GROUP BY analysis_id) Unigene ON Unigene.analysis_id = A.analysis_id
-			
-					LEFT JOIN (SELECT count (F.feature_id) AS contig_no, 
-												min(F.seqlen) AS contig_min, 
-												max(F.seqlen) AS contig_max, 
-												round(avg(F.seqlen),0) AS contig_avg, 
-												analysis_id 
-											FROM feature F
-         								INNER JOIN analysisfeature AF ON F.feature_id = AF.feature_id
-											LEFT JOIN featureprop FP on F.feature_id = FP.feature_id
-            							WHERE F.type_id = $contig_type
-            							AND ((FP.type_id = $singlet_type_id AND FP.rank != AF.analysis_id) OR FP.type_id IS NULL)
-											GROUP BY analysis_id) Contig ON Contig.analysis_id = A.analysis_id
-
-					LEFT JOIN (SELECT count (F.feature_id) AS singlet_no, 
-												min(F.seqlen) AS singlet_min, 
-												max(F.seqlen) AS singlet_max, 
-												round(avg(F.seqlen),0) AS singlet_avg, 
-												analysis_id 
-											FROM featureprop FP
-											INNER JOIN feature F ON F.feature_id = FP.feature_id
-         								INNER JOIN analysisfeature AF ON FP.feature_id = AF.feature_id
-											WHERE FP.type_id = $singlet_type_id AND FP.rank = AF.analysis_id
-											GROUP BY analysis_id) Singlet ON Singlet.analysis_id = A.analysis_id			
-			
-					WHERE type_id = $ana_type AND value = 'tripal_analysis_unigene'";
-	 
-	// Create the MView
-	tripal_add_mview(
-	// view name
-	$view_name,
-	// tripal module name
-      ' tripal_analysis_unigene',
-	// table name
-	$view_name,
-	// table schema definition
-	$schema,
-	// columns for indexing
-	$index,
-	// SQL statement to populate the view
-	$sql,
-	// special index
-      ''
-	);
-	 
-	// add a job to the job queue so this view gets updated automatically next
-	// time the job facility is run
-	$mview_id = tripal_mviews_get_mview_id($view_name);
-	if($mview_id){
-		tripal_mviews_action('update',$mview_id);
-	}
-}

+ 0 - 922
extensions/tripal_analysis_unigene/tripal_analysis_unigene.module

@@ -1,922 +0,0 @@
-<?php
-
-function tripal_analysis_unigene_init(){
-   // Add style sheet
-   drupal_add_css(drupal_get_path('module', 'tripal_analysis_unigene').'/theme/css/tripal_analysis_unigene.css', 'theme');
-}
-/**
-*
-*/
-function tripal_analysis_unigene_node_info() {
-	$nodes = array();
-	$nodes['chado_analysis_unigene'] = array(
-      'name' => t('Analysis: Unigene'),
-      'module' => 'chado_analysis_unigene',
-      'description' => t('A unigene assembly constructed from transcriptomic reads.'),
-      'has_title' => FALSE,
-      'title_label' => t('Analysis: Unigene'),
-      'has_body' => FALSE,
-      'body_label' => t('Unigene Analysis Description'),
-      'locked' => TRUE
-	);
-	return $nodes;
-}
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_unigene_perm(){
-   return array(
-      'access chado_analysis_unigene content',
-      'create chado_analysis_unigene content',
-      'delete chado_analysis_unigene content',
-      'edit chado_analysis_unigene content',
-   );
-}
-
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_unigene_access($op, $node, $account){
-	if ($op == 'create') {
-		if(!user_access('create chado_analysis_unigene content', $account)){
-			return FALSE;
-      }
-	}
-	if ($op == 'update') {
-		if (!user_access('edit chado_analysis_unigene content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'delete') {
-		if (!user_access('delete chado_analysis_unigene content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'view') {
-		if(!user_access('access chado_analysis_unigene content', $account)){
-         return FALSE;
-      }
-	}
-   return NULL;
-}
-/**
-*
-*/
-function chado_analysis_unigene_form ($node){
-
-   $unigene = $node->analysis->tripal_analysis_unigene;
-
-   // set the form defaults
-   $unigene_name = $node->unigene_name;
-   if(!$unigene_name){
-      $unigene_name = $unigene->unigene_name;
-   }
-   $num_reads = $node->num_reads;
-   if(!$num_reads){
-      $num_reads = $unigene->num_reads;
-   }
-   $avg_length = $node->avg_length;
-   if(!$avg_length){
-      $avg_length = $unigene->avg_length;
-   }
-   $num_clusters = $node->num_clusters;
-   if(!$num_clusters){
-      $num_clusters = $unigene->num_clusters;
-   }
-   $num_contigs = $node->num_contigs;
-   if(!$num_contigs){
-      $num_contigs = $unigene->num_contigs;
-   }
-   $num_singlets = $node->num_singlets;
-   if(!$num_singlets){
-      $num_singlets = $unigene->num_singlets;
-   }
-   $contig_min_len= $node->contig_min_len;
-   if(!$contig_min_len){
-      $contig_min_len = $unigene->contig_min_len;
-   }
-   $contig_max_len= $node->contig_max_len;
-   if(!$contig_max_len){
-      $contig_max_len = $unigene->contig_max_len;
-   }
-   $contig_avg_len= $node->contig_avg_len;
-   if(!$contig_avg_len){
-      $contig_avg_len = $unigene->contig_avg_len;
-   }
-   $singlet_min_len= $node->singlet_min_len;
-   if(!$singlet_min_len){
-      $singlet_min_len = $unigene->singlet_min_len;
-   }
-   $singlet_max_len= $node->singlet_max_len;
-   if(!$singlet_max_len){
-      $singlet_max_len = $unigene->singlet_max_len;
-   }
-   $singlet_avg_len= $node->singlet_avg_len;
-   if(!$singlet_avg_len){
-      $singlet_avg_len = $unigene->singlet_avg_len;
-   }
-
-
-   // add in the default fields for an analysis
-   $form = chado_analysis_form($node);
-
-	$form['unigene_name'] = array(
-      '#title' => t('Unigene Name'),
-      '#type' => 'textfield',
-      '#required' => TRUE,
-      '#description' => t('A distinct name used to identify this unigene'),
-      '#default_value' => $unigene_name,
-	);
-
-
-	$form['unigene_stats'] = array(
-      '#title' => t('Unigene Stats'),
-      '#type' => 'fieldset',
-      '#description' => t('Unigene, contig and singlet statistics'),
-      '#collapsible' => TRUE,
-	);
-
-   
-	$form['unigene_stats']['num_reads'] = array(
-      '#title' => t('Number of Reads'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the number of reads, after filtering that were used for input into the assembly'),
-      '#default_value' => $num_reads,
-	);
-
-	$form['unigene_stats']['avg_length'] = array(
-      '#title' => t('Average Contig Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the average sequence length in the ungiene (average of contigs and signlets).'),
-      '#default_value' => $avg_length,
-	);
-
-	$form['unigene_stats']['num_clusters'] = array(
-      '#title' => t('Number of Clusters'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the number of clusters generated by the asssembly if a clustering mechanism was used for unigene constructions'),
-      '#default_value' => $num_clusters,
-	);
-
-	$form['unigene_stats']['num_contigs'] = array(
-      '#title' => t('Number of Contigs'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the number of contigs generated by the assembly'),
-      '#default_value' => $num_contigs,
-	);
-
-	$form['unigene_stats']['num_singlets'] = array(
-      '#title' => t('Number of Singlets'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the number of singlets remaining in the assembly'),
-      '#default_value' => $num_singlets,
-	);
-
-
-	$form['contig_stats'] = array(
-      '#title' => t('Contig Stats'),
-      '#type' => 'fieldset',
-      '#description' => t('Unigene Contig statistics'),
-      '#collapsible' => TRUE,
-	);
-	$form['contig_stats']['contig_min_len'] = array(
-      '#title' => t('Minimum Contig Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the length of the smallest contig'),
-      '#default_value' => $contig_min_len,
-	);
-	$form['contig_stats']['contig_max_len'] = array(
-      '#title' => t('Maximum Contig Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the length of the largest contig'),
-      '#default_value' => $contig_max_len,
-	);
-	$form['contig_stats']['contig_avg_len'] = array(
-      '#title' => t('Average Contig Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the average contig length'),
-      '#default_value' => $contig_avg_len,
-	);
-
-
-	$form['singlet_stats'] = array(
-      '#title' => t('Singlet Stats'),
-      '#type' => 'fieldset',
-      '#description' => t('Unigene Singlet statistics'),
-      '#collapsible' => TRUE,
-	);
-	$form['singlet_stats']['singlet_min_len'] = array(
-      '#title' => t('Minimum Singlet Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the length of the smallest singlet'),
-      '#default_value' => $singlet_min_len,
-	);
-	$form['singlet_stats']['singlet_max_len'] = array(
-      '#title' => t('Maximum Singlet Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the length of the largest singlet'),
-      '#default_value' => $singlet_max_len,
-	);
-	$form['singlet_stats']['singlet_avg_len'] = array(
-      '#title' => t('Average Singlet Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the average singlet length'),
-      '#default_value' => $singlet_avg_len,
-	);
-   return $form;
-}
-/**
-*
-*/
-function chado_analysis_unigene_validate($node, &$form){
-   // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form); 
-}
-/**
-*
-*/
-function chado_analysis_unigene_insert($node){
-   // insert the analysis
-   chado_analysis_insert($node);
-
-   // add the unigene name as a property of the anslysis
-   tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_unigene');	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_name',$node->unigene_name);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_num_contigs',$node->num_contigs);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_num_reads',$node->num_reads);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_avg_length',$node->avg_length);
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_num_clusters',$node->num_clusters);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_num_singlets',$node->num_clusters);	
-}
-/**
-*
-*/
-function chado_analysis_unigene_update($node){
-   chado_analysis_update($node); 
-
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_name',$node->unigene_name,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_num_contigs',$node->num_contigs,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_num_reads',$node->num_reads,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_avg_length',$node->avg_length,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_num_clusters',$node->num_clusters,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_num_singlets',$node->num_singlets,1);   
-}
-/**
-*
-*/
-function chado_analysis_unigene_delete($node){
-  chado_analysis_delete($node);
-}
-/**
-*
-*/
-function chado_analysis_unigene_view ($node, $teaser = FALSE, $page = FALSE) {
-   // use drupal's default node view:
-   $node = node_prepare($node, $teaser);
-   return $node;
-}
-/**
-*
-*/
-function chado_analysis_unigene_load($node){
-
-   // load the default set of analysis fields
-	$additions = chado_analysis_load($node);
-
-   // create some variables for easier lookup
-   $analysis = $additions->analysis;
-   $analysis_id = $analysis->analysis_id;
-
-   // add in the properties
-   $unigene_name = tripal_analysis_get_property($analysis_id,'analysis_unigene_name');
-   $num_contigs  = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_contigs');
-   $num_reads    = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_reads');
-   $avg_length   = tripal_analysis_get_property($analysis_id,'analysis_unigene_avg_length');
-   $num_clusters = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_clusters');
-   $num_singlets = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_singlets');
-
-   $analysis->tripal_analysis_unigene->unigene_name = $unigene_name->value;
-   $analysis->tripal_analysis_unigene->num_contigs = $num_contigs->value;
-   $analysis->tripal_analysis_unigene->num_reads = $num_reads->value;
-   $analysis->tripal_analysis_unigene->avg_length = $avg_length->value;
-   $analysis->tripal_analysis_unigene->num_clusters = $num_clusters->value;
-   $analysis->tripal_analysis_unigene->num_singlets = $num_singlets->value;
-
-   // add in organism information using the materialized view
-   $sql = "SELECT * FROM {organism_unigene_mview} OUM ".
-          "  INNER JOIN {organism} O on OUM.organism_id = O.organism_id ".
-          "WHERE OUM.analysis_id = %d ".
-          "ORDER BY O.genus, O.species";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $organisms = db_query($sql,$analysis_id);
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   while($organism = db_fetch_object($organisms)){
-      $sql = "SELECT nid FROM {chado_organism} WHERE organism_id = %d";
-      $c_org = db_fetch_object(db_query($sql,$organism->organism_id));
-      $organism->nid = $c_org->nid;
-      $analysis->tripal_analysis_unigene->organisms[] = $organism;
-   }
-
-
-   return $additions;
-}
-/**
- *
- *
- * @ingroup tripal_analysis_unigene
- */
-function tripal_analysis_unigene_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['base_ugene']['info'] = t('Analysis: Unigene Details');
-         $blocks['base_ugene']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['feature_ugene']['info'] = t('Tripal Feature Unigene');
-         $blocks['feature_ugene']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['org_ugene']['info'] = t('Tripal Organism Unigene');
-         $blocks['org_ugene']['cache'] = BLOCK_NO_CACHE;
-         
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_unigene content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-               case 'base_ugene':
-                  $block['subject'] = t('Unigene Details');
-                  $block['content'] = theme('tripal_analysis_unigene_base',$node);
-                  break;
-               case 'feature_ugene':
-                  $block['subject'] = t('Unigene');
-                  $block['content'] = theme('tripal_feature_unigenes',$node);
-                  break;
-               case 'org_ugene':
-                  $block['subject'] = t('Unigene');
-                  $block['content'] = theme('tripal_organism_unigenes',$node);
-                  break;
-               default :
-            }
-            return $block;
-         }
-   }
-}
-/*******************************************************************************
- * tripal_analysis_unigene_nodeapi()
- * HOOK: Implementation of hook_nodeapi()
- * Display unigene results for allowed node types
- */
-function tripal_analysis_unigene_nodeapi(&$node, $op, $teaser, $page) {
-
-   switch ($op) {
-      case 'view':
-         // Find out which node types for showing the unigene
-         $types_to_show = variable_get('tripal_analysis_unigene_setting',
-            array('chado_feature','chado_organism'));
-
-         // Abort if this node is not one of the types we should show.
-         if (in_array($node->type, $types_to_show, TRUE)) {
-            // Add unigene to the content item if it's not a teaser
-            if ($teaser) {
-               return '';
-            }
-         	
-            // add the alignment to the feature search indexing
-            if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-               $node->content['tripal_analysis_unigene_index_version'] = array(
-						'#value' => theme('tripal_analysis_unigene_search_index',$node),
-						'#weight' => 4,
-               );
-            } else if ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
-               $node->content['tripal_analysis_unigene_index_version'] = array(
-						'#value' => theme('tripal_analysis_unigene_search_result',$node),
-						'#weight' => 4,
-               );
-            } else {
-
-               if(strcmp($node->type,'chado_organism')==0){
-                  $node->content['tripal_organism_unigenes'] = array(
-					   	'#value' => theme('tripal_organism_unigenes', $node),
-						'#weight' => 4
-                  );
-               }
-               if(strcmp($node->type,'chado_feature')==0){
-                  $node->content['tripal_feature_unigenes'] = array(
-					   	'#value' => theme('tripal_feature_unigenes', $node),
-						'#weight' => 4
-                  );
-               }
-            }
-         }
-      break;   
-   }
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-function tripal_analysis_unigene_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_analysis_unigene')));
-}
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_unigene_theme () {
-	$path = drupal_get_path('module', 'tripal_analysis_unigene') . '/theme';
-   return array(
-      'tripal_analysis_unigene_search_index' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_analysis_unigene_search_result' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_organism_unigenes' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_organism_unigenes',
-         'path' => $path . '/tripal_organism',
-      ),
-      'tripal_analysis_unigene_base' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_analysis_unigene_base',
-         'path' => $path . '/tripal_analysis_unigene',
-      ),
-   );
-}
-
-/*******************************************************************************
- *  
- */
-function tripal_analysis_unigene_preprocess_tripal_organism_unigenes(&$variables){
-   $node = $variables['node'];
-   $organism = $node->organism;
-   $unigenes = tripal_analysis_unigene_load_organism_unigenes($organism);
-   $node->organism->tripal_analysis_unigene->unigenes =  $unigenes;
-}
-/*******************************************************************************
- *  
- */
-function tripal_analysis_unigene_preprocess_tripal_feature_unigenes(&$variables){
-   $node = $variables['node'];
-   $feature = $node->feature;
-   $unigenes = tripal_analysis_unigene_load_feature_unigenes($feature);
-   $node->feature->tripal_analysis_unigene->unigenes =  $unigenes;
-}
-/************************************************************************
- *  This function is an extension of the chado_feature_view by providing
- *  the markup for the feature object THAT WILL BE INDEXED.
- */
-function theme_tripal_analysis_unigene_search_index ($node) {
-
-   $feature = $node->feature;
-   $obj_feature = tripal_analysis_unigene_get_alignments($feature);
-   $alignments = $obj_feature->alignments;
-   $content = "<strong>";
-   if(count($alignments) > 0){
-      // iterate through each alignment
-      foreach ($alignments as $result){
-         // EST alignments in chado use an EST_match type to map ESTs to
-         // contigs and a rank to indicate the major srcfeature.
-         // We don't want to show EST_matches on the alignment view
-         // since that doesn't make much sense to the end user.  If this
-         // is an EST_match and the feature is an EST then we want to show
-         // the contig in the alignments.  The contig name is part of the
-         // uniquename in the EST_match
-         if($node->feature->cvname == 'EST' && $result->cvname == 'EST_match'){
-            $sql = "SELECT srcfeature_id ".
-                   "FROM {featureloc} ".
-                   "WHERE feature_id = $result->feature_id ".
-                   "ORDER BY rank";
-            $previous_db = tripal_db_set_active ('chado');
-            $contig_fid = db_result(db_query($sql));
-            $sql = "SELECT name FROM {feature} WHERE feature_id = $contig_fid";
-            $contig_name = db_result(db_query($sql));
-            tripal_db_set_active($previous_db);
-            $sql = "SELECT nid ".
-                   "FROM {chado_feature} ".
-                   "WHERE feature_id = $contig_fid";
-            $contig_nid = db_result(db_query($sql));
-            // Check if the EST exists as a drupal node. If yes, add a link to
-            // it. If no, just show the name
-            if ($contig_nid != 0) {
-               $sql = "SELECT nid FROM {node} WHERE nid=$contig_nid";
-               $node_exists = db_result(db_query($sql));
-            }
-            $content .= "$contig_name " ;
-         }
-         elseif($node->feature->cvname == 'contig' && $result->cvname == 'EST_match'){
-            $sql = "SELECT vid ".
-                   "FROM {node} ".
-                   "WHERE title = '$result->feature_name'".
-                   "ORDER BY vid DESC";
-            // since the feature name is also the node title we can look it up
-            $est_node = db_fetch_object(db_query($sql));
-            $content .= "$result->feature_name ";
-         }
-         else {
-            $content .= "$result->cvname $result->feature_name ";
-         }
-      }
-   }
-   $content .= "</strong>";
-   return $content;
-}
-
-/************************************************************************
- *  This function is an extension of the chado_feature_view by providing
- *  the markup for the feature object to show on a search result page.
- */
-function theme_tripal_analysis_unigene_search_result ($node) {
-
-   $feature = $node->feature;
-   $obj_feature = tripal_analysis_unigene_get_alignments($feature);
-   $alignments = $obj_feature->alignments;
-   $content = "<strong>";
-   if(count($alignments) > 0){
-      // iterate through each alignment
-      foreach ($alignments as $result){
-         // EST alignments in chado use an EST_match type to map ESTs to
-         // contigs and a rank to indicate the major srcfeature.
-         // We don't want to show EST_matches on the alignment view
-         // since that doesn't make much sense to the end user.  If this
-         // is an EST_match and the feature is an EST then we want to show
-         // the contig in the alignments.  The contig name is part of the
-         // uniquename in the EST_match
-         if($node->feature->cvname == 'EST' && $result->cvname == 'EST_match'){
-            $sql = "SELECT srcfeature_id ".
-                   "FROM {featureloc} ".
-                   "WHERE feature_id = $result->feature_id ".
-                   "ORDER BY rank";
-            $previous_db = tripal_db_set_active ('chado');
-            $contig_fid = db_result(db_query($sql));
-            $sql = "SELECT name FROM {feature} WHERE feature_id = $contig_fid";
-            $contig_name = db_result(db_query($sql));
-            tripal_db_set_active($previous_db);
-            $sql = "SELECT nid ".
-                   "FROM {chado_feature} ".
-                   "WHERE feature_id = $contig_fid";
-            $contig_nid = db_result(db_query($sql));
-            // Check if the EST exists as a drupal node. If yes, add a link to
-            // it. If no, just show the name
-            if ($contig_nid != 0) {
-               $sql = "SELECT nid FROM {node} WHERE nid=$contig_nid";
-               $node_exists = db_result(db_query($sql));
-            }
-            $content .= "Alignment to contig $contig_name. " ;
-         }
-         elseif($node->feature->cvname == 'contig' && $result->cvname == 'EST_match'){
-            $sql = "SELECT vid ".
-                   "FROM {node} ".
-                   "WHERE title = '$result->feature_name'".
-                   "ORDER BY vid DESC";
-            // since the feature name is also the node title we can look it up
-            $est_node = db_fetch_object(db_query($sql));
-            $content .= "Aligned EST: $result->feature_name ";
-         }
-         else {
-            $content .= "Aligned $result->cvname: $result->feature_name ";
-         }
-      }
-   }
-   $content .= "</strong>";
-   return $content;
-}
-
-/*******************************************************************************
- * tripal_analysis_unigene_results ()
- * Prepare unigene result for the feature shown on the page
- */
-function theme_tripal_analysis_unigene_feature_alignments($node) {
-   $feature = $node->feature;
-   $obj_feature = tripal_analysis_unigene_get_alignments($feature);
-   $alignments = $obj_feature->alignments;
-   if(count($alignments) > 0){
-      $content = "<div id=\"tripal_analysis_unigene_box\" class=\"tripal_unigene-info-box\">";
-      // we're showing contig alignments in GBrowse so create a link here for
-      // that if this feature is a contig
-      if($node->feature->cvname == 'contig'){
-         $content .= "<div class=\"tripal_expandableBox\">".
-                     "  <h3>ESTs in this contig</h3>".
-                     "</div>";
-         $content .= "<div class=\"tripal_expandableBoxContent\">";
-      } else {
-         $content .= "<div class=\"tripal_expandableBox\">".
-                     "  <h3>Alignments</h3>".
-                     "</div>";
-         $content .= "<div class=\"tripal_expandableBoxContent\">";
-      }
-      $content .= "".
-         "<table class=\"tripal_table_horz\">".
-         "  <tr>".
-         "    <th>Type</th>".
-         "    <th>Feature</th>".
-         "    <th align=\"right\">Position</th>".
-         "  </tr>";
-      // iterate through each alignment
-      foreach ($alignments as $result){
-         // EST alignments in chado use an EST_match type to map ESTs to
-         // contigs and a rank to indicate the major srcfeature.
-         // We don't want to show EST_matches on the alignment view
-         // since that doesn't make much sense to the end user.  If this
-         // is an EST_match and the feature is an EST then we want to show
-         // the contig in the alignments.  The contig name is part of the
-         // uniquename in the EST_match
-         if($node->feature->cvname == 'EST' && $result->cvname == 'EST_match'){
-            $sql = "SELECT srcfeature_id ".
-                   "FROM {featureloc} ".
-                   "WHERE feature_id = $result->feature_id ".
-                   "ORDER BY rank";
-            $previous_db = tripal_db_set_active ('chado');
-            $contig_fid = db_result(db_query($sql));
-            $sql = "SELECT name FROM {feature} WHERE feature_id = $contig_fid";
-            $contig_name = db_result(db_query($sql));
-            tripal_db_set_active($previous_db);
-            $sql = "SELECT nid ".
-                   "FROM {chado_feature} ".
-                   "WHERE feature_id = $contig_fid";
-            $contig_nid = db_result(db_query($sql));
-            // Check if the EST exists as a drupal node. If yes, add a link to
-            // it. If no, just show the name
-            if ($contig_nid != 0) {
-               $sql = "SELECT nid FROM {node} WHERE nid=$contig_nid";
-               $node_exists = db_result(db_query($sql));
-            }
-            $content .=
-              "<tr>".
-              "  <td>Contig</td>".
-              "  <td>";
-            if ($node_exists != 0) {
-               $content .= "<a href=\"".url("node/$contig_nid")."\">".
-              	     	   "$contig_name</a>";
-            } else {
-               $content .= $contig_name;
-            }
-            $content .=
-              "  </td>".
-              "  <td align=\"right\">".
-            number_format($result->fmin).
-                   "-".
-            number_format($result->fmax).
-              "  </td>".
-              "</tr>";
-         }
-
-         elseif($node->feature->cvname == 'contig' &&
-         $result->cvname == 'EST_match'){
-            $sql = "SELECT vid ".
-                   "FROM {node} ".
-                   "WHERE title = '$result->feature_name'".
-                   "ORDER BY vid DESC";
-            // since the feature name is also the node title we can look it up
-            $est_node = db_fetch_object(db_query($sql));
-            $content .=
-              "<tr>".
-              "  <td>EST</td>".
-              "  <td>";
-            //Check if the EST exists as a drupal node before adding a hyperlink
-            if ($est_node->vid != 0) {
-               $content .=
-               	 "<a href=\"".url("node/$est_node->vid")."\">".
-               $result->feature_name.
-              	 "</a>";
-            } else {
-               $content .= $result->feature_name;
-            }
-            $content .=
-              "  </td>".
-              "  <td align=\"right\">".
-            number_format($result->fmin).
-                   "-".
-            number_format($result->fmax).
-              "  </td>".
-              "</tr>";
-         }
-         else {
-            $content .= "".
-              "<tr>".
-              "  <td>$result->cvname</td>".
-              "  <td>$result->feature_name</td>".
-              "  <td align=\"right\">$result->fmin</td>".
-              "  <td align=\"right\">$result->fmax</td>".
-              "  <td align=\"right\">$result->strand</td>".
-              "</tr>";
-         }
-      }
-      $content .= "</table>";
-
-      /* if this is a contig then get the alignment
-       if($node->feature->cvname == 'contig'){
-       // get the directory prefix
-       $prefix = preg_replace("/^(\d*)\d{3}$/","$1",$node->feature_id);
-       if(!$prefix){
-       $prefix = '0';
-       }
-       $data_url = variable_get('chado_feature_data_url','sites/default/files/data');
-       $fh = fopen("$data_url/misc/$prefix/$node->feature->feature_id/alignment.txt", 'r');
-       if($fh){
-       $content .= "<b>Alignment:</b><div class=\"tripal_feature_assembly_alignment\"><pre>";
-       while(!feof($fh)){
-       $content .= fgets($fh);
-       }
-       $content .="</pre></div>";
-       }
-       fclose($fh);
-       }
-       */
-      $content .= "</div></div>";
-   }
-   return $content;
-}
-/*******************************************************************************
-*
-*/
-function tripal_analysis_unigene_get_alignments($map) {
-
-   // get the alignments for this feature
-   $sql = "SELECT F.name as feature_name, FL.fmin, FL.fmax, FL.strand, ".
-          "  FL.phase, CVT.name as cvname, F.feature_id, F.uniquename, ".
-          "  FL.featureloc_id ".
-          "FROM {featureloc} FL ".
-          "  INNER JOIN Feature F ON F.feature_id = FL.feature_id ".
-          "  INNER JOIN Cvterm CVT ON CVT.cvterm_id = F.type_id ".
-          "WHERE srcfeature_id = %d AND ".
-          "  NOT(CVT.name = 'match' or CVT.name = 'match_part') ".
-          "ORDER BY FL.fmin, FL.fmax";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$map->feature_id);
-   $alignments = array();
-   $i=0;
-   while($subfeature = db_fetch_object($results)){
-      $alignments[$i++] = $subfeature;
-   }
-   $additions->alignments = $alignments;
-
-   /* get the GO Terms
-    $sql = "SELECT DISTINCT * FROM {go_results_mview} ".
-    "WHERE feature_id = %d";
-    $results = db_query($sql,$map->feature_id);
-    $go_terms = array();
-    $i=0;
-    while($term = db_fetch_object($results)){
-    $go_terms[$i++] = $term;
-    }
-    $additions->go_terms = $go_terms;
-
-    // get the feature properties
-    $sql = "SELECT FP.value,FP.rank,CVT.name,CVT.definition ".
-    "FROM {featureprop} FP".
-    "  INNER JOIN Cvterm CVT ".
-    "    ON FP.type_id = CVT.cvterm_id ".
-    "WHERE feature_id = %d";
-    $results = db_query($sql,$map->feature_id);
-    $properties = array();
-    $i=0;
-    while($property = db_fetch_object($results)){
-    $properties[$i++] = $property;
-    }
-    $additions->properties = $properties;
-    */
-   tripal_db_set_active($previous_db);
-   return $additions;
-}
-/************************************************************************
-*
-*/   
-function tripal_analysis_unigene_load_organism_unigenes($organism){
-
-   // get information about this assemblies and add it to the items in this node
-   $sql = "SELECT * FROM {organism_unigene_mview} OUM ".
-          "  INNER JOIN {analysis} A  ON A.analysis_id = OUM.analysis_id ".
-          "WHERE OUM.organism_id = %d ".
-          "ORDER BY A.timeexecuted DESC";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $results = db_query($sql,$organism->organism_id);
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   $unigenes = array();
-   $i=0;
-   $sql = "SELECT nid FROM {chado_analysis} WHERE analysis_id = %d";
-   while($unigene = db_fetch_object($results)){
-      $analysis_id = $unigene->analysis_id;
-      $c_node = db_fetch_object(db_query($sql,$analysis_id));
-      if($c_node){  
-         $unigene->nid = $c_node->nid;
-      }
-      // add in the properties
-      $unigene_name = tripal_analysis_get_property($analysis_id,'analysis_unigene_name');
-      $num_contigs  = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_contigs');
-      $num_reads    = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_reads');
-      $num_clusters = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_clusters');
-      $num_singlets = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_singlets');
-      
-      $unigene->unigene_name = $unigene_name->value;
-      $unigene->num_reads = $num_reads->value;
-      $unigene->num_clusters = $num_clusters->value;
-      $unigene->num_contigs = $num_contigs->value;     
-      $unigene->num_singlets = $num_singlets->value;
-
-      $unigenes[$i++] = $unigene;
-   }
-   return $unigenes;
-}
-/************************************************************************
-*
-*/   
-function tripal_analysis_unigene_load_feature_unigenes($feature){
-
-   // first get all the unigene analyses for this organism
-   $sql = "SELECT * FROM {organism_unigene_mview} OUM ".
-          "  INNER JOIN {analysis} A  ON A.analysis_id = OUM.analysis_id ".
-          "WHERE OUM.organism_id = %d ".
-          "ORDER BY A.timeexecuted DESC";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $results = db_query($sql,$feature->organism_id->organism_id);
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   // iterate through the unigenes and find those that use this feature
-   $unigenes = array();
-   $i=0;
-   $sql = "SELECT nid FROM {chado_analysis} WHERE analysis_id = %d";
-   while($unigene = db_fetch_object($results)){
-      $analysis_id = $unigene->analysis_id;
-
-      // check if this feature is present in the unigene
-      $values = array(
-         'feature_id' => $feature->feature_id,
-         'analysis_id' => $analysis_id,
-      );
-      $hasFeature = tripal_core_chado_select('analysisfeature',array('*'),$values);
-      
-      // if the feature is present then get information about it
-      if(sizeof($hasFeature) > 0){
-         // see if there is a drupal node for this unigene
-         $c_node = db_fetch_object(db_query($sql,$analysis_id));
-         if($c_node){  
-            $unigene->nid = $c_node->nid;
-         }
-         // add in the properties
-         $unigene_name = tripal_analysis_get_property($analysis_id,'analysis_unigene_name');
-         $singlet = tripal_core_get_property('analysisfeature',$analysis_id,'singlet','tripal');       
-         
-         $unigene->unigene_name = $unigene_name->value;    
-         $unigene->singlet = $num_singlets->value;
-
-         $unigenes[$i++] = $unigene;
-      }
-   }
-   return $unigenes;
-}
-/*******************************************************************************
- * Tripal Unigene administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_unigene_get_settings() {
-   // Get an array of node types with internal names as keys
-   $options = node_get_types('names');
-   // Add 'chado_feature' to allowed content types for showing unigene results
-   $allowedoptions ['chado_feature'] = "Show 'ESTs in this contig' on feature pages";
-   $allowedoptions ['chado_organism'] = "Show assemblies on organism pages";
-
-   $form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("This option allows user to display the unigene assembly ".
-          "information. For contigs, this would include an alignment and for ".
-          "organisms this would be a list of assemblies. Check the box to ".
-          "enable the display of unigene information. Uncheck to disable."),
-		 '#weight' => 0,
-   );
-
-   $form['tripal_analysis_unigene_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value'=>variable_get('tripal_analysis_unigene_setting',array()),
-   );
-   $settings->form = $form;
-   $settings->title = "Tripal Unigene";
-   return $settings;
-}
-
-

+ 0 - 0
base/tripal_analysis/tripal_analysis.admin.inc → tripal_analysis/tripal_analysis.admin.inc


+ 0 - 0
base/tripal_analysis/tripal_analysis.api.inc → tripal_analysis/tripal_analysis.api.inc


+ 0 - 0
base/tripal_analysis/tripal_analysis.info → tripal_analysis/tripal_analysis.info


+ 0 - 0
base/tripal_analysis/tripal_analysis.install → tripal_analysis/tripal_analysis.install


+ 0 - 0
base/tripal_analysis/tripal_analysis.module → tripal_analysis/tripal_analysis.module


+ 0 - 0
base/tripal_analysis/tripal_analysis.views.inc → tripal_analysis/tripal_analysis.views.inc


+ 0 - 0
base/tripal_analysis/tripal_analysis_privacy.inc → tripal_analysis/tripal_analysis_privacy.inc


+ 0 - 0
base/tripal_analysis/views/README → tripal_analysis/views/README


+ 0 - 0
base/tripal_analysis/views/analysis.views.inc → tripal_analysis/views/analysis.views.inc


+ 0 - 0
base/tripal_analysis/views/chado_analysis.views.inc → tripal_analysis/views/chado_analysis.views.inc


+ 0 - 0
base/tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc → tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc


+ 0 - 0
base/tripal_analysis/views/misc_tables.views.inc → tripal_analysis/views/misc_tables.views.inc


+ 0 - 0
base/tripal_analysis/views/template.node_join.views.inc → tripal_analysis/views/template.node_join.views.inc


+ 0 - 0
base/tripal_analysis/views/template.table_defn.views.inc → tripal_analysis/views/template.table_defn.views.inc


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.admin.inc → tripal_bulk_loader/tripal_bulk_loader.admin.inc


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.constants.inc → tripal_bulk_loader/tripal_bulk_loader.constants.inc


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.info → tripal_bulk_loader/tripal_bulk_loader.info


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.install → tripal_bulk_loader/tripal_bulk_loader.install


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.loader.inc → tripal_bulk_loader/tripal_bulk_loader.loader.inc


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.module → tripal_bulk_loader/tripal_bulk_loader.module


+ 0 - 0
base/tripal_contact/tripal_contact.api.inc → tripal_contact/tripal_contact.api.inc


+ 0 - 0
base/tripal_contact/tripal_contact.info → tripal_contact/tripal_contact.info


+ 0 - 0
base/tripal_contact/tripal_contact.module → tripal_contact/tripal_contact.module


+ 0 - 0
base/tripal_contact/tripal_contact.views.inc → tripal_contact/tripal_contact.views.inc


+ 0 - 0
base/tripal_contact/views/README → tripal_contact/views/README


+ 0 - 0
base/tripal_contact/views/template.node_join.views.inc → tripal_contact/views/template.node_join.views.inc


+ 0 - 0
base/tripal_contact/views/template.table_defn.views.inc → tripal_contact/views/template.table_defn.views.inc


+ 0 - 0
base/tripal_core/chado_install.php → tripal_core/chado_install.php


+ 0 - 0
base/tripal_core/cvterms.php → tripal_core/cvterms.php


+ 0 - 0
base/tripal_core/default_schema.sql → tripal_core/default_schema.sql


+ 0 - 0
base/tripal_core/initialize.sql → tripal_core/initialize.sql


+ 0 - 0
base/tripal_core/jobs.php → tripal_core/jobs.php


+ 0 - 0
base/tripal_core/mviews.php → tripal_core/mviews.php


+ 0 - 0
base/tripal_core/tripal_core.api.inc → tripal_core/tripal_core.api.inc


+ 0 - 0
base/tripal_core/tripal_core.info → tripal_core/tripal_core.info


+ 0 - 0
base/tripal_core/tripal_core.install → tripal_core/tripal_core.install


+ 0 - 0
base/tripal_core/tripal_core.module → tripal_core/tripal_core.module


+ 0 - 0
base/tripal_core/tripal_core.schema.api.inc → tripal_core/tripal_core.schema.api.inc


+ 0 - 0
base/tripal_core/tripal_core_job_view.tpl.php → tripal_core/tripal_core_job_view.tpl.php


+ 0 - 0
base/tripal_core/tripal_launch_jobs.php → tripal_core/tripal_launch_jobs.php


+ 0 - 0
base/tripal_core/tripal_launch_jobs_multi.php → tripal_core/tripal_launch_jobs_multi.php


+ 0 - 0
base/tripal_cv/charts.php → tripal_cv/charts.php


+ 0 - 0
base/tripal_cv/feature_property.obo → tripal_cv/feature_property.obo


+ 0 - 0
base/tripal_cv/obo_loader.php → tripal_cv/obo_loader.php


+ 0 - 0
base/tripal_cv/trees.php → tripal_cv/trees.php


Some files were not shown because too many files changed in this diff