Browse Source

Merge branch '6.x-1.x' into 6.x-1482618-API_for_default_views_integration

Lacey Sanderson 12 years ago
parent
commit
3678cae957
47 changed files with 4069 additions and 2443 deletions
  1. 0 40
      extensions/tripal_search_unigene/theme/css/tripal_search_unigene.css
  2. 0 20
      extensions/tripal_search_unigene/theme/js/tripal_search_unigene.js
  3. 0 195
      extensions/tripal_search_unigene/theme/views-exposed-form--unigene_search.tpl.php
  4. 0 221
      extensions/tripal_search_unigene/theme/views-view-table--unigene_search.tpl.php
  5. 0 12
      extensions/tripal_search_unigene/tripal_search_unigene.info
  6. 0 155
      extensions/tripal_search_unigene/tripal_search_unigene.install
  7. 0 58
      extensions/tripal_search_unigene/tripal_search_unigene.module
  8. 0 952
      extensions/tripal_search_unigene/tripal_search_unigene.views.inc
  9. 0 53
      extensions/tripal_search_unigene/views_handler_filter_analysis_name.inc
  10. 0 26
      extensions/tripal_search_unigene/views_handler_filter_feature_type_id.inc
  11. 0 30
      extensions/tripal_search_unigene/views_handler_filter_organism_common_name.inc
  12. 1 2
      tripal_analysis/tripal_analysis.info
  13. 97 97
      tripal_analysis/tripal_analysis_privacy.inc
  14. 268 249
      tripal_bulk_loader/tripal_bulk_loader.admin.inc
  15. 47 0
      tripal_bulk_loader/tripal_bulk_loader.drush.inc
  16. 1 1
      tripal_bulk_loader/tripal_bulk_loader.info
  17. 33 9
      tripal_bulk_loader/tripal_bulk_loader.install
  18. 119 52
      tripal_bulk_loader/tripal_bulk_loader.loader.inc
  19. 95 5
      tripal_bulk_loader/tripal_bulk_loader.module
  20. 3 4
      tripal_contact/tripal_contact.info
  21. 55 21
      tripal_core/chado_install.php
  22. 570 0
      tripal_core/chado_schema/default_schema-1.11-1.2-diff.sql
  23. 15 15
      tripal_core/chado_schema/default_schema-1.11.sql
  24. 2462 0
      tripal_core/chado_schema/default_schema-1.2.sql
  25. 10 0
      tripal_core/chado_schema/initialize-1.11-1.2.sql
  26. 0 0
      tripal_core/chado_schema/initialize-1.11.sql
  27. 237 0
      tripal_core/chado_schema/initialize-1.2.sql
  28. 16 1
      tripal_core/jobs.php
  29. 3 1
      tripal_core/tripal_core.api.inc
  30. 1 2
      tripal_core/tripal_core.info
  31. 7 5
      tripal_core/tripal_core.module
  32. 1 3
      tripal_cv/tripal_cv.info
  33. 1 3
      tripal_db/tripal_db.info
  34. 2 2
      tripal_feature/tripal_feature.info
  35. 3 4
      tripal_genetic/tripal_genetic.info
  36. 2 2
      tripal_library/tripal_library.info
  37. 3 4
      tripal_natural_diversity/tripal_natural_diversity.info
  38. 2 2
      tripal_organism/tripal_organism.info
  39. 3 4
      tripal_phenotype/tripal_phenotype.info
  40. 3 4
      tripal_project/tripal_project.info
  41. 3 4
      tripal_pub/tripal_pub.info
  42. 0 8
      tripal_search/tripal_search.coder_ignores.txt
  43. 0 10
      tripal_search/tripal_search.info
  44. 0 159
      tripal_search/tripal_search.module
  45. 3 4
      tripal_stock/tripal_stock.info
  46. 1 2
      tripal_views/tripal_views.info
  47. 2 2
      tripal_views/views/handlers/chado_views_handler_field_counter.inc

+ 0 - 40
extensions/tripal_search_unigene/theme/css/tripal_search_unigene.css

@@ -1,40 +0,0 @@
-.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 - 20
extensions/tripal_search_unigene/theme/js/tripal_search_unigene.js

@@ -1,20 +0,0 @@
-//
-// 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);
-		}
-   });
-}

+ 0 - 195
extensions/tripal_search_unigene/theme/views-exposed-form--unigene_search.tpl.php

@@ -1,195 +0,0 @@
-<?php
-// $Id: views-exposed-form.tpl.php,v 1.4.4.1 2009/11/18 20:37:58 merlinofchaos Exp $
-/**
- * @file views-exposed-form.tpl.php
- *
- * This template handles the layout of the views exposed filter form.
- *
- * Variables available:
- * - $widgets: An array of exposed form widgets. Each widget contains:
- * - $widget->label: The visible label to print. May be optional.
- * - $widget->operator: The operator for the widget. May be optional.
- * - $widget->widget: The widget itself.
- * - $button: The submit button for the form.
- *
- * @ingroup views_templates
- */
-?>
-<?php if (!empty($q)): ?>
-  <?php
-    // This ensures that, if clean URLs are off, the 'q' is added first so that
-    // it shows up first in the URL.
-    print $q;
-
-  ?>
-<?php endif;     //dsm($widgets);?>
-<div class="tripal_search_unigene-views-exposed-form views-exposed-form">
-  <div class="views-exposed-widgets clear-block">
-    
-    <?php 
-    	$feature_type_id =  $widgets['filter-feature_type']; 
-    	$orgnism_common_name =  $widgets['filter-organism_common_name'];
-    	$analysis_name =  $widgets['filter-unigene'];
-    	$feature_name =  $widgets['filter-feature_name'];
-    	$feature_seqlen =  $widgets['filter-feature_seqlen'];
-    	$cvterm_name =  $widgets['filter-go_term'];
-    	$blast_value =  $widgets['filter-blast_value'];
-    	$interpro_value =  $widgets['filter-interpro_value'];
-    	$kegg_value =  $widgets['filter-kegg_value'];
-    ?>
-    
-    <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-unigene-exposed-widgets-fields">
-				<legend>Search by Name</legend>
-				<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="tripal_search_unigene-views-operator">
-					<?php print $orgnism_common_name->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-					<?php print $orgnism_common_name->widget; ?>
-					</div>
-				</div>
-				<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="tripal_search_unigene-views-operator">
-					<?php print $feature_name->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-						<?php print $feature_name->widget; ?>
-					</div>
-				</div>
-			</fieldset>
-
-			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
-				<legend>Search by Assembly</legend>
-				<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="tripal_search_unigene-views-operator">
-					<?php print $feature_type_id->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-					<?php print $feature_type_id->widget; ?>
-					</div>
-				</div>
-				<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="tripal_search_unigene-views-operator">
-					<?php print $analysis_name->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-						<?php print $analysis_name->widget; ?>
-					</div>
-				</div>
-			</fieldset>
-
-			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
-				<legend>Search by Sequence</legend>
-				<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="tripal_search_unigene-views-operator">
-					<?php print $feature_seqlen->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-					<?php print $feature_seqlen->widget; ?>
-					</div>
-				</div>
-			</fieldset>
-
-			<fieldset class="tripal-search-unigene-exposed-widgets-fields">
-				<legend>Search by Putative Function</legend>
-				<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="tripal_search_unigene-views-operator">
-					<?php print $cvterm_name->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-					<?php print $cvterm_name->widget; ?>
-					</div>
-				</div>
-
-				<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="tripal_search_unigene-views-operator">
-					<?php print $blast_value->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-						<?php print $blast_value->widget; ?>
-					</div>
-				</div>
-				
-				<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="tripal_search_unigene-views-operator">
-					<?php print $kegg_value->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-						<?php print $kegg_value->widget; ?>
-					</div>
-				</div>
-				
-				<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="tripal_search_unigene-views-operator">
-					<?php print $interpro_value->operator; ?>
-					</div>
-					<?php endif; ?>
-					<div class="tripal_search_unigene-views-widget">
-						<?php print $interpro_value->widget; ?>
-					</div>
-				</div>
-			</fieldset>
-
-		</div>
-    
-    <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>
-</div>

+ 0 - 221
extensions/tripal_search_unigene/theme/views-view-table--unigene_search.tpl.php

@@ -1,221 +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
- */
-?>
-
-<?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);
-}
-?>

+ 0 - 12
extensions/tripal_search_unigene/tripal_search_unigene.info

@@ -1,12 +0,0 @@
-; $Id$
-package = Tripal Extensions
-name = Tripal Search Unigene
-description = A module to provide advanced search functions for unigenes
-core = 6.x
-
-dependencies[] = tripal_core
-dependencies[] = tripal_organism
-dependencies[] = tripal_cv
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis
-dependencies[] = views

+ 0 - 155
extensions/tripal_search_unigene/tripal_search_unigene.install

@@ -1,155 +0,0 @@
-<?php
-
-/*******************************************************************************
-*  Implementation of hook_install();
-*/
-function tripal_search_unigene_install(){
-
-   // create the module's data directory
-   tripal_create_moddir('tripal_search_unigene');
-	
-	// 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 = '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 = " unigene_for_search_id integer, 
-   							  feature_id integer,
-   							  feature_type character varying(1024),
-   							  feature_name character varying(1024),
-   							  feature_uniquename text,
-   							  feature_is_obsolete boolean,
-   							  organism_common_name character varying(255),
-   							  feature_seqlen integer,
-   							  go_term character varying(1024),
-   							  unigene character varying(255),
-   							  blast_value text,
-   							  kegg_value text,
-   							  interpro_value text
-   							  ";
-   
-   $index = "feature_id, go_term, unigene, blast_value, kegg_value, interpro_value";
-   $singlet_type_id = tripal_cv_get_cvterm_by_name('singlet_in_analysis');
-   if ($singlet_type_id) {
-   	$singlet_condition = " 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')))";
-   }
-   $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, 
-										F.uniquename AS feature_uniquename,
-										F.is_obsolete AS feature_is_obsolete,
-										O.common_name AS organism_common_name, 
-										F.seqlen AS feature_seqlen, 
-										C.name AS go_term,
-										UNIGENE.name AS unigene_name,
-										BLAST.value AS blast_value, 
-										KEGG.value AS KEGG_value, 
-										INTERPRO.value AS interpro_value 
-						FROM feature F
-						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 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 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 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 
-													INNER JOIN analysisprop AP ON AF.analysis_id = AP.analysis_id
-													WHERE AP.type_id = (SELECT cvterm_id FROM cvterm
-																								WHERE name = 'analysis_type' 
-																								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') $singlet_condition
-						) T";
-   
-      // Create the MView
-      tripal_add_mview(
-      // view name
-      $view_name,
-      // tripal module name
-      ' tripal_search_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);
-   }
-
-}
-
-/*******************************************************************************
- * Implementation of hook_uninstall()
- */
-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){
-		tripal_mviews_action("delete",$mview_id);
-	}
-	 
-	// Drop the sequence
-	$sql = "DROP SEQUENCE IF EXISTS unigene_for_search_id";
-	chado_query($sql);
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' is enabled
- * before installation
- */
-function tripal_search_unigene_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir')) {
-         $requirements ['tripal_search_unigene'] = array(
-            'title' => "tripal_search_unigene",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}

+ 0 - 58
extensions/tripal_search_unigene/tripal_search_unigene.module

@@ -1,58 +0,0 @@
-<?php
-
-// require_once "PHPExcel/Classes/PHPExcel.php";
-
-/*************************************************************************
- * tripal_search_unigene_init
- */
-function tripal_search_unigene_init(){
-	drupal_add_css(drupal_get_path('module', 'tripal_search_unigene').'/theme/css/tripal_search_unigene.css');
-	drupal_add_js(drupal_get_path('module', 'tripal_search_unigene').'/theme/js/tripal_search_unigene.js');
-}
-
-/*************************************************************************
- * tripal_search_unigene_views_api
- */
-function tripal_search_unigene_views_api() {
-   return array(
-      'api' => 2.0,
-   );
-}
-
-// A function to rewrite the SQL statement before submitting the query
-// Force GROUP BY feature_id and return only one row
-
-function  tripal_search_unigene_views_pre_execute(&$view){
-	if ($view->name == 'unigene_search') {
-
-		// AGGREGATORS
-		$search = array('SELECT');
-		$replace = array('SELECT min(');
-		$view->build_info['query'] = str_replace($search, $replace, $view->build_info['query']);
-		$view->build_info['count_query']  = str_replace($search, $replace, $view->build_info['count_query']);
-		 
-		$search = array(',');
-		$replace = array(', min(');
-		$view->build_info['query'] = str_replace($search, $replace, $view->build_info['query']);
-		$view->build_info['count_query']  = str_replace($search, $replace, $view->build_info['count_query']);
-		 
-		$search = array(' AS ');
-		$replace = array(') AS ');
-		$view->build_info['query'] = str_replace($search, $replace, $view->build_info['query']);
-		$view->build_info['count_query']  = str_replace($search, $replace, $view->build_info['count_query']);
-
-		// GROUP BY
-		if (preg_match("'ORDER BY'",  $view->build_info['query'])) {
-			$search = array('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 unigene_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']);
-		 
-	}
-}

+ 0 - 952
extensions/tripal_search_unigene/tripal_search_unigene.views.inc

@@ -1,952 +0,0 @@
-<?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(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'counter_start' => '1',
-    'exclude' => 0,
-    'id' => 'counter',
-    'table' => 'views',
-    'field' => 'counter',
-    'relationship' => 'none',
-	),
-  'feature_id' => array(
-    'label' => 'feature ID',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'set_precision' => FALSE,
-    'precision' => 0,
-    'decimal' => '.',
-    'separator' => '',
-    'prefix' => '',
-    'suffix' => '',
-    'exclude' => 1,
-    'id' => 'feature_id',
-    'table' => 'unigene_for_search',
-    'field' => 'feature_id',
-    'relationship' => 'none',
-	),
-  'feature_name' => array(
-    'label' => 'Sequence',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 1,
-      'path' => 'ID[feature_id]',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'exclude' => 0,
-    'id' => 'feature_name',
-    'table' => 'unigene_for_search',
-    'field' => 'feature_name',
-    'relationship' => 'none',
-	),
-  'organism_common_name' => array(
-    'label' => 'Organism',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'exclude' => 0,
-    'id' => 'organism_common_name',
-    'table' => 'unigene_for_search',
-    'field' => 'organism_common_name',
-    'relationship' => 'none',
-	),
-  'feature_seqlen' => array(
-    'label' => 'Length',
-    'alter' => array(
-      'alter_text' => 1,
-      'text' => '[feature_seqlen] bp',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'set_precision' => FALSE,
-    'precision' => 0,
-    'decimal' => '.',
-    'separator' => ',',
-    'prefix' => '',
-    'suffix' => '',
-    'exclude' => 0,
-    'id' => 'feature_seqlen',
-    'table' => 'unigene_for_search',
-    'field' => 'feature_seqlen',
-    'relationship' => 'none',
-	),
-  'feature_type' => array(
-    'label' => 'Type',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'exclude' => 0,
-    'id' => 'feature_type',
-    'table' => 'unigene_for_search',
-    'field' => 'feature_type',
-    'relationship' => 'none',
-	),
-  'go_term' => array(
-    'label' => 'GO Term',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 0,
-      'max_length' => '',
-      'word_boundary' => 1,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'exclude' => 0,
-    'id' => 'go_term',
-    'table' => 'unigene_for_search',
-    'field' => 'go_term',
-    'relationship' => 'none',
-	),
-  'blast_value' => array(
-    'label' => 'Blast',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 1,
-      'max_length' => '200',
-      'word_boundary' => 0,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'exclude' => 0,
-    'id' => 'blast_value',
-    'table' => 'unigene_for_search',
-    'field' => 'blast_value',
-    'relationship' => 'none',
-	),
-  'kegg_value' => array(
-    'label' => 'KEGG',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 1,
-      'max_length' => '200',
-      'word_boundary' => 0,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'exclude' => 0,
-    'id' => 'kegg_value',
-    'table' => 'unigene_for_search',
-    'field' => 'kegg_value',
-    'relationship' => 'none',
-	),
-  'interpro_value' => array(
-    'label' => 'Interpro',
-    'alter' => array(
-      'alter_text' => 0,
-      'text' => '',
-      'make_link' => 0,
-      'path' => '',
-      'link_class' => '',
-      'alt' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'target' => '',
-      'help' => '',
-      'trim' => 1,
-      'max_length' => '200',
-      'word_boundary' => 0,
-      'ellipsis' => 1,
-      'html' => 0,
-      'strip_tags' => 0,
-	),
-    'empty' => '',
-    'hide_empty' => 0,
-    'empty_zero' => 0,
-    'exclude' => 0,
-    'id' => 'interpro_value',
-    'table' => 'unigene_for_search',
-    'field' => 'interpro_value',
-    'relationship' => 'none',
-	),
-	));
-	$handler->override_option('arguments', array(
-  'null' => array(
-    'default_action' => 'default',
-    'style_plugin' => 'default_summary',
-    'style_options' => array(),
-    'wildcard' => 'all',
-    'wildcard_substitution' => 'All',
-    'title' => '',
-    'breadcrumb' => '',
-    'default_argument_type' => 'fixed',
-    'default_argument' => '',
-    'validate_type' => 'php',
-    'validate_fail' => 'empty',
-    'must_not_be' => 0,
-    'id' => 'null',
-    'table' => 'views',
-    'field' => 'null',
-    'validate_user_argument_type' => 'uid',
-    'validate_user_roles' => array(
-      '2' => 0,
-      '3' => 0,
-      '5' => 0,
-      '4' => 0,
-	),
-    'relationship' => 'none',
-    'default_options_div_prefix' => '',
-    'default_argument_fixed' => '',
-    'default_argument_user' => 0,
-    'default_argument_php' => '',
-    'validate_argument_node_type' => array(
-      'iframe' => 0,
-      'news' => 0,
-      'chado_analysis' => 0,
-      'chado_analysis_blast' => 0,
-      'chado_analysis_interpro' => 0,
-      'chado_analysis_kegg' => 0,
-      'chado_analysis_unigene' => 0,
-      'chado_feature' => 0,
-      'chado_library' => 0,
-      'chado_organism' => 0,
-      'calendar_event' => 0,
-      'page' => 0,
-      'story' => 0,
-	),
-    'validate_argument_node_access' => 0,
-    'validate_argument_nid_type' => 'nid',
-    'validate_argument_vocabulary' => array(
-      '17' => 0,
-      '13' => 0,
-      '14' => 0,
-      '15' => 0,
-      '16' => 0,
-      '9' => 0,
-      '10' => 0,
-      '11' => 0,
-      '12' => 0,
-      '5' => 0,
-      '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(
-  'feature_name' => array(
-    'operator' => 'contains',
-    'value' => '',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 1,
-      'operator' => 'feature_name_op',
-      'identifier' => 'feature_name',
-      'label' => 'sequence name',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'case' => 0,
-    'id' => 'feature_name',
-    'table' => 'unigene_for_search',
-    'field' => 'feature_name',
-    'relationship' => 'none',
-	),
-  'feature_seqlen' => array(
-    'operator' => '>=',
-    'value' => array(
-      'value' => '',
-      'min' => '',
-      'max' => '',
-	),
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 1,
-      'operator' => 'feature_seqlen_op',
-      'identifier' => 'feature_seqlen',
-      'label' => 'sequence length (bp)',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'id' => 'feature_seqlen',
-    'table' => 'unigene_for_search',
-    'field' => 'feature_seqlen',
-    'relationship' => 'none',
-	),
-  'feature_type' => array(
-    'operator' => '=',
-    'value' => '260',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 0,
-      'operator' => 'feature_type_op',
-      'identifier' => 'feature_type',
-      'label' => 'type of sequence',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'case' => 0,
-    'id' => 'feature_type',
-    'table' => 'unigene_for_search',
-    'field' => 'feature_type',
-    'relationship' => 'none',
-	),
-  'go_term' => array(
-    'operator' => 'contains',
-    'value' => '',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 1,
-      'operator' => 'go_term_op',
-      'identifier' => 'go_term',
-      'label' => 'GO term',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'case' => 0,
-    'id' => 'go_term',
-    'table' => 'unigene_for_search',
-    'field' => 'go_term',
-    'relationship' => 'none',
-	),
-  'organism_common_name' => array(
-    'operator' => '=',
-    'value' => 'chickpea',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 0,
-      'operator' => 'organism_common_name_op',
-      'identifier' => 'organism_common_name',
-      'label' => 'organism',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'case' => 0,
-    'id' => 'organism_common_name',
-    'table' => 'unigene_for_search',
-    'field' => 'organism_common_name',
-    'relationship' => 'none',
-	),
-  'unigene' => array(
-    'operator' => '=',
-    'value' => 'Cicer arietinum unigene v1',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 0,
-      'operator' => 'unigene_op',
-      'identifier' => 'unigene',
-      'label' => 'belongs to unigene',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'case' => 0,
-    'id' => 'unigene',
-    'table' => 'unigene_for_search',
-    'field' => 'unigene',
-    'relationship' => 'none',
-	),
-  'interpro_value' => array(
-    'operator' => 'contains',
-    'value' => '',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 1,
-      'operator' => 'interpro_value_op',
-      'identifier' => 'interpro_value',
-      'label' => 'interpro description',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'case' => 0,
-    'id' => 'interpro_value',
-    'table' => 'unigene_for_search',
-    'field' => 'interpro_value',
-    'relationship' => 'none',
-	),
-  'blast_value' => array(
-    'operator' => 'contains',
-    'value' => '',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 1,
-      'operator' => 'blast_value_op',
-      'identifier' => 'blast_value',
-      'label' => 'blast description',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'case' => 0,
-    'id' => 'blast_value',
-    'table' => 'unigene_for_search',
-    'field' => 'blast_value',
-    'relationship' => 'none',
-	),
-  'kegg_value' => array(
-    'operator' => 'contains',
-    'value' => '',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 1,
-      'operator' => 'kegg_value_op',
-      'identifier' => 'kegg_value',
-      'label' => 'kegg description',
-      'optional' => 1,
-      'remember' => 0,
-	),
-    'case' => 0,
-    'id' => 'kegg_value',
-    'table' => 'unigene_for_search',
-    'field' => 'kegg_value',
-    'relationship' => 'none',
-	),
-	));
-	$handler->override_option('access', array(
-  'type' => 'none',
-	));
-	$handler->override_option('cache', array(
-  'type' => 'none',
-	));
-	$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(
-  'grouping' => '',
-  'override' => 1,
-  'sticky' => 0,
-  'order' => 'asc',
-  'columns' => array(
-    'feature_id' => 'feature_id',
-    'feature_name' => 'feature_name',
-    'feature_seqlen' => 'feature_seqlen',
-    'feature_type' => 'feature_type',
-    'go_term' => 'go_term',
-    'organism_common_name' => 'organism_common_name',
-    'unigene' => 'unigene',
-    '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', 'unigene_search');
-	$handler->override_option('menu', array(
-  'type' => 'normal',
-  'title' => 'Unigene Search',
-  'description' => 'Advanced Search for unigenes',
-  'weight' => '0',
-  'name' => 'primary-links',
-	));
-	$handler->override_option('tab_options', array(
-  'type' => 'none',
-  'title' => '',
-  'description' => '',
-  'weight' => 0,
-  'name' => 'navigation',
-	));
-  $views[$view->name] = $view;
-  
-  return $views;
-}

+ 0 - 53
extensions/tripal_search_unigene/views_handler_filter_analysis_name.inc

@@ -1,53 +0,0 @@
-<?php
-class views_handler_filter_analysis_name extends views_handler_filter_string {
-	function value_form(&$form, &$form_state) {
-		$type_id = tripal_cv_get_cvterm_by_name("analysis_type");
-		$sql = "SELECT name, A.analysis_id 
-		        FROM {analysis} A 
-		           INNER JOIN {analysisprop} AP ON A.analysis_id = AP.analysis_id 
-		        WHERE type_id = %d AND value = 'tripal_analysis_unigene'";
-
-		$results = chado_query($sql,$typ_id->cvterm_id);
-		$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"))) {
-				// 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('Analysis'),
-		'#options' => $analyses,
-		'#default_value' => 0,
-		);
-
-		return $form;
-	}
-
-	function operator_options () {
-		return array(
-			'=' => t('Is equal to')
-		);
-	}
-}

+ 0 - 26
extensions/tripal_search_unigene/views_handler_filter_feature_type_id.inc

@@ -1,26 +0,0 @@
-<?php
-class views_handler_filter_feature_type_id extends views_handler_filter_string {
-
-	function value_form(&$form, &$form_state) {
-
-		$sql = "SELECT distinct feature_type FROM {unigene_for_search}";
-		$results = chado_query($sql);
-		$options = array ();
-		while($type = db_fetch_object($results)) {
-			$options[$type->feature_type] = $type->feature_type;
-		}
-
-		$form['value'] = array(
-		'#type' => 'select',
-		'#title' => t('Type of sequence'),
-		'#options' => $options,
-		);
-		return $form;
-	}
-
-	function operator_options () {
-		return array(
-			'=' => t('Is equal to')
-		);
-	}
-}

+ 0 - 30
extensions/tripal_search_unigene/views_handler_filter_organism_common_name.inc

@@ -1,30 +0,0 @@
-<?php
-class views_handler_filter_organism_common_name extends views_handler_filter_string {
-
-	function value_form(&$form, &$form_state) {
-		$sql = "SELECT distinct common_name, organism_id FROM {organism}";
-		$results = chado_query($sql);
-		$organisms = array();
-		
-		while ($org = db_fetch_object($results)) {
-			// check if the organisms is synced
-			if (db_result(db_query("SELECT * FROM {chado_organism} WHERE organism_id = $org->organism_id"))) {
-				$organisms[$org->common_name] = t($org->common_name);
-			}
-		}
-		$form['value'] = array(
-		'#type' => 'select',
-		'#title' => t('Organism'),
-		'#options' => $organisms,
-		'#default_value' => 0,
-		);
- 
-	return $form;
-	}
-	
-	function operator_options () {
-		return array(
-			'=' => t('Is equal to')
-		);
-	}
-}

+ 1 - 2
tripal_analysis/tripal_analysis.info

@@ -1,10 +1,9 @@
-; $Id:
 name = Tripal Analysis
 description = A module that controls the display of all analysis sub-modules. This module also interfaces the GMOD chado database with Drupal, providing viewing, inserting and editing of chado analyses.
 core = 6.x
 project = tripal_analysis
 package = Tripal
-version = 6.x-0.3.1b
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_db
 dependencies[] = tripal_cv

+ 97 - 97
tripal_analysis/tripal_analysis_privacy.inc

@@ -1,97 +1,97 @@
-<?php
-/**
- * @file
- * Perform permission check (required node_privacy_byrole module)
- */
-
-/**
- * Perform permission check by analysis_id only if 'node_privacy_byrole' module is enabled
- *
- * @param $analysis_id
- *   Which analysis to check if the user has permission to view
- */
-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;
-  }
-}
-
-/**
- * Set permissions for features associated with an analysis
- * @todo Stephen: ensure the $nid param is defined correctly
- *
- * @param $analysis_id
- *   Features associated with this analysis will have their permissions set
- * @param $nid
- *   The node ID of the 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", $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 ++;
-  }
-}
+<?php
+/**
+ * @file
+ * Perform permission check (required node_privacy_byrole module)
+ */
+
+/**
+ * Perform permission check by analysis_id only if 'node_privacy_byrole' module is enabled
+ *
+ * @param $analysis_id
+ *   Which analysis to check if the user has permission to view
+ */
+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;
+  }
+}
+
+/**
+ * Set permissions for features associated with an analysis
+ * @todo Stephen: ensure the $nid param is defined correctly
+ *
+ * @param $analysis_id
+ *   Features associated with this analysis will have their permissions set
+ * @param $nid
+ *   The node ID of the 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", $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 ++;
+  }
+}

+ 268 - 249
tripal_bulk_loader/tripal_bulk_loader.admin.inc

@@ -1,249 +1,268 @@
-<?php
-
-/**
- * @file
- * Bulk Loader Administration (Miscellaneous)
- */
-
-/**
- * Provides a description page and quick links for the bulk loader
- */
-function tripal_bulk_loader_admin_template() {
-  $output = '';
-
-  $output .= '<br /><h3>Quick Links:</h3>';
-  $output .= '<ul>'
-    . '<li>'
-      . t('<a href="@link">Configure settings</a>',
-        array('@link' => url('admin/tripal/tripal_bulk_loader_template/configure')))
-      . '</li>'
-    . '<li>'
-      . t('List <a href="@link">Bulk Loader Jobs</a>',
-      array('@link' => url('admin/tripal/tripal_bulk_loader_template/jobs')))
-      . '</li>'
-    . '<li>'
-      . t('List <a href="@link">Manage Templates</a>',
-      array('@link' => url('admin/tripal/tripal_bulk_loader_template/manage_templates')))
-      . '</li>'
-      . '<ul>'
-      . '<li>'
-        . t('<a href="@create">Create</a> a new template',
-        array('@create' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/create')))
-        . '</li>'
-      . '<li>'
-        . t('<a href="@edit">Edit</a> an existing template',
-        array('@edit' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/edit')))
-        . '</li>'
-      . '<li>'
-        . t('<a href="@delete">Delete</a> an existing template',
-        array('@delete' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/delete')))
-        . '</li>'
-      . '<li>'
-        . t('<a href="@import">Import</a> a new template',
-        array('@import' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/import')))
-        . '</li>'
-      . '<li>'
-        . t('<a href="@export">Export</a> an existing template',
-        array('@export' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/export')))
-        . '</li>'
-      . '</ul>'
-    . '</ul>';
-
-  $output .= '<h3>Module Description:</h3>';
-  $output .= '<p>This module provides the ability to create loading templates for any tab-delimited '
-    . 'data file allowing it to be loaded into chado. The Loading Templates are a direct mapping '
-    . 'between the columns in your file and the columns in chado tables. As such to use this tool '
-    . 'you need to be very familar with the chado schema -See '
-    . l(t('Chado -Getting Started'), 'http://gmod.org/wiki/Chado_-_Getting_Started')
-    . '. The ability to add constants and specify foreign key contraints is also provided '
-    . 'in order for the loader to fill chado columns which may be required but are not specified '
-    . 'in your input file.</p>';
-  $output .= '<br />';
-
-  $output .= '<h3>Setup Instructions</h3>';
-  $output .= '<p>After intallation of the bulk loader module, the following tasks should be performed:</p>';
-  $output .= '<ol>';
-  $output .= '<li><b>Install Theme:</b> In order for Bulk Loading pages to be displayed correctly, '
-    .'the contents of the Tripal Bulk Loader theme directory ([drupal root]/sites/all/modules/tripal/tripal_bulk_loader/theme) '
-    .'should be moved to the base directory of the Tripal theme ([drupal root]/sites/all/themes/tripal). '
-    .'Finally the drupal cache should be cleared for the new theme to take effect -navigate to admin/settings/performance '
-    .'and click the Clear Cached Data button.</li>';
-  $output .= '</ol>';
-
-  return $output;
-}
-
-/**
- * Provides a description page and quick links for template management
- */
-function tripal_bulk_loader_admin_manage_templates() {
-  $output = '';
-
-  $output .= '<br /><h3>Quick Links:</h3>';
-  $output .= '<ul>'
-    . '<li>'
-      . t('<a href="@create">Create</a> a new template',
-      array('@create' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/create')))
-      . '</li>'
-    . '<li>'
-      . t('<a href="@edit">Edit</a> an existing template',
-      array('@edit' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/edit')))
-      . '</li>'
-    . '<li>'
-      . t('<a href="@delete">Delete</a> an existing template',
-      array('@delete' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/delete')))
-      . '</li>'
-    . '<li>'
-      . t('<a href="@import">Import</a> a new template',
-      array('@import' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/import')))
-      . '</li>'
-    . '<li>'
-      . t('<a href="@export">Export</a> an existing template',
-      array('@export' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/export')))
-      . '</li>'
-    . '</ul>';
-
-  $output .= '<p>' . t('Templates, as the term is used for this module, refer to plans
-  describing how the columns in the data file supplied to a bulk loading job map to tables
-  and fields in chado. Templates are created independently of bulk loading jobs so that
-  they can be re-used. Thus you only need one template to load any number of files of the
-  same format.') . '</p>';
-
-
-
-  return $output;
-}
-
-/**
- * Provides a listing of bulk loader jobs and links for administration
- */
-function tripal_bulk_loader_admin_jobs() {
-  $output = '';
-  $num_jobs_per_page = 50;
-
-  $output .= '<p>' . t('Jobs are not automatically submitted to the tripal jobs management
-  system when they are first created. Any jobs listed below with a status of "Initialized"
-  will not have a Job ID until you go to the bulk loader page and submit the job.') . '</p>';
-
-  $header = array(
-    array('data' => 'Job ID', 'field' => 'job_id', 'sort' => 'DESC'),
-    array('data' => 'Name', 'field' => 'loader_name'),
-    array('data' =>  'Template', 'field' => 'template_name'),
-    array('data' =>  'Status', 'field' => 'job_status'),
-    '');
-  $rows = array();
-  $resource = pager_query("SELECT n.*, t.name as template_name
-    FROM {tripal_bulk_loader} n
-    LEFT JOIN {tripal_bulk_loader_template} t ON cast(n.template_id as integer)=t.template_id"
-    . tablesort_sql($header),
-    $num_jobs_per_page);
-  while ($n = db_fetch_object($resource)) {
-    $rows[] = array(
-      l($n->job_id, 'admin/tripal/tripal_jobs/view/' . $n->job_id),
-      l($n->loader_name, 'node/' . $n->nid),
-      l($n->template_name, 'admin/tripal/tripal_bulk_loader_template/manage_templates/edit', array('query' => 'template_id=' . $n->template_id)),
-      $n->job_status,
-      l('View', 'node/' . $n->nid) . ' | ' .  l('Edit', 'node/' . $n->nid . '/edit')
-    );
-  }
-  $output .= theme_table($header, $rows);
-
-  $output .= theme('pager');
-
-  return $output;
-}
-
-/**
- * @section
- * Configuration Form
- */
-
-/**
- * A Configuration form for this module
- */
-function tripal_bulk_loader_configuration_form($form_state = NULL) {
-  $form = array();
-
-  $form['speed'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Possible Speed Improvements'),
-  );
-
-  $form['speed']['prepare'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Use Prepared Statements'),
-    '#description' => t('SQL Prepared Statements allow for SQL queries which will be run '
-      .'many times to be parsed, rewritten and planned only once rather then every time '
-      .'the query is run. In the case of the bulk loader, this ensures that planning only '
-      .'occurs once for each "record" in your bulk loading template.'),
-    '#default_value' => variable_get('tripal_bulk_loader_prepare', TRUE),
-  );
-
-  $form['speed']['disable_triggers'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Delay Constraint Checking during loading job.'),
-    '#description' => t('This delays the constraint checking until the end of the
-    loading proccess.'),
-    '#default_value' => variable_get('tripal_bulk_loader_disable_triggers', TRUE),
-  );
-
-  $form['speed']['no_validate'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Skip Validation at the Tripal Core API level'),
-    '#description' => t('If an error is encountered, the Tripal core API will try
-      to provide informative error messages. With this turned off, you will not benifit
-      from these more informative error messages; however, your job will load faster
-      since it doesn\'t have to do the additional checking before inserting.'),
-    '#default_value' => variable_get('tripal_bulk_loader_skip_validation', FALSE),
-  );
-
-  $form['speed']['transactions'] = array(
-    '#type' => 'radios',
-    '#title' => t('Transaction Rollback when an error is encountered'),
-    '#options' => array(
-      'all' => t('Rollback the last constant set.'
-        .'<div class="description"If you added more then one constant set then the
-        successfully loaded constant sets will not be rolled back. However, once an error
-        is encountered no further constant sets will be loaded either.</div>'),
-      'row' => t('Only Rollback the last line of the input file.'
-        .'<div class="description">This option may allow you to restart the job after
-        fixing the error (manual intervention needed).</div>'),
-      'none' => t('Do not use transactions<div class="description">This is not recommended.</div>')
-    ),
-    '#default_value' => variable_get('tripal_bulk_loader_transactions',   'row')
-  );
-
-  $form['speed']['lock'] = array(
-    '#type' => 'radios',
-    '#title' => t('Lock Type'),
-    '#description' => t('The type of lock used by the bulk loading jobs. The lock is '
-      .'acquired at the beginning of the job and kept till the end. A lock of the type '
-      .'selected will be acquired for every table being inserted into.'),
-    '#options' => array(
-      'ROW EXCLUSIVE' => t('ROW EXCLUSIVE: The default lock type for insert queries.'),
-      'EXCLUSIVE' => t('EXCLUSIVE: Only Select Queries can access the table.'),
-      'ACCESS EXCLUSIVE' => t('ACCESS EXCLUSIVE: No other queries can access the table.'),
-    ),
-    '#default_value' => variable_get('tripal_bulk_loader_lock', 'ROW EXCLUSIVE'),
-  );
-
-  $form['submit1'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save')
-  );
-
-  return $form;
-}
-
-/**
- * A Configuration form for this module (Submit)
- */
-function tripal_bulk_loader_configuration_form_submit($form, $form_state) {
-
-  variable_set('tripal_bulk_loader_prepare', $form_state['values']['prepare']);
-  variable_set('tripal_bulk_loader_disable_triggers', $form_state['values']['disable_triggers']);
-  variable_set('tripal_bulk_loader_skip_validation', $form_state['values']['no_validate']);
-  variable_set('tripal_bulk_loader_transactions', $form_state['values']['transactions']);
-  variable_set('tripal_bulk_loader_lock', $form_state['values']['lock']);
-
-}
+<?php
+
+/**
+ * @file
+ * Bulk Loader Administration (Miscellaneous)
+ */
+
+/**
+ * Provides a description page and quick links for the bulk loader
+ */
+function tripal_bulk_loader_admin_template() {
+  $output = '';
+
+  $output .= '<br /><h3>Quick Links:</h3>';
+  $output .= '<ul>'
+    . '<li>'
+      . t('<a href="@link">Configure settings</a>',
+        array('@link' => url('admin/tripal/tripal_bulk_loader_template/configure')))
+      . '</li>'
+    . '<li>'
+      . t('List <a href="@link">Bulk Loader Jobs</a>',
+      array('@link' => url('admin/tripal/tripal_bulk_loader_template/jobs')))
+      . '</li>'
+    . '<li>'
+      . t('List <a href="@link">Manage Templates</a>',
+      array('@link' => url('admin/tripal/tripal_bulk_loader_template/manage_templates')))
+      . '</li>'
+      . '<ul>'
+      . '<li>'
+        . t('<a href="@create">Create</a> a new template',
+        array('@create' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/create')))
+        . '</li>'
+      . '<li>'
+        . t('<a href="@edit">Edit</a> an existing template',
+        array('@edit' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/edit')))
+        . '</li>'
+      . '<li>'
+        . t('<a href="@delete">Delete</a> an existing template',
+        array('@delete' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/delete')))
+        . '</li>'
+      . '<li>'
+        . t('<a href="@import">Import</a> a new template',
+        array('@import' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/import')))
+        . '</li>'
+      . '<li>'
+        . t('<a href="@export">Export</a> an existing template',
+        array('@export' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/export')))
+        . '</li>'
+      . '</ul>'
+    . '</ul>';
+
+  $output .= '<h3>Module Description:</h3>';
+  $output .= '<p>This module provides the ability to create loading templates for any tab-delimited '
+    . 'data file allowing it to be loaded into chado. The Loading Templates are a direct mapping '
+    . 'between the columns in your file and the columns in chado tables. As such to use this tool '
+    . 'you need to be very familar with the chado schema -See '
+    . l(t('Chado -Getting Started'), 'http://gmod.org/wiki/Chado_-_Getting_Started')
+    . '. The ability to add constants and specify foreign key contraints is also provided '
+    . 'in order for the loader to fill chado columns which may be required but are not specified '
+    . 'in your input file.</p>';
+  $output .= '<br />';
+
+  $output .= '<h3>Setup Instructions</h3>';
+  $output .= '<p>After intallation of the bulk loader module, the following tasks should be performed:</p>';
+  $output .= '<ol>';
+  $output .= '<li><b>Install Theme:</b> In order for Bulk Loading pages to be displayed correctly, '
+    .'the contents of the Tripal Bulk Loader theme directory ([drupal root]/sites/all/modules/tripal/tripal_bulk_loader/theme) '
+    .'should be moved to the base directory of the Tripal theme ([drupal root]/sites/all/themes/tripal). '
+    .'Finally the drupal cache should be cleared for the new theme to take effect -navigate to admin/settings/performance '
+    .'and click the Clear Cached Data button.</li>';
+  $output .= '</ol>';
+
+  return $output;
+}
+
+/**
+ * Provides a description page and quick links for template management
+ */
+function tripal_bulk_loader_admin_manage_templates() {
+  $output = '';
+
+  $output .= '<br /><h3>Quick Links:</h3>';
+  $output .= '<ul>'
+    . '<li>'
+      . t('<a href="@create">Create</a> a new template',
+      array('@create' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/create')))
+      . '</li>'
+    . '<li>'
+      . t('<a href="@edit">Edit</a> an existing template',
+      array('@edit' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/edit')))
+      . '</li>'
+    . '<li>'
+      . t('<a href="@delete">Delete</a> an existing template',
+      array('@delete' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/delete')))
+      . '</li>'
+    . '<li>'
+      . t('<a href="@import">Import</a> a new template',
+      array('@import' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/import')))
+      . '</li>'
+    . '<li>'
+      . t('<a href="@export">Export</a> an existing template',
+      array('@export' => url('admin/tripal/tripal_bulk_loader_template/manage_templates/export')))
+      . '</li>'
+    . '</ul>';
+
+  $output .= '<p>' . t('Templates, as the term is used for this module, refer to plans
+  describing how the columns in the data file supplied to a bulk loading job map to tables
+  and fields in chado. Templates are created independently of bulk loading jobs so that
+  they can be re-used. Thus you only need one template to load any number of files of the
+  same format.') . '</p>';
+
+
+
+  return $output;
+}
+
+/**
+ * Provides a listing of bulk loader jobs and links for administration
+ */
+function tripal_bulk_loader_admin_jobs() {
+  $output = '';
+  $num_jobs_per_page = 50;
+
+  $output .= '<p>' . t('Jobs are not automatically submitted to the tripal jobs management
+  system when they are first created. Any jobs listed below with a status of "Initialized"
+  will not have a Job ID until you go to the bulk loader page and submit the job.') . '</p>';
+
+  $header = array(
+    array('data' => 'Job ID', 'field' => 'job_id', 'sort' => 'DESC'),
+    array('data' => 'Name', 'field' => 'loader_name'),
+    array('data' =>  'Template', 'field' => 'template_name'),
+    array('data' =>  'Status', 'field' => 'job_status'),
+    array('data' => 'Progress', 'field' => 'progress'),
+    '');
+  $rows = array();
+  $resource = pager_query("SELECT n.*, t.name as template_name, j.progress
+    FROM {tripal_bulk_loader} n
+    LEFT JOIN {tripal_bulk_loader_template} t ON cast(n.template_id as integer) = t.template_id
+    LEFT JOIN {tripal_jobs} j ON n.job_id = j.job_id"
+    . tablesort_sql($header),
+    $num_jobs_per_page);
+  while ($n = db_fetch_object($resource)) {
+    $rows[] = array(
+      l($n->job_id, 'admin/tripal/tripal_jobs/view/' . $n->job_id),
+      l($n->loader_name, 'node/' . $n->nid),
+      l($n->template_name, 'admin/tripal/tripal_bulk_loader_template/manage_templates/edit', array('query' => 'template_id=' . $n->template_id)),
+      $n->job_status,
+      ($n->progress) ? $n->progress . '%' : '',
+      l('View', 'node/' . $n->nid) . ' | ' .  l('Edit', 'node/' . $n->nid . '/edit')
+    );
+  }
+  $output .= theme_table($header, $rows);
+
+  $output .= theme('pager');
+
+  return $output;
+}
+
+/**
+ * @section
+ * Configuration Form
+ */
+
+/**
+ * A Configuration form for this module
+ */
+function tripal_bulk_loader_configuration_form($form_state = NULL) {
+  $form = array();
+
+  $form['space'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Enable/Disable Functionality'),
+  );
+
+  $form['space']['keep_track_inserted'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Keep track of inserted record IDs'),
+    '#description' => t('This enables the ability to revert an entire loading job even if '
+      .'it completed successfully. Furthermore, it displays the number of records '
+      .'successfully inserted into each table.'),
+    '#default_value' => variable_get('tripal_bulk_loader_keep_track_inserted', FALSE),
+  );
+
+  $form['speed'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Possible Speed Improvements'),
+  );
+
+  $form['speed']['prepare'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use Prepared Statements'),
+    '#description' => t('SQL Prepared Statements allow for SQL queries which will be run '
+      .'many times to be parsed, rewritten and planned only once rather then every time '
+      .'the query is run. In the case of the bulk loader, this ensures that planning only '
+      .'occurs once for each "record" in your bulk loading template.'),
+    '#default_value' => variable_get('tripal_bulk_loader_prepare', TRUE),
+  );
+
+  $form['speed']['disable_triggers'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Delay Constraint Checking during loading job.'),
+    '#description' => t('This delays the constraint checking until the end of the
+    loading proccess.'),
+    '#default_value' => variable_get('tripal_bulk_loader_disable_triggers', TRUE),
+  );
+
+  $form['speed']['no_validate'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Skip Validation at the Tripal Core API level'),
+    '#description' => t('If an error is encountered, the Tripal core API will try
+      to provide informative error messages. With this turned off, you will not benifit
+      from these more informative error messages; however, your job will load faster
+      since it doesn\'t have to do the additional checking before inserting.'),
+    '#default_value' => variable_get('tripal_bulk_loader_skip_validation', FALSE),
+  );
+
+  $form['speed']['transactions'] = array(
+    '#type' => 'radios',
+    '#title' => t('Transaction Rollback when an error is encountered'),
+    '#options' => array(
+      'all' => t('Rollback the last constant set.'
+        .'<div class="description"If you added more then one constant set then the
+        successfully loaded constant sets will not be rolled back. However, once an error
+        is encountered no further constant sets will be loaded either.</div>'),
+      'row' => t('Only Rollback the last line of the input file.'
+        .'<div class="description">This option may allow you to restart the job after
+        fixing the error (manual intervention needed).</div>'),
+      'none' => t('Do not use transactions<div class="description">This is not recommended.</div>')
+    ),
+    '#default_value' => variable_get('tripal_bulk_loader_transactions',   'row')
+  );
+
+  $form['speed']['lock'] = array(
+    '#type' => 'radios',
+    '#title' => t('Lock Type'),
+    '#description' => t('The type of lock used by the bulk loading jobs. The lock is '
+      .'acquired at the beginning of the job and kept till the end. A lock of the type '
+      .'selected will be acquired for every table being inserted into.'),
+    '#options' => array(
+      'ROW EXCLUSIVE' => t('ROW EXCLUSIVE: The default lock type for insert queries.'),
+      'EXCLUSIVE' => t('EXCLUSIVE: Only Select Queries can access the table.'),
+      'ACCESS EXCLUSIVE' => t('ACCESS EXCLUSIVE: No other queries can access the table.'),
+    ),
+    '#default_value' => variable_get('tripal_bulk_loader_lock', 'ROW EXCLUSIVE'),
+  );
+
+  $form['submit1'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save')
+  );
+
+  return $form;
+}
+
+/**
+ * A Configuration form for this module (Submit)
+ */
+function tripal_bulk_loader_configuration_form_submit($form, $form_state) {
+
+  variable_set('tripal_bulk_loader_prepare', $form_state['values']['prepare']);
+  variable_set('tripal_bulk_loader_disable_triggers', $form_state['values']['disable_triggers']);
+  variable_set('tripal_bulk_loader_skip_validation', $form_state['values']['no_validate']);
+  variable_set('tripal_bulk_loader_transactions', $form_state['values']['transactions']);
+  variable_set('tripal_bulk_loader_lock', $form_state['values']['lock']);
+
+  variable_set('tripal_bulk_loader_keep_track_inserted', $form_state['values']['keep_track_inserted']);
+
+}

+ 47 - 0
tripal_bulk_loader/tripal_bulk_loader.drush.inc

@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * Implements drush integration for this module
+ */
+
+/**
+ * Implements hook_drush_command().
+ */
+function tripal_bulk_loader_drush_command() {
+  $items = array();
+  $items['tripal-loader-progress'] = array(
+    'description' => dt('Display the progress of any running tripal bulk loading job.'),
+    'aliases' => array('trpload-%'),
+  );
+  return $items;
+}
+
+/**
+ * Code ran for the tripal-loader-progress drush command
+ * Display the progress of any running tripal bulk loading job.
+ */
+function drush_tripal_bulk_loader_tripal_loader_progress () {
+
+  // determine the progress of any loading jobs
+  $sql = "SELECT t.loader_name, t.file, t.job_id FROM tripal_bulk_loader t WHERE job_status='Loading...'";
+  $resource = db_query($sql);
+
+  while ($r = db_fetch_object($resource)) {
+    if ($r->job_id) {
+      $progress = tripal_bulk_loader_progess_file_get_progress($r->job_id);
+      if ($progress->num_records > 0 AND $progress->total_percent < 100) {
+        drush_print(
+          $r->loader_name . "\n"
+          . str_repeat("-", 40) . "\n"
+          . "File:" . $r->file . "\n"
+          . "Current Constant Set:\n"
+          . "\tLines processed: " . $progress->num_lines . "\n"
+          . "\tRecord Inserted: " .$progress->num_records . "\n"
+          . "\tPercent Complete: " . $progress->percent_file . "\n"
+          . "Number of Constant Sets fully loaded: " . $progress->num_constant_sets_loaded . "\n"
+          . "Job Percent Complete: " . $progress->total_percent . "\n"
+        );
+      }
+    }
+  }
+}

+ 1 - 1
tripal_bulk_loader/tripal_bulk_loader.info

@@ -3,5 +3,5 @@ description = A module for uploading tab-delimit data into GMOD chado database u
 core = 6.x
 project = tripal_bulk_loader
 package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
-version = 6.x-0.3.1b-1.5

+ 33 - 9
tripal_bulk_loader/tripal_bulk_loader.install

@@ -30,17 +30,17 @@ function tripal_bulk_loader_uninstall() {
 function tripal_bulk_loader_schema() {
   $schema = array();
   $schema['tripal_bulk_loader'] = array(
-      'fields' => array(
-         'nid' => array(
-            'type' => 'int',
-            'unsigned' => TRUE,
-            'not null' => TRUE,
+    'fields' => array(
+      'nid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
       ),
-         'loader_name' => array(
-            'type' => 'varchar',
+      'loader_name' => array(
+        'type' => 'varchar',
       ),
-         'template_id' => array(
-            'type' => 'varchar',
+      'template_id' => array(
+        'type' => 'varchar',
       ),
       'file' => array(
         'type' => 'varchar',
@@ -58,6 +58,12 @@ function tripal_bulk_loader_schema() {
         'not null' => TRUE,
         'default' => 0,
       ),
+      'keep_track_inserted' => array(
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'default' => 1
+      ),
     ),
       'primary key' => array('nid'),
       'unique keys' => array(
@@ -190,3 +196,21 @@ function tripal_bulk_loader_update_6151() {
 
   return $ret;
 }
+
+function tripal_bulk_loader_update_6152() {
+  $ret = array();
+
+  db_add_field(
+    $ret,
+    'tripal_bulk_loader',
+    'keep_track_inserted',
+    array(
+      'type' => 'int',
+      'size' => 'tiny',
+      'not null' => TRUE,
+      'default' => 1
+    )
+  );
+
+  return $ret;
+}

+ 119 - 52
tripal_bulk_loader/tripal_bulk_loader.loader.inc

@@ -14,8 +14,12 @@
 function tripal_bulk_loader_add_loader_job_form($form_state, $node) {
   $form = array();
 
-  if (($node->job_status == 'Loading...') AND (variable_get('tripal_bulk_loader_transactions',   'row') != 'none')) {
-    drupal_set_message("Job Progress and Loading Summary will only be updated at the end of each constant set.","warning");
+  // --notify--
+  if ($node->job_status == 'Loading...') {
+    $progress = tripal_bulk_loader_progess_file_get_progress($node->job_id);
+    drupal_set_message(t("The Loading Summary only updates at the end of each constant set.
+      %num records have already been inserted; however, they won't be available until the
+      current constant set is full loaded and no errors are encountered.", array('%num' => $progress->num_records)), 'warning');
   }
 
   $form['nid'] = array(
@@ -43,10 +47,12 @@ function tripal_bulk_loader_add_loader_job_form($form_state, $node) {
     '#value' => 'Cancel Job',
   );
 
-  $form['submit-revert'] = array(
-    '#type' => ($node->job_id) ? 'submit' : 'hidden',
-    '#value' => 'Revert',
-  );
+  if ($node->keep_track_inserted) {
+    $form['submit-revert'] = array(
+      '#type' => ($node->job_id) ? 'submit' : 'hidden',
+      '#value' => 'Revert',
+    );
+  }
 
   return $form;
 }
@@ -117,7 +123,7 @@ function tripal_bulk_loader_add_loader_job_form_submit($form, $form_state) {
  * Note: Instead of returning a value this function updates the tripal_bulk_loader.status.
  *   Errors are thrown through watchdog and can be viewed at admin/reports/dblog.
  */
-function tripal_bulk_loader_load_data($nid) {
+function tripal_bulk_loader_load_data($nid, $job_id) {
 
   // ensure no timeout
   set_time_limit(0);
@@ -327,7 +333,17 @@ function tripal_bulk_loader_load_data($nid) {
 
       $data_keys = array_keys($data);
       foreach ($data_keys as $priority) {
-        $status = process_data_array_for_line($priority, $data, $default_data, $field2column, $record2priority, $line, $nid, $num_lines, $group_index);
+        $options = array(
+          'field2column' => $field2column,
+          'record2priority' => $record2priority,
+          'line' => $line,
+          'line_num' => $num_lines,
+          'group_index' => $group_index,
+          'node' => $node,
+          'nid' => $node->nid,
+        );
+        $status = process_data_array_for_line($priority, $data, $default_data, $options);
+        tripal_bulk_loader_progress_file_track_job($job_id, $status);
         if (!$status ) {
           // Encountered an error
           if ($transactions) {
@@ -338,6 +354,8 @@ function tripal_bulk_loader_load_data($nid) {
         }
       } // end of foreach table in default data array
 
+      tripal_bulk_loader_progress_file_track_job($job_id, FALSE, TRUE);
+
       if ($failed) {
         break;
       }
@@ -369,16 +387,9 @@ function tripal_bulk_loader_load_data($nid) {
     }
 
     tripal_bulk_loader_progress_bar($total_lines,$total_lines);
+    tripal_bulk_loader_progress_file_track_job($job_id, FALSE, FALSE, TRUE);
   } //end of foreach constant set
 
-  // check that data was inserted and update job_status
-  $sql = 'SELECT count(*) as num_tables FROM {tripal_bulk_loader_inserted} WHERE nid=%d GROUP BY nid';
-  $result = db_fetch_object(db_query($sql, $nid));
-  if ($result->num_tables > 0) {
-    $node->job_status = 'Data Inserted';
-    drupal_write_record('node', $node, 'nid');
-  }
-
   // set the status of the job (in the node not the tripal jobs)
   if ($loaded_without_errors) {
     $status = 'Loading Completed Successfully';
@@ -393,10 +404,19 @@ function tripal_bulk_loader_load_data($nid) {
 /**
  *
  *
+         $options = array(
+          'field2column' => $field2column,
+          'record2priority' => $record2priority,
+          'line' => $line,
+          'line_num' => $num_lines,
+          'group_index' => $group_index,
+          'node' => $node,
+          'nid' => $node->nid,
+        );
  */
-function process_data_array_for_line($priority, &$data, &$default_data, $field2column, $record2priority, $line, $nid, $line_num, $group_index) {
+function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
   $table_data = $data[$priority];
-
+  $addt = (object) $addt;
   $no_errors = TRUE;
 
   $table = $table_data['table'];
@@ -406,23 +426,23 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
 
   //print 'default values:'.print_r($values,TRUE)."\n";
   if ($table_data['need_further_processing']) {
-    $values = tripal_bulk_loader_add_spreadsheetdata_to_values($values, $line, $field2column[$priority]);
+    $values = tripal_bulk_loader_add_spreadsheetdata_to_values($values, $addt->line, $addt->field2column[$priority]);
     if (!$values) {
-      //watchdog('T_bulk_loader', 'Line ' . $line_num . ' Data File Added:' . print_r($values, TRUE), array(), WATCHDOG_NOTICE);
+      //watchdog('T_bulk_loader', 'Line ' . $addt->line_num . ' Data File Added:' . print_r($values, TRUE), array(), WATCHDOG_NOTICE);
     }
 
-    $values = tripal_bulk_loader_add_foreignkey_to_values($values, $data, $record2priority);
+    $values = tripal_bulk_loader_add_foreignkey_to_values($values, $data, $addt->record2priority);
     if (!$values) {
-      //watchdog('T_bulk_loader', 'Line ' . $line_num . ' FK Added:<pre>' . print_r($values, TRUE) . print_r($data[$priority], TRUE) . '</pre>', array(), WATCHDOG_NOTICE);
+      //watchdog('T_bulk_loader', 'Line ' . $addt->line_num . ' FK Added:<pre>' . print_r($values, TRUE) . print_r($data[$priority], TRUE) . '</pre>', array(), WATCHDOG_NOTICE);
     }
   }
-  $values = tripal_bulk_loader_regex_tranform_values($values, $table_data, $line);
+  $values = tripal_bulk_loader_regex_tranform_values($values, $table_data, $addt->line);
   if (!$values) {
-    //watchdog('T_bulk_loader', 'Line ' . $line_num . ' Regex:<pre>' . print_r($values, TRUE) . print_r($table_data, TRUE) . '</pre>' . '</pre>', array(), WATCHDOG_NOTICE);
+    //watchdog('T_bulk_loader', 'Line ' . $addt->line_num . ' Regex:<pre>' . print_r($values, TRUE) . print_r($table_data, TRUE) . '</pre>' . '</pre>', array(), WATCHDOG_NOTICE);
   }
 
   if (!$values) {
-    $msg = 'Line ' . $line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Aborted due to error in previous record. Values of current record:' . print_r($table_data['values_array'], TRUE);
+    $msg = 'Line ' . $addt->line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Aborted due to error in previous record. Values of current record:' . print_r($table_data['values_array'], TRUE);
     watchdog('T_bulk_loader', $msg, array(), WATCHDOG_WARNING);
     print "ERROR: " . $msg . "\n";
     $data[$priority]['error'] = TRUE;
@@ -437,7 +457,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
       // a field is considered missing if it cannot be null and there is no default
       // value for it or it is of type 'serial'
       if ($def['not null'] == 1 and !array_key_exists($field, $insert_values) and !isset($def['default']) and strcmp($def['type'], serial)!=0) {
-        $msg = 'Line ' . $line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Missing Database Required Value: ' . $table . '.' . $field;
+        $msg = 'Line ' . $addt->line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Missing Database Required Value: ' . $table . '.' . $field;
         watchdog('T_bulk_loader', $msg, array(), WATCHDOG_NOTICE);
         $data[$priority]['error'] = TRUE;
       }
@@ -448,7 +468,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
   foreach ($table_data['required'] as $field => $required) {
     if ($required) {
       if (!isset($values[$field])) {
-        $msg = 'Line ' . $line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Missing Template Required Value: ' . $table . '.' . $field;
+        $msg = 'Line ' . $addt->line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Missing Template Required Value: ' . $table . '.' . $field;
         watchdog('T_bulk_loader', $msg, array(), WATCHDOG_NOTICE);
         $data[$priority]['error'] = TRUE;
       }
@@ -493,7 +513,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
     // Use prepared statement?
     if (variable_get('tripal_bulk_loader_prepare', TRUE)) {
       $options = array('statement_name' => 'record_' . $priority);
-      if ($line_num == 1 && $group_index == 1) {
+      if ($addt->line_num == 1 && $addt->group_index == 1) {
         $options['prepare'] = TRUE;
       }
     }
@@ -509,7 +529,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
     $record = tripal_core_chado_insert($table, $values, $options);
 
     if (!$record) {
-      $msg = 'Line ' . $line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Unable to insert record into ' . $table . ' where values:' . print_r($values, TRUE);
+      $msg = 'Line ' . $addt->line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Unable to insert record into ' . $table . ' where values:' . print_r($values, TRUE);
       watchdog('T_bulk_loader', $msg, array(), WATCHDOG_ERROR);
       print "ERROR: " . $msg . "\n";
       $data[$priority]['error'] = TRUE;
@@ -526,28 +546,30 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
       }
 
       // add to tripal_bulk_loader_inserted
-      $insert_record = db_fetch_object(db_query(
-        "SELECT * FROM {tripal_bulk_loader_inserted} WHERE table_inserted_into='%s' AND nid=%d",
-        $table,
-        $nid
-      ));
-      if ($insert_record) {
-        $insert_record->ids_inserted .= ',' . $values[ $table_desc['primary key'][0] ];
-        drupal_write_record('tripal_bulk_loader_inserted', $insert_record, 'tripal_bulk_loader_inserted_id');
-        //print 'Update: '.print_r($insert_record,TRUE)."\n";
-        return $no_errors;
-      }
-      else {
-        $insert_record = array(
-          'nid' => $nid,
-          'table_inserted_into' => $table,
-          'table_primary_key' => $table_desc['primary key'][0],
-          'ids_inserted' => $values[ $table_desc['primary key'][0] ],
-        );
-        //print 'New: '.print_r($insert_record,TRUE)."\n";
-        $success = drupal_write_record('tripal_bulk_loader_inserted', $insert_record);
-        return $no_errors;
-      }//end of if insert record
+      if ($addt->node->keep_track_inserted) {
+        $insert_record = db_fetch_object(db_query(
+          "SELECT * FROM {tripal_bulk_loader_inserted} WHERE table_inserted_into='%s' AND nid=%d",
+          $table,
+          $addt->nid
+        ));
+        if ($insert_record) {
+          $insert_record->ids_inserted .= ',' . $values[ $table_desc['primary key'][0] ];
+          drupal_write_record('tripal_bulk_loader_inserted', $insert_record, 'tripal_bulk_loader_inserted_id');
+          //print 'Update: '.print_r($insert_record,TRUE)."\n";
+          return $no_errors;
+        }
+        else {
+          $insert_record = array(
+            'nid' => $addt->nid,
+            'table_inserted_into' => $table,
+            'table_primary_key' => $table_desc['primary key'][0],
+            'ids_inserted' => $values[ $table_desc['primary key'][0] ],
+          );
+          //print 'New: '.print_r($insert_record,TRUE)."\n";
+          $success = drupal_write_record('tripal_bulk_loader_inserted', $insert_record);
+          return $no_errors;
+        }//end of if insert record
+      }// end of if keeping track of records inserted
 
     } //end of if insert was successful
   }
@@ -555,7 +577,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $field2c
     $exists = tripal_core_chado_select($table, array_keys($table_desc['fields']), $values, array('has_record' => TRUE));
     if (!$exists) {
       // No record on select
-      $msg = 'Line ' . $line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') No Matching record in ' . $table . ' where values:' . print_r($values, TRUE);
+      $msg = 'Line ' . $addt->line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') No Matching record in ' . $table . ' where values:' . print_r($values, TRUE);
       watchdog('T_bulk_loader', $msg, array(), WATCHDOG_WARNING);
       $data[$priority]['error'] = TRUE;
       $no_errors = FALSE;
@@ -756,3 +778,48 @@ function tripal_bulk_loader_progress_bar($current=0, $total=100, $size=50) {
   }
 
 }
+
+/**
+ * Keep track of progress in file rather then database
+ *
+ * This provides an alternative method to keep track of progress that doesn't require the
+ * database. It was needed because you can't switch databases within a transaction...
+ * Waiting until the end of a constant set is much too long to wait for any indication
+ * that things are working.
+ *
+ * Each line represents a line processed in the loading file. Each period (.) represents
+ * a successfully inserted record.
+ *
+ * @param $job_id
+ *   The ID of the current tripal job
+ * @param $record_added
+ *   A boolean indicated whether a record was added successfully
+ * @param $line_complete
+ *   A boolean indicating whether the current line is finished
+ * @param $close
+ *   A boolean indicating that the file should be closed
+ */
+function tripal_bulk_loader_progress_file_track_job($job_id, $record_added, $line_complete = FALSE, $close = FALSE) {
+  // retrieve the file handle
+  $file_handle = variable_get('tripal_bulk_loader_progress_file_handle',NULL);
+
+  // open file for reading if not already
+  if (!$file_handle) {
+    $file_handle = fopen('/tmp/tripal_bulk_loader_progress-'.$job_id.'.out', 'w');
+    variable_set('tripal_bulk_loader_progress_file_handle', $file_handle);
+  }
+
+  if ($record_added) {
+    fwrite($file_handle,'.');
+  }
+
+  if ($line_complete) {
+    fwrite($file_handle,"\n");
+  }
+
+  // close the file if finished
+  if ($close) {
+    fclose($file_handle);
+    variable_set('tripal_bulk_loader_progress_file_handle', NULL);
+  }
+}

+ 95 - 5
tripal_bulk_loader/tripal_bulk_loader.module

@@ -314,6 +314,17 @@ function tripal_bulk_loader_form($node, $form_state) {
     '#default_value' => $node->file_has_header,
   );
 
+  $form['loader']['keep_track_inserted'] = array(
+    '#type' => 'radios',
+    '#title' => t('Keep track of inserted record IDs'),
+    '#description' => t('This enables the ability to revert an entire loading job even if '
+      .'it completed successfully. Furthermore, it displays the number of records '
+      .'successfully inserted into each table.'),
+    '#options' => array( 1 => 'Yes', 0 => 'No'),
+    '#weight' => -7,
+    '#default_value' => (isset($node->keep_track_inserted)) ? $node->keep_track_inserted : variable_get('tripal_bulk_loader_keep_track_inserted', FALSE),
+  );
+
   return $form;
 }
 
@@ -327,6 +338,11 @@ function tripal_bulk_loader_load($node) {
 
   $node->title = 'Bulk Loading Job: ' . $node->loader_name;
 
+  // Add job details
+  $progress = tripal_bulk_loader_progess_file_get_progress($node->job_id);
+  $sql = "SELECT * FROM {tripal_jobs} WHERE job_id=%d";
+  $node->job = db_fetch_object(db_query($sql, $node->job_id));
+
   // Add the loader template
   $sql = "SELECT * FROM {tripal_bulk_loader_template} WHERE template_id=%d";
   $results = db_fetch_object(db_query($sql, $node->template_id));
@@ -391,8 +407,8 @@ function tripal_bulk_loader_load($node) {
 function tripal_bulk_loader_insert($node) {
 
   // Insert into tripal_bulk_loader
-  $sql = "INSERT INTO {tripal_bulk_loader} (nid, loader_name, template_id, file, file_has_header, job_status) VALUES (%d, '%s', %d, '%s', %d, '%s')";
-  db_query($sql, $node->nid, $node->loader_name, $node->template_id, $node->file, $node->has_header, 'Initialized');
+  $sql = "INSERT INTO {tripal_bulk_loader} (nid, loader_name, template_id, file, file_has_header, job_status, keep_track_inserted) VALUES (%d, '%s', %d, '%s', %d, '%s', %d)";
+  db_query($sql, $node->nid, $node->loader_name, $node->template_id, $node->file, $node->has_header, 'Initialized', $node->keep_track_inserted);
 
   // Update title
   $node->title =$node->loader_name;
@@ -419,8 +435,8 @@ function tripal_bulk_loader_delete($node) {
 function tripal_bulk_loader_update($node) {
 
   // Update tripal_bulk_loader
-  $sql = "UPDATE {tripal_bulk_loader} SET nid = %d, loader_name = '%s', template_id = %d, file = '%s', file_has_header = '%s' WHERE nid = %d";
-  db_query($sql, $node->nid, $node->loader_name, $node->template_id, $node->file, $node->has_header, $node->nid);
+  $sql = "UPDATE {tripal_bulk_loader} SET nid = %d, loader_name = '%s', template_id = %d, file = '%s', file_has_header = '%s', keep_track_inserted = %d WHERE nid = %d";
+  db_query($sql, $node->nid, $node->loader_name, $node->template_id, $node->file, $node->has_header, $node->keep_track_inserted, $node->nid);
 
   // Add a job if the user want to load the data
   global $user;
@@ -453,6 +469,80 @@ function tripal_bulk_loader_preprocess_tripal_bulk_loader_template(&$variables)
 
 }
 
+/**
+ * Get the progress of the current constant set from the progress file
+ *
+ * When transactions are used, database updates to drupal cannot be made. Thus a separate
+ * method to keep track of progress was implemented: save a period to the file for each
+ * record successfully inserted; each line in the file represents a processed line.
+ *
+ * @param $job_id
+ *   The id of the tripal job to check the progress of
+ * @param $node
+ *   The tripal_bulk_loader node associated with the job
+ *
+ * @return
+ *   An array with the following keys:
+ *     num_lines = the number of lines in the file processed so far
+ *     total_lines = the total number of lines in the input file
+ *     percent_file = the percent the input file has been loaded
+ *     num_records = the number of records successfully inserted
+ */
+function tripal_bulk_loader_progess_file_get_progress($job_id, $update_progress = TRUE) {
+  $filename = '/tmp/tripal_bulk_loader_progress-' . $job_id . '.out';
+  if (!file_exists($filename)) {
+    return (object) array();
+  }
+
+  $num_lines = trim(`wc --lines < $filename`);
+  $num_records = trim(`grep -c "." $filename`);
+
+  $job = db_fetch_object(db_query("SELECT j.*, b.file, b.file_has_header, c.num as num_constant_sets
+                              FROM {tripal_jobs} j
+                              LEFT JOIN {tripal_bulk_loader} b ON b.job_id=j.job_id
+                              LEFT JOIN (
+                                  SELECT nid, count(distinct(group_id)) as num
+                                  FROM {tripal_bulk_loader_constants}
+                                  GROUP BY nid
+                                ) c ON c.nid=b.nid
+                              WHERE j.job_id=%d", $job_id));
+  if ($job->num_constant_sets) {
+    $num_constant_sets_loaded = round($job->progress / (100 / $job->num_constant_sets), 4);
+
+    // If the next constant set has started loading
+    if ($job->num_constant_sets != $num_constant_sets_loaded) {
+
+      // total lines in input file
+      $total_lines = trim(`wc --lines < $job->file`);
+      if ($job->file_has_header) {
+        $total_lines--;
+      }
+
+      // percent of the current constant set loaded
+      $percent = round($num_lines/$total_lines * 100, 2);
+
+      // percent of the total job = (<# fully loaded constant sets> * 100 )
+      //                           + <percent of current constant set>
+      //                           / <total number of constant sets>
+      $total_percent = (($num_constant_sets_loaded * 100) + $percent) / $job->num_constant_sets;
+
+      // update the progress of the job
+      if ($update_progress AND ($percent != 0 OR $percent != 100)) {
+        tripal_job_set_progress($job_id, round($total_percent, 0));
+      }
+    }
+  }
+
+  return (object) array(
+    'num_lines' => $num_lines,
+    'total_lines' => $total_lines,
+    'percent_file' => $percent,
+    'num_constant_sets_loaded' => $num_constant_sets_loaded,
+    'total_percent' => $total_percent,
+    'num_records' => $num_records
+  );
+}
+
 /**
  * Implements hook_job_describe_args()
  * Specifically to make viewing past tripal jobs more readable for jobs registered by this module
@@ -486,4 +576,4 @@ function tripal_bulk_loader_coder_ignore() {
     'path' => drupal_get_path('module', 'tripal_bulk_loader'),
     'line prefix' => drupal_get_path('module', 'tripal_bulk_loader'),
   );
-}
+}

+ 3 - 4
tripal_contact/tripal_contact.info

@@ -1,9 +1,8 @@
-; $Id$
-package = Tripal
 name = Tripal Contact
-version = 6.x-0.3.1b
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing of Contacts
 core = 6.x
-
+project = tripal_contact
+package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_cv

+ 55 - 21
tripal_core/chado_install.php

@@ -10,23 +10,37 @@
  *
  * @ingroup tripal_core
  */
-function tripal_core_chado_v1_11_load_form() {
+function tripal_core_chado_load_form() {
 
   $form['description'] = array(
     '#type' => 'item',
-    '#value' => t("Click the submit button below to install Chado into the Drupal "
-      ."database. <br /><font color=\"red\">WARNING:</font> use this only for a new "
-      ."chado installation or reinstall completely.  This will erase any data currently "
-      ."in the chado database.  If you are using chado in a database external to the "
+    '#value' => t("<font color=\"red\">WARNING:</font> A new install of Chado v1.2 or v1.11 "
+      ."will install Chado within the Drupal database in a \"chado\" schema. If the \"chado\" schema already exists it will "
+      ."be overwritten and all data will be lost.  You may choose to update an existing Chado v1.11 if it was installed with a previous "
+      ."version of Tripal (e.g. v0.3b or v0.3.1). The update will not erase any data. "
+      ."If you are using chado in a database external to the "
       ."Drupal database with a 'chado' entry in the 'settings.php' \$db_url argument "
-      ."then this option will intall chado but it will not be usable.  The external "
+      ."then Chado will be installed but will not be used .  The external "
       ."database specified in the settings.php file takes precedence."),
     '#weight' => 1,
   );
 
+  $form['action_to_do'] = array(
+     '#type' => 'radios',
+     '#title' => 'Installation/Upgrade Action',
+     '#options' => array(
+        'Install Chado v1.2' => t('New Install of Chado v1.2 (erases all existing Chado data if Chado already exists)'),
+        'Upgrade Chado v1.11 to v1.2' => t('Upgrade existing Chado v1.11 to v1.2 (no data is lost)'),
+        'Install Chado v1.11' => t('New Install of Chado v1.11 (erases all existing Chado data if Chado already exists)')
+     ),
+     '#description' => t('Select an action to perform'),
+     '#required' => TRUE
+     
+  );
+
   $form['button'] = array(
     '#type' => 'submit',
-    '#value' => t('Install Chado'),
+    '#value' => t('Install/Upgrade Chado'),
     '#weight' => 2,
   );
 
@@ -38,13 +52,13 @@ function tripal_core_chado_v1_11_load_form() {
  *
  * @ingroup tripal_core
  */
-function tripal_core_chado_v1_11_load_form_submit($form, &$form_state) {
+function tripal_core_chado_load_form_submit($form, &$form_state) {
   global $user;
+  $action_to_do   = trim($form_state['values']['action_to_do']);
 
-  $args = array();
-  tripal_add_job("Install Chado", 'tripal_core',
+  $args = array($action_to_do);
+  tripal_add_job($action_to_do, 'tripal_core',
     'tripal_core_install_chado', $args, $user->uid);
-
 }
 
 /**
@@ -52,18 +66,38 @@ function tripal_core_chado_v1_11_load_form_submit($form, &$form_state) {
  *
  * @ingroup tripal_core
  */
-function tripal_core_install_chado() {
-  $schema_file = drupal_get_path('module', 'tripal_core') . '/default_schema.sql';
-  $init_file = drupal_get_path('module', 'tripal_core') . '/initialize.sql';
+function tripal_core_install_chado($action) {
 
-  if (tripal_core_reset_chado_schema()) {
-    tripal_core_install_sql($schema_file);
-    tripal_core_install_sql($init_file);
+  if($action == 'Install Chado v1.2'){
+    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.2.sql';
+    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/initialize-1.2.sql';
+    if (tripal_core_reset_chado_schema()) {
+      tripal_core_install_sql($schema_file);
+      tripal_core_install_sql($init_file);
+    }
+    else {
+      print "ERROR: cannot install chado.  Please check database permissions\n";
+      exit;
+    }
   }
-  else {
-    print "ERROR: cannot install chado.  Please check database permissions\n";
-    exit;
+  elseif($action == 'Upgrade Chado v1.11 to v1.2') {
+    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.11-1.2-diff.sql';
+    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/initialize-1.11-1.2.sql';
+#    tripal_core_install_sql($schema_file);
+    tripal_core_install_sql($init_file);
   }
+  elseif($action == 'Install Chado v1.11'){
+    $schema_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/default_schema-1.11.sql';
+    $init_file = drupal_get_path('module', 'tripal_core') . '/chado_schema/initialize-1.11.sql';
+    if (tripal_core_reset_chado_schema()) {
+      tripal_core_install_sql($schema_file);
+      tripal_core_install_sql($init_file);
+    }
+    else {
+      print "ERROR: cannot install chado.  Please check database permissions\n";
+      exit;
+    }
+  }  
 }
 
 /**
@@ -303,4 +337,4 @@ function tripal_core_chado_install_done() {
   global $active_db;
   pg_query($active_db, "set search_path to public,chado");
 
-}
+}

+ 570 - 0
tripal_core/chado_schema/default_schema-1.11-1.2-diff.sql

@@ -0,0 +1,570 @@
+ create table cvprop (
+     cvprop_id serial not null,
+     primary key (cvprop_id),
+     cv_id int not null,
+     foreign key (cv_id) references cv (cv_id) INITIALLY DEFERRED,
+     type_id int not null,
+     foreign key (type_id) references cvterm (cvterm_id) INITIALLY DEFERRED,
+     value text,
+     rank int not null default 0,
+     constraint cvprop_c1 unique (cv_id,type_id,rank)
+ );
+ 
+ COMMENT ON TABLE cvprop IS 'Additional extensible properties can be attached to a cv using this table.  A notable example would be the cv version';
+ 
+ COMMENT ON COLUMN cvprop.type_id IS 'The name of the property or slot is a cvterm. The meaning of the property is defined in that cvterm.';
+ COMMENT ON COLUMN cvprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation.';
+ 
+ COMMENT ON COLUMN cvprop.rank IS 'Property-Value ordering. Any
+ cv can have multiple values for any particular property type -
+ these are ordered in a list using rank, counting from zero. For
+ properties that are single-valued rather than multi-valued, the
+ default 0 value should be used.';
+ 
+ create table chadoprop (
+     chadoprop_id serial not null,
+     primary key (chadoprop_id),
+     type_id int not null,
+     foreign key (type_id) references cvterm (cvterm_id) INITIALLY DEFERRED,
+     value text,
+     rank int not null default 0,
+     constraint chadoprop_c1 unique (type_id,rank)
+ );
+ 
+ COMMENT ON TABLE chadoprop IS 'This table is different from other prop tables in the database, as it is for storing information about the database itself, like schema version';
+ 
+ COMMENT ON COLUMN chadoprop.type_id IS 'The name of the property or slot is a cvterm. The meaning of the property is defined in that cvterm.';
+ COMMENT ON COLUMN chadoprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation.';
+ 
+ COMMENT ON COLUMN chadoprop.rank IS 'Property-Value ordering. Any
+ cv can have multiple values for any particular property type -
+ these are ordered in a list using rank, counting from zero. For
+ properties that are single-valued rather than multi-valued, the
+ default 0 value should be used.';
+
+ALTER TABLE genetic_code.gencode_startcodon ADD  CONSTRAINT gencode_startcodon_unique UNIQUE( gencode_id, codon );
+
+ALTER TABLE phenotype ADD COLUMN name TEXT default null;
+
+ALTER TABLE genotype ADD COLUMN type_id INT NOT NULL;
+ALTER TABLE genotype ADD CONSTRAINT genotype_type_id_fkey FOREIGN KEY (type_id) REFERENCES cvterm (cvterm_id) ON DELETE CASCADE;
+
+
+ create table genotypeprop (
+     genotypeprop_id serial not null,
+     primary key (genotypeprop_id),
+     genotype_id int not null,
+     foreign key (genotype_id) references genotype (genotype_id) on delete cascade INITIALLY DEFERRED,
+     type_id int not null,
+     foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
+     value text null,
+     rank int not null default 0,
+     constraint genotypeprop_c1 unique (genotype_id,type_id,rank)
+ );
+ create index genotypeprop_idx1 on genotypeprop (genotype_id);
+ create index genotypeprop_idx2 on genotypeprop (type_id);
+ 
+ CREATE TABLE projectprop (
+ 	projectprop_id serial NOT NULL,
+ 	PRIMARY KEY (projectprop_id),
+ 	project_id integer NOT NULL,
+ 	FOREIGN KEY (project_id) REFERENCES project (project_id) ON DELETE CASCADE,
+ 	type_id integer NOT NULL,
+ 	FOREIGN KEY (type_id) REFERENCES cvterm (cvterm_id) ON DELETE CASCADE,
+ 	value text,
+ 	rank integer not null default 0,
+ 	CONSTRAINT projectprop_c1 UNIQUE (project_id, type_id, rank)
+ );
+ 
+ -- ================================================
+ -- TABLE: project_relationship
+ -- ================================================
+ 
+ CREATE TABLE project_relationship (
+ 	project_relationship_id serial NOT NULL,
+ 	PRIMARY KEY (project_relationship_id),
+ 	subject_project_id integer NOT NULL,
+ 	FOREIGN KEY (subject_project_id) REFERENCES project (project_id) ON DELETE CASCADE,
+ 	object_project_id integer NOT NULL,
+ 	FOREIGN KEY (object_project_id) REFERENCES project (project_id) ON DELETE CASCADE,
+ 	type_id integer NOT NULL,
+ 	FOREIGN KEY (type_id) REFERENCES cvterm (cvterm_id) ON DELETE RESTRICT,
+ 	CONSTRAINT project_relationship_c1 UNIQUE (subject_project_id, object_project_id, type_id)
+ );
+ COMMENT ON TABLE project_relationship IS 'A project can be composed of several smaller scale projects';
+ COMMENT ON COLUMN project_relationship.type_id IS 'The type of relationship being stated, such as "is part of".';
+ 
+ 
+ create table project_pub (
+        project_pub_id serial not null,
+        primary key (project_pub_id),
+        project_id int not null,
+        foreign key (project_id) references project (project_id) on delete cascade INITIALLY DEFERRED,
+        pub_id int not null,
+        foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED,
+        constraint project_pub_c1 unique (project_id,pub_id)
+ );
+ create index project_pub_idx1 on project_pub (project_id);
+ create index project_pub_idx2 on project_pub (pub_id);
+ 
+ COMMENT ON TABLE project_pub IS 'Linking project(s) to publication(s)';
+ 
+ 
+ create table project_contact (
+        project_contact_id serial not null,
+        primary key (project_contact_id),
+        project_id int not null,
+        foreign key (project_id) references project (project_id) on delete cascade INITIALLY DEFERRED,
+        contact_id int not null,
+        foreign key (contact_id) references contact (contact_id) on delete cascade INITIALLY DEFERRED,
+        constraint project_contact_c1 unique (project_id,contact_id)
+ );
+ create index project_contact_idx1 on project_contact (project_id);
+ create index project_contact_idx2 on project_contact (contact_id);
+ 
+ COMMENT ON TABLE project_contact IS 'Linking project(s) to contact(s)';
+
+ALTER TABLE stock alter organism_id drop not null;
+
+ COMMENT ON COLUMN stock.organism_id IS 'The organism_id is the organism to which the stock belongs. This column is mandatory.';
+ 
+ CREATE TABLE stock_relationship_cvterm (
+ 	stock_relationship_cvterm_id SERIAL NOT NULL,
+ 	PRIMARY KEY (stock_relationship_cvterm_id),
+ 	stock_relationship_id integer NOT NULL,
+ 	FOREIGN KEY (stock_relationship_id) references stock_relationship (stock_relationship_id) ON DELETE CASCADE INITIALLY DEFERRED,
+ 	cvterm_id integer NOT NULL,
+ 	FOREIGN KEY (cvterm_id) REFERENCES cvterm (cvterm_id) ON DELETE RESTRICT,
+ 	pub_id integer,
+ 	FOREIGN KEY (pub_id) REFERENCES pub (pub_id) ON DELETE RESTRICT
+ );
+COMMENT ON TABLE stock_relationship_cvterm is 'For germplasm maintenance and pedigree data, stock_relationship. type_id will record cvterms such as "is a female parent of", "a parent for mutation", "is a group_id of", "is a source_id of", etc The cvterms for higher categories such as "generative", "derivative" or "maintenance" can be stored in table stock_relationship_cvterm';
+
+
+alter table stock_cvterm add column is_not boolean not null default false;
+alter table stock_cvterm add column rank integer not null default 0;
+alter table stock_cvterm drop constraint stock_cvterm_c1;
+alter table stock_cvterm add constraint stock_cvterm_c1 unique (stock_id,cvterm_id,pub_id,rank)
+;
+
+
+ create table stock_cvtermprop (
+     stock_cvtermprop_id serial not null,
+     primary key (stock_cvtermprop_id),
+     stock_cvterm_id int not null,
+     foreign key (stock_cvterm_id) references stock_cvterm (stock_cvterm_id) on delete cascade,
+     type_id int not null,
+     foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
+     value text null,
+     rank int not null default 0,
+     constraint stock_cvtermprop_c1 unique (stock_cvterm_id,type_id,rank)
+ );
+ create index stock_cvtermprop_idx1 on stock_cvtermprop (stock_cvterm_id);
+ create index stock_cvtermprop_idx2 on stock_cvtermprop (type_id);
+ 
+ COMMENT ON TABLE stock_cvtermprop IS 'Extensible properties for
+ stock to cvterm associations. Examples: GO evidence codes;
+ qualifiers; metadata such as the date on which the entry was curated
+ and the source of the association. See the stockprop table for
+ meanings of type_id, value and rank.';
+ 
+ COMMENT ON COLUMN stock_cvtermprop.type_id IS 'The name of the
+ property/slot is a cvterm. The meaning of the property is defined in
+ that cvterm. cvterms may come from the OBO evidence code cv.';
+ 
+ COMMENT ON COLUMN stock_cvtermprop.value IS 'The value of the
+ property, represented as text. Numeric values are converted to their
+ text representation. This is less efficient than using native database
+ types, but is easier to query.';
+ 
+ COMMENT ON COLUMN stock_cvtermprop.rank IS 'Property-Value
+ ordering. Any stock_cvterm can have multiple values for any particular
+ property type - these are ordered in a list using rank, counting from
+ zero. For properties that are single-valued rather than multi-valued,
+ the default 0 value should be used.';
+ 
+ create table stock_dbxrefprop (
+        stock_dbxrefprop_id serial not null,
+        primary key (stock_dbxrefprop_id),
+        stock_dbxref_id int not null,
+        foreign key (stock_dbxref_id) references stock_dbxref (stock_dbxref_id) on delete cascade INITIALLY DEFERRED,
+        type_id int not null,
+        foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
+        value text null,
+        rank int not null default 0,
+        constraint stock_dbxrefprop_c1 unique (stock_dbxref_id,type_id,rank)
+ );
+ create index stock_dbxrefprop_idx1 on stock_dbxrefprop (stock_dbxref_id);
+ create index stock_dbxrefprop_idx2 on stock_dbxrefprop (type_id);
+ 
+ COMMENT ON TABLE stock_dbxrefprop IS 'A stock_dbxref can have any number of
+ slot-value property tags attached to it. This is useful for storing properties related to dbxref annotations of stocks, such as evidence codes, and references, and metadata, such as create/modify dates. This is an alternative to
+ hardcoding a list of columns in the relational schema, and is
+ completely extensible. There is a unique constraint, stock_dbxrefprop_c1, for
+ the combination of stock_dbxref_id, rank, and type_id. Multivalued property-value pairs must be differentiated by rank.';
+
+-- VIEW gffatts: a view to get feature attributes in a format that
+-- will make it easy to convert them to GFF attributes
+
+CREATE OR REPLACE VIEW gffatts (
+    feature_id,
+    type,
+    attribute
+) AS
+SELECT feature_id, 'Ontology_term' AS type,  s.name AS attribute
+FROM cvterm s, feature_cvterm fs
+WHERE fs.cvterm_id = s.cvterm_id
+UNION ALL
+SELECT feature_id, 'Dbxref' AS type, d.name || ':' || s.accession AS attribute
+FROM dbxref s, feature_dbxref fs, db d
+WHERE fs.dbxref_id = s.dbxref_id and s.db_id = d.db_id
+UNION ALL
+SELECT feature_id, 'Alias' AS type, s.name AS attribute
+FROM synonym s, feature_synonym fs
+WHERE fs.synonym_id = s.synonym_id
+UNION ALL
+SELECT fp.feature_id,cv.name,fp.value
+FROM featureprop fp, cvterm cv
+WHERE fp.type_id = cv.cvterm_id
+UNION ALL
+SELECT feature_id, 'pub' AS type, s.series_name || ':' || s.title AS attribute
+FROM pub s, feature_pub fs
+WHERE fs.pub_id = s.pub_id;
+
+CREATE OR REPLACE VIEW gff3atts (
+    feature_id,
+    type,
+    attribute
+) AS
+SELECT feature_id,
+      'Ontology_term' AS type,
+      CASE WHEN db.name like '%Gene Ontology%'    THEN 'GO:'|| dbx.accession
+           WHEN db.name like 'Sequence Ontology%' THEN 'SO:'|| dbx.accession
+           ELSE                            CAST(db.name||':'|| dbx.accession AS varchar)
+      END
+FROM cvterm s, dbxref dbx, feature_cvterm fs, db
+WHERE fs.cvterm_id = s.cvterm_id and s.dbxref_id=dbx.dbxref_id and
+      db.db_id = dbx.db_id
+UNION ALL
+SELECT feature_id, 'Dbxref' AS type, d.name || ':' || s.accession AS
+attribute
+FROM dbxref s, feature_dbxref fs, db d
+WHERE fs.dbxref_id = s.dbxref_id and s.db_id = d.db_id and
+      d.name != 'GFF_source'
+UNION ALL
+SELECT f.feature_id, 'Alias' AS type, s.name AS attribute
+FROM synonym s, feature_synonym fs, feature f
+WHERE fs.synonym_id = s.synonym_id and f.feature_id = fs.feature_id and
+      f.name != s.name and f.uniquename != s.name
+UNION ALL
+SELECT fp.feature_id,cv.name,fp.value
+FROM featureprop fp, cvterm cv
+WHERE fp.type_id = cv.cvterm_id
+UNION ALL
+SELECT feature_id, 'pub' AS type, s.series_name || ':' || s.title AS
+attribute
+FROM pub s, feature_pub fs
+WHERE fs.pub_id = s.pub_id
+UNION ALL
+SELECT fr.subject_id as feature_id, 'Parent' as type,  parent.uniquename
+as attribute
+FROM feature_relationship fr, feature parent
+WHERE  fr.object_id=parent.feature_id AND fr.type_id = (SELECT cvterm_id
+FROM cvterm WHERE name='part_of' and cv_id in (select cv_id
+  FROM cv WHERE name='relationship'))
+UNION ALL
+SELECT fr.subject_id as feature_id, 'Derives_from' as type,
+parent.uniquename as attribute
+FROM feature_relationship fr, feature parent
+WHERE  fr.object_id=parent.feature_id AND fr.type_id = (SELECT cvterm_id
+FROM cvterm WHERE name='derives_from' and cv_id in (select cv_id
+  FROM cv WHERE name='relationship'))
+UNION ALL
+SELECT fl.feature_id, 'Target' as type, target.name || ' ' || fl.fmin+1
+|| ' ' || fl.fmax || ' ' || fl.strand as attribute
+FROM featureloc fl, feature target
+WHERE fl.srcfeature_id=target.feature_id
+        AND fl.rank != 0
+UNION ALL
+SELECT feature_id, 'ID' as type, uniquename as attribute
+FROM feature
+WHERE type_id NOT IN (SELECT cvterm_id FROM cvterm WHERE name='CDS')
+UNION ALL
+SELECT feature_id, 'chado_feature_id' as type, CAST(feature_id AS
+varchar) as attribute
+FROM feature
+UNION ALL
+SELECT feature_id, 'Name' as type, name as attribute
+FROM feature;
+
+
+-- =================================================================
+-- Dependencies:
+--
+-- :import feature from sequence
+-- :import cvterm from cv
+-- :import pub from pub
+-- :import phenotype from phenotype
+-- :import organism from organism
+-- :import genotype from genetic
+-- :import contact from contact
+-- :import project from project
+-- :import stock from stock
+-- :import synonym
+-- =================================================================
+
+
+-- this probably needs some work, depending on how cross-database we
+-- want to be.  In Postgres, at least, there are much better ways to 
+-- represent geo information.
+
+CREATE TABLE nd_geolocation (
+    nd_geolocation_id serial PRIMARY KEY NOT NULL,
+    description character varying(255),
+    latitude real,
+    longitude real,
+    geodetic_datum character varying(32),
+    altitude real
+);
+
+COMMENT ON TABLE nd_geolocation IS 'The geo-referencable location of the stock. NOTE: This entity is subject to change as a more general and possibly more OpenGIS-compliant geolocation module may be introduced into Chado.';
+
+COMMENT ON COLUMN nd_geolocation.description IS 'A textual representation of the location, if this is the original georeference. Optional if the original georeference is available in lat/long coordinates.';
+
+
+COMMENT ON COLUMN nd_geolocation.latitude IS 'The decimal latitude coordinate of the georeference, using positive and negative sign to indicate N and S, respectively.';
+
+COMMENT ON COLUMN nd_geolocation.longitude IS 'The decimal longitude coordinate of the georeference, using positive and negative sign to indicate E and W, respectively.';
+
+COMMENT ON COLUMN nd_geolocation.geodetic_datum IS 'The geodetic system on which the geo-reference coordinates are based. For geo-references measured between 1984 and 2010, this will typically be WGS84.';
+
+COMMENT ON COLUMN nd_geolocation.altitude IS 'The altitude (elevation) of the location in meters. If the altitude is only known as a range, this is the average, and altitude_dev will hold half of the width of the range.';
+
+
+
+CREATE TABLE nd_experiment (
+    nd_experiment_id serial PRIMARY KEY NOT NULL,
+    nd_geolocation_id integer NOT NULL references nd_geolocation (nd_geolocation_id) on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED 
+);
+
+--
+--used to be nd_diversityexperiment_project
+--then was nd_assay_project
+CREATE TABLE nd_experiment_project (
+    nd_experiment_project_id serial PRIMARY KEY NOT NULL,
+    project_id integer not null references project (project_id) on delete cascade INITIALLY DEFERRED,
+    nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED
+);
+
+
+
+CREATE TABLE nd_experimentprop (
+    nd_experimentprop_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED ,
+    value text null,
+    rank integer NOT NULL default 0,
+    constraint nd_experimentprop_c1 unique (nd_experiment_id,type_id,rank)
+);
+
+CREATE TABLE nd_experiment_pub (
+       nd_experiment_pub_id serial PRIMARY KEY not null,
+       nd_experiment_id int not null,
+       foreign key (nd_experiment_id) references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
+       pub_id int not null,
+       foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED,
+       constraint nd_experiment_pub_c1 unique (nd_experiment_id,pub_id)
+);
+create index nd_experiment_pub_idx1 on nd_experiment_pub (nd_experiment_id);
+create index nd_experiment_pub_idx2 on nd_experiment_pub (pub_id);
+
+COMMENT ON TABLE nd_experiment_pub IS 'Linking nd_experiment(s) to publication(s)';
+
+
+
+
+CREATE TABLE nd_geolocationprop (
+    nd_geolocationprop_id serial PRIMARY KEY NOT NULL,
+    nd_geolocation_id integer NOT NULL references nd_geolocation (nd_geolocation_id) on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
+    value text null,
+    rank integer NOT NULL DEFAULT 0,
+    constraint nd_geolocationprop_c1 unique (nd_geolocation_id,type_id,rank)
+);
+
+COMMENT ON TABLE nd_geolocationprop IS 'Property/value associations for geolocations. This table can store the properties such as location and environment';
+
+COMMENT ON COLUMN nd_geolocationprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
+
+COMMENT ON COLUMN nd_geolocationprop.value IS 'The value of the property.';
+
+COMMENT ON COLUMN nd_geolocationprop.rank IS 'The rank of the property value, if the property has an array of values.';
+
+
+CREATE TABLE nd_protocol (
+    nd_protocol_id serial PRIMARY KEY  NOT NULL,
+    name character varying(255) NOT NULL unique,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
+);
+
+COMMENT ON TABLE nd_protocol IS 'A protocol can be anything that is done as part of the experiment.';
+
+COMMENT ON COLUMN nd_protocol.name IS 'The protocol name.';
+
+CREATE TABLE nd_reagent (
+    nd_reagent_id serial PRIMARY KEY NOT NULL,
+    name character varying(80) NOT NULL,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
+    feature_id integer
+);
+
+COMMENT ON TABLE nd_reagent IS 'A reagent such as a primer, an enzyme, an adapter oligo, a linker oligo. Reagents are used in genotyping experiments, or in any other kind of experiment.';
+
+COMMENT ON COLUMN nd_reagent.name IS 'The name of the reagent. The name should be unique for a given type.';
+
+COMMENT ON COLUMN nd_reagent.type_id IS 'The type of the reagent, for example linker oligomer, or forward primer.';
+
+COMMENT ON COLUMN nd_reagent.feature_id IS 'If the reagent is a primer, the feature that it corresponds to. More generally, the corresponding feature for any reagent that has a sequence that maps to another sequence.';
+
+
+
+CREATE TABLE nd_protocol_reagent (
+    nd_protocol_reagent_id serial PRIMARY KEY NOT NULL,
+    nd_protocol_id integer NOT NULL references nd_protocol (nd_protocol_id) on delete cascade INITIALLY DEFERRED,
+    reagent_id integer NOT NULL references nd_reagent (nd_reagent_id) on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
+);
+
+
+CREATE TABLE nd_protocolprop (
+    nd_protocolprop_id serial PRIMARY KEY NOT NULL,
+    nd_protocol_id integer NOT NULL references nd_protocol (nd_protocol_id) on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
+    value text null,
+    rank integer DEFAULT 0 NOT NULL,
+    constraint nd_protocolprop_c1 unique (nd_protocol_id,type_id,rank)
+);
+
+COMMENT ON TABLE nd_protocolprop IS 'Property/value associations for protocol.';
+
+COMMENT ON COLUMN nd_protocolprop.nd_protocol_id IS 'The protocol to which the property applies.';
+
+COMMENT ON COLUMN nd_protocolprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
+
+COMMENT ON COLUMN nd_protocolprop.value IS 'The value of the property.';
+
+COMMENT ON COLUMN nd_protocolprop.rank IS 'The rank of the property value, if the property has an array of values.';
+
+
+
+CREATE TABLE nd_experiment_stock (
+    nd_experiment_stock_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
+    stock_id integer NOT NULL references stock (stock_id)  on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
+);
+
+COMMENT ON TABLE nd_experiment_stock IS 'Part of a stock or a clone of a stock that is used in an experiment';
+
+
+COMMENT ON COLUMN nd_experiment_stock.stock_id IS 'stock used in the extraction or the corresponding stock for the clone';
+
+
+CREATE TABLE nd_experiment_protocol (
+    nd_experiment_protocol_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
+    nd_protocol_id integer NOT NULL references nd_protocol (nd_protocol_id) on delete cascade INITIALLY DEFERRED
+);
+
+COMMENT ON TABLE nd_experiment_protocol IS 'Linking table: experiments to the protocols they involve.';
+
+
+CREATE TABLE nd_experiment_phenotype (
+    nd_experiment_phenotype_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_id integer NOT NULL REFERENCES nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
+    phenotype_id integer NOT NULL references phenotype (phenotype_id) on delete cascade INITIALLY DEFERRED,
+   constraint nd_experiment_phenotype_c1 unique (nd_experiment_id,phenotype_id)
+); 
+
+COMMENT ON TABLE nd_experiment_phenotype IS 'Linking table: experiments to the phenotypes they produce. There is a one-to-one relationship between an experiment and a phenotype since each phenotype record should point to one experiment. Add a new experiment_id for each phenotype record.';
+
+CREATE TABLE nd_experiment_genotype (
+    nd_experiment_genotype_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
+    genotype_id integer NOT NULL references genotype (genotype_id) on delete cascade INITIALLY DEFERRED ,
+    constraint nd_experiment_genotype_c1 unique (nd_experiment_id,genotype_id)
+);
+
+COMMENT ON TABLE nd_experiment_genotype IS 'Linking table: experiments to the genotypes they produce. There is a one-to-one relationship between an experiment and a genotype since each genotype record should point to one experiment. Add a new experiment_id for each genotype record.';
+
+
+CREATE TABLE nd_reagent_relationship (
+    nd_reagent_relationship_id serial PRIMARY KEY NOT NULL,
+    subject_reagent_id integer NOT NULL references nd_reagent (nd_reagent_id) on delete cascade INITIALLY DEFERRED,
+    object_reagent_id integer NOT NULL  references nd_reagent (nd_reagent_id) on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL  references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
+);
+
+COMMENT ON TABLE nd_reagent_relationship IS 'Relationships between reagents. Some reagents form a group. i.e., they are used all together or not at all. Examples are adapter/linker/enzyme experiment reagents.';
+
+COMMENT ON COLUMN nd_reagent_relationship.subject_reagent_id IS 'The subject reagent in the relationship. In parent/child terminology, the subject is the child. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
+
+COMMENT ON COLUMN nd_reagent_relationship.object_reagent_id IS 'The object reagent in the relationship. In parent/child terminology, the object is the parent. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
+
+COMMENT ON COLUMN nd_reagent_relationship.type_id IS 'The type (or predicate) of the relationship. For example, in "linkerA 3prime-overhang-linker enzymeA" linkerA is the subject, 3prime-overhand-linker is the type, and enzymeA is the object.';
+
+
+CREATE TABLE nd_reagentprop (
+    nd_reagentprop_id serial PRIMARY KEY NOT NULL,
+    nd_reagent_id integer NOT NULL references nd_reagent (nd_reagent_id) on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
+    value text null,
+    rank integer DEFAULT 0 NOT NULL,
+    constraint nd_reagentprop_c1 unique (nd_reagent_id,type_id,rank)
+);
+
+CREATE TABLE nd_experiment_stockprop (
+    nd_experiment_stockprop_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_stock_id integer NOT NULL references nd_experiment_stock (nd_experiment_stock_id) on delete cascade INITIALLY DEFERRED,
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
+    value text null,
+    rank integer DEFAULT 0 NOT NULL,
+    constraint nd_experiment_stockprop_c1 unique (nd_experiment_stock_id,type_id,rank)
+);
+
+COMMENT ON TABLE nd_experiment_stockprop IS 'Property/value associations for experiment_stocks. This table can store the properties such as treatment';
+
+COMMENT ON COLUMN nd_experiment_stockprop.nd_experiment_stock_id IS 'The experiment_stock to which the property applies.';
+
+COMMENT ON COLUMN nd_experiment_stockprop.type_id IS 'The name of the property as a reference to a controlled vocabulary term.';
+
+COMMENT ON COLUMN nd_experiment_stockprop.value IS 'The value of the property.';
+
+COMMENT ON COLUMN nd_experiment_stockprop.rank IS 'The rank of the property value, if the property has an array of values.';
+
+
+CREATE TABLE nd_experiment_stock_dbxref (
+    nd_experiment_stock_dbxref_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_stock_id integer NOT NULL references nd_experiment_stock (nd_experiment_stock_id) on delete cascade INITIALLY DEFERRED,
+    dbxref_id integer NOT NULL references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED
+);
+
+COMMENT ON TABLE nd_experiment_stock_dbxref IS 'Cross-reference experiment_stock to accessions, images, etc';
+
+
+
+CREATE TABLE nd_experiment_dbxref (
+    nd_experiment_dbxref_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
+    dbxref_id integer NOT NULL references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED
+);
+
+COMMENT ON TABLE nd_experiment_dbxref IS 'Cross-reference experiment to accessions, images, etc';
+
+
+CREATE TABLE nd_experiment_contact (
+    nd_experiment_contact_id serial PRIMARY KEY NOT NULL,
+    nd_experiment_id integer NOT NULL references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED,
+    contact_id integer NOT NULL references contact (contact_id) on delete cascade INITIALLY DEFERRED
+);

+ 15 - 15
tripal_core/default_schema.sql → tripal_core/chado_schema/default_schema-1.11.sql

@@ -1,4 +1,4 @@
--- $Id: general.sql,v 1.31 2007-03-01 02:45:54 briano Exp $
+
 -- ==========================================
 -- Chado general module
 --
@@ -131,7 +131,7 @@ CREATE OR REPLACE FUNCTION store_dbxref (VARCHAR,VARCHAR)
  END;
 ' LANGUAGE 'plpgsql';
   
--- $Id: cv.sql,v 1.37 2007-02-28 15:08:48 briano Exp $
+
 -- ==========================================
 -- Chado cv module
 --
@@ -947,7 +947,7 @@ BEGIN
 END;   
 '
 LANGUAGE 'plpgsql';
--- $Id: pub.sql,v 1.27 2007-02-19 20:50:44 briano Exp $
+
 -- ==========================================
 -- Chado pub module
 --
@@ -1083,7 +1083,7 @@ create index pubprop_idx1 on pubprop (pub_id);
 create index pubprop_idx2 on pubprop (type_id);
 
 COMMENT ON TABLE pubprop IS 'Property-value pairs for a pub. Follows standard chado pattern.';
--- $Id: organism.sql,v 1.19 2007-04-01 18:45:41 briano Exp $
+
 -- ==========================================
 -- Chado organism module
 --
@@ -1211,7 +1211,7 @@ CREATE OR REPLACE FUNCTION store_organism (VARCHAR,VARCHAR,VARCHAR)
  END;
 ' LANGUAGE 'plpgsql';
   
--- $Id: sequence.sql,v 1.69 2009-05-14 02:44:23 scottcain Exp $
+
 -- ==========================================
 -- Chado sequence module
 --
@@ -33779,7 +33779,7 @@ BEGIN
 END;
 '
 LANGUAGE 'plpgsql';
--- $Id: companalysis.sql,v 1.37 2007-03-23 15:18:02 scottcain Exp $
+
 -- ==========================================
 -- Chado companalysis module
 --
@@ -33914,7 +33914,7 @@ CREATE OR REPLACE FUNCTION store_analysis (VARCHAR,VARCHAR,VARCHAR)
 --'DECLARE
 --  v_srcfeature_id       ALIAS FOR $1;
   
--- $Id: phenotype.sql,v 1.6 2007-04-27 16:09:46 emmert Exp $
+
 -- ==========================================
 -- Chado phenotype module
 --
@@ -33994,7 +33994,7 @@ CREATE INDEX feature_phenotype_idx1 ON feature_phenotype (feature_id);
 CREATE INDEX feature_phenotype_idx2 ON feature_phenotype (phenotype_id);
 
 COMMENT ON TABLE feature_phenotype IS NULL;
--- $Id: genetic.sql,v 1.31 2008-08-25 19:53:14 scottcain Exp $
+
 -- ==========================================
 -- Chado genetics module
 --
@@ -34201,7 +34201,7 @@ CREATE TABLE phenotype_comparison_cvterm (
 );
 CREATE INDEX phenotype_comparison_cvterm_idx1 on phenotype_comparison_cvterm (phenotype_comparison_id);
 CREATE INDEX  phenotype_comparison_cvterm_idx2 on phenotype_comparison_cvterm (cvterm_id);
--- $Id: map.sql,v 1.14 2007-03-23 15:18:02 scottcain Exp $
+
 -- ==========================================
 -- Chado map module
 --
@@ -34296,7 +34296,7 @@ create table featuremap_pub (
 );
 create index featuremap_pub_idx1 on featuremap_pub (featuremap_id);
 create index featuremap_pub_idx2 on featuremap_pub (pub_id);
--- $Id: phylogeny.sql,v 1.11 2007-04-12 17:00:30 briano Exp $
+
 -- ==========================================
 -- Chado phylogenetics module
 --
@@ -34528,7 +34528,7 @@ CREATE OR REPLACE FUNCTION phylonode_height(INT)
 '
 LANGUAGE 'sql';
 
--- $Id: contact.sql,v 1.5 2007-02-25 17:00:17 briano Exp $
+
 -- ==========================================
 -- Chado contact module
 --
@@ -34578,7 +34578,7 @@ COMMENT ON TABLE contact_relationship IS 'Model relationships between contacts';
 COMMENT ON COLUMN contact_relationship.subject_id IS 'The subject of the subj-predicate-obj sentence. In a DAG, this corresponds to the child node.';
 COMMENT ON COLUMN contact_relationship.object_id IS 'The object of the subj-predicate-obj sentence. In a DAG, this corresponds to the parent node.';
 COMMENT ON COLUMN contact_relationship.type_id IS 'Relationship type between subject and object. This is a cvterm, typically from the OBO relationship ontology, although other relationship types are allowed.';
--- $Id: expression.sql,v 1.14 2007-03-23 15:18:02 scottcain Exp $
+
 -- ==========================================
 -- Chado expression module
 --
@@ -34771,7 +34771,7 @@ create table expression_image (
 );
 create index expression_image_idx1 on expression_image (expression_id);
 create index expression_image_idx2 on expression_image (eimage_id);
--- $Id: mage.sql,v 1.3 2008-03-19 18:32:51 scottcain Exp $
+
 -- ==========================================
 -- Chado mage module
 --
@@ -35596,7 +35596,7 @@ CREATE TABLE studyprop_feature (
 create index studyprop_feature_idx1 on studyprop_feature (studyprop_id);
 create index studyprop_feature_idx2 on studyprop_feature (feature_id);
 
--- $Id: stock.sql,v 1.7 2007-03-23 15:18:03 scottcain Exp $
+
 -- ==========================================
 -- Chado stock module
 --
@@ -35884,7 +35884,7 @@ create index stockcollection_stock_idx2 on stockcollection_stock (stock_id);
 
 COMMENT ON TABLE stockcollection_stock IS 'stockcollection_stock links
 a stock collection to the stocks which are contained in the collection.';
--- $Id: library.sql,v 1.10 2008-03-25 16:00:43 emmert Exp $
+
 -- =================================================================
 -- Dependencies:
 --

File diff suppressed because it is too large
+ 2462 - 0
tripal_core/chado_schema/default_schema-1.2.sql


+ 10 - 0
tripal_core/chado_schema/initialize-1.11-1.2.sql

@@ -0,0 +1,10 @@
+insert into cv (name,definition) values ('chado_properties','Terms that are used in the chadoprop table to describe the state of the database');
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'chado_properties:version');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('version','Chado schema version',(select cv_id from cv where name = 'chado_properties'),(select dbxref_id from dbxref where accession='chado_properties:version'));
+
+INSERT INTO chadoprop (type_id, value) VALUES 
+  ((SELECT cvterm_id 
+   FROM cvterm CVT 
+     INNER JOIN cv CV on CVT.cv_id = CV.cv_id 
+   WHERE CV.name = 'chado_properties' AND CVT.name = 'version'),
+   '1.2')

+ 0 - 0
tripal_core/initialize.sql → tripal_core/chado_schema/initialize-1.11.sql


+ 237 - 0
tripal_core/chado_schema/initialize-1.2.sql

@@ -0,0 +1,237 @@
+/* For load_gff3.pl */
+insert into organism (abbreviation, genus, species, common_name)
+       values ('H.sapiens', 'Homo','sapiens','human');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('D.melanogaster', 'Drosophila','melanogaster','fruitfly');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('M.musculus', 'Mus','musculus','mouse');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('A.gambiae', 'Anopheles','gambiae','mosquito');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('R.norvegicus', 'Rattus','norvegicus','rat');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('A.thaliana', 'Arabidopsis','thaliana','mouse-ear cress');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('C.elegans', 'Caenorhabditis','elegans','worm');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('D.rerio', 'Danio','rerio','zebrafish');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('O.sativa', 'Oryza','sativa','rice');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('S.cerevisiae', 'Saccharomyces','cerevisiae','yeast');
+insert into organism (abbreviation, genus, species, common_name)
+       values ('X.laevis', 'Xenopus','laevis','frog');
+insert into organism (abbreviation, genus, species,common_name) 
+       values ('D.discoideum','Dictyostelium','discoideum','dicty');
+insert into contact (name) values ('Affymetrix');
+insert into contact (name,description) values ('null','null');
+insert into cv (name) values ('null');
+insert into cv (name,definition) values ('local','Locally created terms');
+insert into cv (name,definition) values ('Statistical Terms','Locally created terms for statistics');
+insert into db (name, description) values ('null','a fake database for local items');
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'local:null');
+insert into cvterm (name,cv_id,dbxref_id) values ('null',(select cv_id from cv where name = 'null'),(select dbxref_id from dbxref where accession='local:null'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'local:computer file');
+insert into cvterm (name,cv_id,dbxref_id) values ('computer file', (select cv_id from cv where name = 'null'),(select dbxref_id from dbxref where accession='local:computer file'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'local:glass');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('glass','glass array',(select cv_id from cv where name = 'local'),(select dbxref_id from dbxref where accession='local:glass'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'local:photochemical_oligo');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('photochemical_oligo','in-situ photochemically synthesized oligoes',(select cv_id from cv where name = 'local'),(select dbxref_id from dbxref where accession='local:photochemical_oligo'));
+
+insert into pub (miniref,uniquename,type_id) values ('null','null',(select cvterm_id from cvterm where name = 'null'));
+insert into db (name, description) values ('GFF_source', 'A collection of sources (ie, column 2) from GFF files');
+
+insert into db (name) values ('ATCC');
+
+insert into db (name) values ('refseq');
+insert into db (name) values ('genbank');
+insert into db (name) values ('EMBL');
+insert into db (name) values ('TIGR');
+insert into db (name) values ('ucsc');
+insert into db (name) values ('ucla');
+insert into db (name) values ('SGD');
+
+insert into db (name) values ('PFAM');
+insert into db (name) values ('SUPERFAMILY');
+insert into db (name) values ('PROFILE');
+insert into db (name) values ('PRODOM');
+insert into db (name) values ('PRINTS');
+insert into db (name) values ('SMART');
+insert into db (name) values ('TIGRFAMs');
+insert into db (name) values ('PIR');
+
+insert into db (name) values ('Affymetrix_U133');
+insert into db (name) values ('Affymetrix_U133PLUS');
+insert into db (name) values ('Affymetrix_U95');
+insert into db (name) values ('LocusLink');
+insert into db (name) values ('RefSeq_protein');
+insert into db (name) values ('GenBank_protein');
+insert into db (name) values ('OMIM');
+insert into db (name) values ('Swiss');
+insert into db (name) values ('RefSNP');
+insert into db (name) values ('TSC');
+--insert into db (name, contact_id, description, urlprefix) values ('affy:U133',(select contact_id from contact where name = 'null'),'Affymetrix U133','http://https://www.affymetrix.com/analysis/netaffx/fullrecord.affx?pk=HG-U133_PLUS_2:');
+--insert into db (name, contact_id, description, urlprefix) values ('affy:U95',(select contact_id from contact where name = 'null'),'Affymetrix U95','http://https://www.affymetrix.com/analysis/netaffx/fullrecord.affx?pk=HG-U95AV2:');
+
+insert into db (name, description) values ('GR','Gramene');
+insert into db (name, description, urlprefix) values ('uniprot','UniProt/TrEMBL','http://us.expasy.org/cgi-bin/niceprot.pl?');
+insert into db (name, description, urlprefix) values ('refseq:mrna','RefSeq mRNA','http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db=nucleotide&dopt=GenBank&term=');
+insert into db (name, description, urlprefix) values ('refseq:protein','RefSeq Protein','http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db=protein&dopt=GenBank&term=');
+insert into db (name, description, urlprefix) values ('unigene','Unigene','http://www.ncbi.nih.gov/entrez/query.fcgi?db=unigene&cmd=search&term=');
+insert into db (name, description, urlprefix) values ('omim','OMIM','http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=');
+insert into db (name, description, urlprefix) values ('locuslink','LocusLink','http://www.ncbi.nlm.nih.gov/LocusLink/LocRpt.cgi?l=');
+insert into db (name, description, urlprefix) values ('genbank:mrna','GenBank mRNA','http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db=nucleotide&dopt=GenBank&term=');
+insert into db (name, description, urlprefix) values ('genbank:protein','GenBank Protein','http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db=protein&dopt=GenBank&term=');
+insert into db (name, description, urlprefix) values ('swissprot:display','SwissProt','http://us.expasy.org/cgi-bin/niceprot.pl?');
+insert into db (name, description, urlprefix) values ('pfam','Pfam','http://www.sanger.ac.uk/cgi-bin/Pfam/dql.pl?query=');
+
+insert into analysis (name,program,programversion) values ('dabg' ,'dabg' ,'dabg' );
+insert into analysis (name,program,programversion) values ('dchip','dchip','dchip');
+insert into analysis (name,program,programversion) values ('gcrma','gcrma','gcrma');
+insert into analysis (name,program,programversion) values ('mas5' ,'mas5' ,'mas5' );
+insert into analysis (name,program,programversion) values ('mpam' ,'mpam' ,'mpam' );
+insert into analysis (name,program,programversion) values ('plier','plier','plier');
+insert into analysis (name,program,programversion) values ('rma'  ,'rma'  ,'rma'  );
+insert into analysis (name,program,programversion) values ('sea'  ,'sea'  ,'sea'  );
+insert into analysis (name,program,programversion) values ('vsn'  ,'vsn'  ,'vsn'  );
+
+insert into arraydesign (name,manufacturer_id,platformtype_id) values ('unknown'                                    , (select contact_id from contact where name = 'null'),(select cvterm_id from cvterm where name = 'null'));
+insert into arraydesign (name,manufacturer_id,platformtype_id) values ('virtual array'                              , (select contact_id from contact where name = 'null'),(select cvterm_id from cvterm where name = 'null'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U133_Plus_2' , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U133A'       , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U133A_2'     , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U133B'       , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U95Av2'      , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U95B'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U95C'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U95D'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HG-U95E'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HuExon1'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_HuGeneFL'       , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_U74Av2'         , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_MG-U74Av2'      , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_MG-U74Bv2'      , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_MG-U74Cv2'      , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_RG-U34A'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_RG-U34B'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_RG-U34C'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_RT-U34'         , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_RN-U34'         , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_YG-S98'         , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Yeast_2'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_RAE230A'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_RAE230B'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Rat230_2'       , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_MOE430A'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_MOE430B'        , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Mouse430_2'     , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Mouse430A_2'    , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_ATH1-121501'    , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Mapping100K_Hind240' , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Mapping100K_Xba240'  , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Mapping10K_Xba131'   , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Mapping10K_Xba142'   , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Mapping500K_NspI'    , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+insert into arraydesign (name,manufacturer_id,platformtype_id,substratetype_id) values ('Affymetrix_Mapping500K_StyI'    , (select contact_id from contact where name = 'Affymetrix'),(select cvterm_id from cvterm where name = 'photochemical_oligo'),(select cvterm_id from cvterm where name = 'glass'));
+
+insert into cv (name) values ('developmental stages');
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'developmental stages:fetus');
+insert into cvterm (name,cv_id,dbxref_id) values ('fetus',      (select cv_id from cv where name = 'local'),(select dbxref_id from dbxref where accession='developmental stages:fetus'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'developmental stages:neonate');
+insert into cvterm (name,cv_id,dbxref_id) values ('neonate',    (select cv_id from cv where name = 'developmental stages'), (select dbxref_id from dbxref where accession='developmental stages:neonate'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'developmental stages:child');
+insert into cvterm (name,cv_id,dbxref_id) values ('child',      (select cv_id from cv where name = 'developmental stages'), (select dbxref_id from dbxref where accession='developmental stages:child'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'developmental stages:adult_young');
+insert into cvterm (name,cv_id,dbxref_id) values ('adult_young',(select cv_id from cv where name = 'developmental stages'),(select dbxref_id from dbxref where accession='developmental stages:adult_young'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'developmental stages:adult');
+insert into cvterm (name,cv_id,dbxref_id) values ('adult',      (select cv_id from cv where name = 'developmental stages'),(select dbxref_id from dbxref where accession='developmental stages:adult'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'developmental stages:adult_old');
+insert into cvterm (name,cv_id,dbxref_id) values ('adult_old',  (select cv_id from cv where name = 'developmental stages'), (select dbxref_id from dbxref where accession='developmental stages:adult_old'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'local:survival_time');
+insert into cvterm (name,cv_id,dbxref_id) values ('survival_time',(select cv_id from cv where name = 'local'),(select dbxref_id from dbxref where accession='local:survival_time'));
+
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:n');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('n','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:n'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:minimum');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('minimum','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:minimum'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:maximum');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('maximum','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:maximum'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:modality');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('modality','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:modality'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:modality p');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('modality p','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:modality p'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:mean');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('mean','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:mean'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:median');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('median','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:median'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:mode');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('mode','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:mode'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:quartile 1');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('quartile 1','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:quartile 1'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:quartile 3');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('quartile 3','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:quartile 3'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:skewness');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('skewness','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:skewness'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:kurtosis');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('kurtosis','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:kurtosis'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:chi square p');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('chi square p','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:chi square p'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:standard deviation');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('standard deviation','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:standard deviation'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:expectation maximization gaussian mean');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('expectation maximization gaussian mean','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:expectation maximization gaussian mean'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:expectation maximization p');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('expectation maximization p','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:expectation maximization p'));
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'Statistical Terms:histogram');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('histogram','sensu statistica',  (select cv_id from cv where name = 'Statistical Terms'),(select dbxref_id from dbxref where accession='Statistical Terms:histogram'));
+
+insert into cv (name,definition) values ('autocreated','Terms that are automatically inserted by loading software');
+
+insert into cv (name,definition) values ('chado_properties','Terms that are used in the chadoprop table to describe the state of the database');
+
+insert into dbxref (db_id,accession) values ((select db_id from db where name='null'), 'chado_properties:version');
+insert into cvterm (name,definition,cv_id,dbxref_id) values ('version','Chado schema version',(select cv_id from cv where name = 'chado_properties'),(select dbxref_id from dbxref where accession='chado_properties:version'));
+
+
+--this table will probably end up in general.sql
+ CREATE TABLE public.materialized_view   (       
+                                materialized_view_id SERIAL,
+                                last_update TIMESTAMP,
+                                refresh_time INT,
+                                name VARCHAR(64) UNIQUE,
+                                mv_schema VARCHAR(64),
+                                mv_table VARCHAR(128),
+                                mv_specs TEXT,
+                                indexed TEXT,
+                                query TEXT,
+                                special_index TEXT
+                                );
+
+

+ 16 - 1
tripal_core/jobs.php

@@ -45,6 +45,21 @@
  * @return
  *    The job_id of the registered job
  *
+ * Example usage:
+ * @code
+ *  $args = array($dfile, $organism_id, $type, $library_id, $re_name, $re_uname,
+ *        $re_accession, $db_id, $rel_type, $re_subject, $parent_type, $method,
+ *         $user->uid, $analysis_id, $match_type);
+ *
+ * tripal_add_job("Import FASTA file: $dfile", 'tripal_feature',
+ *   'tripal_feature_load_fasta', $args, $user->uid);
+ * @endcode
+ * The code above is copied from the tripal_feature/fasta_loader.php file. The 
+ * snipped first builds an array of arguments that will then be passed to the
+ * tripal_add_job function.  The number of arguments provided in the $arguments
+ * variable should match the argument set for the callback function provided
+ * as the third argument.
+ *
  * @ingroup tripal_jobs_api
  */
 function tripal_add_job($job_name, $modulename, $callback, $arguments, $uid, $priority = 10) {
@@ -450,4 +465,4 @@ function tripal_jobs_cancel($job_id) {
     drupal_set_message(t("Job %job_id cannot be cancelled. It is in progress or has finished.", array('%job_id' => $job_id)));
   }
   drupal_goto("admin/tripal/tripal_jobs");
-}
+}

+ 3 - 1
tripal_core/tripal_core.api.inc

@@ -1263,7 +1263,9 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
             // than once with the same table we want to alter the
             // array structure
             if (count($foreign_table_desc['foreign keys'][$base_table]['columns']) > 1) {
-              $object->{$foreign_table} = new stdClass();
+              if(!is_object($object->{$foreign_table})){
+                 $object->{$foreign_table} = new stdClass();
+              }
               $object->{$foreign_table}->{$left} = $foreign_object;
               $object->expanded = $to_expand;
             }

+ 1 - 2
tripal_core/tripal_core.info

@@ -1,8 +1,7 @@
-; $Id: tripal_core.info,v 1.3 2009/10/23 02:12:34 ccheng Exp $
 name = Tripal Core
 description = The core module for the Tripal package that integrates Drupal and GMOD chado. This module provides common support for all Tripal modules.
 core = 6.x
 project = tripal_core
 package = Tripal
-version = 6.x-0.4
+version = 6.x-1.0
 

+ 7 - 5
tripal_core/tripal_core.module

@@ -90,11 +90,11 @@ function tripal_core_menu() {
     'access arguments' => array('access administration pages'),
     'type' => MENU_CALLBACK | MENU_LINKS_TO_PARENT
   );
-  $items['admin/tripal/chado_1_11_install'] = array(
-    'title' => 'Install Chado v1.11',
-    'description' => 'Installs Chado version 1.11 inside the current Drupal database',
+  $items['admin/tripal/chado_install'] = array(
+    'title' => 'Install Chado Schema',
+    'description' => 'Installs the Chado database tables, views, etc., inside the current Drupal database',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_core_chado_v1_11_load_form'),
+    'page arguments' => array('tripal_core_chado_load_form'),
     'access arguments' => array('access administration pages'),
     'type' => MENU_NORMAL_ITEM,
   );
@@ -249,7 +249,9 @@ function tripal_core_job_describe_args($callback, $args) {
     $mview = db_fetch_object(db_query($sql, $args[0]));
     $new_args['View Name'] = $mview->name;
   }
-
+  elseif($callback == 'tripal_core_install_chado'){
+     $new_args['Action'] = $args[0];
+  }
   return $new_args;
 }
 

+ 1 - 3
tripal_cv/tripal_cv.info

@@ -1,10 +1,8 @@
-; $Id: tripal_cv.info,v 1.3 2009/12/05 06:11:56 ficklin Exp $
 name = Tripal CV
 description = The controlled vocabulary module for the Tripal package that integrates Drupal and GMOD chado. This module provides support for managing and viewing controlled vocabularies.
 core = 6.x
 project = tripal_cv
 package = Tripal
-version = 6.x-0.3.1b
-
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_db

+ 1 - 3
tripal_db/tripal_db.info

@@ -1,9 +1,7 @@
-; $Id: tripal_db.info,v 1.2 2009/12/05 06:11:56 ficklin Exp $
 name = Tripal DB
 description = The database module for the Tripal package that integrates Drupal and GMOD chado. This module provides support for managing and viewing external databases.
 core = 6.x
 project = tripal_db
 package = Tripal
-version = 6.x-0.3.1b
-
+version = 6.x-1.0
 dependencies[] = tripal_core

+ 2 - 2
tripal_feature/tripal_feature.info

@@ -1,9 +1,9 @@
-; $Id: tripal_feature.info,v 1.4 2009/10/01 17:52:24 ccheng Exp $
 name = Tripal Feature
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing, inserting and editing of chado features.
 core = 6.x
 project = tripal_feature
 package = Tripal
+version = 6.x-1.0
 dependencies[] = search
 dependencies[] = path
 dependencies[] = tripal_core
@@ -11,4 +11,4 @@ dependencies[] = tripal_db
 dependencies[] = tripal_cv
 dependencies[] = tripal_organism
 dependencies[] = tripal_analysis
-version = 6.x-0.3.1b
+

+ 3 - 4
tripal_genetic/tripal_genetic.info

@@ -1,10 +1,9 @@
-; $Id$
-package = Tripal
 name = Tripal Genetic
-version = 6.x-0.3.1b
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing of Genetic data
 core = 6.x
-
+project = tripal_genetic
+package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_feature

+ 2 - 2
tripal_library/tripal_library.info

@@ -1,12 +1,12 @@
-; $Id: tripal_library.info,v 1.3 2009/10/23 02:12:42 ccheng Exp $
 name = Tripal Library
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing, inserting and editing of lbraries.
 core = 6.x
 project = tripal_library
 package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_organism
 dependencies[] = search
 dependencies[] = path
 dependencies[] = tripal_cv
-version = 6.x-0.3.1b
+

+ 3 - 4
tripal_natural_diversity/tripal_natural_diversity.info

@@ -1,10 +1,9 @@
-; $Id$
-package = Tripal
 name = Tripal Natural Diversity
-version = 6.x-0.3.1b
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing of Natural Diversity data
 core = 6.x
-
+project = tripal_natural_diversity
+package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_db

+ 2 - 2
tripal_organism/tripal_organism.info

@@ -1,10 +1,10 @@
-; $Id: tripal_organism.info,v 1.3 2009/09/02 23:28:46 sficklin Exp $
 name = Tripal Organism
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing, inserting and editing of organisms.
 core = 6.x
 project = tripal_organism
 package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = search
 dependencies[] = path
-version = 6.x-0.3.1b
+

+ 3 - 4
tripal_phenotype/tripal_phenotype.info

@@ -1,10 +1,9 @@
-; $Id$
-package = Tripal
 name = Tripal Phenotype
-version = 6.x-0.3.1b
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing of Phenotype Data
 core = 6.x
-
+project = tripal_phenotype
+package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_feature

+ 3 - 4
tripal_project/tripal_project.info

@@ -1,9 +1,8 @@
-; $Id$
-package = Tripal
 name = Tripal Project
-version = 6.x-0.3.1b
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing of projects
 core = 6.x
-
+project = tripal_project
+package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_cv

+ 3 - 4
tripal_pub/tripal_pub.info

@@ -1,10 +1,9 @@
-; $Id$
-package = Tripal
 name = Tripal Publication
-version = 6.x-0.3.1b
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing of publications
 core = 6.x
-
+project = tripal_pub
+package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_db

+ 0 - 8
tripal_search/tripal_search.coder_ignores.txt

@@ -1,8 +0,0 @@
-; The file should be formatted this way :
-; file:line:warning-type
-; where warning-type is one of security, style, sql, i18n, comment, etc.
-
-; Can't use db placeholders in this case since the variable contains the SQL describing
-; a join and this would be sanitized if that was added through a placeholder
-tripal_search.module:126:sql
-tripal_search.module:136:sql

+ 0 - 10
tripal_search/tripal_search.info

@@ -1,10 +0,0 @@
-; $Id:
-name = Tripal Search
-description = A module that adds advanced search functions to Drupal, including feature fasta file export from the search result.
-core = 6.x
-project = tripal_search
-package = Tripal
-version = 6.x-0.3.1b
-dependencies[] = search
-dependencies[] = tripal_core
-dependencies[] = tripal_feature

+ 0 - 159
tripal_search/tripal_search.module

@@ -1,159 +0,0 @@
-<?php
-/**
- * @file
- * @todo Add file header description
- */
-
-//
-// Copyright 2009 Clemson University
-//
-/**
- * Tripal Search initiation
- */
-function tripal_search_init() {
-  // Add javascript
-  drupal_add_js(drupal_get_path('theme', 'tripal') .
-                                  '/js/tripal_search.js');
-}
-/**
- *  Tripal Search adds advanced search functions to Drupal's Search module
- */
-function tripal_search_menu() {
-  $items = array();
-  foreach (module_list() as $name) {
-    if (module_hook($name, 'search') && $title = module_invoke($name, 'search', 'name')) {
-      $items['tripal_search/'. $name] = array(
-        'title' => $title,
-        'page callback' => 'tripal_search_view',
-        'access arguments' => array('search content'),
-        'type' => MENU_LOCAL_TASK
-      );
-    }
-  }
-  return $items;
-}
-
-/**
- * Implementation of hook_form_alter().
- */
-function tripal_search_form_alter(&$form, $form_state, $form_id) {
-  if ($form_id == 'search_form' && arg(2)) {
-    // for pagination etc.
-    $get = drupal_query_string_encode($_GET, array('q'));
-    if (preg_match("/node/", arg(1))) {
-      $form['basic']['inline']['fasta'] = array('#type' => 'markup',
-          '#value' => "<br /><br /><a id=\"tripal_search_link\" href=\"".
-                      url('tripal_search/'. arg(1) .'/'. urlencode(search_get_keys()),
-                      array('query' => trim($get)?$get:NULL)) .
-                      "\">Download features (multi-FASTA format)</a><br /><br />");
-
-    }
-  }
-}
-
-/*******************************************************************************
- * Menu callback; presents an tripal_search results page.
- */
-function tripal_search_view() {
-  $type = arg(1);
-  $keys = search_get_keys();
-
-  // Only perform search if there is non-whitespace search term:
-  if (!module_hook($type, 'search')) {
-    return drupal_not_found();
-  }
-
-  if (trim($keys)) {
-    $results = tripal_do_search($keys, $type);    //var_dump($pager_total['0']);
-    return tripal_search_file($type, $keys, $results);
-  }
-}
-
-/*******************************************************************************
- * Return an open search results file.
- */
-function tripal_search_file($type, $keys, $results) {
-
-  drupal_set_header('Content-Type: text');
-  drupal_set_header('Content-Disposition: attachment; filename="searchresults.fasta"');
-
-  foreach ($results as $result) {
-    // Get feature id from drupal database
-    $sqld = "SELECT * FROM {chado_feature} CF INNER JOIN {node} N on N.nid = CF.nid WHERE CF.nid = %d";
-    if ($f_objd = db_fetch_object(db_query($sqld, $result->sid))) {
-
-      // Get sequence from chado database
-      $previous_db = tripal_db_set_active('chado');  // use chado database
-      $sqlc = "SELECT * FROM {feature} WHERE feature_id = '%s'";
-      $f_objc = db_fetch_object(db_query($sqlc, $f_objd->feature_id));
-      tripal_db_set_active($previous_db);  // now use drupal database
-      print tripal_feature_return_fasta($f_objc, $desc);
-    }
-  }
-}
-
-/*******************************************************************************
- *  This code is a duplicate of the do_search function but with the paging
- *  call replaced by a simle db_query call.
- */
-function tripal_do_search($keywords, $type, $join1 = '', $where1 = '1 = 1', $arguments1 = array(), $columns2 = 'i.relevance AS score', $join2 = '', $arguments2 = array(), $sort_parameters = 'ORDER BY score DESC') {
-  $query = search_parse_query($keywords);
-
-  if ($query[2] == '') {
-    form_set_error('keys', t('You must include at least one positive keyword with @count characters or more.', array('@count' => variable_get('minimum_word_size', 3))));
-  }
-  if ($query[6]) {
-    if ($query[6] == 'or') {
-      drupal_set_message(t('Search for either of the two terms with uppercase <strong>OR</strong>. For example, <strong>cats OR dogs</strong>.'));
-    }
-  }
-  if ($query === NULL || $query[0] == '' || $query[2] == '') {
-    return array();
-  }
-
-  // Build query for keyword normalization.
-  $conditions = "$where1 AND ($query[2]) AND i.type = '%s'";
-  $arguments1 = array_merge($arguments1, $query[3], array($type));
-  $join = "INNER JOIN {search_total} t ON i.word = t.word $join1";
-  if (!$query[5]) {
-    $conditions .= " AND ($query[0])";
-    $arguments1 = array_merge($arguments1, $query[1]);
-    $join .= " INNER JOIN {search_dataset} d ON i.sid = d.sid AND i.type = d.type";
-  }
-
-  // Calculate maximum keyword relevance, to normalize it.
-  // @coder-ignore: can't use placeholders since variable defines a join
-  $select = "SELECT SUM(i.score * t.count) AS score FROM {search_index} i " . $join . " WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d ORDER BY score DESC";
-  $arguments = array_merge($arguments1, array($query[4]));
-  $normalize = db_result(db_query_range($select, $arguments, 0, 1));
-  if (!$normalize) {
-    return array();
-  }
-  $columns2 = str_replace('i.relevance', '('. (1.0 / $normalize) .' * SUM(i.score * t.count))', $columns2);
-
-  // Build query to retrieve results.
-  // @coder-ignore: can't use placeholders since variable defines a join
-  $select = "SELECT i.type, i.sid, $columns2 FROM {search_index} i " . $join . " " . $join2 . " WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d";
-  $count_select =  "SELECT COUNT(*) FROM ($select) n1";
-  $arguments = array_merge($arguments2, $arguments1, array($query[4]));
-
-  // Do actual search query
-//  $result = pager_query("$select $sort_parameters", 10, 0, $count_select, $arguments);
-  $result = db_query("$select $sort_parameters", $arguments);
-  $results = array();
-  while ($item = db_fetch_object($result)) {
-    $results[] = $item;
-  }
-  return $results;
-}
-
-/**
- * Implements hook_coder_ignore().
- * Defines the path to the file (tripal_search.coder_ignores.txt) where ignore rules for coder are stored
- */
-function tripal_search_coder_ignore() {
-  return array(
-    'path' => drupal_get_path('module', 'tripal_search'),
-    'line prefix' => drupal_get_path('module', 'tripal_search'),
-  );
-}

+ 3 - 4
tripal_stock/tripal_stock.info

@@ -1,9 +1,8 @@
-; $Id$
-package = Tripal
 name = Tripal Stock
-version = 6.x-0.3.1b
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing, inserting and editing of stocks (including stock relationships and properties).
 core = 6.x
-
+project = tripal_stock
+package = Tripal
+version = 6.x-1.0
 dependencies[] = tripal_core
 dependencies[] = tripal_organism

+ 1 - 2
tripal_views/tripal_views.info

@@ -3,8 +3,7 @@ description = This module provides integration with Drupal Views. Other Tripal m
 core = 6.x
 project = tripal_core
 package = Tripal
-version = 6.x-0.4
-
+version = 6.x-1.0
 dependencies[] = views
 dependencies[] = ahah_helper
 dependencies[] = views_data_export

+ 2 - 2
tripal_views/views/handlers/chado_views_handler_field_counter.inc

@@ -10,7 +10,7 @@
  */
 class chado_views_handler_field_counter extends views_handler_field_counter {
 
-  function init =(&$view, $options) {
+  function init (&$view, $options) {
     include_once('chado_wrapper_functions.inc');
     parent::init($view, $options);
   }
@@ -92,4 +92,4 @@ class chado_views_handler_field_counter extends views_handler_field_counter {
     return parent::render($val);
   }
 
-}
+}

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