ccheng 14 years ago
parent
commit
5305a34059

+ 0 - 35
theme_tripal/css/tripal_search_feature.css

@@ -1,35 +0,0 @@
-.view-est-search .views-exposed-form {
-	margin: 10px;
-	padding:10px;
-	background: #FFFFFF;
-	border: 1px solid #CCCCCC;
-}
-
-.view-est-search .tripal-search-feature-exposed-widget {
-	clear:both;
-	padding: 5px;
-}
-
-.view-est-search .tripal-search-feature-form-labels {
-	float:left;
-}
-
-.view-est-search .views-operator {
-	float:left;
-	clear:none;
-	margin-left: 5px;
-}
-
-.view-est-search .views-widget {
-	float:left;
-	clear:none;
-	margin-left: 5px;
-}
-
-.view-est-search .view-content .views-table {
-	margin-left: 10px;
-}
- 
- .tripal-search-feature-exposed-widgets-fields legend{
-   color:green;
- }

+ 40 - 0
theme_tripal/css/tripal_search_unigene.css

@@ -0,0 +1,40 @@
+.tripal_search_unigene-views-exposed-form {
+	margin: 10px;
+	padding:10px;
+	background: #FFFFFF;
+	border: 1px solid #CCCCCC;
+}
+
+.tripal-search-unigene-exposed-widget {
+	clear:both;
+	padding: 5px;
+}
+
+.tripal-search-unigene-form-labels {
+	float:left;
+}
+
+.tripal_search_unigene-views-operator {
+	float:left;
+	clear:none;
+	margin-left: 5px;
+}
+
+.tripal_search_unigene-views-widget {
+	float:left;
+	clear:none;
+	margin-left: 5px;
+}
+
+.tripal_search_unigene-table {
+	margin-left: 10px;
+}
+ 
+ .tripal-search-unigene-exposed-widgets-fields legend{
+   color:green;
+ }
+ 
+ #tripal_search_unigene-result-top:hover {
+   text-decoration: none;
+   color:#292929;
+ }

+ 0 - 9
theme_tripal/js/tripal_search_feature.js

@@ -1,9 +0,0 @@
-//
-// Copyright 2009 Clemson University
-//
-
-if (Drupal.jsEnabled) {
-
-   $(document).ready(function(){   
-   });
-}

+ 20 - 0
theme_tripal/js/tripal_search_unigene.js

@@ -0,0 +1,20 @@
+//
+// Copyright 2009 Clemson University
+//
+
+if (Drupal.jsEnabled) {
+
+   $(document).ready(function(){
+
+		// Move to the result top
+		var result_top = document.getElementById('tripal_search_unigene-result-top');
+		if (result_top) {	
+			 var target_offset = $("#tripal_search_unigene-result-top").offset();
+			 var target_top = target_offset.top;
+			 if (navigator.userAgent.indexOf('MSIE 8.0') !=-1) 	{
+				target_top -= 60;	
+			}
+			$('html, body').animate({scrollTop: target_top}, 1000);
+		}
+   });
+}

+ 1 - 0
theme_tripal/tripal_analysis_blast

@@ -0,0 +1 @@
+../tripal_analysis_blast/theme/tripal_analysis_blast

+ 1 - 0
theme_tripal/tripal_analysis_kegg

@@ -0,0 +1 @@
+../tripal_analysis_kegg/theme/tripal_analysis_kegg

+ 1 - 0
theme_tripal/tripal_analysis_unigene

@@ -0,0 +1 @@
+../tripal_analysis_unigene/theme/tripal_analysis_unigene

+ 44 - 44
theme_tripal/views-exposed-form--est_search.tpl.php → theme_tripal/views-exposed-form--unigene_search.tpl.php

@@ -23,7 +23,7 @@
 
   ?>
 <?php endif;     //dsm($widgets);?>
-<div class="views-exposed-form">
+<div class="tripal_search_unigene-views-exposed-form views-exposed-form">
   <div class="views-exposed-widgets clear-block">
     
     <?php 
@@ -38,148 +38,148 @@
     	$kegg_value =  $widgets['filter-kegg_value'];
     ?>
     
-    <div id="tripal-search-feature-exposed-widgets">
+    <div id="tripal-search-unigene-exposed-widgets">
     <div> Search ESTs or unigene contigs by name, assembly, sequence type, length, or their putative function. <br><br></div>
-			<fieldset class="tripal-search-feature-exposed-widgets-fields">
+			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
 				<legend>Search by Name</legend>
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $orgnism_common_name->id; ?>"><?php print $orgnism_common_name->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($orgnism_common_name->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $orgnism_common_name->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 					<?php print $orgnism_common_name->widget; ?>
 					</div>
 				</div>
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $feature_name->id; ?>"><?php print $feature_name->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($feature_name->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $feature_name->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 						<?php print $feature_name->widget; ?>
 					</div>
 				</div>
 			</fieldset>
 
-			<fieldset class="tripal-search-feature-exposed-widgets-fields">
+			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
 				<legend>Search by Assembly</legend>
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $feature_type_id->id; ?>"><?php print $feature_type_id->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($feature_type_id->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $feature_type_id->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 					<?php print $feature_type_id->widget; ?>
 					</div>
 				</div>
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $analysis_name->id; ?>"><?php print $analysis_name->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($analysis_name->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $analysis_name->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 						<?php print $analysis_name->widget; ?>
 					</div>
 				</div>
 			</fieldset>
 
-			<fieldset class="tripal-search-feature-exposed-widgets-fields">
+			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
 				<legend>Search by Sequence</legend>
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $feature_seqlen->id; ?>"><?php print $feature_seqlen->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($feature_seqlen->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $feature_seqlen->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 					<?php print $feature_seqlen->widget; ?>
 					</div>
 				</div>
 			</fieldset>
 
-			<fieldset class="tripal-search-feature-exposed-widgets-fields">
+			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
 				<legend>Search by Putative Function</legend>
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $cvterm_name->id; ?>"><?php print $cvterm_name->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($cvterm_name->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $cvterm_name->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 					<?php print $cvterm_name->widget; ?>
 					</div>
 				</div>
 
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $blast_value->id; ?>"><?php print $blast_value->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($blast_value->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $blast_value->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 						<?php print $blast_value->widget; ?>
 					</div>
 				</div>
 				
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $kegg_value->id; ?>"><?php print $kegg_value->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($kegg_value->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $kegg_value->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 						<?php print $kegg_value->widget; ?>
 					</div>
 				</div>
 				
-				<div class="tripal-search-feature-exposed-widget">
-					<div class="tripal-search-feature-form-labels">
+				<div class="tripal-search-unigene-exposed-widget">
+					<div class="tripal-search-unigene-form-labels">
 						<label for="<?php print $interpro_value->id; ?>"><?php print $interpro_value->label; ?>
 						</label>
 					</div>
 					<?php if (!empty($interpro_value->operator)): ?>
-					<div class="views-operator">
+					<div class="tripal_search_unigene-views-operator">
 					<?php print $interpro_value->operator; ?>
 					</div>
 					<?php endif; ?>
-					<div class="views-widget">
+					<div class="tripal_search_unigene-views-widget">
 						<?php print $interpro_value->widget; ?>
 					</div>
 				</div>
@@ -187,8 +187,8 @@
 
 		</div>
     
-    <div class="tripal-search-feature-exposed-widget">
-    	<input type="Button" class="form-submit" value="Reset" onClick="window.location = '<?php global $base_url; print "$base_url/est_search"?>';">
+    <div class="tripal-search-unigene-exposed-widget">
+    	<input TYPE="Button" value="Reset" onClick="window.location = '<?php global $base_url; print "$base_url/est_search"?>';">
       <?php $button = preg_replace("'Apply'", "Search", $button); print $button ?>
     </div>
   </div>

+ 0 - 50
theme_tripal/views-view-table--est_search.tpl.php

@@ -1,50 +0,0 @@
-<?php
-// $Id: views-view-table.tpl.php,v 1.8 2009/01/28 00:43:43 merlinofchaos Exp $
-/**
- * @file views-view-table.tpl.php
- * Template to display a view as a table.
- *
- * - $title : The title of this group of rows.  May be empty.
- * - $header: An array of header labels keyed by field id.
- * - $fields: An array of CSS IDs to use for each field id.
- * - $class: A class or classes to apply to the table, based on settings.
- * - $row_classes: An array of classes to apply to each row, indexed by row
- *   number. This matches the index in $rows.
- * - $rows: An array of row items. Each row is an array of content.
- *   $rows are keyed by row number, fields within rows are keyed by field ID.
- * @ingroup views_templates
- */
-?>
-<i>&nbsp;&nbsp;&nbsp;Note: To get complete annotation for a sequence, click on the sequence name.</i>
-<table class="tripal_search_feature-table  tripal-table tripal-table-horz <?php print $class; ?>">
-  <?php if (!empty($title)) : ?>
-    <caption><?php print $title; ?></caption>
-  <?php endif; ?>
-  <thead>
-    <tr class="tripal_search_feature-table-odd-row tripal-table-odd-row">
-      <?php foreach ($header as $field => $label): ?>
-        <th class="views-field views-field-<?php print $fields[$field]; ?>">
-          <?php print $label; ?>
-        </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>
-  <tbody>
-    <?php foreach ($rows as $count => $row): 
-    			$rowclass = "";
-    			if ($count % 2 == 0) {
-    				$rowclass = "tripal_search_feature-table-even-row tripal-table-even-row";
-    			} else {
-    				$rowclass = "tripal_search_feature-table-odd-row tripal-table-odd-row";
-    			}
-    ?>
-      <tr class="<?php print $rowclass?> <?php print implode(' ', $row_classes[$count]); ?>">
-        <?php foreach ($row as $field => $content): ?>
-          <td class="views-field views-field-<?php print $fields[$field]; ?>">
-            <?php print $content; ?>
-          </td>
-        <?php endforeach; ?>
-      </tr>
-    <?php endforeach; ?>
-  </tbody>
-</table>

+ 219 - 0
theme_tripal/views-view-table--unigene_search.tpl.php

@@ -0,0 +1,219 @@
+<?php
+// $Id: views-view-table.tpl.php,v 1.8 2009/01/28 00:43:43 merlinofchaos Exp $
+/**
+ * @file views-view-table.tpl.php
+ * Template to display a view as a table.
+ *
+ * - $title : The title of this group of rows.  May be empty.
+ * - $header: An array of header labels keyed by field id.
+ * - $fields: An array of CSS IDs to use for each field id.
+ * - $class: A class or classes to apply to the table, based on settings.
+ * - $row_classes: An array of classes to apply to each row, indexed by row
+ *   number. This matches the index in $rows.
+ * - $rows: An array of row items. Each row is an array of content.
+ *   $rows are keyed by row number, fields within rows are keyed by field ID.
+ * @ingroup views_templates
+ */
+?>
+
+<?php
+$total = $view->total_rows;
+$query = $view->build_info['query'];
+$pager = $view->pager;
+$limit = $pager ['items_per_page'];
+$offset = $pager ['current_page'] * $limit;
+$args = $view->build_info['query_args'];
+global $base_url;
+?>
+
+<a id="tripal_search_unigene-result-top" name="search_results">
+&nbsp;&nbsp;&nbsp;Your search produced <b><?php print $total ?></b> results<br>
+<i>&nbsp;&nbsp;&nbsp;Note: To get complete annotation for a sequence, click on the sequence name.</i>
+</a>
+<table class="tripal_search_unigene-table <?php print $class; ?> tripal-table-horz">
+  <?php if (!empty($title)) : ?>
+    <caption><?php print $title; ?></caption>
+  <?php endif; ?>
+  <thead>
+    <tr class="tripal_search_unigene-table-header tripal-table-header">
+      <?php foreach ($header as $field => $label): ?>
+        <th class="views-field views-field-<?php print $fields[$field]; ?>">
+          <?php print $label; ?>
+        </th>
+      <?php endforeach; ?>
+    </tr>
+  </thead>
+  <tbody>
+    <?php foreach ($rows as $count => $row): 
+    			$rowclass = "";
+    			if ($count % 2 != 0) {
+    				$rowclass = "tripal_search_unigene-table-even-row tripal-table-even-row";
+    			} else {
+    				$rowclass = "tripal_search_unigene-table-odd-row tripal-table-odd-row";
+    			}
+    ?>
+      <tr class="<?php print $rowclass?> <?php print implode(' ', $row_classes[$count]); ?>">
+        <?php foreach ($row as $field => $content): ?>
+          <td class="views-field views-field-<?php print $fields[$field]; ?>">
+            <?php print $content; ?>
+          </td>
+        <?php endforeach; ?>
+      </tr>
+    <?php endforeach; ?>
+  </tbody>
+</table>
+
+<?php if ($count != 0) {
+	// Generate Excel files
+	// set parameters for excel file
+	$param_excel= array();
+	global $user;
+	$dir = file_directory_path().'/tripal/tripal_search_unigene/'.session_id();
+	if (!file_exists($dir)) {
+		mkdir ($dir, 0777);
+	}
+	$file =session_id().'/unigene_search_result.xls';
+	
+	$param_excel['sheet_name']		= 'unigene_search';
+	$path = "/tripal/tripal_search_unigene/$file";
+	$param_excel['filename']		= file_directory_path().$path;
+	$path_url =url("sites/default/files/tripal/tripal_search_unigene/$file");
+	# set SQL
+	$sql = "$query LIMIT $limit OFFSET $offset";
+	# create heades
+	$col_chr = 'A';
+	$headers = array();
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'hyperlink', 'field' => 'unigene_for_search_feature_name', 'heading' => 'Feature name');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 10, 'type' => 'text', 'field' => 'unigene_for_search_organism_common_name', 'heading' => 'Organism');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 10, 'type' => 'text', 'field' => 'unigene_for_search_feature_seqlen', 'heading' => 'Length');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 10, 'type' => 'text', 'field' => 'unigene_for_search_feature_type', 'heading' => 'Type');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'text', 'field' => 'unigene_for_search_go_term', 'heading' => 'GO term');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'text', 'field' => 'unigene_for_search_blast_value', 'heading' => 'Blast');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'text', 'field' => 'unigene_for_search_kegg_value', 'heading' => 'KEGG');
+	$headers[$col_chr++] = array('align' => 'left', 'width' => 20, 'type' => 'text', 'field' => 'unigene_for_search_interpro_value', 'heading' => 'Interpro');
+	
+	# populate data
+	$result = chado_query($sql, $args);
+	$data = array();
+	while ($row = db_fetch_array($result)) {
+		$data[] = array ('unigene_for_search_feature_name' => $row['unigene_for_search_feature_name'],
+									 'hyperlink_unigene_for_search_feature_name' => "$base_url/ID".$row['unigene_for_search_feature_id'],
+									 'unigene_for_search_organism_common_name' => $row['unigene_for_search_organism_common_name'],
+									 'unigene_for_search_feature_seqlen' => $row['unigene_for_search_feature_seqlen'],
+									 'unigene_for_search_feature_type' => $row['unigene_for_search_feature_type'],
+									 'unigene_for_search_go_term' => $row['unigene_for_search_go_term'],
+									 'unigene_for_search_blast_value' => $row['unigene_for_search_blast_value'],
+									 'unigene_for_search_kegg_value' => $row['unigene_for_search_kegg_value'],
+									 'unigene_for_search_interpro_value' => $row['unigene_for_search_interpro_value']
+									 );
+	}
+	# add headers and data
+	$param_excel['contents']['sheet']['headers']= $headers;
+	$param_excel['contents']['sheet']['data']= $data;
+	# generate excel
+	ml_generate_excel($param_excel);
+	print "&nbsp;&nbsp;&nbsp;<a href=\"$path_url\">Download as Excel file</a>";
+}?>
+
+<?php 
+# ----------------------------------------- #
+# [UD] ml_generate_excel
+# ----------------------------------------- #
+function ml_generate_excel ($param_excel) {
+	# get and update parameters
+	$writer		= ($param_excel['version'] == '2007') ? 'Excel2007' : 'Excel5';
+	$link_clr	= (empty($param_excel['link_clr'])) ? '0000FF' : $param_excel['link_clr'];
+	$filename	= $param_excel['filename'];
+	if (!preg_match("/(xls|xlsx)$/", $filename)) {
+		$filename = ($param_excel['version'] == '2007') ? $filename.'.xlsx' : $filename.'.xls';
+	}
+	/*********************************************/
+	# create an excel file
+	/*********************************************/
+	# create new PHPExcel object
+	$excel = new PHPExcel();
+	# Set properties
+	$excel->getProperties()->setCreator("Main Lab");
+	$excel->getProperties()->setLastModifiedBy("Main Lab");
+	$excel->getProperties()->setTitle("Office 2007 XLSX Document");
+	$excel->getProperties()->setSubject("");
+	$excel->getProperties()->setKeywords("");
+	$excel->getProperties()->setCategory("");
+	$excel->getProperties()->setDescription("");
+	# set default styles
+	$excel->getDefaultStyle()->getFont()->setName('Times New Roman');
+	$excel->getDefaultStyle()->getFont()->setSize(11);
+	# create worksheets
+	$sheet_no= 0;
+	foreach ($param_excel['contents'] as $sheet_name => $sheet) {
+		if ($sheet_no != 0) {
+			# add a new worksheet
+			$excel->createSheet();
+		}	
+		# set active sheet
+		$excel->setActiveSheetIndex($sheet_no);		
+		# get current worksheet
+		$worksheet = $excel->getActiveSheet();	
+		# set title for this sheet
+		$worksheet->setTitle($sheet_name);
+		# get headers
+		$headers= $param_excel['contents'][$sheet_name]['headers'];
+		# set style and headings for headers
+		foreach ($headers as $col_chr => $prop) {
+			# set alignment for column
+			$align= PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
+			if ($prop['align'] == 'right') {
+				$align= PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
+			}
+			else if ($prop['align'] == 'center') {
+				$align= PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
+			}
+			$worksheet->getStyle($col_chr.'1')->getAlignment()->setHorizontal($align);		
+			# set width
+			$worksheet->getColumnDimension($col_chr)->setWidth($prop['width']);
+			$worksheet->getStyle($col_chr.'1')->getFont()->setBold(true);
+			$worksheet->getStyle($col_chr.'1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
+			$worksheet->getStyle($col_chr.'1')->getFill()->getStartColor()->setARGB('FFCDCDCD');
+			$worksheet->setCellValue($col_chr.'1', $prop['heading']);
+		}		
+		# add data to current worksheet
+		foreach ($param_excel['contents'][$sheet_name]['data'] as $idx => $row) {
+			foreach ($headers as $col_chr => $prop) {
+				$loc= $col_chr.($idx+2);
+				# set alignment for cell
+				$align= PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
+				if ($prop['align'] == 'right') {
+					$align= PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
+				}
+				else if ($prop['align'] == 'center') {
+					$align= PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
+				}
+				$worksheet->getStyle($loc)->getAlignment()->setHorizontal($align);
+				
+				if (!empty($row[$prop['field']])) {
+					# set cell value
+					if ($prop['type'] == 'text') {
+						$worksheet->setCellValue($loc, $row[$prop['field']]);
+					}
+					else if ($prop['type'] == 'hyperlink') {
+						$worksheet->setCellValue($loc, $row[$prop['field']]);
+						if ($row['hyperlink_'.$prop['field']]) {
+							# add underline
+							$worksheet->getStyle($loc)->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
+							# set link color
+							$worksheet->getStyle($loc)->getFont()->getColor()->setRGB($link_clr);		
+							# set URL
+							$worksheet->getCell($loc)->getHyperlink()->setUrl($row['hyperlink_'.$prop['field']]);
+						}
+					}
+				}
+			}
+		}
+		$sheet_no++;
+	}	
+		# create excel file
+ 		$excel->setActiveSheetIndex(0);
+ 		$objWriter = PHPExcel_IOFactory::createWriter($excel, $writer);
+ 		$objWriter->save($filename);
+}
+?>

+ 1 - 0
tripal_analysis/tripal_analysis.module

@@ -15,6 +15,7 @@
  */
 
 require('tripal_analysis.api.inc');
+require('tripal_analysis_privacy.inc');
 
 
 /**

+ 109 - 0
tripal_analysis/tripal_analysis_privacy.inc

@@ -0,0 +1,109 @@
+<?php
+
+/*
+ *  Perform permission check by analysis_id only if 'node_privacy_byrole' module is enabled
+ */
+function tripal_analysis_check_permission ($analysis_id) {
+	if (module_exists('node_privacy_byrole')) {
+		global $user;
+		$roles = $user->roles;
+		$node_access = 0;
+		foreach ($roles AS $rid => $role) {
+			$p_sql = "SELECT grant_view FROM {node_access} NA INNER JOIN {chado_analysis} CA ON NA.nid = CA.nid WHERE analysis_id=%d AND gid = %d";
+			$access = db_result(db_query($p_sql,$analysis_id, $rid));
+			if ($access == 1) {
+				$node_access = 1;
+				break;
+			}
+		}
+		if ($node_access == 1 || $user->uid == 1) {
+			return TRUE;
+		} else {
+			return FALSE;
+		}
+	
+	// If 'node_privacy_byrole' module is not enabled, return TRUE;
+	} else {
+		return TRUE;
+	}
+}
+/*
+ *  Perform permission check by node_id only if 'node_privacy_byrole' module is enabled
+ */
+function tripal_analysis_check_permission_by_node_id ($nid) {
+	if (module_exists('node_privacy_byrole')) {
+		global $user;
+		$roles = $user->roles;
+		$node_access = 0;
+		foreach ($roles AS $rid => $role) {
+			$p_sql = "SELECT grant_view FROM {node_access} WHERE nid=%d AND gid = %d";
+			$access = db_result(db_query($p_sql,$nid, $rid));
+			if ($access == 1) {
+				$node_access = 1;
+				break;
+			}
+		}
+		if ($node_access == 1 || $user->uid == 1) {
+			return TRUE;
+		} else {
+			return FALSE;
+		}
+	
+	// If 'node_privacy_byrole' module is not enabled, return TRUE;
+	} else {
+		return TRUE;
+	}
+}
+
+/*
+ * Set permissions for features associated with an analysis
+ */
+function tripal_analysis_set_feature_permission ($analysis_id, $nid) {
+	
+	print "Updating feature permissions:\n";
+	
+	// Get features associated with the analysis
+	$sql = "SELECT feature_id FROM {analysisfeature} WHERE analysis_id = %d";
+	$previous_db = db_set_active('chado');
+	$features = db_query($sql, $analysis_id);
+	db_set_active($previous_db);
+	
+	// Convert feature_id into node_id
+	$feature_nids = array ();
+	$counter = 0;
+	$sql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
+	while ($feature = db_fetch_object($features)) {
+		$feature_nids [$counter] = db_result(db_query($sql, $feature->feature_id));
+		$counter ++;
+	}
+	
+	//Convert analysis_id into node_id
+	$ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = $analysis_id"));
+	// Get available roles
+	$roles = array_keys(user_roles());
+	
+	$interval = intval(($counter + 1) * 0.01);
+	$idx_iterations = 1;
+	
+	// Update permission node by node
+	foreach ($feature_nids AS $fnid) {
+		if ($idx_iterations % $interval == 0) {
+			$percentage = (int) ($idx_iterations / ($counter + 1) * 100);
+			tripal_job_set_progress($job_id, $percentage);
+			print $percentage."% ";
+		}
+
+		db_query("DELETE FROM {node_privacy_byrole} WHERE nid = %d AND realm = 'node_privacy_byrole_role'", $fnid);
+		foreach($roles AS $rid) {
+			// Get permissions of this analysis for this role
+			$rsql = "SELECT * FROM {node_privacy_byrole} WHERE gid = %d AND nid = %d AND realm = 'node_privacy_byrole_role'";
+			$ana_perm = db_fetch_object(db_query($rsql, $rid, $ana_nid));
+			db_query("INSERT INTO {node_privacy_byrole} (nid, gid, realm, grant_view, grant_update, grant_delete)
+                  VALUES (%d, %d, '%s', %d, %d, %d)", $fnid, $rid, 'node_privacy_byrole_role', $ana_perm->grant_view,
+                  $ana_perm->grant_update, $ana_perm->grant_delete);
+		}
+		$node = node_load($fnid);
+		node_save($node);
+		$idx_iterations ++;
+	}	
+}

+ 0 - 288
tripal_search_feature/tripal_search_feature.views.inc

@@ -1,288 +0,0 @@
-<?php
-
-/*************************************************************************
- * tripal_search_feature_views_data()
- */
-
-function tripal_search_feature_views_data()  {
-	global $db_url;
-	$data = array();
-	
-	// if the chado database is not local to the drupal database
-	// then we need to set the database name.  This should always
-	// be 'chado'.
-	if(is_array($db_url) and array_key_exists('chado', $db_url)) {
-		$database = 'chado';
-	}
-	
- 	// Basic table definition
-	$data['feature_for_search']['table']['group'] = 'Tripal Search feature';
-	$data['feature_for_search']['table']['base'] = array(
-		'field' => 'feature_for_search_id',
-		'title' => t('Chado Feature with searchable annotations'),
-		'help'  => t('A materialized view for feature is generated to enable the search for different annotations'),
-	);
- 	if ($database) {
- 		$data['feature_for_search']['table']['base']['database'] = $database;
-	}
-	
-	// Table Field Definitions----------------------
-	// Field: feature_id (integer)
-	$data['feature_for_search']['feature_for_search_id'] = array(
-		'title' => t('feature_for_search ID'),
-		'help' => t('The primary key of feature_for_search'),
-		'field' => array(
-			'handler' => 'views_handler_field_numeric',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_numeric',
-		),
-	);
-			
-	// Field: feature_id (integer)
-	$data['feature_for_search']['feature_id'] = array(
-		'title' => t('feature ID'),
-		'help' => t('The primary key of a feature'),
-		'field' => array(
-			'handler' => 'views_handler_field_numeric',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_numeric',
-		),
-	);
-	
-	// Field: name (character varying(1024))
-	$data['feature_for_search']['feature_type'] = array(
-		'title' => t('feature_type'),
-		'help' => t('Type of the feature'),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_feature_type_id',
-		),
-		'argument' => array(
-			'handler' => 'views_handler_argument_string',
-		),
-	);
-	
-	// Field: name (character varying(255),)
-	$data['feature_for_search']['feature_name'] = array(
-		'title' => t('feature_name'),
-		'help' => t('The optional human-readable common name for a feature, for display purposes.'),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_string',
-		),
-		'argument' => array(
-			'handler' => 'views_handler_argument_string',
-		),
-	);
-	
-		// Field: uniquename (text)
-	$data['feature_for_search']['feature_uniquename'] = array(
-		'title' => t('feature_uniquename'),
-		'help' => t('The unique name for a feature; may not be necessarily be particularly human-readable, although this is preferred. This name must be unique for this type of feature within this organism.'),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_string',
-		),
-		'argument' => array(
-			'handler' => 'views_handler_argument_string',
-		),
-	);
-	
-	// Field: is_obsolete (boolean)
-	$data['feature_for_search']['feature_is_obsolete'] = array(
-		'title' => t('feature_is_obsolete'),
-		'help' => t('Boolean indicating whether this feature has been obsoleted. Some chado instances may choose to simply remove the feature altogether, others may choose to keep an obsolete row in the table.'),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_boolean_operator_string',
-		),
-	);
-	
-	// Field: common name (varchar 255)
-  $data['feature_for_search']['organism_common_name'] = array(
-    'title' => 'organism_common_name',
-    'help' => 'The common name of the organism.',
-    'field' => array(
-       'handler' => 'views_handler_field',
-       'click sortable' => TRUE,
-     ),
-     'sort' => array(
-       'handler' => 'views_handler_sort',
-     ),
-     'filter' => array(
-       'handler' => 'views_handler_filter_organism_common_name',
-     ),
-     'argument' => array(
-       'handler' => 'views_handler_argument_string',
-     ),
-  );
-  
-  	// Field: seqlen (integer)
-	$data['feature_for_search']['feature_seqlen'] = array(
-		'title' => t('feature_seqlen'),
-		'help' => t('The length of the residue feature. See column:residues. This column is partially redundant with the residues column, and also with featureloc. This column is required because the location may be unknown and the residue sequence may not be manifested, yet it may be desirable to store and query the length of the feature. The seqlen should always be manifested where the length of the sequence is known.'),
-		'field' => array(
-			'handler' => 'views_handler_field_numeric',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_numeric',
-		),
-	);
-	
-		// Field: name (character varying(1024))
-	$data['feature_for_search']['go_term'] = array(
-		'title' => t('go_term'),
-		'help' => t('GO Terms associated with a feature'),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_string',
-		),
-		'argument' => array(
-			'handler' => 'views_handler_argument_string',
-		),
-	);
-		
-	// Field: name (character varying(255),)
-	$data['feature_for_search']['unigene'] = array(
-		'title' => t('unigene'),
-		'help' => t('Unigene analysis name.'),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_analysis_name',
-		),
-		'argument' => array(
-			'handler' => 'views_handler_argument_string',
-		),
-	);
-	
-		// Field: value (text,)
-	$data['feature_for_search']['blast_value'] = array(
-		'title' => t('value'),
-		'help' => t(''),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_string',
-		),
-		'argument' => array(
-			'handler' => 'views_handler_argument_string',
-		),
-	);
-	
-		// Field: value (text,)
-	$data['feature_for_search']['kegg_value'] = array(
-		'title' => t('value'),
-		'help' => t(''),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_string',
-		),
-		'argument' => array(
-			'handler' => 'views_handler_argument_string',
-		),
-	);
-	
-		// Field: value (text,)
-	$data['feature_for_search']['interpro_value'] = array(
-		'title' => t('value'),
-		'help' => t(''),
-		'field' => array(
-			'handler' => 'views_handler_field',
-			'click sortable' => TRUE,
-		),
-		'sort' => array(
-			'handler' => 'views_handler_sort',
-		),
-		'filter' => array(
-			'handler' => 'views_handler_filter_string',
-		),
-		'argument' => array(
-			'handler' => 'views_handler_argument_string',
-		),
-	);
-
-	return $data;
-}
-
-/*************************************************************************
- * tripal_search_feature_views_handlers
- */
-function tripal_search_feature_views_handlers() {
- return array(
-   'info' => array(
-     'path' => drupal_get_path('module', 'tripal_search_feature'),
-   ),
-   'handlers' => array(
-   	'views_handler_filter_organism_common_name' => array(
-   		'parent' => 'views_handler_filter_string'
-   	),
-   	'views_handler_filter_analysis_name' => array(
-   		'parent' => 'views_handler_filter_string'
-   	),
-   	'views_handler_filter_feature_type_id' => array(
-   		'parent' => 'views_handler_filter_numeric'
-   	),
-   ),
- );
-}

+ 3 - 3
tripal_search_feature/tripal_search_feature.info → tripal_search_unigene/tripal_search_unigene.info

@@ -1,8 +1,8 @@
 ; $Id$
-package = Tripal
-name = Tripal Search Feature
+package = Tripal Extensions
+name = Tripal Search Unigene
 version = 6.x-0.3b
-description = A module to provide advanced search functionalities for the features
+description = A module to provide advanced search functions for unigenes
 core = 6.x
 
 dependencies[] = tripal_core

+ 29 - 22
tripal_search_feature/tripal_search_feature.install → tripal_search_unigene/tripal_search_unigene.install

@@ -3,23 +3,23 @@
 /*******************************************************************************
 *  Implementation of hook_install();
 */
-function tripal_search_feature_install(){
+function tripal_search_unigene_install(){
 
    // create the module's data directory
-   tripal_create_moddir('tripal_search_feature');
+   tripal_create_moddir('tripal_search_unigene');
 	
-	// Create a sequence as the primiry key for the feature_for_search
-	$sql = "DROP SEQUENCE IF EXISTS feature_for_search_id; CREATE SEQUENCE feature_for_search_id";
+	// Create a sequence as the primiry key for the unigene_for_search
+	$sql = "DROP SEQUENCE IF EXISTS unigene_for_search_id; CREATE SEQUENCE unigene_for_search_id";
 	chado_query($sql);	
 
-	$view_name = 'feature_for_search';
+	$view_name = 'unigene_for_search';
    // 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 = " feature_for_search_id integer, 
+   $schema = " unigene_for_search_id integer, 
    							  feature_id integer,
    							  feature_type character varying(1024),
    							  feature_name character varying(1024),
@@ -34,9 +34,10 @@ function tripal_search_feature_install(){
    							  interpro_value text
    							  ";
    
-   $index = "feature_id, go_term, blast_value, kegg_value, interpro_value";
-   
-   $sql = "SELECT nextval ('feature_for_search_id') AS feature_for_search_id, T.* FROM (
+   $index = "feature_id, go_term, unigene, blast_value, kegg_value, interpro_value";
+   $singlet_type_id = tripal_get_cvterm_id('singlet_in_analysis');
+   $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 nextval ('unigene_for_search_id') AS unigene_for_search_id, T.* FROM (
 						SELECT F.feature_id AS feature_id, 
 										(SELECT name FROM cvterm WHERE F.type_id = cvterm_id) AS feature_type,
 										F.name AS feature_name, 
@@ -53,26 +54,26 @@ function tripal_search_feature_install(){
 						LEFT JOIN organism O ON F.organism_id = O.organism_id 
 						LEFT JOIN feature_cvterm FC ON F.feature_id = FC.feature_id 
 						LEFT JOIN cvterm C ON FC.cvterm_id = C.cvterm_id 
-						LEFT JOIN (SELECT * FROM analysisfeatureprop AFP
+						LEFT JOIN (SELECT AF.feature_id, AFP.value FROM analysisfeatureprop AFP
 													INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id
 													WHERE type_id = (SELECT cvterm_id FROM cvterm 
 																								WHERE name = 'analysis_blast_besthit_description' 
 																								AND cv_id = (SELECT cv_id FROM cv WHERE name = 'tripal')
-																								)
+																								) GROUP BY feature_id, value
 													) BLAST ON BLAST.feature_id = F.feature_id
-						LEFT JOIN (SELECT * FROM analysisfeatureprop AFP
+						LEFT JOIN (SELECT AF.feature_id, AFP.value FROM analysisfeatureprop AFP
 													INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id
 													WHERE type_id = (SELECT cvterm_id FROM cvterm 
 																								WHERE name = 'analysis_kegg_output_keywords' 
 																								AND cv_id = (SELECT cv_id FROM cv WHERE name = 'tripal')
-																								)			
+																								) GROUP BY feature_id, value			
 													) KEGG ON KEGG.feature_id = F.feature_id
-						LEFT JOIN (SELECT * FROM analysisfeatureprop AFP
+						LEFT JOIN (SELECT AF.feature_id, AFP.value FROM analysisfeatureprop AFP
 													INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id
 													WHERE type_id = (SELECT cvterm_id FROM cvterm
 																								WHERE name = 'analysis_interpro_output_keywords' 
 																								AND cv_id = (SELECT cv_id FROM cv WHERE name = 'tripal')
-																								)
+																								) GROUP BY feature_id, value
 													) INTERPRO ON INTERPRO.feature_id = F.feature_id 
 						LEFT JOIN (SELECT * FROM analysisfeature AF 
 													INNER JOIN analysis A ON A.analysis_id = AF.analysis_id 
@@ -82,6 +83,12 @@ function tripal_search_feature_install(){
 																								AND cv_id = (SELECT cv_id FROM cv WHERE name = 'tripal')
 																								)
 													AND value = 'tripal_analysis_unigene') UNIGENE ON F.feature_id = UNIGENE.feature_id
+						WHERE F.type_id != (SELECT cvterm_id FROM cvterm WHERE name = 'EST_match')
+						AND F.feature_id NOT IN (SELECT feature_id from feature 
+																					 WHERE type_id = (select cvterm_id from cvterm where name = 'EST') 
+																					 AND feature_id NOT IN (SELECT F.feature_id FROM feature F 
+																					 														  INNER JOIN featureprop FP ON F.feature_id = FP.feature_id 
+																					 														  AND FP.type_id = (select cvterm_id from cvterm where name = 'singlet_in_analysis')))
 						) T";
    
       // Create the MView
@@ -89,7 +96,7 @@ function tripal_search_feature_install(){
       // view name
       $view_name,
       // tripal module name
-      ' tripal_search_feature',
+      ' tripal_search_unigene',
       // table name
       $view_name,
       // table schema definition
@@ -114,8 +121,8 @@ function tripal_search_feature_install(){
 /*******************************************************************************
  * Implementation of hook_uninstall()
  */
-function tripal_search_feature_uninstall(){
-	$view_name = 'feature_for_search';
+function tripal_search_unigene_uninstall(){
+	$view_name = 'unigene_for_search';
 	// Drop the MView table if it exists
 	$mview_id = tripal_mviews_get_mview_id($view_name);
 	if($mview_id){
@@ -123,7 +130,7 @@ function tripal_search_feature_uninstall(){
 	}
 	 
 	// Drop the sequence
-	$sql = "DROP SEQUENCE IF EXISTS feature_for_search_id";
+	$sql = "DROP SEQUENCE IF EXISTS unigene_for_search_id";
 	chado_query($sql);
 }
 
@@ -131,12 +138,12 @@ function tripal_search_feature_uninstall(){
  * Implementation of hook_requirements(). Make sure 'Tripal Core' is enabled
  * before installation
  */
-function tripal_search_feature_requirements($phase) {
+function tripal_search_unigene_requirements($phase) {
    $requirements = array();
    if ($phase == 'install') {
       if (!function_exists('tripal_create_moddir')) {
-         $requirements ['tripal_search_feature'] = array(
-            'title' => "tripal_search_feature",
+         $requirements ['tripal_search_unigene'] = array(
+            'title' => "tripal_search_unigene",
             'value' => "error. Some required modules are just being installed. Please try again.",
             'severity' => REQUIREMENT_ERROR,
          );

+ 14 - 12
tripal_search_feature/tripal_search_feature.module → tripal_search_unigene/tripal_search_unigene.module

@@ -1,17 +1,19 @@
 <?php
 
+require_once "PHPExcel/Classes/PHPExcel.php";
+
 /*************************************************************************
- * tripal_search_feature_init
+ * tripal_search_unigene_init
  */ 
-function tripal_search_feature_init(){
-	drupal_add_css(drupal_get_path('theme', 'tripal').'/css/tripal_search_feature.css');
-	drupal_add_js(drupal_get_path('theme', 'tripal').'/js/tripal_search_feature.js');
+function tripal_search_unigene_init(){
+	drupal_add_css(drupal_get_path('theme', 'tripal').'/css/tripal_search_unigene.css');
+	drupal_add_js(drupal_get_path('theme', 'tripal').'/js/tripal_search_unigene.js');
 }
 
 /*************************************************************************
- * tripal_search_feature_views_api
+ * tripal_search_unigene_views_api
  */ 
-function tripal_search_feature_views_api() {
+function tripal_search_unigene_views_api() {
    return array(
       'api' => 2.0,
    );
@@ -20,8 +22,8 @@ function tripal_search_feature_views_api() {
 // A function to rewrite the SQL statement before submitting the query
 // Force GROUP BY feature_id and return only one row
 
-function  tripal_search_feature_views_pre_execute(&$view){
-	if ($view->name == 'est_search') {
+function  tripal_search_unigene_views_pre_execute(&$view){
+	if ($view->name == 'unigene_search') {
 
 		// AGGREGATORS
 		$search = array('SELECT');
@@ -42,15 +44,15 @@ function  tripal_search_feature_views_pre_execute(&$view){
 		// GROUP BY
 		if (preg_match("'ORDER BY'",  $view->build_info['query'])) {
 			$search = array('ORDER BY');
-			$replace = array('GROUP BY feature_for_search.feature_id ORDER BY');
+			$replace = array('GROUP BY unigene_for_search.feature_id ORDER BY');
 			$view->build_info['query'] = str_replace($search, $replace, $view->build_info['query']);
 		} else {
-			$view->build_info['query']  .= " GROUP BY feature_for_search.feature_id";
+			$view->build_info['query']  .= " GROUP BY unigene_for_search.feature_id";
 		}
-		$view->build_info['count_query'] .= " GROUP BY feature_for_search.feature_id";
+		$view->build_info['count_query'] .= " GROUP BY unigene_for_search.feature_id";
 		 
 		//drupal_set_message($view->build_info['query']);
 		//drupal_set_message($view->build_info['count_query']);
 		 
 	}
-}
+}

+ 407 - 109
tripal_search_feature/exported_est_search_view.txt → tripal_search_unigene/tripal_search_unigene.views.inc

@@ -1,14 +1,308 @@
-$view = new view;
-$view->name = 'est_search';
-$view->description = 'EST Search';
-$view->tag = '';
-$view->view_php = '';
-$view->base_table = 'feature_for_search';
-$view->is_cacheable = FALSE;
-$view->api_version = 2;
-$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-$handler = $view->new_display('default', 'Defaults', 'default');
-$handler->override_option('fields', array(
+<?php
+
+/*************************************************************************
+ * tripal_search_unigene_views_data()
+ */
+
+function tripal_search_unigene_views_data()  {
+	global $db_url;
+	$data = array();
+	
+	// if the chado database is not local to the drupal database
+	// then we need to set the database name.  This should always
+	// be 'chado'.
+	if(is_array($db_url) and array_key_exists('chado', $db_url)) {
+		$database = 'chado';
+	}
+	
+ 	// Basic table definition
+	$data['unigene_for_search']['table']['group'] = 'Tripal Search feature';
+	$data['unigene_for_search']['table']['base'] = array(
+		'field' => 'unigene_for_search_id',
+		'title' => t('Chado Feature with searchable annotations'),
+		'help'  => t('A materialized view for feature is generated to enable the search for different annotations'),
+	);
+ 	if ($database) {
+ 		$data['unigene_for_search']['table']['base']['database'] = $database;
+	}
+	
+	// Table Field Definitions----------------------
+	// Field: feature_id (integer)
+	$data['unigene_for_search']['unigene_for_search_id'] = array(
+		'title' => t('unigene_for_search ID'),
+		'help' => t('The primary key of unigene_for_search'),
+		'field' => array(
+			'handler' => 'views_handler_field_numeric',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_numeric',
+		),
+	);
+			
+	// Field: feature_id (integer)
+	$data['unigene_for_search']['feature_id'] = array(
+		'title' => t('feature ID'),
+		'help' => t('The primary key of a feature'),
+		'field' => array(
+			'handler' => 'views_handler_field_numeric',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_numeric',
+		),
+	);
+	
+	// Field: name (character varying(1024))
+	$data['unigene_for_search']['feature_type'] = array(
+		'title' => t('feature_type'),
+		'help' => t('Type of the feature'),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_feature_type_id',
+		),
+		'argument' => array(
+			'handler' => 'views_handler_argument_string',
+		),
+	);
+	
+	// Field: name (character varying(255),)
+	$data['unigene_for_search']['feature_name'] = array(
+		'title' => t('feature_name'),
+		'help' => t('The optional human-readable common name for a feature, for display purposes.'),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_string',
+		),
+		'argument' => array(
+			'handler' => 'views_handler_argument_string',
+		),
+	);
+	
+		// Field: uniquename (text)
+	$data['unigene_for_search']['feature_uniquename'] = array(
+		'title' => t('feature_uniquename'),
+		'help' => t('The unique name for a feature; may not be necessarily be particularly human-readable, although this is preferred. This name must be unique for this type of feature within this organism.'),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_string',
+		),
+		'argument' => array(
+			'handler' => 'views_handler_argument_string',
+		),
+	);
+	
+	// Field: is_obsolete (boolean)
+	$data['unigene_for_search']['feature_is_obsolete'] = array(
+		'title' => t('feature_is_obsolete'),
+		'help' => t('Boolean indicating whether this feature has been obsoleted. Some chado instances may choose to simply remove the feature altogether, others may choose to keep an obsolete row in the table.'),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_boolean_operator_string',
+		),
+	);
+	
+	// Field: common name (varchar 255)
+  $data['unigene_for_search']['organism_common_name'] = array(
+    'title' => 'organism_common_name',
+    'help' => 'The common name of the organism.',
+    'field' => array(
+       'handler' => 'views_handler_field',
+       'click sortable' => TRUE,
+     ),
+     'sort' => array(
+       'handler' => 'views_handler_sort',
+     ),
+     'filter' => array(
+       'handler' => 'views_handler_filter_organism_common_name',
+     ),
+     'argument' => array(
+       'handler' => 'views_handler_argument_string',
+     ),
+  );
+  
+  	// Field: seqlen (integer)
+	$data['unigene_for_search']['feature_seqlen'] = array(
+		'title' => t('feature_seqlen'),
+		'help' => t('The length of the residue feature. See column:residues. This column is partially redundant with the residues column, and also with featureloc. This column is required because the location may be unknown and the residue sequence may not be manifested, yet it may be desirable to store and query the length of the feature. The seqlen should always be manifested where the length of the sequence is known.'),
+		'field' => array(
+			'handler' => 'views_handler_field_numeric',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_numeric',
+		),
+	);
+	
+		// Field: name (character varying(1024))
+	$data['unigene_for_search']['go_term'] = array(
+		'title' => t('go_term'),
+		'help' => t('GO Terms associated with a feature'),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_string',
+		),
+		'argument' => array(
+			'handler' => 'views_handler_argument_string',
+		),
+	);
+		
+	// Field: name (character varying(255),)
+	$data['unigene_for_search']['unigene'] = array(
+		'title' => t('unigene'),
+		'help' => t('Unigene analysis name.'),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_analysis_name',
+		),
+		'argument' => array(
+			'handler' => 'views_handler_argument_string',
+		),
+	);
+	
+		// Field: value (text,)
+	$data['unigene_for_search']['blast_value'] = array(
+		'title' => t('value'),
+		'help' => t(''),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_string',
+		),
+		'argument' => array(
+			'handler' => 'views_handler_argument_string',
+		),
+	);
+	
+		// Field: value (text,)
+	$data['unigene_for_search']['kegg_value'] = array(
+		'title' => t('value'),
+		'help' => t(''),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_string',
+		),
+		'argument' => array(
+			'handler' => 'views_handler_argument_string',
+		),
+	);
+	
+		// Field: value (text,)
+	$data['unigene_for_search']['interpro_value'] = array(
+		'title' => t('value'),
+		'help' => t(''),
+		'field' => array(
+			'handler' => 'views_handler_field',
+			'click sortable' => TRUE,
+		),
+		'sort' => array(
+			'handler' => 'views_handler_sort',
+		),
+		'filter' => array(
+			'handler' => 'views_handler_filter_string',
+		),
+		'argument' => array(
+			'handler' => 'views_handler_argument_string',
+		),
+	);
+
+	return $data;
+}
+
+/*************************************************************************
+ * tripal_search_unigene_views_handlers
+ */
+function tripal_search_unigene_views_handlers() {
+ return array(
+   'info' => array(
+     'path' => drupal_get_path('module', 'tripal_search_unigene'),
+   ),
+   'handlers' => array(
+   	'views_handler_filter_organism_common_name' => array(
+   		'parent' => 'views_handler_filter_string'
+   	),
+   	'views_handler_filter_analysis_name' => array(
+   		'parent' => 'views_handler_filter_string'
+   	),
+   	'views_handler_filter_feature_type_id' => array(
+   		'parent' => 'views_handler_filter_numeric'
+   	),
+   ),
+ );
+}
+
+/*************************************************************************
+ * tripal_search_unigene_views_default_views
+ */
+function tripal_search_unigene_views_default_views () {
+	$views = array();
+	$view = new view;
+	$view->name = 'unigene_search';
+	$view->description = 'Unigene Search';
+	$view->tag = '';
+	$view->view_php = '';
+	$view->base_table = 'unigene_for_search';
+	$view->is_cacheable = FALSE;
+	$view->api_version = 2;
+	$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+	$handler = $view->new_display('default', 'Defaults', 'default');
+	$handler->override_option('fields', array(
   'counter' => array(
     'label' => '#',
     'alter' => array(
@@ -28,7 +322,7 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
@@ -38,7 +332,7 @@ $handler->override_option('fields', array(
     'table' => 'views',
     'field' => 'counter',
     'relationship' => 'none',
-  ),
+	),
   'feature_id' => array(
     'label' => 'feature ID',
     'alter' => array(
@@ -58,7 +352,7 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
@@ -70,10 +364,10 @@ $handler->override_option('fields', array(
     'suffix' => '',
     'exclude' => 1,
     'id' => 'feature_id',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'feature_id',
     'relationship' => 'none',
-  ),
+	),
   'feature_name' => array(
     'label' => 'Sequence',
     'alter' => array(
@@ -93,16 +387,16 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
     'exclude' => 0,
     'id' => 'feature_name',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'feature_name',
     'relationship' => 'none',
-  ),
+	),
   'organism_common_name' => array(
     'label' => 'Organism',
     'alter' => array(
@@ -122,16 +416,16 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
     'exclude' => 0,
     'id' => 'organism_common_name',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'organism_common_name',
     'relationship' => 'none',
-  ),
+	),
   'feature_seqlen' => array(
     'label' => 'Length',
     'alter' => array(
@@ -151,7 +445,7 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
@@ -163,10 +457,10 @@ $handler->override_option('fields', array(
     'suffix' => '',
     'exclude' => 0,
     'id' => 'feature_seqlen',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'feature_seqlen',
     'relationship' => 'none',
-  ),
+	),
   'feature_type' => array(
     'label' => 'Type',
     'alter' => array(
@@ -186,16 +480,16 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
     'exclude' => 0,
     'id' => 'feature_type',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'feature_type',
     'relationship' => 'none',
-  ),
+	),
   'go_term' => array(
     'label' => 'GO Term',
     'alter' => array(
@@ -215,16 +509,16 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
     'exclude' => 0,
     'id' => 'go_term',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'go_term',
     'relationship' => 'none',
-  ),
+	),
   'blast_value' => array(
     'label' => 'Blast',
     'alter' => array(
@@ -244,16 +538,16 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
     'exclude' => 0,
     'id' => 'blast_value',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'blast_value',
     'relationship' => 'none',
-  ),
+	),
   'kegg_value' => array(
     'label' => 'KEGG',
     'alter' => array(
@@ -273,16 +567,16 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
     'exclude' => 0,
     'id' => 'kegg_value',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'kegg_value',
     'relationship' => 'none',
-  ),
+	),
   'interpro_value' => array(
     'label' => 'Interpro',
     'alter' => array(
@@ -302,18 +596,18 @@ $handler->override_option('fields', array(
       'ellipsis' => 1,
       'html' => 0,
       'strip_tags' => 0,
-    ),
+	),
     'empty' => '',
     'hide_empty' => 0,
     'empty_zero' => 0,
     'exclude' => 0,
     'id' => 'interpro_value',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'interpro_value',
     'relationship' => 'none',
-  ),
-));
-$handler->override_option('arguments', array(
+	),
+	));
+	$handler->override_option('arguments', array(
   'null' => array(
     'default_action' => 'default',
     'style_plugin' => 'default_summary',
@@ -336,7 +630,7 @@ $handler->override_option('arguments', array(
       '3' => 0,
       '5' => 0,
       '4' => 0,
-    ),
+	),
     'relationship' => 'none',
     'default_options_div_prefix' => '',
     'default_argument_fixed' => '',
@@ -356,7 +650,7 @@ $handler->override_option('arguments', array(
       'calendar_event' => 0,
       'page' => 0,
       'story' => 0,
-    ),
+	),
     'validate_argument_node_access' => 0,
     'validate_argument_nid_type' => 'nid',
     'validate_argument_vocabulary' => array(
@@ -373,16 +667,16 @@ $handler->override_option('arguments', array(
       '6' => 0,
       '7' => 0,
       '8' => 0,
-    ),
+	),
     'validate_argument_type' => 'tid',
     'validate_argument_transform' => 0,
     'validate_user_restrict_roles' => 0,
     'validate_argument_php' => 'if (count($view->exposed_input)) {
 return TRUE;
 }',
-  ),
-));
-$handler->override_option('filters', array(
+	),
+	));
+	$handler->override_option('filters', array(
   'feature_name' => array(
     'operator' => 'contains',
     'value' => '',
@@ -395,20 +689,20 @@ $handler->override_option('filters', array(
       'label' => 'sequence name',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'case' => 0,
     'id' => 'feature_name',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'feature_name',
     'relationship' => 'none',
-  ),
+	),
   'feature_seqlen' => array(
     'operator' => '>=',
     'value' => array(
       'value' => '',
       'min' => '',
       'max' => '',
-    ),
+	),
     'group' => '0',
     'exposed' => TRUE,
     'expose' => array(
@@ -418,12 +712,12 @@ $handler->override_option('filters', array(
       'label' => 'sequence length (bp)',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'id' => 'feature_seqlen',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'feature_seqlen',
     'relationship' => 'none',
-  ),
+	),
   'feature_type' => array(
     'operator' => '=',
     'value' => '260',
@@ -436,13 +730,13 @@ $handler->override_option('filters', array(
       'label' => 'type of sequence',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'case' => 0,
     'id' => 'feature_type',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'feature_type',
     'relationship' => 'none',
-  ),
+	),
   'go_term' => array(
     'operator' => 'contains',
     'value' => '',
@@ -455,13 +749,13 @@ $handler->override_option('filters', array(
       'label' => 'GO term',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'case' => 0,
     'id' => 'go_term',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'go_term',
     'relationship' => 'none',
-  ),
+	),
   'organism_common_name' => array(
     'operator' => '=',
     'value' => 'chickpea',
@@ -474,13 +768,13 @@ $handler->override_option('filters', array(
       'label' => 'organism',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'case' => 0,
     'id' => 'organism_common_name',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'organism_common_name',
     'relationship' => 'none',
-  ),
+	),
   'unigene' => array(
     'operator' => '=',
     'value' => 'Cicer arietinum unigene v1',
@@ -493,13 +787,13 @@ $handler->override_option('filters', array(
       'label' => 'belongs to unigene',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'case' => 0,
     'id' => 'unigene',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'unigene',
     'relationship' => 'none',
-  ),
+	),
   'interpro_value' => array(
     'operator' => 'contains',
     'value' => '',
@@ -512,13 +806,13 @@ $handler->override_option('filters', array(
       'label' => 'interpro description',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'case' => 0,
     'id' => 'interpro_value',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'interpro_value',
     'relationship' => 'none',
-  ),
+	),
   'blast_value' => array(
     'operator' => 'contains',
     'value' => '',
@@ -531,13 +825,13 @@ $handler->override_option('filters', array(
       'label' => 'blast description',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'case' => 0,
     'id' => 'blast_value',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'blast_value',
     'relationship' => 'none',
-  ),
+	),
   'kegg_value' => array(
     'operator' => 'contains',
     'value' => '',
@@ -550,32 +844,32 @@ $handler->override_option('filters', array(
       'label' => 'kegg description',
       'optional' => 1,
       'remember' => 0,
-    ),
+	),
     'case' => 0,
     'id' => 'kegg_value',
-    'table' => 'feature_for_search',
+    'table' => 'unigene_for_search',
     'field' => 'kegg_value',
     'relationship' => 'none',
-  ),
-));
-$handler->override_option('access', array(
+	),
+	));
+	$handler->override_option('access', array(
   'type' => 'none',
-));
-$handler->override_option('cache', array(
+	));
+	$handler->override_option('cache', array(
   'type' => 'none',
-));
-$handler->override_option('title', 'EST Unigene Search');
-$handler->override_option('css_class', 'tripal-search-feature');
-$handler->override_option('empty', '<?php 
+	));
+	$handler->override_option('title', 'Unigene Search');
+	$handler->override_option('css_class', 'tripal-search-feature');
+	$handler->override_option('empty', '<?php
 $view = views_get_current_view();
   if (count($view->exposed_input)) {
     drupal_set_message("Your search returns no results. Please adjust your search criteria and try again.");
 } 
 ?>');
-$handler->override_option('empty_format', '3');
-$handler->override_option('use_pager', '1');
-$handler->override_option('style_plugin', 'table');
-$handler->override_option('style_options', array(
+	$handler->override_option('empty_format', '3');
+	$handler->override_option('use_pager', '1');
+	$handler->override_option('style_plugin', 'table');
+	$handler->override_option('style_options', array(
   'grouping' => '',
   'override' => 1,
   'sticky' => 0,
@@ -591,64 +885,68 @@ $handler->override_option('style_options', array(
     'blast_value' => 'blast_value',
     'kegg_value' => 'kegg_value',
     'interpro_value' => 'interpro_value',
-  ),
+	),
   'info' => array(
     'feature_id' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'feature_name' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'feature_seqlen' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'feature_type' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'go_term' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'organism_common_name' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'unigene' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'blast_value' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'kegg_value' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
+	),
     'interpro_value' => array(
       'sortable' => 1,
       'separator' => '',
-    ),
-  ),
+	),
+	),
   'default' => '-1',
-));
-$handler = $view->new_display('page', 'Page', 'page_1');
-$handler->override_option('path', 'est_search');
-$handler->override_option('menu', array(
+	));
+	$handler = $view->new_display('page', 'Page', 'page_1');
+	$handler->override_option('path', 'unigene_search');
+	$handler->override_option('menu', array(
   'type' => 'normal',
-  'title' => 'EST Unigene Search',
-  'description' => 'Advanced Search for EST and unigenes',
+  'title' => 'Unigene Search',
+  'description' => 'Advanced Search for unigenes',
   'weight' => '0',
   'name' => 'primary-links',
-));
-$handler->override_option('tab_options', array(
+	));
+	$handler->override_option('tab_options', array(
   'type' => 'none',
   'title' => '',
   'description' => '',
   'weight' => 0,
   'name' => 'navigation',
-));
+	));
+  $views[$view->name] = $view;
+  
+  return $views;
+}

+ 22 - 3
tripal_search_feature/views_handler_filter_analysis_name.inc → tripal_search_unigene/views_handler_filter_analysis_name.inc

@@ -6,16 +6,35 @@ class views_handler_filter_analysis_name extends views_handler_filter_string {
 
 		$results = chado_query($sql);
 		$analyses = array();
-
+		$block_ana = array();
+		$counter = 0;
 		while ($ana = db_fetch_object($results)) {
 			// check if the organisms is synced
 			if (db_result(db_query("SELECT * FROM {chado_analysis} WHERE analysis_id = $ana->analysis_id"))) {
-				$analyses[$ana->name] = t($ana->name);
+				// check user's permission
+				if (tripal_analysis_check_permission($ana->analysis_id)) {
+					$analyses[$ana->name] = t($ana->name);
+				} else {
+					$block_ana[$counter] = t($ana->name);
+					$counter ++;
+				}
+			}
+		}
+		
+		if ($block_ana) {
+			$where = "";
+			for ($i = 0; $i < count($block_ana); $i ++) {
+					$where .= "unigene_for_search.unigene <> '$block_ana[$i]'";
+					if ($i != count($block_ana) - 1) {
+						$where .= " AND ";
+					}
 			}
+			$this->query->add_where($this->options['group'], $where);
 		}
+		
 		$form['value'] = array(
 		'#type' => 'select',
-		'#title' => t('Organism'),
+		'#title' => t('Analysis'),
 		'#options' => $analyses,
 		'#default_value' => 0,
 		);

+ 1 - 1
tripal_search_feature/views_handler_filter_feature_type_id.inc → tripal_search_unigene/views_handler_filter_feature_type_id.inc

@@ -3,7 +3,7 @@ class views_handler_filter_feature_type_id extends views_handler_filter_string {
 
 	function value_form(&$form, &$form_state) {
 
-		$sql = "SELECT distinct feature_type FROM {feature_for_search}";
+		$sql = "SELECT distinct feature_type FROM {unigene_for_search}";
 		$results = chado_query($sql);
 		$options = array ();
 		while($type = db_fetch_object($results)) {

+ 0 - 0
tripal_search_feature/views_handler_filter_organism_common_name.inc → tripal_search_unigene/views_handler_filter_organism_common_name.inc