Browse Source

Moved Tripal GBrowse out to it's own git repository

Lacey Sanderson 12 years ago
parent
commit
df72dd3821

+ 0 - 177
extensions/tripal_gbrowse/node-tripal_gbrowse.tpl.php

@@ -1,177 +0,0 @@
-<?php
-// Developed by: Chad N.A Krilow at The University of Saskatchewan
-//
-// Purpose: This template provides the layout of the Tripal GBrowse Instances node (page)
-//   using the same templates used for the various Tripal GBrowse blocks. An I-Frame is 
-//	 included to show the representation of the GBrowse instance(including tracks). Along with 
-//	 the I-Frame, a link to open a external I-Frame in a new window is supplied
-//
-// To Customize the Stock Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes and it also includes Tripal GBrowse specific fields.
-//
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($node,TRUE).'</pre>';
- drupal_add_css('./tripal-node-templates.css');
-?>
-
-<?php if ($teaser) { 
-  
-  include('tripal_gbrowse/tripal_gbrowse_teaser.tpl.php');
-} else { ?>
-	  
-<script type="text/javascript">
- if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_gbrowse_toc_list').append('<li><a href="#'+id+'" class="tripal_gbrowse_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show corresponding item in details box
-      $(".tripal_gbrowse_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // make sure table of contents and the details
-         // box stay the same height
-         $("#tripal_gbrowse_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // base details show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/\?block=.*/);
-      if(block != null){
-         block_title = block.toString().replace(/\?block=/g,'');
-         $("#tripal_gbrowse-"+block_title+"-box").show();
-      } else {
-         $("#tripal_gbrowse-base-box").show();
-      }
-
-      $("#tripal_gbrowse_toc").height($("#tripal_gbrowse-base-box").parent().height());
-   });
-}
-</script>
-
-<style type="text/css">
-  /* these styles are specific for this template and is not included 
-     in the main CSS files for the theme as it is anticipated that the
-     elements on this page may not be used for other customizations */
-  #tripal_gbrowse_toc {
-     float: left;
-     width: 20%;
-     background-color: #EEEEEE;
-     -moz-border-radius: 15px;
-     border-radius: 15px;
-     -moz-box-shadow: 3px 3px 4px #888888;
-	  -webkit-box-shadow: 3px 3px 4px #888888;
-	  box-shadow: 3px 3px 4px #888888;
-     padding: 20px;
-     min-height: 200px;
-     border-style:solid;
-     border-width:1px;
-  }
-  #tripal_gbrowse_toc ul {
-    margin-left: 0px;
-    margin-top: 5px;
-    padding-left: 15px;
-  }
-  #tripal_gbrowse_toc_title {
-     font-size: 1.5em;
-  }
-  #tripal_gbrowse_toc_desc {
-    font-style: italic;
-  }
-  #tripal_gbrowse_details {
-     float: left;
-     width: 70%;
-     background-color: #FFFFFF;
-     -moz-border-radius: 15px;
-     border-radius: 15px;
-     -moz-box-shadow: 3px 3px 4px #888888;
-	  -webkit-box-shadow: 3px 3px 4px #888888;
-	  box-shadow: 3px 3px 4px #888888;
-     padding: 20px;
-     min-height: 200px;
-     margin-right: 10px;
-     border-style:solid;
-     border-width:1px;
-  }
-  #tripal_gbrowse-base-box img {
-    float: left;
-    margin-bottom: 10px;
-  }
-  #tripal_gbrowse-table-base {
-    float: left;
-    width: 400px;
-    margin-left: 10px;
-    margin-bottom: 10px;
-  }
-  #tripal_gbrowse_addtional_content {
-		clear:both;
-  	width: 100%;
-  }
-</style>
-
-<div id ="tripal_gbrowse_content">
-<div id="tripal_gbrowse_details" class="tripal_details"><h2>
-
-   <!-- Basic Details Theme -->
-   <?php include('tripal_gbrowse/tripal_gbrowse_details.tpl.php'); ?>
-
-   <!-- GBrowse Details -->
-   <?php 
-   global $account;
-   if(user_access('access database-related details',$account)){
-     include('tripal_gbrowse/tripal_gbrowse_database_details.tpl.php'); 
-	 }?>
-   <?php print $content ?>
-   
-    <!-- GBrowse Loaded Sources -->
-   <?php 
-     include('tripal_gbrowse/tripal_gbrowse_loaded_sources.tpl.php');
-     ?>
-   <?php print $content ?>
- 
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_gbrowse_toc" class="tripal_toc">
-   <div id="tripal_gbrowse_toc_title" class="tripal_toc_title">Resources</div>
-   <span id="tripal_gbrowse_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_gbrowse_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-</div>
-
-<!--- I-Frame Code Section --->
-<div id="tripal_gbrowse_addtional_content">
-
-	<!--- Include for file that makes the I-Frame and external window possible --->
- <?php include('tripal_gbrowse/tripal_gbrowse_gbrowse_instance.tpl.php'); ?>
-
-</div>
-<?php } ?>

+ 0 - 148
extensions/tripal_gbrowse/template.conf

@@ -1,148 +0,0 @@
-[GENERAL]
-description   = <#gbrowse_name#>
-db_adaptor    = Bio::DB::SeqFeature::Store
-db_args       = -adaptor DBI::mysql
-	      	-dsn dbi:mysql:database=<#database_name#>;host=localhost
-		-user 'www-data'
-
-plugins = BatchDumper FastaDumper Submitter
-
-# Web site configuration info
-gbrowse root = gbrowse
-stylesheet   = gbrowse.css
-buttons      = images/buttons
-js           = js
-tmpimages    = tmp
-
-region segment = 100000
-
-# advanced features
-balloon tips    = 1
-balloon style = GBox
-drag and drop = 1
-
-# one hour
-cache time    = 0
-
-# where to link to when user clicks in detailed view
-link          = AUTO
-
-# what image widths to offer
-image widths  = 450 640 800 1024
-
-# default width of detailed view (pixels)
-default width = 640
-
-# max and default segment sizes for detailed view
-max segment     = 500000
-default segment = 50000
-
-# zoom levels
-zoom levels    = 50 100 200 1000 2000 5000 10000 20000 40000 100000 200000 500000 1000000
-
-# whether to show the sources popup menu (0=false, 1=true; defaults to true)
-show sources   = 1
-
-# colors of the overview, detailed map and key
-overview bgcolor = #EAF3D1
-detailed bgcolor = #EAF3D1
-key bgcolor      = lightgrey
-
-# color of the selection rectangle  
-hilite fill    = honeydew
-hilite outline = darkseagreen
-
-# examples to show in the introduction
-#examples = MtChr1:325500..329900 MtChr1:182000..199000 MtChr1:148000..193000 MtChr3:42058653..42059652
-
-# "automatic" classes to try when an unqualified identifier is given
-automatic classes = Symbol Gene Clone
-
-### HTML TO INSERT AT VARIOUS STRATEGIC LOCATIONS ###
-# inside the <head></head> section
-head = 
-
-# at the top...
-#header = <font color="white">Pulse Crop GBrowse</font>
-
-# a footer
-#footer = <hr>
-#	<table width="100%"><TR><TD align="LEFT">
-#	For the source code for this browser, see the <a href="http://www.gmod.org">Generic Model Organism Database Project.</a>  For other questions, send
-#	mail to <a href="mailto:lacey.sanderson@usask.ca">lacey.sanderson@usask.ca</a>.
-#	</TD></TR></table>
-#	<hr><pre>$Id: Medicago Assembly 3.5, Pulse GBrowse v 1.0 02/02/2011 laceysanderson Exp $</pre>
-
-# Various places where you can insert your own HTML -- see configuration docs
-html1 = 
-#html2 = <p align="center"><b>All features are displayed on the Medicago 3.5 chromosomes regardless of species of origin.</b></p>
-html3 = 
-html4 = 
-html5 = 
-html6 = 
-
-# Advanced feature: custom balloons
-custom balloons = [balloon]
-                  delayTime = 500
-
-		  [GBox]
-                  balloonImage  = Box.png
-                  stem          = 0
-                  vOffset       = 20
-                  hOffset       = 20
-                  padding       = 1
-                  shadow        = 0
-
-
-# Advanced feature: an example of a customized popup mentu for rubber band selection
-[OVERVIEW SELECT MENU]
-width = 100
-html  =  <table style="width:100%"> 
-         <tr><th style="background:lightgrey">Overview</span></th></tr>
-         <tr><td><span style="color:blue;cursor:pointer" onclick="SelectArea.prototype.clearAndSubmit()">Zoom</span></td></tr>
-         <tr><td><span style="color:blue;cursor:pointer" onclick="SelectArea.prototype.cancelRubber()">Cancel</span></td></tr>
-        </table>
-
-
-[DETAIL SELECT MENU]
-width = 250
-html  = <table style="width:100%">
-         <tr><th style="background:lightgrey;cell-padding:5">SELECTION
-             <span style="right:0px;position:absolute;color:blue;cursor:pointer" onclick="SelectArea.prototype.cancelRubber()"> [X] </span> </th></tr>
-         <tr><td><span style="color:blue;cursor:pointer" onclick="SelectArea.prototype.clearAndSubmit()">Zoom in</span></td></tr>
-         <tr><td><span style="color:blue;cursor:pointer" onclick="SelectArea.prototype.clearAndRecenter()">Recenter on this region</span></td></tr>
-         <tr><td onmouseup="SelectArea.prototype.cancelRubber()"><a href="?plugin=FastaDumper;plugin_action=Go;name=SELECTION" target="_BLANK">
-               Dump selection as FASTA</a></td></tr>
-         <tr><td onmouseup="SelectArea.prototype.cancelRubber()"><a href="?name=SELECTION;plugin=Submitter;plugin_do=Go;Submitter.target=NCBI_BLAST" target="_BLANK">
-               Submit selection to NCBI BLAST</a></td></tr>
-       </table>
-
-# Configuration for submitter plugin (used in above menu)
-[Submitter:plugin]
-submitter = [NCBI_BLAST]
-            confirm   = 1
-            url       = http://www.ncbi.nlm.nih.gov/blast/Blast.cgi
-            seq_label = QUERY
-            PAGE      = Nucleotides
-            PROGRAM   = blastn
-            DATABASE  = nr
-            CLIENT    = web
-            CMD       = put
-
-
-
-# Default glyph settings
-[TRACK DEFAULTS]
-glyph       = generic
-height      = 8
-bgcolor     = cyan
-fgcolor     = cyan
-label density = 25
-bump density  = 100
-link = AUTO
-link_target = _blank
-
-[Genes]
-feature		= gene
-glyph		= transcript
-key		= Genes

+ 0 - 48
extensions/tripal_gbrowse/theme/tripal_gbrowse/tripal_gbrowse_database_details.tpl.php

@@ -1,48 +0,0 @@
-<?php
-// Developed by: Chad N.A Krilow at The University of Saskatchewan
-//
-// Purpose: Provide layout and content for the GBrowse database details. This
-//   includes database related fields in the tripal_gbrowse_instances table.
-//
-// Note: This template controls the layout/content for the default tripal_gbrowse node
-//   template (node-tripal_grbowse.tpl.php) and the Database Details Block
-//
-// Variables Available:
-//   - $node: a standard object which contains includes GBrowse Databse specific fields such as  
-//			 database_name, database_user, user_password, etc.
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($node,TRUE).'</pre>';
-?>  
-
-<?php
-
-$gbrowse = $node->gbrowse;
-
-?>
-<div id="tripal_gbrowse-database-box" class="tripal_gbrowse-info-box tripal-info-box">
-  <div class="tripal_gbrowse-info-box-title tripal-info-box-title"> Data Base Details</div>
-  <div class="tripal_gbrowse-info-box-desc tripal-info-box-desc"></div>
-
-   <?php //if the gbrowse is deleted/removed issue a warning
-   if(strcmp($gbrowse->is_obsolete,'t')==0){ 
-   ?>
-      <div class="tripal_gbrowse-obsolete">This GBrowse Instance is obsolete or has been deleted/removed</div>
-   <?php }?>
-   <table id="tripal_gbrowse-base-table" class="tripal_gbrowse-table tripal-table tripal-table-vert">
-      <tr class="tripal_gbrowse-table-even-row tripal-table-even-row">
-        <th>Data Base Name</th>
-        <td><?php print $node->gbrowse->database_name; ?></td>
-      </tr>
-      <tr class="tripal_gbrowse-table-odd-row tripal-table-odd-row">
-        <th nowrap>Database User Name</th>
-        <td><?php print $node->gbrowse->database_user; ?></td>
-      </tr>
-      <tr class="tripal_gbrowse-table-even-row tripal-table-even-row">
-        <th>User Password</th>
-        <td><?php print $node->gbrowse->user_password; ?></td>
-      </tr>     	                                
-   </table>
-</div>

+ 0 - 45
extensions/tripal_gbrowse/theme/tripal_gbrowse/tripal_gbrowse_details.tpl.php

@@ -1,45 +0,0 @@
-<?php
-// Developed by: Chad N.A Krilow at The University of Saskatchewan 
-//
-// Purpose: Provide layout and content for the GBrowse database details. This
-//   includes databse user specific fields in the tripal_gbrowse_instances table.
-//
-// Note: This template controls the layout/content for the default tripal_gbrowse node
-//   template (node-tripal_grbowse.tpl.php) and the Database Details Block
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes. It also includes GBrowse specific fields such as gbrowse_name, 
-//			 database_link, config_file.
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($node,TRUE).'</pre>';
-?> 
-
-
-<?php $gbrowse = $node->gbrowse; ?>
-
-<div id="tripal_gbrowse-base-box" class="tripal_gbrowse-info-box tripal-info-box">
-  <div class="tripal_gbrowse-info-box-title tripal-info-box-title"> GBrowse Details</div>
-  <div class="tripal_gbrowse-info-box-desc tripal-info-box-desc"></div>
-
-   <?php if(strcmp($gbrowse->is_obsolete,'t')==0){ ?>
-      <div class="tripal_gbrowse-obsolete">This GBrowse Instance is obsolete or has been deleted/removed</div>
-   <?php }?>
-   <table id="tripal_gbrowse-base-table" class="tripal_gbrowse-table tripal-table tripal-table-vert">
-      <tr class="tripal_gbrowse-table-even-row tripal-table-even-row">
-        <th>GBrowse Instance</th>
-        <td><?php print $node->gbrowse->gbrowse_name; ?></td>
-      </tr>
-      <tr class="tripal_gbrowse-table-odd-row tripal-table-odd-row">
-        <th nowrap>GBrowse Instance Link</th>
-        <td><?php print $node->gbrowse->gbrowse_link; ?></td>
-      </tr>
-      <tr class="tripal_gbrowse-table-even-row tripal-table-even-row">
-        <th>Configuration File</th>
-        <td><?php print $node->gbrowse->config_file; ?></td>
-      </tr>     	                                
-   </table>
-</div>

+ 0 - 28
extensions/tripal_gbrowse/theme/tripal_gbrowse/tripal_gbrowse_gbrowse_instance.tpl.php

@@ -1,28 +0,0 @@
-<?php
-// Developed by: Chad N.A Krilow at The University of Saskatchewan
-//
-// Purpose: Provide a in window I-Frame that displays the GBrowse instance. As well,
-// a link to open the GBrowse instance in a external window is provided. If the window can not be
-// opened a warning is issued
-//   
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes. Here it is utilized for accessing the link to a specific GBrowse instance.
-//
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($node,TRUE).'</pre>';
-?>
-
-<br />
-<h3><a href="<?php print $node->gbrowse->gbrowse_link; ?>" target="_blank">Open GBrowse Instance in new Window</a></h3>
-<br />
-
-<iframe src="<?php print $node->gbrowse->gbrowse_link; ?>" width="100%" height="800">
-  <p>Your browser does not support iframes.</p>
-</iframe>

+ 0 - 42
extensions/tripal_gbrowse/theme/tripal_gbrowse/tripal_gbrowse_loaded_sources.tpl.php

@@ -1,42 +0,0 @@
-<?php
-// Developed by: Chad N.A Krilow at The University of Saskatchewan
-//
-// Variables Available:
-//   - $node: a standard object which contains includes GBrowse Databse specific fields such as  
-//			 database_name, database_user, user_password, etc.
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($node,TRUE).'</pre>';
-?>  
-
-<?php
-
-$gbrowse = $node->gbrowse;
-$node->sources = tripal_gbrowse_getloaded_sources($node->gbrowse);
-
-?>
-<div id="tripal_gbrowse-source-box" class="tripal_gbrowse-info-box tripal-info-box">
-  <div class="tripal_gbrowse-info-box-title tripal-info-box-title"> Loaded Sources</div>
-  <div class="tripal_gbrowse-info-box-desc tripal-info-box-desc">A source can be either a library or analysis or any other grouping of features.</div>
-
-   <?php //if the gbrowse is deleted/removed issue a warning
-   if(strcmp($gbrowse->is_obsolete,'t')==0){ 
-   ?>
-      <div class="tripal_gbrowse-obsolete">This GBrowse Library is obsolete or has been deleted/removed</div>
-   <?php }?>
-   <table id="tripal_gbrowse-base-table" class="tripal_gbrowse-table tripal-table tripal-table-vert">
-   <tr><th>Name</th></tr>
-   
-   
-   <?php 
-   if(!empty($node->sources)){
-   	foreach($node->sources as $key => $source){
-   ?>
-      <tr class="tripal_gbrowse-table-even-row tripal-table-even-row">
-        <td><?php print $source; ?></td>
-      </tr>
-		<?php }} //end of foreach library & end of if statement ?>  	                                
-   </table>
-</div>

+ 0 - 34
extensions/tripal_gbrowse/theme/tripal_gbrowse/tripal_gbrowse_teaser.tpl.php

@@ -1,34 +0,0 @@
-<?php
-// Developed by: Chad N.A Krilow at The University of Saskatchewan
-//
-// Purpose: Provide layout and content for the Tripal Gbrowse details.Represents
-// what the user will see if the there is no information in the node
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, gbrowse_id.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($node,TRUE).'</pre>';
-?>
-
-<div id="tripal_gbrowse-base-box" class="tripal_gbrowse-info-box tripal-info-box">
-  <div class="tripal_gbrowse-info-box-title tripal-info-box-title">
-  
-  	<!-- Title -->  	
-    <?php print l($node->gbrowse->gbrowse_name, 'node/'.$node->nid); ?>
-
-		
-  </div>
-  <div class="tripal_gbrowse-info-box-desc tripal-info-box-desc"></div>
-
-<p>This is a representation of a created GBrowse instance.<p>
-<?php print l('See More Details', 'node/'.$node->nid); ?>
-
- 
-</div>

+ 0 - 647
extensions/tripal_gbrowse/tripal_gbrowse.align_features.inc

@@ -1,647 +0,0 @@
-<?php
-
-/**
- * Form to initialize an align library tripal job
- */
-function tripal_gbrowse_align_features_form ($form_state) {
-  $form = array();
-  
-  // compile all analysis' as options
-  $analysis_options = array();
-  $results = tripal_core_chado_select('analysis',array('analysis_id','name', 'program'), array());
-  foreach ($results as $r) {
-    $analysis_options[ 'A'.$r->analysis_id ] = $r->name .' --'.$r->program;
-  }
-  
-  // compile all libraries as options
-  $library_options = array();
-  $results = tripal_core_chado_select('library',array('library_id','name', 'uniquename'), array());
-  foreach ($results as $r) {
-    $library_options[ 'L'.$r->library_id ] = $r->name .' --'.$r->uniquename;
-  }  
-  
-  $form['description'] = array(
-    '#type' => 'item',
-    '#value' => 'This form allows you to select a query library/analysis and align the '
-      .'features that are part of that query library/analysis against those from a database '
-      .'library/analysis using BLAST. Depending upon the Alignment Criteria, the top BLAST '
-      .'result(s) for each query feature will be used to determine the location of the query '
-      .'feature on a database feature.',
-  );
-  
-  $form['q'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'Features to be Aligned (Query)',
-    '#description' => 'Please select the library or analysis below which groups the features you '
-      .'want aligned together.',
-  );
-  
-  $form['q']['query'] = array(
-    '#type' => 'select',
-    '#title' => 'Query Features',
-    '#options' => array(
-      'Libraries' => $library_options,
-      "Analaysis'" => $analysis_options
-    ),
-    '#default_value' => $form_state['values']['query'],
-  );
-  
-  $form['d'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'Features to Align To (Database)',
-    '#description' => 'Please select the library of analysis below, which contains the features '
-      .'you want to align the query features selected above to. Only features in the selected '
-      .'library/analysis with sequence data will be used.',
-  );
-
-  $form['d']['database'] = array(
-    '#type' => 'select',
-    '#title' => 'Database Features',
-    '#options' => array(
-      'Libraries' => $library_options,
-      "Analaysis'" => $analysis_options
-    ),
-    '#default_value' => $form_state['values']['database'],
-  );
-  
-  $form['b'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'Alignment Criteria',
-  );
-  
-  $form['b']['program'] = array(
-  	'#type' => 'radios',
-  	'#title' => 'Alignment Program',
-  	'#options' => array(
-  		'blast' => 'BLAST',
-  		'blat' => 'BLAT',
-  	),
-  	'#default_value' => 'blat',
-  );
-
-  $form['b']['blat'] = array(
-  	'#type' => 'fieldset',
-  	'#title' => 'BLAT Options',
-  	'#collapsible' => TRUE,
-		'#collapsed' => TRUE,
-  );
-  
-  $form['b']['blat']['min_identity'] = array(
-  	'#type' => 'textfield',
-  	'#title' => 'Minimum Identity',
-  	'#default_value' => '90',
-  );
-  
-  $form['b']['blast'] = array(
-  	'#type' => 'fieldset',
-  	'#title' => 'BLAST Options',
-  	'#collapsible' => TRUE,
-		'#collapsed' => TRUE,
-  );
-  
-  $form['b']['blast']['gapped_alignment'] = array(
-  	'#type' => 'checkbox',
-  	'#title' => 'Gapped Alignment?',
-  	'#default_value' => TRUE,
-  );
-  
-  $form['b']['blast']['evalue'] = array(
-  	'#type' => 'textfield',
-  	'#title' => 'Expectation Values (E-value) Cutoff',
-  	'#description' => 'To enter in scientific notation (ie: 5 x 10-6), enter [base number]e[power] (ie: 5e-6)',
-  	'#default_value' => 10.0
-  );
-  
-  $form['g'] = array(
-  	'#type' => 'fieldset',
-  	'#title' => 'GBrowse Information',
-  );
-  
-  $form['g']['source'] = array(
-  	'#type' => 'textfield',
-  	'#title' => 'Source of Features',
-  	'#description' => 'The source of the features grouped by the selected query library'
-  );
-  
-  //Sending query to the database
-  $resource = db_query('SELECT * FROM {tripal_gbrowse_instances}');
-	$items = array();
-	while($record = db_fetch_object($resource)){
-		$items[$record->gbrowse_id]= $record->gbrowse_name;
-	}
-   
-  //GBrowse Instances
-  $form['g']['gbrowse_id'] = array(
-    '#type' => 'select',
-    '#title' => t('GBrowse Instances'),
-    '#options' => $items,
-    '#description' => t('Selected GBrowse Instances to load the query features into.'),
-  );
-  
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#name' => 'align',
-    '#value' => 'Align Features',
-  );
-  
-  return $form;
-}
-
-/**
- * Form submit to initialize an align library tripal job
- */
-function tripal_gbrowse_align_features_form_submit ($form, &$form_state) {
-  
-  switch($form_state['clicked_button']['#name']) {
-    case 'align':
-      $options = array();
-      // Query
-      if (preg_match('/(L|A)(\d+)/',$form_state['values']['query'], $matches)) {
-        if ($matches[1] == 'L') {
-          $options['query_type'] = 'library';
-        } else {
-          $options['query_type'] = 'analysis';
-        }
-        $options['query_id'] = $matches[2];
-      }
-      
-      // Database
-      if (preg_match('/(L|A)(\d+)/',$form_state['values']['database'], $matches)) {
-        if ($matches[1] == 'L') {
-          $options['db_type'] = 'library';
-        } else {
-          $options['db_type'] = 'analysis';
-        }
-        $options['db_id'] = $matches[2];
-      } 
-      
-      $options['source'] = $form_state['values']['source'];
-      
-      // db options
-      $sql = 'SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id = %d';
-      $r = db_fetch_object(db_query($sql,$form_state['values']['gbrowse_id']));
-      $options['dbname'] = $r->database_name;
-      $options['dbuser'] = $r->database_user;
-      $options['dbpass'] = $r->user_password;
-
-			if ($form_state['values']['program'] == 'blat') { 
-				// blat options
-				$options['min_identity'] = $form_state['values']['min_identity'];
-				
-				global $user;
-				tripal_add_job(
-					'Align '.$options['query_type'].' features ('.$options['query_type'].'_id='.$options['query_id'].')',
-					'tripal_gbrowse',
-					'tripal_gbrowse_align_features_by_blat',
-					array(serialize($options)),
-					$user->uid
-				);			
-			} elseif ($form_state['values']['program'] == 'blast') {      
-				// blast options
-				$options['evalue'] = $form_state['values']['evalue'];
-				$options['gapped_alignment'] = $form_state['values']['gapped_alignment'];
-			
-				global $user;
-				tripal_add_job(
-					'Align '.$options['query_type'].' features ('.$options['query_type'].'_id='.$options['query_id'].')',
-					'tripal_gbrowse',
-					'tripal_gbrowse_align_features_by_blast',
-					array(serialize($options)),
-					$user->uid
-				);
-      }
-      
-    break;
-  }
-}
-
-/**
- * Aligns feature from a query library/analysis to a database library/analysis,
- * saving the results as a GFF3 file and then loading it into the selected gbrowse instance
- *
- * @param $options
- *   An array containing options needed to align features and create featurelocs
- *    -query_type: the type of chado grouping containing query features (either library or analysis)
- *    -query_id: the library_id/analysis_id containing the query features
- *    -db_type: the type of chado grouping containing database features (either library or analysis)
- *    -db_id: the library_id/analysis_id containing the database features
- *    -dbname: name of the MySQL GBrowse database to load into
- *    -dbuser: name of the user with permission to load into the above database
- *    -dbpass: the password for the above user
- */
-function tripal_gbrowse_align_features_by_blast ($options) {
-  $options = unserialize($options);
-  print 'Query: '.$options['query_type'].' where '.$options['query_type'].'_id='.$options['query_id']."\n";
-  print 'Database: '.$options['db_type'].' where '.$options['db_type'].'_id='.$options['db_id']."\n";
-  
-  // Generate FASTA ---------------------------------------
-  print "\nGenerating fasta files for query and database...\n";
-  $query_file = tripal_gbrowse_export_fasta_for_features( $options['query_type'], $options['query_id'], TRUE );
-  print "\t".$query_file['file']."\n";
-  
-  $db_file = tripal_gbrowse_export_fasta_for_features( $options['db_type'], $options['db_id'], TRUE, TRUE );
-  print "\t".$db_file['file']."\n";
-  
-  // Align using BLAST ------------------------------------
-  print "\nAligning features using BLAST...\n";
-  
-  print "\tFormating Database FASTA into BLASTdb...\n";
-  $db = '/tmp/exported_'.$options['db_type'].'_'.$options['db_id'];
-  $formatdb_cmd = 'formatdb -n '.$db.' -p F -i '.$db_file['file'];
-	print "\t\t".$formatdb_cmd."\n";  
-  exec($formatdb_cmd);
-	
-	print "\tExecuting BLAST...\n";
-	$blast_outfile = $db.'_by_'.$options['query_type'].'_'.$options['query_id'].'.blast.xml';
-	$blastall_cmd = 'blastall -p blastn -d '.$db.' -i '.$query_file['file'].' -m 7 -o '.$blast_outfile.' -e '.$options['evalue'];
-	if ($options['gapped_alignment']) {
-		$blastall_cmd .= ' -g';
-	}
-	print "\t\t".$blastall_cmd."\n";
-	exec($blastall_cmd);
-  
-  // Parse BLAST results ----------------------------------
-  print "\nParsing Blast Results into GFF3...\n";
-  $gff3_file = $db.'_by_'.$options['query_type'].'_'.$options['query_id'].'.gff3';
-  $fgff3 = fopen($gff3_file, 'w');
-  fwrite($fgff3, "##gff-version 3\n");
-  $iteration = tripal_gbrowse_get_next_xml_record ($blast_outfile, "<Iteration>");
-  while ($iteration) {
-  	//print "Record:".$iteration['record']->asXML()."\n";
-  	//print "Query: ".$iteration['record']->{'Iteration_query-def'}."\n";
-		
-		// Find the best Hit by looking at the bit scores of the hsps
-		// the larger the bit score the better the alignment
-		$hits = array();
-		$scores = array();
-  	foreach ($iteration['record']->Iteration_hits->Hit as $hit) {
-  		$score = 0;
-  		$num = 0;
-  		foreach ($hit->{'Hit_hsps'}->{'Hsp'} as $hsp) {
-  			//print 'HSP:'.$hsp->asXML()."\n";
-  			$score = $score + $hsp->{'Hsp_bit-score'};
-  			$num++;
-  		}
-  		$avg = round($score / $num,2);
-  		$hit->{'Hit_bit-score'} = $avg;
-  		$hits[] = array('score' => $avg, 'hit' => $hit);
-  	}
-  	usort($hits, 'tripal_gbrowse_sort_by_score');
-  	$best_hit = $hits[0]['hit'];
-  	//print "\tBest Hit:".$best_hit->Hit_def.' ('.$best_hit->{'Hit_bit-score'}.")\n";
-  	
-  	// generate gff3 for the best hit 
-  	$query_name = $iteration['record']->{'Iteration_query-def'};
-  	$db_name = $best_hit->Hit_def;  
-  	if (isset($db_file['noseq_features'][$db_name])) {
-  	  $db_offset = $db_file['noseq_features'][$db_name]['start'];
-  	  $db_name = $db_file['noseq_features'][$db_name]['parent']['uniquename'];
-  	} else {
-  	  $db_offset = 0;
-  	}
-		$lines = array();
-		$hit_start = 99999999999999999999;
-		$hit_end = 0;
-  	foreach ($best_hit->{'Hit_hsps'}->{'Hsp'} as $hsp) {
-  		if ($hit_start > (int) $hsp->{'Hsp_hit-from'}[0]) { $hit_start = (int) $hsp->{'Hsp_hit-from'}[0]; } 
-  		if ($hit_end < (int) $hsp->{'Hsp_hit-to'}[0]) { $hit_end = (int) $hsp->{'Hsp_hit-to'}; }
-  		$lines[] = implode("\t", array(
-  			$db_name, 
-  			$options['source'],
-  			'match_part',
-  			$hsp->{'Hsp_hit-from'} + $db_offset,
-  			$hsp->{'Hsp_hit-to'} + $db_offset,
-  			$hsp->{'Hsp_bit-score'},
-  			'.',
-  			'.',
-  			'ID='.$query_name.'_'.$hsp->{'Hsp_num'}.';Parent='.$query_name
-  		))."\n";
-  	}
-  	fwrite($fgff3, implode("\t", array(
-			$db_name, 
-			$options['source'],
-			'match',
-			$hit_start + $db_offset,
-			$hit_end + $db_offset,
-			$best_hit->{'Hit_bit-score'},
-			'.',
-			'.',
-			'ID='.$query_name.';Name='.$query_name
-		))."\n");
-		fwrite($fgff3,implode('',$lines));
-  	
-  	// get next iteration xml record
-  	$last_iteration = $iteration;
-  	//print "Getting Iteration...\n";
-  	$iteration = tripal_gbrowse_get_next_xml_record ($blast_outfile, "<Iteration>", $last_iteration['start_line_num']);
-  }
-  
-  print "\nLoading GFF3 into GBrowse...\n";
-  //The loading script: bp_seqfeature_load.pl, allows loading of data to specific file 
-  $command= "bp_seqfeature_load.pl -u '" .$options['dbuser']. "' -p '" .$options['dbpass']. "' -d " .$options['dbname']. " " . $gff3_file;
-  print "\t".$command."\n";
-
-  exec($command);
-}
-
-/**
- * Aligns feature from a query library/analysis to a database library/analysis,
- * saving the results as a GFF3 file and then loading it into the selected gbrowse instance
- *
- * @param $options
- *   An array containing options needed to align features and create featurelocs
- *    -query_type: the type of chado grouping containing query features (either library or analysis)
- *    -query_id: the library_id/analysis_id containing the query features
- *    -db_type: the type of chado grouping containing database features (either library or analysis)
- *    -db_id: the library_id/analysis_id containing the database features
- *    -dbname: name of the MySQL GBrowse database to load into
- *    -dbuser: name of the user with permission to load into the above database
- *    -dbpass: the password for the above user
- */
-function tripal_gbrowse_align_features_by_blat ($options,$job_id) {
-  $options = unserialize($options);
-  print 'Query: '.$options['query_type'].' where '.$options['query_type'].'_id='.$options['query_id']."\n";
-  print 'Database: '.$options['db_type'].' where '.$options['db_type'].'_id='.$options['db_id']."\n";
-  
-  // Generate FASTA ---------------------------------------
-  print "\nGenerating fasta files for query and database...\n";
-  $query_file = tripal_gbrowse_export_fasta_for_features( $options['query_type'], $options['query_id'], TRUE );
-  print "\t".$query_file['file']."\n";
-  tripal_job_set_progress($job_id, 12);
-  
-  $db_file = tripal_gbrowse_export_fasta_for_features( $options['db_type'], $options['db_id'], TRUE, TRUE );
-  print "\t".$db_file['file']."\n";
-  tripal_job_set_progress($job_id, 25);
-  
-  // Align using BLAT ------------------------------------
-  print "\nAligning features using BLAT...\n";
-	$blat_outfile = '/tmp/alignment_'.$options['db_type'].'-'.$options['db_id'].'_by_'.$options['query_type'].'-'.$options['query_id'].'.psl';
-	$blat_cmd = 'blat '.$db_file['file'].' '.$query_file['file'].' -q=dnax -t=dnax -noHead -minIdentity='.$options['min_identity'].' '.$blat_outfile;
-	print "\t\t".$blat_cmd."\n";
-	exec($blat_cmd);
-	tripal_job_set_progress($job_id, 50);
-	
-	// Parse BLAST results ----------------------------------
-	$total_lines = trim(`wc --lines < $blat_outfile`);
-	$interval = intval($total_lines/5);
-	$percent_per_line = 25/$total_lines;
-	$num_lines = 0;
-	$query_seq = array();
-	
-	print "\nParsing BLAT results into GFF3 (".$total_lines." lines)...\n";
-	$gff3_file = '/tmp/alignment_'.$options['db_type'].'-'.$options['db_id'].'_by_'.$options['query_type'].'-'.$options['query_id'].'.gff3';
-  $fgff3 = fopen($gff3_file, 'w');
-  fwrite($fgff3, "##gff-version 3\n");
-	$bh = fopen($blat_outfile, 'r');
-	while (!feof($bh)) {
-		$line = explode("\t", fgets($bh));
-		$num_lines++;
-		if (($num_lines%$interval) == 0) { tripal_job_set_progress($job_id, intval($percent_per_line * $num_lines)); }
-		
-		$print_match = TRUE;
-    $db_name = $line[13];
-  	if (isset($db_file['noseq_features'][$db_name])) {
-  	  $db_offset = $db_file['noseq_features'][$db_name]['start'];
-  	  $db_name = $db_file['noseq_features'][$db_name]['parent']['uniquename'];
-  	} else {
-  	  $db_offset = 0;
-  	}
-  	
-  	$query_id = $line[9];
-  	if (!isset($query_seq[ $line[9] ])) {
-  		$query_seq[ $line[9] ]['id'] = 0;
-  		$query_seq[ $line[9] ]['start'] = $line[15] + $db_offset;
-  		$query_seq[ $line[9] ]['end'] = $line[16] + $db_offset;
-  		$query_id .= '_0';
-  	} elseif ( abs($line[15]+$db_offset-$query_seq[ $line[9] ]['start']) < 5 ) {
-  		$print_match = FALSE;
-  		$query_id .= '_' . $query_seq[ $line[9] ]['id'];
-  	}else {
-  		$query_seq[ $line[9] ]['id']++;
-  		$query_id .= '_' . $query_seq[ $line[9] ]['id'];
-  	}
-  	
-		// match line
-		if ($print_match) {
-			fwrite($fgff3, implode("\t", array(
-				$db_name, 
-				$options['source'],
-				'match',
-				$line[15] + $db_offset,
-				$line[16] + $db_offset,
-				'.',
-				$line[8][1],
-				'.',
-				'ID='.$query_id.';Name='.$line[9]
-			))."\n");
-		}
-		
-		// match parts
-		$parts_size = explode(',',trim($line[18]));
-		$parts_start = explode(',',trim($line[20]));
-		foreach ($parts_size as $k => $length) {
-
-			if (!empty($parts_start[$k])) {
-				fwrite($fgff3, implode("\t", array(
-					$db_name, 
-					$options['source'],
-					'match_part',
-					$parts_start[$k] + $db_offset,
-					$parts_start[$k] + $length + $db_offset,
-					'.',
-					$line[8][1],
-					'.',
-					'ID='.$query_id.'_'.$k.';Parent='.$query_id
-				))."\n");
-  		}
-  		
-		}
-	}
-	tripal_job_set_progress($job_id, 75);
-	
-	// Load into GBrowse ------------------------------------
-  print "\nLoading GFF3 into GBrowse...\n";
-  //The loading script: bp_seqfeature_load.pl, allows loading of data to specific file 
-  $command= "bp_seqfeature_load.pl -u '" .$options['dbuser']. "' -p '" .$options['dbpass']. "' -d " .$options['dbname']. " " . $gff3_file;
-  print "\t".$command."\n";
-	exec($command);
-
-}
-
-/**
- * Creates a fasta file for a given chado grouping of features
- *
- * @param $type
- *   The type of chado grouping. Allowed values are either library or analysis
- * @param $id
- *   The library_id/analysis_id of the chado grouping
- * @return
- *   The name of the multi-fasta file containing records for all features with residues
- *   in the supplied library/analysis
- */
-function tripal_gbrowse_export_fasta_for_features ($type, $id, $use_parent_seq = FALSE, $save_offset = FALSE) {
-
-  $fasta_file = '/tmp/exported_fasta-'.$type.'-'.$id.'.fasta';
-  $noseq_features = array();
-  
-  $fh = fopen($fasta_file,'w');
-  
-  $sql = 'SELECT f.uniquename, f.residues, fl.fmin, fl.fmax, fl.srcfeature_id as parent_feature_id FROM feature f '
-  	.'LEFT JOIN featureloc fl ON fl.feature_id=f.feature_id ';
-  $parent_sql = 'SELECT p.feature_id as parent_feature_id, p.uniquename as parent_uniquename, count(fl.feature_id) FROM feature p '
-  	.'LEFT JOIN featureloc fl ON fl.srcfeature_id=p.feature_id '
-  	."WHERE fl.feature_id IN (SELECT feature_id FROM feature WHERE residues='') AND ";
-  if ($type == 'library') { 
-  	$sql .= 'LEFT JOIN library_feature lf ON f.feature_id=lf.feature_id WHERE lf.library_id=%d';
-  	$parent_sql .= 'fl.feature_id IN (SELECT feature_id FROM library_feature WHERE library_id=%d) GROUP BY p.uniquename, p.feature_id';
-    
-  } elseif ($type == 'analysis') {
-  	$sql .= 'LEFT JOIN analysisfeature af ON f.feature_id=af.feature_id WHERE af.analysis_id=%d';
-		$parent_sql .= 'fl.feature_id IN (SELECT feature_id FROM analysisfeature WHERE analysis_id=%d) GROUP BY p.uniquename, p.feature_id';
-    $resource = db_query($sql, $id);
-  } else {
-    print "ERROR: Unable to generate FASTA due to unrecognized type -".$type."!\n";
-    return FALSE;
-  }
-
-  
-  // check if some don't have sequence but are aligned on a parent who does
-	//print "SQL: ".$parent_sql."\n";
-  $resource = db_query($parent_sql, $id);
-	$parent_seq = array();
-	$residues_seq = 'SELECT residues FROM feature WHERE feature_id=%d';
-  while ($r = db_fetch_object($resource)) {
-  	//print 'Creating index for '.$r->parent_feature_id. " (".$r->parent_uniquename.")\n";
-  	$seq = db_fetch_object(db_query($residues_seq, $r->parent_feature_id));
-  	//print "Residues:".$seq->residues."\n";
-  	if (!empty($seq->residues)) {
-	  	//print "\tGot Seq!\n";
-	  }
-		$parent_seq[ $r->parent_feature_id ] = array(
-			'residues' => $seq->residues,
-			'uniquename' => $r->parent_uniquename
-		);
-  }
-  
-	$resource = db_query($sql, $id);
-  while ($r = db_fetch_object($resource)) {
-    if (!empty($r->residues)) {
-      fwrite($fh, '>'.$r->uniquename."\n");
-      fwrite($fh, wordwrap($r->residues,80,"\n",TRUE)."\n");
-    } else {
-	    //print $r->uniquename." (based on ".$r->parent_feature_id.' -'.$parent_seq[$r->parent_feature_id]['uniquename'].")\n";
-      if (!empty($parent_seq[$r->parent_feature_id]['residues'])) {
-      	//print "\tHave Seq\n";
-      	fwrite($fh, '>'.$r->uniquename." (based on ".$parent_seq[$r->parent_feature_id]['uniquename'].")\n");
-        $seq = substr($parent_seq[$r->parent_feature_id]['residues'], $r->fmin, $r->fmax - $r->fmin);
-        fwrite($fh, wordwrap($seq,80,"\n",TRUE)."\n");
-        if ($save_offset) {
-          $noseq_features[ $r->uniquename ] = array(
-            'start' => $r->fmin,
-            'end' => $r->fmax,
-            'parent' => array(
-              'uniquename' => $parent_seq[$r->parent_feature_id]['uniquename'],
-            ),
-          );
-        }
-      }
-    }
-  }
-  
-  fclose($fh);
-  return array(
-    'file' => $fasta_file,
-    'noseq_features' => $noseq_features
-  );
-}
-
-/**
- * Retrieves the next xml record with $record_identifier
- *
- * Assumption: the end tag for $record_identifier is one line before the next opening tag
- * @param $xml_file
- *   The file containing the xml records; must supply the full path
- * @param $record_identifier
- *   The opening tag enclosing a record (ie: <Iteration>)
- * @param $last_record_line_num
- *   The line number of the openin tag for the last record
- * 
- * @return
- *   An array describing the next xml record
- *    -record: the simpleXML record
- *    -start_line_num: the line number in the file that this record starts at
- *    -end_line_num: the line number in the file that this record ends at
- */
-function tripal_gbrowse_get_next_xml_record ($xml_file, $record_identifier, $last_record_line_num = NULL) {
-
-	// If first record ------------------------------------------------
-	if (!$last_record_line_num) {
-		$cmd = 'grep -n "'.$record_identifier.'" -m 2 '.$xml_file;
-		exec($cmd, $line_num_raw);
-
-		// get start of next record
-		if (preg_match('/(\d+):.*/',$line_num_raw[0],$matches)) {
-			$start = $matches[1];
-		} else {
-			return FALSE;
-		}
-
-		// get end of next record
-		if (preg_match('/(\d+):.*/',$line_num_raw[1],$matches)) {
-			$end = $matches[1] -1;
-		} else {
-			return FALSE;
-		}
-
-	// If not first record --------------------------------------------
-	} else {
-
-		$cmd = 'tail --lines=+'.($last_record_line_num+1).' '.$xml_file.' 2>/dev/null | grep -n "'.$record_identifier.'" -m 2 2>/dev/null ';
-		exec($cmd, $line_num_raw);
-
-		// get start of next record
-		if (preg_match('/(\d+):.*/',$line_num_raw[0],$matches)) {
-			$start = $matches[1] + $last_record_line_num;
-		} else {
-			return FALSE;
-		}
-
-		// get end of next record
-		if (preg_match('/(\d+):.*/',$line_num_raw[1],$matches)) {
-			$end = $matches[1] + $last_record_line_num -1;
-		} else {
-			return FALSE;
-		}
-		
-	}
-	
-	$cmd = 'tail --lines=+'.$start.' '.$xml_file.' 2>/dev/null | head -n '.($end-$start+1).' 2>/dev/null';
-	exec($cmd, $xml);
-	
-	//print "XML:".implode("\n",$xml)."\n";
-	if (!$xml) {
-		return FALSE;
-	}
-	
-	$xml_record = new SimpleXMLElement(implode("\n",$xml));
-	return array(
-		'record' => $xml_record,
-		'start_line_num' => $start,
-		'end_line_num' => $end,
-	);
-}
-
-/**
- * Custom sort function to be used with usort
- * Sorts an array( 'score' => \d+, 'hit' => simplexml obj)
- */
-function tripal_gbrowse_sort_by_score ($a, $b) {
-
-	if ($a['score'] == $b['score']) {
-		return 0;
-	} elseif ($a['score'] < $b['score']) {
-		return 1;
-	} else {
-		return -1;
-	}
-}

+ 0 - 5
extensions/tripal_gbrowse/tripal_gbrowse.info

@@ -1,5 +0,0 @@
-; $Id$ 
-name = "GBrowse Management" 
-description = "Provides an interface to sync Tripal/Chado Features with a specified GBrowse instance. Management of GBrowse instances including creation and deletion is also provided." 
-core = 6.x
-package = Tripal Extensions

+ 0 - 119
extensions/tripal_gbrowse/tripal_gbrowse.install

@@ -1,119 +0,0 @@
-<?php
-// $Id$
-
-/**
- * @file
- * This file contains all the functions which describe and implement drupal database tables
- * needed by this module. This module was developed by Chad N.A. Krilow and Lacey-Anne Sanderson, 
- * University of Saskatchewan. 
- *
- * The GBrowse manamgenet module allows you to sync data in a chado/Tripal instance with
- * multiple GBrowse/mysql instances as well as manage and create such GBrowse instances
- */
-
-/**
- * Implementation of hook_install()
- */
-function tripal_gbrowse_install() {
-	drupal_install_schema('tripal_gbrowse');
-}
-
-
-
-function tripal_gbrowse_update_2 (&$sandbox) {
-
-	$ret = array();
-	
-  db_add_field($ret, 'tripal_gbrowse_instances', 'nid', array('type' => 'int','unsigned' => FALSE, 'not null' => TRUE));
-  
-  db_add_field($ret, 'tripal_gbrowse_instances', 'vid', array('type' => 'int','unsigned' => FALSE, 'not null' => TRUE));
-  
-  return $ret;
-}
-
-
-/**
- * Implementation of hook_uninstall() 
- */
-function tripal_gbrowse_uninstall() {
-	drupal_uninstall_schema('tripal_gbrowse');
-}
-
-/**
- * Implementation of hook_schema()
- */
-function tripal_gbrowse_schema() {
-
-	//specification for 'tripal_gbrowse_instances'
-	$schema['tripal_gbrowse_instances'] = array(
-		
-		'fields' => array(
-
-			//a int field that cannot be null and acts as a unique identifier for all nid's
-      'nid' => array(
-				'type' => 'int',
-				'unsigned' => FALSE,
-				'not null' => TRUE,
- 	 	  ),
-		
-	    //a int field that cannot be null and is vid 	  
-  		'vid' => array(
-   	   	'type' => 'int',
-   	   	'unsigned' => FALSE,
-   	   	'not null' => TRUE,
-  	  ),
-			
-	    //a serial field that cannot be null and acts as a unique identifier for all gbrowse instances
-      'gbrowse_id' => array(
-				'type' => 'serial',
-				'unsigned' => TRUE,
-				'not null' => TRUE,
- 	 	  ),
-		
-	    //a varchar field that cannot be null and is the name of a gbrowse instance  	  
-  		'database_name' => array(
-   	   	'type' => 'varchar',
-   	   	'not null' => TRUE,
-  	  ),
-   	 	
-      //a varchar field, not null and is name of a mysql user that has insert and select permissions on the database
-    	 'database_user' => array(
-   	   	'type' => 'varchar',
-   	   	'not null' => TRUE,
-    	),
-    	 	
-	    //user_password: a varchar field that is the password for the above user 	
-    	'user_password' => array(
-   	   	'type' => 'varchar',
-   	   	'not null' => TRUE,
-    	),
-    	
-      //name: a varchar which is a human-readable name for the gbrowse instance    	
-    	'gbrowse_name' => array(
-   	   	'type' => 'varchar',
-   	   	'not null' => TRUE,
-    	),
-    	
-    	
-      //link: a varchar which is the link to the gbrowse instance    	
-    	'gbrowse_link' => array(
-   	   	'type' => 'varchar',
-   	   	'not null' => TRUE,
-    	),
-    	
-    	
-      //config_file: fully qualified location to the gbrowse configuration file    	
-    	'config_file' => array(
-   	   	'type' => 'varchar',
-   	   	'not null' => TRUE,
-    	),
-  	  	
-    ),//end of shema
-  	
-  	'primary key' => array('gbrowse_id'),
-	
-	);
-
-  return $schema;
-}
-

+ 0 - 2994
extensions/tripal_gbrowse/tripal_gbrowse.module

@@ -1,2994 +0,0 @@
-<?php
-// $Id$
-
-/**
- * @file
- * This file contains all the functions which provide functionality to this module.
- * This module was developed by Chad N.A. Krilow and Lacey-Anne Sanderson, 
- * University of Saskatchewan. 
- *
- * The GBrowse manamgenet module allows you to sync data in a chado/Tripal instance with
- * multiple GBrowse/mysql instances as well as manage and create such GBrowse instances
- */
-
-include('tripal_gbrowse.align_features.inc');
-
-//-----------------------------------------------------------------------------
-//  SECTION: Main Outline Menu for GBrowse Management 
-//-----------------------------------------------------------------------------
-
-
-/**
- * Tripal-GBrowse-Menu
- *
- * Implemets hook_menu(): Adds menu items for the tripal_gbrowse module menu. This section
- * gives the outline for the main menu of the Tripal-GBrowse module
- *
- * @return
- *   An array of menu items that is visible within the Drupal Menu, returned as soon
- *   as the program is ran
- */
-function tripal_gbrowse_menu() {
-  
-  $items = array();
-  
-  $items[ 'admin/tripal/tripal_gbrowse' ]= array(
-    'title' => t('GBrowse Management'),
-    'description' => ('GBrowse management allows a user to create a database, register
-     a GBrowse instance and to load/delete feature libraries'),
-    'page callback' => 'tripal_gbrowse_administration_description_page',
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_NORMAL_ITEM
-  ); 
-
-  $items['admin/tripal/tripal_gbrowse/configuration'] = array(
-    'title' => t('Configuration'),
-    'description' => t('Configuration for this module'),
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_gbrowse_administration_form'),
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_NORMAL_ITEM
-  );
-
-  $items['admin/tripal/tripal_gbrowse/register_gbrowse'] = array(
-    'title' => t('Register GBrowse Instance'),
-    'description' => t('Interface to enter gbrowse details and save to the database'), 
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_gbrowse_register_gbrowse_form'), 
-    'access arguments' => array('administer site configuration'),
-    'weight' => 20,
-    'type' => MENU_NORMAL_ITEM
-  );
-  
-  $items['admin/tripal/tripal_gbrowse/unregister_gbrowse']=array(
-    'title' => t('Un-Register GBrowse Instance'),
-    'description' => t('Interface to remove gbrowse details from the database'), 
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_gbrowse_unregister_gbrowse_instances_form'), 
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_NORMAL_ITEM
-  );
-  
-  $items['admin/tripal/tripal_gbrowse/load_library_features'] = array(
-    'title' => t('Load Library Features'),
-    'description' => t('Load features associated with a specified library into a GBrowse instance.'),
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_gbrowse_load_library_features_form'),
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_NORMAL_ITEM
-  );
-  
-  $items['admin/tripal/tripal_gbrowse/load_analysis_features'] = array(
-    'title' => t('Load Analysis Features'),
-    'description' => t('Load features associated with a specified analyses into a GBrowse instance.'),
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_gbrowse_load_analyses_form'),
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_NORMAL_ITEM
-  );
-  
-  $items['admin/tripal/tripal_gbrowse/delete_library_features']=array(
-    'title' => t('Delete Library Features'),
-    'description' => t('Interface to delete features of a given library from a GBrowse Instance'), 
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_gbrowse_delete_library_features_from_gbrowse_form'), 
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_NORMAL_ITEM
-  );
-  
-  $items['admin/tripal/tripal_gbrowse/delete_analysis_features']=array(
-    'title' => t('Delete Analysis Features'),
-    'description' => t('Interface to delete features of a given analysis from a GBrowse Instance'), 
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_gbrowse_delete_analysis_features_from_gbrowse_form'), 
-    'access arguments' => array('administer site configuration'),
-    'type' => MENU_NORMAL_ITEM
-  );
-  
-  $items['admin/tripal/tripal_gbrowse/add_tracks']=array(
-      'title' => t('Add Tracks'),
-      'description' => t('Interface for Adding tracks to a GBrowse Instance'), 
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_gbrowse_add_tracks_form'), 
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM
-  );
-  
-  $items['admin/tripal/tripal_gbrowse/delete_tracks']=array(
-      'title' => t('Delete Tracks'),
-      'description' => t('Interface for Deleting tracks from a GBrowse Instance'), 
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_gbrowse_delete_tracks_form'), 
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM
-  );
-  
-  $items['admin/tripal/tripal_gbrowse/align_features']=array(
-      'title' => t('Align Features'),
-      'description' => t('Align a group of features (either library or analysis) against another grouping of features.'), 
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('tripal_gbrowse_align_features_form'), 
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM
-  );  
-
-  return $items;
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-function tripal_gbrowse_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_gbrowse')));
-}
-
-
-/**
- * Implements hook_theme(): Register themeing functions for this module
- *
- * Contains the seperate tripal_gbrowse_X.tpl.php files, so as they can be included in the
- * theme for the designed module
- *
- * @return
- *   An array of themeing functions to register
- *
- */
-function tripal_gbrowse_theme() {
-	
-	$path = drupal_get_path('module', 'tripal_gbrowse_theme') . '/theme/tripal_gbrowse';
-	
-	return array(
-    // Block Templates------------------------------
-    'tripal_gbrowse_database_details' => array (
-      'arguments' => array('node'=> null),
-      'template' => 'tripal_gbrowse_database_details',
-      'path' => $path,
-    ),
-    'tripal_gbrowse_details' => array (
-      'arguments' => array('node'=> null),
-      'template' => 'tripal_gbrowse_details',
-      'path' => $path,
-    ),
-    'tripal_gbrowse_gbrowse_instance' => array (
-      'arguments' => array('node'=> null),
-      'template' => 'tripal_gbrowse_gbrowse_instance',
-      'path' => $path,
-    ),
-    'tripal_gbrowse_teaser' => array (
-      'arguments' => array('node'=> null),
-      'template' => 'tripal_gbrowse_teaser',
-      'path' => $path,
-    ),
-    'tripal_gbrowse_loaded_sources' => array (
-      'arguments' => array('node'=> null),
-      'template' => 'tripal_gbrowse_loaded_sources',
-      'path' => $path,
-    ),
-	);
-}
-
-
-/**
- * Purpose: Implement Blocks relating to Tripal GBrowse content
- *
- * @param $op
- *   What kind of information to retrieve about the block or blocks. 
- *   Possible values include list, configure, save, view.
- * @param $delta
- *   Which block to return (not applicable if $op is 'list').
- * @param $edit
- *   If $op is 'save', the submitted form data from the configuration form.
- *
- * @return
- *   One of the following depending on $op: An array of block descriptions (list), the configuration 
- *   form (configure), nothing (save), an array defining subject and content for the block indexed 
- *   by $delta (view)
- *
- */
-function tripal_gbrowse_block ($op = 'list', $delta = 0, $edit=array()) {
-  switch($op) {
-    case 'list':
-      $blocks['database_details']['info'] = t('Tripal GBrowse Database Details');
-      $blocks['database_details']['cache'] = BLOCK_NO_CACHE;
-
-      $blocks['details']['info'] = t('Tripal GBrowse Details');
-      $blocks['details']['cache'] = BLOCK_NO_CACHE;
-         
-      $blocks['gbrowse_instance']['info'] = t('Tripal GBrowse Instance');
-      $blocks['gbrowse_instance']['cache'] = BLOCK_NO_CACHE;
-         
-      $blocks['teaser']['info'] = t('Tripal GBrowse Teaser');
-      $blocks['teaser']['cache'] = BLOCK_NO_CACHE;
-      
-      $blocks['teaser']['info'] = t('Tripal GBrowse Sources');
-      $blocks['teaser']['cache'] = BLOCK_NO_CACHE;
-      
-      return $blocks;
-
- 		case 'view':
- 			if(user_access('access tripal_gbrowse content') and arg(0) == 'node' and is_numeric(arg(1))) {
-      	$nid = arg(1);
-      	$node = node_load($nid);
- 
-        $block = array();
-        switch($delta){
-					case 'database_details':
-						$block['subject'] = t('Tripal GBrowse Database Details');
-						$block['content'] = theme('tripal_gbrowse_database_details',$node);
-						break;
-						
-					case 'details':
-						$block['subject'] = t('Tripal GBrowse Details');
-						$block['content'] = theme('tripal_gbrowse_details',$node);
-						break;
-						
-					case 'gbrowse_instance':
-						$block['subject'] = t('Tripal GBrowse Instance');
-						$block['content'] = theme('tripal_gbrowse_gbrowse_instance',$node);
-						break;
-						
-					case 'teaser':
-						$block['subject'] = t('Tripal GBrowse Teaser');
-						$block['content'] = theme('tripal_gbrowse_teaser',$node);
-						break;
-						
-					case 'teaser':
-						$block['subject'] = t('Tripal GBrowse Sources');
-						$block['content'] = theme('tripal_gbrowse_loaded_sources',$node);
-						break;	
-							
-        }
-				return $block;
-			}
-	}
-}
-
-
-/**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support
- *  for this module which then includes tripal_db.views.inc where all the
- *  views integration code is
- */ 
-function tripal_gbrowse_views_api() {
-   return array(
-      'api' => 2.0,
-   );
-}
-
-
-/**
- * This section uses HTML to output the descriptions of the module, through the Tripal Management
- * Administation window.Any installation instructions are given as well as included features
- * as well as a overview of the purpose Module.
- *
- * @return
- *   Returns '$text'The HTML description of the Module, its instructions, features, and any other 
- *   important aspects. This is returned when the Administration page is selected.
- */
-function tripal_gbrowse_administration_description_page() {
-
-  $text = ' ';
-
-  $text .= '</p><h3>GBrowse Feature Administrative Tools Quick Links:</h3>';
-  
-  $text .= "<ul>";
-  
-  $text .= "<li>".l("Configuration", "admin/tripal/tripal_gbrowse/configuration"). "</li>";
-	$text .= "<li>".l('Register GBrowse Instance', 'node/add/tripal-gbrowse')."</li>";
-  $text .= "<li>".l("Load Library Features", "admin/tripal/tripal_gbrowse/load_library_features"). "</li>";
-  $text .= "<li>".l("Delete Library Features", "admin/tripal/tripal_gbrowse/delete_library_features"). "</li>";
-  $text .= "<li>".l("Load Analysis Features", "admin/tripal/tripal_gbrowse/load_analysis_features"). "</li>";
-  $text .= "<li>".l("Delete Analysis Features", "admin/tripal/tripal_gbrowse/delete_analysis_features"). "</li>";
-  $text .= "<li>".l("Add Tracks","admin/tripal/tripal_gbrowse/add_tracks"). "</li>";
-  $text .= "<li>".l("Delete Tracks","admin/tripal/tripal_gbrowse/delete_tracks"). "</li>";
-
-   
-   $text .= "</ul>";
- 
-  $text .= '<h3>Module Description:</h3>';
-  $text .= '<p>This module provides an interface to register already existing GBrowse instances with Drupal/Tripal and/or create new '
-            .'GBrowse Instances. Furthermore, it allows basic management of these GBrowse instances including un-registering and/or '
-            .'deleting and loading of features in Tripal/Chado into a MySQL GBrowse instance. As such, it provides interoperability '
-            .'and syncronization between a Tripal/Chado installation and GBrowse</p>';
-
-  $text .= '<h3>Setup Instructions:</h3>';
-  $text .= '<ol>';
-  $text .= '<li><b>Ensure the PHP-MySQL extension is installed:</b> Installation instructions are dependant upon your operating system.</li>';
-  $text .= '<li><b>Move Template Configuration File:</b> Move the template.conf file included with this module into the GBrowse configuration file directory.</li>';
-    $text .= '<li><b>Set GBrowse Instance Defaults :</b> Set default repository for Configuration files, also set the default GBrowse web link address.</li>'
-						.'<a href="tripal_gbrowse/configuration">Administration -> Tripal Management -> GBrowse Management -> Configuration</a>.</li>';
-  
-  $text .= '<li><b>Register Existing GBrowse Instances</b>: Register any existing GBrowse instances through the form provided at '
-            .'<a href="tripal_gbrowse/register_gbrowse">Administration -> Tripal Management -> GBrowse Management -> Register GBrowse Instance</a>.</li>';
-  $text .= '<li><b>Load desired Feature Libraries into GBrowse Instances</b>: Additional feature libraries should be loaded through the form provided at '.l('Administration -> Tripal Management -> GBrowse Management -> Load Features','admin/tripal/tripal_gbrowse/load_features').'</li>';
-  $text .= '<ol>';
-  
-  $text .= '<h3>Features of this Module:</h3>';
-    $text .= '<ul>';
-      $text .= '<li><b>Register GBrowse Instance:</b> In order to load features into a GBrowse instance you need to first register it with Tripal/Drupal. Any existing '
-                .'GBrowse instance that utilizes a MySQL database can be registered with the module. Furthermore, you can create new GBrowse Instances '
-                .'through this module by selecting that option in the register GBrowse Instance form. This'
-                .'newly created GBrowse instance uses a MySQL database with is created and '
-                .'a user name and password is setup and a default configuration file is created. Finally, the database is initialized and the first sequence '
-                .'set is loaded into the GBrowse instance.</li>';
-    
-      $text .= '<li><b>Un-Register/Delete GBrowse Instance:</b> Un-registering a GBrowse instance alone will remove the GBrowse instance from the Drupal site.'
-                .'When removing the entire instance, the database and the configuration file will be deleted. This cannot be undone!</li>';
-    	
-    	$text .='<li><b>Intergrated GBrowse Node/Page:</b> Allows users to easily access GBrowse instances that have been created.' 
-    						.'This module provides details for a registered GBrowse Instance, including an I-Frame, providing instance access to the GBrowse display,' 
-    						.'as well,the module provides a link to a GBrowse instance in a new window.</li>';
-    
-      $text .= '<li><b>Load Library Features:</b> Simply by selecting a Tripal Library and a GBrowse Instance, '
-              .'the features associated with the selected Library are loaded into the selected GBrowse Instance. Libraries can also be updated by selecting that option. This removes all of the pre-existing'
-              .'features associated with that library, then reloades them. Both loading and updating utilize the Perl script "bp_seqfeature_load.pl" which should be installed when you install GBrowse.</li>';
-    
-    	$text .= '<li><b>Load Analysis Features:</b> Simply by selecting a Tripal Analysis and a GBrowse Instance, '
-              .'the analyses associated with the selected Library are loaded into the selected GBrowse Instance. Analyses can also be updated by selecting that option. This removes all of the pre-existing'
-              .'features associated with that analysis, then reloades them. Both loading and updating utilize the Perl script "bp_seqfeature_load.pl" which should be installed when you install GBrowse.</li>';
-    
-      $text .= '<li><b>Delete Feature (Libraries) Libraries:</b> A user can select a desired Tripal Library and a specific GBrowse instance and all of the features associated with that library in the selected isntance are removed.'
-              .' This section uses the Perl "script bp_seqfeature_delete.pl" to delete the specified features.</li>';
-      $text .= '<li><b>Delete (Libraries) Analysis :</b> A user can select a desired Tripal Analysis  and a specific GBrowse instance and all of the features associated with that analysis in the selected isntance are removed.'
-              .' This section uses the Perl "script bp_seqfeature_delete.pl" to delete the specified features.</li>';
-              
-      $text .= '<li><b>Add Tracks:</b> Allows a user to add tracks to a given GBrowse instance. This allows them to define exactly how they want their features to be displayed, as well as, to separate their features into their own GBrowse track.</li>';
-      
-      $text .= '<li><b>Delete Tracks:</b> Allows a user to delete default tracks or user created  tracks for a given GBrowse instance.</li>';
-              
-  $text .= '</ul>';
-  
-  return $text;
-}
-
-
-/**
- *  Implements hook_job_describe_args()
- *
- *  This function modifies the Job Arguments page and represents the job arguments with
- *  meaningfull descriptive names, sends a link to the library and shows if the database  
- *  was cleared or not.
- *
- *  @param $call_back
- *    The name of the function being called by tripal_jobs
- *
- *  @param $args
- *    The arguments that are passed, given if the selected proccess is 
- *				1-'tripal_gbrowse_delete_library_features_from_gbrowse'
- *				2-'tripal_gbrowse_load_library_features_into_gbrowse'*				
- *				3-'tripal_gbrowse_delete_analysis_features_from_gbrowse'
- *				3-'tripal_gbrowse_load_analysis_features_into_gbrowse'
- *    If 1- then the arguments are based on deleting a library feature from GBrowse.
- *    If 2- then the arguments are based on loading library features into GBrowse.
- *    If 3- then the arguments are based on deleting a analysis feature from GBrowse.
- *    If 4- then the arguments are based on loading analysis features into GBrowse.
- *
- * @return
- *     Job arguments:Database name, user Name, Password, Library ID, If GBrowse database was cleared, 
- *    to be displayed in Job Details page. 
- */
-function tripal_gbrowse_job_describe_args($call_back, $args){
-
-  switch ($call_back){
-  
-    case 'tripal_gbrowse_delete_library_features_from_gbrowse':
-        
-        $new_args['GBrowse Database Name']=$args[0];
-        
-        $new_args['User Name']=$args[1];
-        
-        $new_args['Password']=$args[2];
-        $result = db_fetch_object(db_query("SELECT nid FROM chado_library WHERE library_id=%d",$args[3]));
-        
-        $node = node_load($result->nid);
-        
-        $new_args['Library']= l($node->title, 'node/'.$result->nid);
-        
-          if(empty($args[4])){
-            $new_args['Clear GBrowse Database']= 'No';
-          }else{
-            $new_args['Clear GBrowse Database']= 'Yes';
-          }
-      
-        break;
-  
-    case 'tripal_gbrowse_load_library_features_into_gbrowse':
-        
-        $new_args['GBrowse Database Name']=$args[0];
-        
-        $new_args['User Name']=$args[1];
-        
-        $new_args['Password']=$args[2];
-        
-        $result = db_fetch_object(db_query("SELECT nid FROM chado_library WHERE library_id=%d",$args[3]));
-        
-        $node = node_load($result->nid);
-        
-        $new_args['Library']= l($node->title, 'node/'.$result->nid);
-        
-          if(empty($args[4])){
-            $new_args['Clear GBrowse Database']= 'No';
-          }else{
-            $new_args['Clear GBrowse Database']= 'Yes';
-          }
-      
-        break;
-        
-  case 'tripal_gbrowse_delete_analysis_features_from_gbrowse':
-        
-        $new_args['GBrowse Database Name']=$args[0];
-        
-        $new_args['User Name']=$args[1];
-        
-        $new_args['Password']=$args[2];
-        $result = db_fetch_object(db_query("SELECT nid FROM chado_analysis WHERE analysis_id=%d",$args[3]));
-        
-        $node = node_load($result->nid);
-        
-        $new_args['Analysis']= l($node->title, 'node/'.$result->nid);
-        
-          if(empty($args[4])){
-            $new_args['Clear GBrowse Database']= 'No';
-          }else{
-            $new_args['Clear GBrowse Database']= 'Yes';
-          }
-      
-        break;
-  
-  case 'tripal_gbrowse_load_analysis_features_into_gbrowse':
-        
-        $new_args['GBrowse Database Name']=$args[0];
-        
-        $new_args['User Name']=$args[1];
-        
-        $new_args['Password']=$args[2];
-        
-        $result = db_fetch_object(db_query("SELECT nid FROM chado_analysis WHERE analysis_id=%d",$args[3]));
-        
-        $node = node_load($result->nid);
-        
-        $new_args['Analysis']= l($node->title, 'node/'.$result->nid);
-        
-          if(empty($args[4])){
-            $new_args['Clear GBrowse Database']= 'No';
-          }else{
-            $new_args['Clear GBrowse Database']= 'Yes';
-          }
-      
-        break;
-  
-  }
-
-  return $new_args;
-
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Database API
-//-----------------------------------------------------------------------------
-
-
-/**
- * The purpose of this function is to retrieve the previousley loaded libraries from database.
- *
- * @param $gbrowse
- *   A GBrowse instance that contains the information of the current instance	
- *
- * @return 
- * 	An array of libraries that have been loaded into the database
- */
-function tripal_gbrowse_getloaded_sources($gbrowse){
-
-  $loaded_libraries = array();
-	
-	$link = mysql_connect('localhost', $gbrowse->database_user, $gbrowse->user_password);
-	
-	if (!$link) {
-		drupal_set_message('Could not connect to database: ' . mysql_error(), 'error');
-	}
- 
-	//Sending query to the database
-	$resource = mysql_query('use ' .$gbrowse->database_name);
-	
-	if (empty($resource)) {
-		drupal_set_message ('Database is empty or Non-existent','error');
-	}
-	
-	$resource = mysql_query('select * from typelist');
-	
-	if (empty($resource)) {
-		drupal_set_message ('Missing table typelist in database. Check sequence backbone has been loaded (Execute: tripal jobs) ','error');
-	}  else {
-	
-		$library_array = array();
-		
-		while($record = mysql_fetch_object($resource)){
-				preg_match('/^[^:]+:(.+)/', $record->tag, $matches);	
-				$library_array[$matches[1]]= $matches[1];
-		}
-	}
-	mysql_close($link);
-
-	return $library_array;
-
-}
-
-
-/**
- * The purpose of this function is to firstly create a file for backup purposes. Secondly, this
- * function uses a 'mysqldump' the contents of the selected database to a backup file. It then
- * access the database, drops the old database, creates a new one with the modified infromation,
- * then uploads the previously backed up infromation into the newly created database.
- * 
- *
- *  @param $node
- *    A node object containing the data and infromation of the GBrowse instance
- *
- *  @param $old_database
- *    The name of the originally created database, which will be replaced if the user
- *	  changes the name of the database that they have created
- *
- *  @return FALSE
- *    If error in creating database, or creating database, else nothing is returned
- */
-function tripal_gbrowse_database_modification($node,$old_database){
-		
-  global $user;
-		
-	$user_name = $node->database_user;
-		
-	$user_password = $node->user_password;
-		
-	//creating a file in the /tmp directory for back-up purposes
-	$back_upfile = '/tmp/' .$old_database .'_'.time().'.sql';
-	
-	//Using the 'mysqldump' command to dump the database for backup purposses
-	$command = 'mysqldump -u' .$user_name .' -p' .$user_password .' ' .$old_database .' > ' .$back_upfile;
-		
-	exec($command);
-		
-	//To create a database use the mysql_query() function to execute an SQL query
-	$link = mysql_connect('localhost', $user_name,$user_password);
-			
-	//Link operation verification
-	if (!$link) {      
-		drupal_set_message('Could not connect: ' . mysql_error(), 'error');
-		return false;
-	}
-
-	//Dropping original database name and information
-	$sql = 'DROP DATABASE ' . $old_database;
-			
-	if(mysql_query($sql, $link)){
-		drupal_set_message( "Database Dropped Successfully\n");
-	}else{
-		drupal_set_message( 'Error Dropping Database: ' . mysql_error(), 'error');
-		return false;
-	}
-
-	$sql = 'CREATE DATABASE ' . $node->database_name;
-
-	if (mysql_query($sql, $link)) {
-		drupal_set_message( "Database Created Successfully\n");
-	} 
-	else {
-		drupal_set_message( 'Error Creating Database: ' . mysql_error() . "\n");  
-		return false;
-	}
-
-	mysql_query( "GRANT SELECT ON " .$node->database_name.".* TO 'www-data'@'localhost'",$link);
-	
-	$command = 'mysql -u' .$user_name .' -p' .$user_password .' ' .$node->database_name .' < ' .$back_upfile;
-	
-	exec($command);
-	
-	mysql_close($link);
-	
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Node Capability
-//-----------------------------------------------------------------------------
-
-
-/**
-* Implementation of hook_tripal_gbrowse_node_info()
-*
-* This node_info, is a simple node that describes the functionallity of the module. It specifies
-* that the title(gbrowse Name) and body(Description) set to true so that they information can be
-* entered
-*
-*/
-function tripal_gbrowse_node_info() {
-  return array(
-    'tripal_gbrowse' => array(
-      'name' => t('GBrowse Instance'),
-      'module' => 'tripal_gbrowse',
-      'description' => t('A module for interfacing the GMOD database with Drupal, providing:
-      Registration,Alteration and Deletion of GBrowse Instances,Configuration Files and Databases
-      and the option to load/delete Sequence & Analysis Libraries'),
-    	'has_title' => TRUE,
-    	'title_label' =>t('gbrowse Name'),
-    	'had_body' => FALSE,
-    )
-  );
-}
-
-
-/**
-* Implementation of tripal_gbrowse_form().
-*
-*  This form takes the gbrowse Title infromation and the gbrowse description from the user. It 
-*  then puts the infromation into the Chado_gbrowse database table.
-*
-*  @parm &$node
-*    The node that is created when the database is initialized
-*
-*  @parm $form_state
-*    The state of the form, that has the user entered information that is neccessary for, setting
-*    up the database of the gbrowse
-*
-*  @return $form
-*    The information that was enterd allong with   
-*
-*/
-function tripal_gbrowse_form(&$node, $form_state) {
-  
-  $type = node_get_types('type', $node);
-
-  //Creating Fieldset for multiple fields in form
-  $form['register_gbrowse'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Data Base Specific Fields'),
-  );
-  
-   //field for the name of the database
-   $form['register_gbrowse']['database_name'] = array(
-    '#type' => 'textfield',
-    '#title' => t('GBrowse Database Name'),
-    '#size' => 30,
-    '#maxlength' => 64,
-    '#description' => t('Desired Database Name Field'),
-    '#default_value' => isset($node->gbrowse->database_name) ? $node->gbrowse->database_name : '',
-    '#required' => TRUE,
-  );
-  
-   //User of database 
-   $form['register_gbrowse']['database_user'] = array(
-    '#type' => 'textfield',
-    '#title' => t('GBrowse User'),
-    '#size' => 30,
-    '#maxlength' => 64,
-    '#description' => t('GBrowse MySQL User Field'),
-    '#default_value' => isset($node->gbrowse->database_user) ? $node->gbrowse->database_user : '',
-    '#required' => TRUE,
-  );
-  
-   //Specified password for access to database 
-   $form['register_gbrowse']['user_password'] = array(
-    '#type' => 'password',
-    '#title' => t('Password'),
-    '#size' => 30,
-    '#maxlength' => 64,
-    '#description' => t('User Password Field'),
-    '#default_value' => isset($node->gbrowse->user_password) ? $node->gbrowse->user_password : '',
-    '#required' => TRUE,
-  );
-  
-   //Creating Fieldset for multiple fields in form
-   $form['gbrowse_details'] = array(
-     '#type' => 'fieldset',
-     '#title'=>'GBrowse Specifications' ,
-   );
-  
-   //Human-readable name for the gbrowse instance 
-   $form['gbrowse_details']['title'] = array(
-    '#type' => 'textfield',
-    '#title' => t('GBrowse Name'),
-    '#size' => 30,
-    '#maxlength' => 256,
-    '#description' => t('GBrowse Instance'),
-    '#default_value' => isset($node->gbrowse->gbrowse_name) ? $node->gbrowse->gbrowse_name : '',
-    '#required' => TRUE,
-  );
-  
-   //$_SERVER: takes the current url and sets to variable
-   $default_value = variable_get('tripal_gbrowse_gbrowse_address_stub', '');
-    
-   //Link to the gbrowse instance
-   $form['gbrowse_details']['gbrowse_link'] = array(
-    '#type' => 'textfield',
-    '#title' => t('GBrowse Link'),
-    '#size' => 30,
-    '#maxlength' => 256,
-    '#description'=>t('Enter Full HTML address Including Host 
-    (ex:http://knowpulse2.usask.ca/) of the new GBrowse instance. By default this is '.$default_value.'[configuration file name] where the configuration file name is the same as that entered below except without .conf'),
-    '#default_value' => isset($node->gbrowse->gbrowse_link) ? $node->gbrowse->gbrowse_link : $default_value,
-    '#required' => TRUE,
-  );
-
-  //Fully qualified location to the gbrowse configuration file 
-   $form['gbrowse_details']['config_file'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Configuration File'),
-    '#size' => 30,
-    '#maxlength' => 256,
-    '#description' => t('Enter Fully Qualified File Name including Path (ex: file.conf) '),
-    '#default_value' => isset($node->gbrowse->config_file) ? $node->gbrowse->config_file : variable_get('tripal_gbrowse_configuration_file_path', ''),
-    '#required' => TRUE,
-  );
-  
-  $result = tripal_core_chado_select ( 'library', array('library_id','name'), array() );
-
-  foreach ($result as $value) {
-  
-    $newArray[$value->library_id]=$value->name;        //options for the select list
-	
-	}
-	
-	if (!$node->gbrowse->gbrowse_id) {
-	
-	 		// Creating Fieldset for multiple fields in form
-  		$form['create_instance'] = array(
-    		'#type' => 'fieldset',
-    		'#title' => t('Create New GBrowse Instance'),
-  		);
-	
-		if(empty($newArray)){
-		
-			drupal_set_message('There are currently no libraries to load.','error');
-		
-			$form['create_instance']['check_box'] = array(
-				'#type' => 'item',
-				'#value'=>'A GBrowse instance can not be created without a valid loadable backbone. 
-				To make a valid loadable backbone available, please load features grouped in a library using 
-				any of the feature loaders available.'
-			);
-		
-		
-		}else { 
-		
-			//A box if checked creates GBrowse Instances if they do not exist
-			$form['create_instance']['check_box'] = array(
-				'#type' => 'checkbox',
-				'#title' => t('Create Instance'),
-				'#description' => t('Create GBrowse Instane Unless Previous Existance'),
-			);
-		
-				//Library ID
-				$form['create_instance']['library_id'] = array(
-					'#type' => 'select',
-					'#title' => t('Sequence BackBone'),
-					'#options' => $newArray,
-					'#description' => t('Sequence Features Locations'),
-				);
-		}
-	
-	}
-	
-  return $form;
-  
-}
-
-function tripal_gbrowse_validate ($node, $form) {
-
-  if (!preg_match('/\.conf$/',$node->config_file)) {
-    form_set_error('config_file','Configuration file must end in .conf');
-  }
-  
-  if (!preg_match('/^http:\/\//',$node->gbrowse_link)) {
-    form_set_error('gbrowse_link','GBrowse Link must be an absolute path (include http://)');
-  }
-}
-
-/**
- *  Implements tripal_gbrowse_help()
- *
- *  This function simply states, in HTML tags, the creator of the the module and the contact	
- *  for the programmer
- *
- *  @parm $path
- *    The absolute path of the module and help information
- *
- *  @parm $arg
- *    The argument
- */
-function tripal_gbrowse_help($path, $arg) {
-  switch ($path) {
-    
-    case 'admin/help#tripal_gbrowse':
-      
-      return '<p>'. t('Module created by:Chad Krilow (e-mail:cnk046@mail.usask.ca)') .'</p>';
-			
-			break;
-  }
-}
-
-
-/**
- * Implements hook_perm()
- *
- *  This function sets the permission for the user to access the information in the database.
- *  This includes creating, inserting, deleting and updating of information in the database
- *
- */
-function tripal_gbrowse_perm(){
-
-  return array('create tripal_gbrowse', 'edit own tripal_gbrowse', 'access database-related details' ,'access tripal_gbrowse content');
-
-}
-
-
-/**
- * Implements tripal_gbrowse_access()
- *
- *  This function sets the access permission for operations on the database.
- *  
- *
- *  @parm $op
- *    The operation that is to be performed
- *
- *  @parm $node
- *    The specific node that is to have the operation performed  
- *
- *  @parm $account
- *    The account of the user that is performing the operations  
- *
- *  @return
- *    True if a operation was performed
- *
- */
-function tripal_gbrowse_access($op, $node, $account) {
-
-  if($op == 'create') {
-    // Only users with permission to do so may create this node type.
-    if(!user_access('create tripal_gbrowse', $account)){
-       return FALSE;
-    }  
-  }
-
-  // Users who create a node may edit or delete it later, assuming they have the
-  // necessary permissions.
-  if($op == 'update' || $op == 'delete') {   
-    if(!user_access('edit own tripal_gbrowse',$account)){
-       return FALSE;
-    } 
-    if(user_access('edit own tripal_gbrowse',$account) && 
-       $account->uid != $node->uid){
-      return FALSE;
-    }
-  }
-  return NULL;
-}
-
-
-/**
-* Implementation of tripal_gbrowse_insert()
-*
-* This function inserts user entered information pertaining to the GBrowse instance into the
-* 'tripal_gbrowse_instances' talble of the database, requiring that a 'Check Box' has been selected.
-*
-*  @parm $node
-*    Then node which contains the information stored within the node-ID
-*
-*
-*
-*/
-function tripal_gbrowse_insert($node) {
-		
-  $values = array(
-    'database_name'=> $node->database_name,
-    'database_user'=> $node->database_user,
-    'user_password'=> $node->user_password,
-    'gbrowse_name'=> $node->title,
-    'gbrowse_link'=> $node->gbrowse_link,
-    'config_file'=> $node->config_file,
-    'library_id'=>$node->library_id,
-    'nid'=>$node->nid,
-    'vid'=>$node->vid,
-   );
-  
-  //used to write to a database table described by Drupal Schema (not workable for chado)
-  drupal_write_record('tripal_gbrowse_instances', $values);
-  
-  if($node->check_box==1){
-  	tripal_gbrowse_create_gbrowse_instance($values);
-	}else{
-		drupal_set_message("Create instance check box not selected, unable initialize instance");
-	}
-	
-}
-
-
-/**
-* Implementation of tripal_gbrowse_delete().
-*
-* This function takes a node and if the variable 'tripal_gbrowse_delete_all' has been defined,
-* the GBrowse instance pertaining to the node passed into the function is deleted. Following,
-* given the node-ID, the instance will be deleted from the 'tripal_gbrowse_instances' table.
-*
-*
-*  @parm $node
-*    Then node which contains the information stored within the node-ID
-*
-*/
-function tripal_gbrowse_delete($node){
-  
- 	if(variable_get('tripal_gbrowse_delete_all', '')){ 
- 		tripal_gbrowse_delete_gbrowse_instance($node->gbrowse);
- 	}
- 	
- 	//deleteing in drupal chado_gbrowse table
-  db_query('DELETE FROM {tripal_gbrowse_instances} WHERE nid = %d', $node->nid);
-	
-}
-
-
-/*
-*
-* Implements hook_update
-*
-* The purpose of the function is to allow the module to take action when an edited node is being 
-* updated in the database. It also updates any name changes to the configuration file that was
-* created upon registering a GBrowse instance. This is done by moving the contents of the original 
-* configuration file to the newly named file.As well, the database will be changed, if the name
-* is altered by a registered user.If this is the case, the function 'tripal_gbrowse_database_modification'
-* is called and the node and the old database infromation is passed, so as it may be altered and updated
-* accordingley.
-*
-* @param $node 
-*   The node being updated
-*
-*/
-function tripal_gbrowse_update($node){
-	
-	//select from table before doing this, cause i wont be able to see the old details afterwards	
-	$old_data = db_fetch_object(
-  db_query('SELECT database_name,config_file FROM {tripal_gbrowse_instances} WHERE nid=%d AND vid=%d',
-	$node->nid, $node->vid));
-	
-	$old_config_file=$old_data->config_file;
-	
-	$old_database_name=$old_data->database_name;
-		
-	$match= array(
-		  'nid',
-		  'vid',
-	);
-	
-	$values =  array(
-    'database_name'  => $node->database_name,
-    'database_user'  => $node->database_user,
-    'user_password'  => $node->user_password,
-    'gbrowse_name'  => $node->gbrowse_name,
-    'gbrowse_link' => $node->gbrowse_link,
-    'config_file' => $node->config_file,
-    'library_id'=>$node->library_id,
-    'nid' => $node->nid,
-    'vid' => $node->vid,
-  );
-  
-  //Pulling out the configuration file
-  $config_file = $node->config_file;
-    
-  if(strcmp($old_config_file, $config_file)!=0){
-  	//Removing configuration file from the directory
-  	$command = "mv " .$old_config_file ." ".$config_file;
-  	exec($command);
-	}
-
-	if($old_database_name != $node->database_name){
-    tripal_gbrowse_database_modification($node,$old_database_name);
-	}		
-
-	drupal_write_record('tripal_gbrowse_instances', $values, $match);
-
-}
-
-
-/**
-* Implementation of tripal_gbrowse_load().
-*
-*
-* @param $node
-*   The node that is to be accessed from the database
-*
-* @return $node
-*   The node with the information to be loaded into the database 
-*
-*/
-function tripal_gbrowse_load($node) {
-	
-	$result = db_fetch_object(db_query('SELECT gbrowse_id,database_name,database_user,user_password,
-	gbrowse_name,gbrowse_link,config_file FROM {tripal_gbrowse_instances} WHERE nid=%d AND vid=%d',$node->nid, $node->vid));
-	
-  $node->gbrowse = $result;
-	
-  return $node;
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Configuration form
-//-----------------------------------------------------------------------------
-
-
-/**
-* Implemets hook_menu(): Adds menu items for the tripal_gbrowse module
-*
-* This form creates a specific Configuration File directory and sets a specific
-* GBrowse web address for later access 
-*
-* @return
-*   An array of menu items '$form' 
-*/
-function tripal_gbrowse_administration_form () {
- 
-  //Creating Fieldset for multiple fields in form
-  $form['configuration_features'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Module Configuration Fields'),
-  );
- 
-  //Configuration File Directory
-  $form['configuration_features']['configuration_file'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Set Default Configuration File Directory'),
-    '#size' => 30,
-    '#maxlength' => 64,
-    '#description' => t('Specific Configuration File Directory'),
-    '#default_value' => variable_get('tripal_gbrowse_configuration_file_path', ''),
-  );
-  
-  //GBrowse Web Address
-  $form['configuration_features']['gbrowse_address'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Set Default GBrowse Web Address'),
-    '#size' => 30,
-    '#maxlength' => 64,
-     '#description' => t('Desired GBrowse web address'),
-     '#default_value' => variable_get('tripal_gbrowse_gbrowse_address_stub', ''),
-  );
-  
-  //A box if checked creates GBrowse Instances(.conf file and database)
-	$form['configuration_features']['delete_check_box'] = array(
-		'#type' => 'checkbox',
-		'#title' => t('Delete Instance'),
-		'#description' => t('Delete GBrowse Configuration file and Database  '),
-		'#default_value'=>variable_get('tripal_gbrowse_delete_all', ''),	
-	);
-
-  $form['configuration_features']['submit'] = array(
-    '#type' => 'submit', 
-    '#weight' => 10,
-    '#value' => t('Submit')
-  );
- 
-  return $form;
-}
-
-
-/**
- * Validate User-submitted data for Register GBrowse Instances Form
- *
- * This function validates the user input for each form element in the Register GBrowse 
- * instances form that is a text field. Validations checked include:
- *    -parse_url-checks that the url can be parsed
- *
- * @param $form
- *   The form that the user submitted and whose input is being validated
- * @param $form_state
- *   An array containing the state of the form being validated including user-input
- */
-function tripal_gbrowse_administration_form_validate ($form, $form_state) {
-  
-  if ( !valid_url($form_state['values']['gbrowse_address'])) {
-    form_set_error('gbrowse_address', 'Invalid URL');
-  }
-}
-
-
-/**
-*
-* Configuration-Form
-*
-* @param $form
-*    -The submitted form containing the user entered infromation
-* @param $form_state 
-*    -Is the state of the form: i.e what button was pressed, what infromation was entered,etc.
-*    The key is the 'values'
-*/
-function tripal_gbrowse_administration_form_submit ($form, $form_state) {
-
-  if(!preg_match('/\/$/', $form_state['values']['configuration_file'])) {
-      $form_state['values']['configuration_file'] = $form_state['values']['configuration_file'] . "/";
-  }
-
-  variable_set('tripal_gbrowse_configuration_file_path',$form_state['values']['configuration_file'] );
-  drupal_set_message('Configuration File Path set to: '.variable_get('tripal_gbrowse_configuration_file_path', ''));
-    
-        
-  variable_set('tripal_gbrowse_gbrowse_address_stub',$form_state['values']['gbrowse_address'] );
-  drupal_set_message('GBrowse Default Address set to: '.variable_get('tripal_gbrowse_gbrowse_address_stub', ''));
-  
-  if($form_state['values']['delete_check_box']==1){									
-  	variable_set('tripal_gbrowse_delete_all',$form_state['values']['delete_check_box'] );
-  	drupal_set_message('Selected GBrowse instance will be deleted: '.variable_get('tripal_gbrowse_delete_all', 'NOT SET'));
-  }
-
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Register-GBrowse-Instance 
-//-----------------------------------------------------------------------------
-
-
-/**
-*
-* Register & Create GBrowse instance ( called by the node form )
-*
-* This form submit takes it's fields from the form for registering a GBrowse instance. The 'sed'command
-* is used to select certain lines of a template 'conf' file and replaces them with the user specified GBrowse instance
-* and data base name. It then removes the temporary file that was created. This function utilizes the MySQL database
-* and uses the commands for MySQL to create a database for the registered GBrowse instance, appropriate warnings
-* are issued if there are problems connecting/registering/accessing the database.
-*
-* @param $form
-*    -The submitted form containing the user entered infromation
-*
-* @param $form_state 
-*    This is the state of the form: i.e what button was pressed.The key is 
-*    the name of the fields in database 
-*
-*/
-function tripal_gbrowse_create_gbrowse_instance($values) {
-    
-    global $user;    //make current user details available so access of user id is available 
-        
-  //checking for existance of configuration file, if allready created a warning is issued
-	if ( file_exists($values['config_file']) ){
-		drupal_set_message('Configuration File Already Exists', 'warning');
-	}else{ 
-	
-		$config_path = variable_get('tripal_gbrowse_configuration_file_path', '');
-		
-		if(empty($config_path)){   
-			drupal_set_message( "Invalid or Non-Existent Configuration Path (Check Configuration Menu Defaults)", 'error');
-		}
-				
-		$temp_file = '/tmp/temporary_gbrowse_'.time().'.conf';
-		
-		// Using 'sed' to select the second line of the template.config substitute <#gbrowse_name>
-		//for .$values['gbrowse_name'] 
-		$command = "sed '2 s/<#gbrowse_name#>/".$values['gbrowse_name']."/' ".$config_path."template.conf > ".$temp_file; 
-
-		exec($command);
-		
-		// Using 'sed' to select the fifth line of the template.config substitute <#database_name>
-		//for .$values['database_name']
-		 $command = "sed '5 s/<#database_name#>/".$values['database_name']."/' ".$temp_file." > ".$values['config_file'];
-
-		exec($command);
-		
-		// Check configuration file is there
-		if (file_exists($values['config_file'])) {
-			drupal_set_message('Configuration File created successfully');
-		} else {
-			drupal_set_message('Unable to create configuration file','error');
-		}
-
-		//To create a database use the mysql_query() function to execute an SQL query
-		$link = mysql_connect('localhost', $values['database_user'],$values['user_password']);
-	
-		if (!$link) {
-			drupal_set_message('Could not connect: ' . mysql_error());
-			return false;
-		}
-
-		$sql = 'CREATE DATABASE ' . $values['database_name'];
-
-		if (mysql_query($sql, $link)) {	
-			drupal_set_message( "Database created successfully\n");
-		} else {
-			drupal_set_message( 'Error creating database: ' . mysql_error() . "\n");
-			return false;
-		}
-	
-		mysql_query( "GRANT SELECT ON " .$values['database_name'].".* TO 'www-data'@'localhost'",$link);
-								
-		mysql_close($link);
-
-		$job_args=array($values['database_name'],$values['database_user'],$values['user_password'],$values['library_id'],TRUE);
-			
-		//registering a job with the tripal system, this job calls the function when executed
-		$job_id = tripal_add_job('Loading Features Into GBrowse', 'tripal_gbrowse','tripal_gbrowse_load_library_features_into_gbrowse', $job_args, $user->uid);
-
-		drupal_set_message(' The Backbone needs to be loaded into GBrowse (done by executing Tripal Jobs Loading script), 
-		Before loaded libraries or GBrowse Instance will be displayed. ');
-
-  	}
-  
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Un-Register Existing GBrowse Instances
-//-----------------------------------------------------------------------------
-
-
-/**
-* Un-Register GBrowse Instance Form Submit
-*
-* This is the Form-Submit section of the Un-Register GBrowse instance function. Depending on 
-* which instance was selected, it will be removed from the database. A check box is provided
-* which, if checked is true, will delete all data/files that was associated with the selected
-* GBrowse instance.SQL commands are used in order to remove the selected instances from the 
-* SQL database.
-*
-* @param $form
-*    the submitted form containing the user entered infromation
-* @param $form_state 
-*    The state of the form: i.e if check-box was checked and what gbrowse_instance was selected to be deleted
-*    The key is the 'values'
-*
-* @return
-*    true or false, depending wheater the check box had been selected, if true, the 
-*   selected GBrowse instance will be deleted
-*/
-function tripal_gbrowse_delete_gbrowse_instance($gbrowse) {
-    
-  // Retrieve current gbrowse instance details
-  $gbrowse_instance = db_fetch_object(
-  db_query('SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id=%d', $gbrowse->gbrowse_id )
-  );
-     
-    //Pulling out the configuration file
-    $config_file = $gbrowse->config_file;
-      
-    //Removing configuration file from the directory
-    $command = "rm ".$config_file;
-
-    exec($command);
-    
-    if (file_exists($config_file)) {
-      drupal_set_message('Configuration File ('.$config_file.') not removed!', 'error');
-    } else {
-      drupal_set_message('Configuration File removed successfully');
-    }
-      
-    $user_name = $gbrowse->database_user;
-    
-    $user_password = $gbrowse->user_password;
-
-    $link = mysql_connect('localhost', $user_name,$user_password);
-      
-    if (!$link) {     
-      drupal_set_message('Could not connect: ' . mysql_error(), 'error');
-      return false;
-    }
-
-    $sql = 'DROP DATABASE ' . $gbrowse->database_name;
-      
-    if(mysql_query($sql, $link)){    
-      drupal_set_message( "Database removed successfully\n"); 
-    }else{
-      drupal_set_message( 'Error removing database: ' . mysql_error(), 'error');
-      return false;
-    }
-      
-    mysql_close($link);
-  
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Load Library features into GBrowse Form & Form Submit
-//-----------------------------------------------------------------------------
-
-
-/**
-* Implements hook_form
-*
-* This function creates a form for the database name, user name for database operation and a 
-* password for access.The module uses these features to access information regarding the user's 
-* operations and needs.
-*
-* @return
-*   An array describing the form to be rendered
-*/
-function tripal_gbrowse_load_library_features_form() {
- 
-  $new_array=array();
-   
-  $result = tripal_core_chado_select ( 'library', array('library_id','name'), array() );
-  
-  foreach ($result as $value) {
-    $new_array[$value->library_id]=$value->name;        //options for the select list
-  }
-  
-  //Creating Fieldset for multiple fields in form
-  $form['load_features'] = array(
-    '#type' => 'fieldset'
-  );
- 
-  //Library ID
-  $form['load_features']['library_id'] = array(
-      '#type' => 'select',
-      '#title' => t('Libraries'),
-      '#options' => $new_array,
-      '#description' => t('Library of Genetic Sequences.'),
-  );
-    
-  //Sending query to the database
-  $resource = db_query('SELECT * FROM {tripal_gbrowse_instances}');
-
-    $items = array();
-  
-    while($record = db_fetch_object($resource)){
-      $items[$record->gbrowse_id]= $record->gbrowse_name;
-    }
-   
-  //GBrowse Instances
-  $form['load_features']['gbrowse_id'] = array(
-    '#type' => 'select',
-    '#title' => t('GBrowse Instances'),
-    '#options' => $items,
-    '#description' => t('Selected GBrowse Instances to be Loaded.'),
-  );
-    
-  //A checkbox to update features for the gbrowse
-  $form['load_features']['check_box'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Update Features'),
-    '#description' => t('Existing Same Name Features Updated Accordingly.'),
-  );
-
-  $form['load_features']['submit'] = array(
-   '#type' => 'submit', 
-   '#weight' => 10,
-   '#value' => t('Submit Job')
-   );
-  
-  return $form;
-}
-
-
-/**
-* Load-Features-Form
-*
-* @param $form
-*    -The submitted form containing the user entered infromation
-* @param $form_state 
-*    -Is the state of the form: i.e what button was pressed, what infromation was entered,etc.
-*    The key is the 'values'
-*/
-function tripal_gbrowse_load_library_features_form_submit($form,$form_state) {
-    
-	global $user;    //needed to make the current users details available so access of user id is available 
-				
-	$record = db_fetch_object(db_query('SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id=%d', $form_state['values']['gbrowse_id']));
-	
-	$name = $record->database_name;
-
-	$user_name = $record->database_user;
-
-	$password= $record->user_password;
-
-	$job_args = array($name,$user_name,$password,$form_state['values']['library_id'], FALSE);   
-								
-	//Checking state of check box, if checked delete features from GBrowse
-	if($form_state['values']['check_box']==1){
-		//registering a delete job with the tripal system, this job calls the function when executed
-			$job_id = tripal_add_job('Deleting Features From GBrowse', 'tripal_gbrowse', 
-			'tripal_gbrowse_delete_library_features_from_gbrowse', $job_args, $user->uid);
-	}
-	
-  //registering a job with the tripal system, this job calls the function when executed
-	$job_id = tripal_add_job('Loading Features Into GBrowse', 'tripal_gbrowse', 
-	'tripal_gbrowse_load_library_features_into_gbrowse', $job_args, $user->uid);
-
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION:Load Library Features into GBrowse
-//-----------------------------------------------------------------------------
-
-
-/**
- * Load Library features into database 
- *
- * This loading function firstly creates a output GFF3 format file for verification purposes. Then, a 'Chado' table
- * is selected,depending which table the user is interested in, from this table specific infromation 
- * is taken out and placed in the GFF3 file.The Featurelocation(fmin) & featurelocation (fmax) are used  
- * to set the featureloc.feature_id = feature.feature_id, the fmin = start & fmax = end of the desired gene.
- * The testing if the phase is empty is done, if so a '.' is inserted into $phase variable. If the parent 
- * feature is indicated in feature location for the child feature will be set.The Attributes section 
- * sets the, ID, Name, Alias, Dbrexf to variables to be put into a CONF file.The strand is either a 
- * positive, negative, or zero value and is represented by +/./- accordingley.
- *
- * @param $name
- *   name of GBrowse database
- *
- * @param $user_name
- *   GBrowse MySQL user name 
- *
- * @param $password
- *   user password for GBrowse
- *
- * @param $library_id
- *   GBrowse MySQL user name 
- *
- * @param $clear_database
- *   Used to clear the database of its backbone structure
- */
-function tripal_gbrowse_load_library_features_into_gbrowse($database_name, $user_name, $password, $library_id,$clear_database){
-
-  //A test file created to verify output
-  $myFile = "/tmp/temporaryGBrowse_".time().".gff3";
-  
-  //Test opening the file, will print warning if file is not able to be opened
-  $fh = fopen($myFile, 'w') or die("WARNING: Can not open file");
-
-  print "Creating GFF3 file of features for library...\n";
- 
-  if (!preg_match('/^\d+$/', $library_id)) {
-   print "ERROR: Invalid Library ID supplied (Library ID = ".$library_id.")\n";  
-   return false;
-  }
-  
-  // Selecting all features
-  $values = array('library_id' => $library_id);
-   
-  $prime_result = tripal_core_chado_select ( 'library_feature', array('feature_id'), $values );
-
-  // Select Table:library; column:uniquename
-  $result = tripal_core_chado_select ( 'library', array('uniquename'), $values );
-
-  $source = $result[0]->uniquename ;
-  
-  // Check source: ERROR
-
-  //For each feature, type id form feature table, specific record the feature id containing $feature_id
-  foreach ($prime_result as $value) {
-
-    $feature_id = $value->feature_id;
-     
-    if (!preg_match('/^\d+$/', $feature_id)) {
-      print "ERROR: Invalid feature ID (".$feature_id.") associated with Library (Library ID = ".$library_id.")\n";
-    }
-   
-    $result = tripal_core_chado_select('feature', array('type_id'), array('feature_id'=>$feature_id));
-   
-    $type_id = $result[0]->type_id;
-     
-    if (empty($type_id)) {
-      print "ERROR: No Type associated with Feature (Feature ID = ".$feature_id.")\n";
-    }
-   
-    //Taking the cvterm name from the cvterm table given the type-id($type_id)
-    $result = tripal_core_chado_select('cvterm', array('name'), array('cvterm_id'=>$type_id));
-
-    //The extracted cvterm name
-    $type = $result[0]->name;
-    
-    if (empty($type)) {
-      print "ERROR: Type associated with Feature (".$type_id.") doesn't exist in cvterm table (Feature ID = ".$feature_id.")\n";
-    }
-    
-    //Featureloc.fmin & featureloc.fmax ( where featureloc.feature_id = feature.feature_id )
-    //fmin = start & fmax = end
-    $result = tripal_core_chado_select('featureloc', array('fmin','fmax', 'strand', 'phase', 'srcfeature_id'), array('feature_id'=>$feature_id));
-  
-    $start = $result[0]->fmin;
-    if (!preg_match('/^\d+$/', $start)) {
-      print "ERROR: Invalid Start (".$start.") of Feature (Feature ID= ".$feature_id.")\n";
-    }
-  
-    $end = $result[0]->fmax;
-    if (!preg_match('/^\d+$/', $end)) {
-      print "ERROR: Invalid End (".$end.") of Feature (Feature ID= ".$feature_id.")\n";
-    }
-    
-    $score = '.';
-
-
-    //Converting from +1/0/-1 to +/./- as there are only three possible values
-    if ($result[0]->strand < 0) {
-    
-      $strand= '-';
-    } elseif ($result[0]->strand == 0) {
-    
-      $strand = '.';
-    } elseif($result[0]->strand > 0) {
-    
-      $strand = '+';
-    } else{
-    
-      $strand = '.';
-    }
-  
-    //Testing if phase is empty, if so a '.' is inserted into $phase variable
-    $phase = $result[0]->phase;
-    if(empty($phase)){
-      $phase = '.';
-    }
-  
-    //This is the parent feature as indicated in feature location for the child feature and 
-    //the current line described the child feature
-    $srcfeature_id = $result[0]->srcfeature_id;
-
-    if (empty($srcfeature_id)) {
-      print "ERROR: No Parent associated with Feature Location (Feature ID = ".$feature_id.")\n";
-    }
-  
-    $result = tripal_core_chado_select('feature', array('name'), array('feature_id'=>$srcfeature_id));
-  
-    $seqid = $result[0]->name;
-
-    if (empty($seqid)) {
-      print "ERROR: Parent (Parent Feature ID = ".$seqid.") associated with Feature doesn't exist in feature table (Feature ID =".$feature_id."\n";
-    }
-
-    
-    //Attributes section, ID, Name, Alias, Dbrexf  
-    $result = tripal_core_chado_select('feature', array('uniquename', 'name'), array('feature_id'=>$feature_id));
-  
-    $id = $result[0]->uniquename;
-  
-    if (empty($id)) {
-      print "ERROR: Missing Unique Name for Feature (Feature ID = ".$feature_id.")\n";
-    }
-
-    $name = $result[0]->name;
-  
-    if (empty($name)) {
-      print "WARNING: Missing Name for Feature (Feature ID = ".$feature_id.")\n";
-    }
-    
-    //Synonym
-    $result = tripal_core_chado_select('feature_synonym', array('synonym_id'), array('feature_id'=>$feature_id));
-
-    $synonyms = array();
-    foreach ($result as $obj){
-  
-      $synonym_id = $obj->synonym_id;
-    
-      $sub_result = tripal_core_chado_select('synonym', array('name'), array('synonym_id'=>$synonym_id));
-
-      // check that $sub_result[0]->name isn't empty
-      if (empty($sub_result[0]->name)) {
-        print "ERROR: Synonym (".$synonym_id.") associated with feature not found in synonym table (Feature ID = ".$feature_id.")\n";
-      } else {
-        $synonyms[] = $sub_result[0]->name;
-      }
-
-    }
-    
-    // Additional Dbxref's
-    $result = tripal_core_chado_select('feature_dbxref', array('dbxref_id'), array('feature_id'=>$feature_id));
-    $dbxref = array();
-    
-    foreach ($result as $obj){
-    
-      $dbxref_id = $obj->dbxref_id;
-  
-      if (!empty($dbxref_id)) {
-        $sub1_result = tripal_core_chado_select('dbxref', array('db_id', 'accession'), array('dbxref_id'=>$dbxref_id));
-    
-        $dbxref_accession = $sub1_result[0]->accession;
-        
-        $db_id = $sub1_result[0]->db_id;
-        
-        if (!empty($db_id)) {
-          $sub_sub_result =tripal_core_chado_select('db', array('name'), array('db_id'=>$db_id));
-        
-          $db_name = $sub_sub_result[0]->name;    
-      
-          if (empty($db_name)) {
-            print "ERROR: Database (".$db_id.") associated with database reference not in db table (Database Reference ID = ".$dbxref_id.")\n";
-          } elseif (empty($dbxref_accession)) {
-            print "WARNING: Missing Accession for Database Reference (Database Reference ID = ".$dbxref_id.")\n";
-          } else {
-            $dbxref[] = $db_name . ':' . $dbxref_accession;
-          }
-        }
-      }
-    }
-
-    //Main Dbxref
-    $result = tripal_core_chado_select('feature', array('dbxref_id'), array('feature_id'=>$feature_id));
-  
-    $dbxref_id = $result[0]->dbxref_id;
-  
-    if (empty($dbxref_id)) {
-      print "WARNING: No Database Reference associated directly with Feature (Feature ID = ".$feature_id.")\n";
-    }
-
-    $result = tripal_core_chado_select('dbxref', array('accession','db_id'), array('dbxref_id'=>$dbxref_id));
-      
-    $dbxref_accession = $result[0]->accession;
-
-    //checking $dbrexf_accession for emptyness 
-    if(!empty($dbxref_accession)){
-
-      $db_id = $result[0]->db_id;
-    
-      $sub_sub_result =tripal_core_chado_select('db', array('name'), array('db_id'=>$db_id));
-
-      $db_name = $sub_sub_result[0]->name;
-  
-      $dbxref[] = $db_name . ':' . $dbxref_accession;
-
-    } else {
-      print "WARNING: Missing Accession for Database Reference (Database Reference ID = ".$dbxref_id.")\n";
-    }
-
-    //attributes array is assigned given elements based on previous initializations
-    $attributes = array();
-
-    $attributes[] = 'ID='.$id;
-
-    if (!empty($name)) { $attributes[] = 'Name='.$name; }
-
-    if (!empty($synonyms)) { $attributes[] = 'Alias='.implode(',',$synonyms); }
-
-    if (!empty($dbxref)) { $attributes[] = 'Dbxref=' .implode(',', $dbxref); }
-
-    //write to string for printing
-    $stringData = implode("\t", array($seqid,$source,$type,$start,$end,$score,$strand,$phase,
-  
-    implode(';',$attributes)))."\n";
-    
-    //Write concatinated data ($stringData) to file    
-    fwrite($fh, $stringData);
-  }
-
-  //Closing file
-  fclose($fh);
-
-
-  if($clear_database){    
-
-    //The loading script: bp_seqfeature_load.pl, allows loading of data to specific file 
-    $command= "bp_seqfeature_load.pl -c -u '" .$user_name. "' -p '" .$password. "' -d " .$database_name. " " . $myFile;
-
-  }else{
-
-    //The loading script: bp_seqfeature_load.pl, allows loading of data to specific file 
-    $command= "bp_seqfeature_load.pl -u '" .$user_name. "' -p '" .$password. "' -d " .$database_name. " " . $myFile;
-  }
-
-  //optional 'print' statement to verify that the above comman is being called and executed properly
-  print 'Executing Command:'.$command."\n";
-
-  exec($command, $out_put, $return_var);
-
-
-} 
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Delete library features from database Form & Form submit
-//-----------------------------------------------------------------------------
-
-
-/**
-*
-* This form's purpose is to delete library featues from a selected GBrowse insatance. By selecting
-* a Library of genetic sequences and a GBrowse instance, the instance will be removed as will all the 
-* associated libraries. This form allows access to a specified database and will delete any
-* selected Library features. It will return the form that contains all of the neccessary
-* information to send to the 'form_submit' function.
-*
-* @return $form
-*   An array of menu items allowing deletion of features from the library
-*/
-function tripal_gbrowse_delete_library_features_from_gbrowse_form() {
-
-  $form = array();
-  
-  $result = tripal_core_chado_select ( 'library', array('library_id','name'), array() );
-
-  foreach ($result as $value){
-    $newArray[$value->library_id]=$value->name;        //options for the select list
-  }
-    
-  //Creating Fieldset for multiple fields in form
-  $form['delete_gbrowse'] = array(
-    '#type' => 'fieldset',
-    '#title' => t(''),
-  );
-     
-   //Library ID
-   $form['delete_gbrowse']['library_id'] = array(
-    '#type' => 'select',
-    '#title' => t('Libraries'),
-    '#options' => $newArray,
-    '#description' => t('Genetic Sequences.'),
-  );
-    
-  //Sending query to the database
-  $resource = db_query('SELECT * FROM {tripal_gbrowse_instances}');
-
-  $items = array();
-  
-  while($record = db_fetch_object($resource)){  
-    $items[$record->gbrowse_id]= $record->gbrowse_name;  
-  }
-
-  $form['delete_gbrowse']['gbrowse_id'] = array(
-    '#type' => 'select',
-    '#title' => t('GBrowse Instances'),
-    '#options' => $items,
-    '#description' => t('Selected Instances to be Removed.'),
-  );
-  
-  //Delete button to remove Library
-  $form['delete_gbrowse']['submit'] = array(
-     '#type' => 'submit', 
-     '#weight' => 10,
-     '#value' => t('Delete')
-   );
-    
-  return $form;
-
-}
-
-
-/**
-* This 'form_submit' function uses MySQL commands to select the GBrowse instance from a selected database.
-* Then the selected features are deleted from the library.
-*
-*
-* @param $form
-*    The submitted form that 
-*
-* @param $form_state 
-*    The state of the form, includes the selected library and the GBrowse instance to be removed
-*    The key is the 'values'
-*/
-function tripal_gbrowse_delete_library_features_from_gbrowse_form_submit($form, $form_state) {
-  
-  global $user;    //needed to make the current users details available so access of user id is available 
-          
-  $record = db_fetch_object(db_query('SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id=%d', $form_state['values']['gbrowse_id']));
-    
-  $name = $record->database_name;
-  
-  $user_name = $record->database_user;
-  
-  $password= $record->user_password;
-  
-  $job_args = array($name,$user_name,$password,$form_state['values']['library_id']);   
-                  
-  //Checking state of submit button, if selected delete features from library
-  if($form_state['values']['op'] == 'Delete'){
-
-    //registering a delete job with the tripal system, this job calls the function when executed
-    $job_id = tripal_add_job('Deleting Library Features From GBrowse', 'tripal_gbrowse', 'tripal_gbrowse_delete_library_features_from_gbrowse', $job_args, $user->uid);
-        
-  }
-    
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Delete Library Features from GBrowse
-//-----------------------------------------------------------------------------
-
-
-/**
-* Delete-GBrowse-Feature
-*
-* This form Removes features from library that the user has specified. The form allows the user
-* to select a desired instance. Once the library and instance are selected and deleted, the selected 
-* libraries 
-*
-*
-*
-* @param $database_name
-*   name of GBrowse database
-* @param $user_name
-*   GBrowse MySQL user name 
-* @param $password
-*   user password for GBrowse
-* @param $library_id
-*   The id of the library that is being selected from
-*
-*/
-function tripal_gbrowse_delete_library_features_from_gbrowse($database_name, $user_name, $password, $library_id){
-
-  $result = tripal_core_chado_select ( 'library', array('name'), array('library_id' => $library_id) 
-  
-  );
-
-  $library_name = $result[0]->name;
-  
-  print "Removing Features of all types related to the ".$library_name." library...\n";
-
-  $sql = 'SELECT cvterm.name FROM feature JOIN cvterm cvterm ON cvterm.cvterm_id=feature.type_id 
-  
-  JOIN library_feature library_feature ON library_feature.feature_id=feature.feature_id JOIN library 
-  
-  library ON library.library_id=library_feature.library_id WHERE library.library_id=%d GROUP BY 
-  
-  cvterm.name';
-
-  $previous_db = tripal_db_set_active('chado');
-  
-  $resource = db_query($sql, $library_id);
-  
-  tripal_db_set_active($previous_db);
-  
-  while($record = db_fetch_object($resource)){
-  
-    $type = $record->name;
-    
-    //The loading script: bp_seqfeature_delete.pl, allows removal of data to specific file 
-    $command= "bp_seqfeature_delete.pl -u '".$user_name."' -p '".$password."' -d '" .$database_name. "' -t '" .$type. ":".$library_name."'";
-    
-    print "Executing Command: ".$command."\n";
-    
-    //exec() allows for execution of a external program: given the input
-    exec($command);
-  
-  }
-
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Load analyses into GBrowse Form and Form Submit
-//-----------------------------------------------------------------------------
-
-
-/**
-* Implements hook_form
-*
-* This function creates a form for the database name, user name for database operation and a 
-* password for access.The module uses these analyses to access information regarding the user's 
-* operations and needs.
-*
-* @return
-*   An array describing the form to be rendered
-*/
-function tripal_gbrowse_load_analyses_form(){
- 
-  $newArray=array();
-  
-  $result = tripal_core_chado_select ( 'analysis', array('analysis_id','name'), array() );
-  
-  foreach ($result as $value) {
-    $newArray[$value->analysis_id]=$value->name;        //options for the select list
-  }
-  
-  //Creating Fieldset for multiple fields in form
-  $form['load_analyses'] = array(
-    '#type' => 'fieldset',
-  );
- 
-  //Library ID
-  $form['load_analyses']['analysis_id'] = array(
-      '#type' => 'select',
-      '#title' => t('Analyses'),
-      '#options' => $newArray,
-      '#description' => t('Analyses.'),
-  );
-    
-  //Sending query to the database
-  $resource = db_query('SELECT * FROM {tripal_gbrowse_instances}');
-
-    $items = array();
-  
-    while($record = db_fetch_object($resource)){
-      $items[$record->gbrowse_id]= $record->gbrowse_name;
-  }
-  
-  //GBrowse Instances
-  $form['load_analyses']['gbrowse_id'] = array(
-      '#type' => 'select',
-      '#title' => t('GBrowse Instances'),
-      '#options' => $items,
-      '#description' => t('Selected GBrowse Instances to be Loaded.'),
-  );
-    
-  //A checkbox to update features for the gbrowse
-  $form['load_analyses']['check_box'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Update Analyses'),
-    '#description' => t('Existing Same Name Analyses Updated Accordingly.'),
-  );
-
-  $form['load_analyses']['submit'] = array(
-   '#type' => 'submit', 
-   '#weight' => 10,
-   '#value' => t('Submit Job')
-   );
-  
-  return $form;
-}
-
-
-/**
-* Load-Features-Form
-*
-* @param $form
-*    -The submitted form containing the user entered infromation
-*
-* @param $form_state 
-*    -Is the state of the form: i.e what button was pressed, what infromation was entered,etc.
-*    The key is the 'values'
-*/
-function tripal_gbrowse_load_analyses_form_submit($form, $form_state) {
-    
-    global $user;    //needed to make the current users details available so access of user id is available 
-          
-    $record = db_fetch_object(db_query('SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id=%d', $form_state['values']['gbrowse_id']));
-    
-    $name = $record->database_name;
-  
-    $user_name = $record->database_user;
-  
-    $password= $record->user_password;
- 
-    $job_args = array($name,$user_name,$password,$form_state['values']['analysis_id'], FALSE);   
-                 
-    //Checking state of check box, if checked delete features from GBrowse
-    if($form_state['values']['check_box']==1){
-        //registering a delete job with the tripal system, this job calls the function when executed
-        $job_id = tripal_add_job('Deleting Features From GBrowse', 'tripal_gbrowse', 
-        'tripal_gbrowse_delete_analysis_features_from_gbrowse', $job_args, $user->uid);
-    }
-    
-    //registering a job with the tripal system, this job calls the function when executed
-    $job_id = tripal_add_job('Loading Features Into GBrowse', 'tripal_gbrowse', 
-    'tripal_gbrowse_load_analysis_features_into_gbrowse', $job_args, $user->uid);
-
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION:Load Analysis Features into GBrowse
-//-----------------------------------------------------------------------------
-
-
-/**
- * Load Analysis features into database 
- *
- * This loading function firstly creates a output GFF3 format file for verification purposes. Then, a 'Chado' table
- * is selected,depending which table the user is interested in, from this table specific infromation 
- * is taken out and placed in the GFF3 file.The Featurelocation(fmin) & featurelocation (fmax) are used  
- * to set the featureloc.feature_id = feature.feature_id, the fmin = start & fmax = end of the desired gene.
- * The testing if the phase is empty is done, if so a '.' is inserted into $phase variable. If the parent 
- * feature is indicated in feature location for the child feature will be set.The Attributes section 
- * sets the, ID, Name, Alias, Dbrexf to variables to be put into a CONF file.The strand is either a 
- * positive, negative, or zero value and is represented by +/./- accordingley.
- *
- * @param $name
- *   name of GBrowse database
- *
- * @param $user_name
- *   GBrowse MySQL user name
- *
- * @param $password
- *   user password for GBrowse
- *
- * @param $library_id
- *   GBrowse MySQL user name 
- *
- * @param $clear_database
- *   Used to clear the database of its backbone structure
- */
-function tripal_gbrowse_load_analysis_features_into_gbrowse($database_name, $user_name, $password, $analysis_id,$clear_database){
-
-	//print 'Analysis ID: '.$analysis_id.".\n";
-
-  //A test file created to verify output
-  $myFile = "/tmp/temporaryGBrowse_".time().".gff3";
-  
-  //Test opening the file, will print warning if file is not able to be opened
-  $fh = fopen($myFile, 'w') or die("WARNING: Can not open file");
-
-  print "Creating GFF3 file of features for Analysis...\n";
- 
-  if (!preg_match('/^\d+$/', $analysis_id)) {
-   print "ERROR: Invalid Analysis ID supplied (Analysis ID= ".$analysis_id.")\n";  
-   return false;
-  }
-  
-  // Selecting all analyses
-  $values = array('analysis_id' => $analysis_id);
-      
-  $prime_result = tripal_core_chado_select ( 'analysisfeature', array('feature_id'), $values);
-
-  // Select Table:library; column:uniquename
-  $result = tripal_core_chado_select ( 'analysis', array('name'), $values );
-
-  $source = $result[0]->name ;
-  
-  // Check source: ERROR
-  //For each feature, type id form feature table, specific record the feature id containing $feature_id
-  foreach ($prime_result as $value) {
-
-    $feature_id = $value->feature_id;
-     
-    if (!preg_match('/^\d+$/', $feature_id)) {
-      print "ERROR: Invalid feature ID (".$feature_id.") associated with Library (Library ID = ".$analysis_id.")\n";
-    }
-   
-    $result = tripal_core_chado_select('feature', array('type_id'), array('feature_id'=>$feature_id));
-   
-    $type_id = $result[0]->type_id;
-     
-    if (empty($type_id)) {
-      print "ERROR: No Type associated with Feature ( Feature ID = ".$feature_id.")\n";
-    }
-   
-    //Taking the cvterm name from the cvterm table given the type-id($type_id)
-    $result = tripal_core_chado_select('cvterm', array('name'), array('cvterm_id'=>$type_id));
-
-    //The extracted cvterm name
-    $type = $result[0]->name;
-    
-    if (empty($type)) {
-      print "ERROR: Type associated with Feature (".$type_id.") doesn't exist in cvterm table (Feature ID = ".$feature_id.")\n";
-    }
-    
-    //Featureloc.fmin & featureloc.fmax ( where featureloc.feature_id = feature.feature_id )
-    //fmin = start & fmax = end
-    $result = tripal_core_chado_select('featureloc', array('fmin','fmax', 'strand', 'phase', 'srcfeature_id'), array('feature_id'=>$feature_id));
-  
-    $start = $result[0]->fmin;
-    if (!preg_match('/^\d+$/', $start)) {
-      print "ERROR: Invalid Start (".$start.") of Feature (Feature ID= ".$feature_id.")\n";
-    }
-  
-    $end = $result[0]->fmax;
-    if (!preg_match('/^\d+$/', $end)) {
-      print "ERROR: Invalid End (".$end.") of Feature (Feature ID= ".$feature_id.")\n";
-    }
-    
-    $score = '.';
-
-    //Converting from +1/0/-1 to +/./- as there are only three possible values
-    if ($result[0]->strand < 0) {
-      $strand= '-';
-    } elseif ($result[0]->strand == 0) {
-      $strand = '.';
-    } elseif($result[0]->strand > 0) {
-      $strand = '+';
-    } else{
-      $strand = '.';
-    }
-  
-    //Testing if phase is empty, if so a '.' is inserted into $phase variable
-    $phase = $result[0]->phase;
-    if(empty($phase)){
-      $phase = '.';
-    }
-  
-    //This is the parent feature as indicated in feature location for the child feature and 
-    //the current line described the child feature
-    $srcfeature_id = $result[0]->srcfeature_id;
-
-    if (empty($srcfeature_id)) {
-      print "ERROR: No Parent associated with Feature Location (Feature ID = ".$feature_id.")\n";
-    }
-  
-    $result = tripal_core_chado_select('feature', array('name'), array('feature_id'=>$srcfeature_id));
-  
-    $seqid = $result[0]->name;
-
-    if (empty($seqid)) {
-      print "ERROR: Parent (Parent Feature ID = ".$seqid.") associated with Feature doesn't exist in feature table (Feature ID =".$feature_id."\n";
-    }
-
-    //Attributes section, ID, Name, Alias, Dbrexf  
-    $result = tripal_core_chado_select('feature', array('uniquename', 'name'), array('feature_id'=>$feature_id));
-  
-    $id = $result[0]->uniquename;
-  
-    if (empty($id)) {
-      print "ERROR: Missing Unique Name for Feature (Feature ID = ".$feature_id.")\n";
-    }
-
-    $name = $result[0]->name;
-  
-    if (empty($name)) {
-      print "WARNING: Missing Name for Feature (Feature ID = ".$feature_id.")\n";
-    }
-    
-    //Synonym
-    $result = tripal_core_chado_select('feature_synonym', array('synonym_id'), array('feature_id'=>$feature_id));
-
-    $synonyms = array();
-    foreach ($result as $obj){
-  
-      $synonym_id = $obj->synonym_id;
-    
-      $sub_result = tripal_core_chado_select('synonym', array('name'), array('synonym_id'=>$synonym_id));
-
-      // check that $sub_result[0]->name isn't empty
-      if (empty($sub_result[0]->name)) {
-        print "ERROR: Synonym (".$synonym_id.") associated with feature not found in synonym table (Feature ID = ".$feature_id.")\n";
-      } else {
-        $synonyms[] = $sub_result[0]->name;
-      }
-
-    }
-    
-    // Additional Dbxref's
-    $result = tripal_core_chado_select('feature_dbxref', array('dbxref_id'), array('feature_id'=>$feature_id));
-    $dbxref = array();
-    
-    foreach ($result as $obj){
-    
-      $dbxref_id = $obj->dbxref_id;
-  
-      if (!empty($dbxref_id)) {
-        $sub1_result = tripal_core_chado_select('dbxref', array('db_id', 'accession'), array('dbxref_id'=>$dbxref_id));
-    
-        $dbxref_accession = $sub1_result[0]->accession;
-        
-        $db_id = $sub1_result[0]->db_id;
-        
-        if (!empty($db_id)) {
-          $sub_sub_result =tripal_core_chado_select('db', array('name'), array('db_id'=>$db_id));
-        
-          $db_name = $sub_sub_result[0]->name;    
-      
-          if (empty($db_name)) {
-            print "ERROR: Database (".$db_id.") associated with database reference not in db table (Database Reference ID = ".$dbxref_id.")\n";
-          } elseif (empty($dbxref_accession)) {
-            print "WARNING: Missing Accession for Database Reference (Database Reference ID = ".$dbxref_id.")\n";
-          } else {
-            $dbxref[] = $db_name . ':' . $dbxref_accession;
-          }
-        }
-      }
-    }
-
-    //Main Dbxref
-    $result = tripal_core_chado_select('feature', array('dbxref_id'), array('feature_id'=>$feature_id));
-  
-    $dbxref_id = $result[0]->dbxref_id;
-  
-    if (empty($dbxref_id)) {
-      print "WARNING: No Database Reference associated directly with Feature (Feature ID = ".$feature_id.")\n";
-    }
-
-    $result = tripal_core_chado_select('dbxref', array('accession','db_id'), array('dbxref_id'=>$dbxref_id));
-      
-    $dbxref_accession = $result[0]->accession;
-
-    //checking $dbrexf_accession for emptyness 
-    if(!empty($dbxref_accession)){
-
-      $db_id = $result[0]->db_id;
-    
-      $sub_sub_result =tripal_core_chado_select('db', array('name'), array('db_id'=>$db_id));
-
-      $db_name = $sub_sub_result[0]->name;
-  
-      $dbxref[] = $db_name . ':' . $dbxref_accession;
-
-    } else {
-      print "WARNING: Missing Accession for Database Reference (Database Reference ID = ".$dbxref_id.")\n";
-    }
-
-    //attributes array is assigned given elements based on previous initializations
-    $attributes = array();
-
-    $attributes[] = 'ID='.$id;
-
-    if (!empty($name)) { 
-      $attributes[] = 'Name='.$name; 
-    }
-
-    if (!empty($synonyms)) { 
-      $attributes[] = 'Alias='.implode(',',$synonyms); 
-    }
-
-    if (!empty($dbxref)) { 
-      $attributes[] = 'Dbxref=' .implode(',', $dbxref); 
-    }
-
-    //write to string for printing
-    $stringData = implode("\t", array($seqid,$source,$type,$start,$end,$score,$strand,$phase,
-  
-    implode(';',$attributes)))."\n";
-    
-    //Write concatinated data ($stringData) to file    
-    fwrite($fh, $stringData);
-  }
-
-  //Closing file
-  fclose($fh);
-
-
-  if($clear_database){    
-    //The loading script: bp_seqfeature_load.pl, allows loading of data to specific file 
-    $command= "bp_seqfeature_load.pl -c -u '" .$user_name. "' -p '" .$password. "' -d " .$database_name. " " . $myFile;
-  }else{
-    //The loading script: bp_seqfeature_load.pl, allows loading of data to specific file 
-    $command= "bp_seqfeature_load.pl -u '" .$user_name. "' -p '" .$password. "' -d " .$database_name. " " . $myFile;
-  }
-
-  //optional 'print' statement to verify that the above comman is being called and executed properly
-  print 'Executing Command:'.$command."\n";
-
-  exec($command, $out_put, $return_var);
-} 
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Delete analysis features from database Form & Form submit
-//-----------------------------------------------------------------------------
-
-
-/**
-* This form's purpose is to delete analysis featues from a selected GBrowse insatance. By selecting
-* a Library of analyses and a GBrowse instance, the instance will be removed as will all the 
-* associated analysis library. This form allows access to a specified database and will delete any
-* selected Analysis features. It will return the form that contains all of the neccessary
-* information to send to the 'form_submit' function.
-*
-* @return $form
-*   An array of menu items allowing deletion of features from the library
-*/
-function tripal_gbrowse_delete_analysis_features_from_gbrowse_form() {
-
-  $form = array();
-  
-  $result = tripal_core_chado_select ( 'analysis', array('analysis_id','name'), array() );
-
-  foreach ($result as $value){
-    $newArray[$value->analysis_id]=$value->name;        //options for the select list
-  }
-    
-  //Creating Fieldset for multiple fields in form
-  $form['delete_analysis'] = array(
-    '#type' => 'fieldset',
-    '#title' => t(''),
-  );
-     
-   //Library ID
-   $form['delete_analysis']['analysis_id'] = array(
-    '#type' => 'select',
-    '#title' => t('Analysis Features'),
-    '#options' => $newArray,
-    '#description' => t('Analysis.'),
-  );
-    
-  //Sending query to the database
-  $resource = db_query('SELECT * FROM {tripal_gbrowse_instances}');
-
-  $items = array();
-  
-  while($record = db_fetch_object($resource)){
-    $items[$record->gbrowse_id]= $record->gbrowse_name;
-  }
-  
-  $form['delete_analysis']['gbrowse_id'] = array(
-    '#type' => 'select',
-    '#title' => t('GBrowse Instances'),
-    '#options' => $items,
-    '#description' => t('Selected Instances to be Removed.'),
-  );
-  
-  //Delete button to remove Library
-  $form['delete_analysis']['submit'] = array(
-     '#type' => 'submit', 
-     '#weight' => 10,
-     '#value' => t('Delete')
-   );
-    
-  return $form;
-}
-
-
-/**
-* This 'form_submit' function uses MySQL commands to select the GBrowse instance from a selected database.
-* Then the selected features are deleted from the library.
-*
-*
-* @param $form
-*    The submitted form that 
-*
-* @param $form_state 
-*    The state of the form, includes the selected library and the GBrowse instance to be removed
-*    The key is the 'values'
-*/
-function tripal_gbrowse_delete_analysis_features_from_gbrowse_form_submit($form, $form_state) {
-  
-  global $user;    //needed to make the current users details available so access of user id is available 
-          
-  $record = db_fetch_object(db_query('SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id=%d', $form_state['values']['gbrowse_id']));
-    
-  $name = $record->database_name;
-  
-  $user_name = $record->database_user;
-  
-  $password= $record->user_password;
-  
-  $job_args = array($name,$user_name,$password,$form_state['values']['analysis_id']);
-                  
-  //Checking state of submit button, if selected delete features from library
-  if($form_state['values']['op'] == 'Delete'){
-    //registering a delete job with the tripal system, this job calls the function when executed
-    $job_id = tripal_add_job('Deleting Analysis Features From GBrowse', 'tripal_gbrowse', 'tripal_gbrowse_delete_analysis_features_from_gbrowse', $job_args, $user->uid);
-  }
-    
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Delete Analysis Features from GBrowse
-//-----------------------------------------------------------------------------
-
-
-/**
-* Delete-GBrowse-Feature
-*
-* This form Removes features from Analysis that the user has specified. The form allows the user
-* to select a desired instance. Once the analysis and instance are selected and deleted, the selected 
-* analyses will be disassociated with the specified instance. 
-*
-* @param $database_name
-*   name of GBrowse database
-*
-* @param $user_name
-*   GBrowse MySQL user name 
-*
-* @param $password
-*   user password for GBrowse
-*
-* @param $library_id
-*   The id of the library that is being selected from
-*
-*/
-function tripal_gbrowse_delete_analysis_features_from_gbrowse($database_name, $user_name, $password, $analysis_id){
-
-  $result = tripal_core_chado_select ( 'analysis', array('name'), array('analysis_id' => $analysis_id) 
-  
-  );
-  
-  $analysis_name = $result[0]->name;
-  
-  print "Removing Analysis Features of all types related to the ".$analysis_name." analysis...\n";
-
-  $sql = 'SELECT cvterm.name FROM feature JOIN cvterm cvterm ON cvterm.cvterm_id=feature.type_id 
-  
-  JOIN analysisfeature analysisfeature ON analysisfeature.feature_id=feature.feature_id JOIN analysis 
-  
-  analysis ON analysis.analysis_id=analysisfeature.analysis_id WHERE analysis.analysis_id=%d GROUP BY 
-  
-  cvterm.name';
-
-  $previous_db = tripal_db_set_active('chado');
-  $resource = db_query($sql, $analysis_id);
-  tripal_db_set_active($previous_db);
-  
-  while($record = db_fetch_object($resource)){
-  
-    $type = $record->name;
-    
-    //The loading script: bp_seqfeature_delete.pl, allows removal of data to specific file 
-    $command= "bp_seqfeature_delete.pl -u '".$user_name."' -p '".$password."' -d '" .$database_name. "' -t '" .$type. ":".$analysis_name."'";
-    
-    print "Executing Command: ".$command."\n";
-    
-    //exec() allows for execution of a external program: given the input
-    exec($command);
-  }
-
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Add Tracks Form & Form submit
-//-----------------------------------------------------------------------------
-
-
-/**
-* Add-GBrowse-Tracks
-*      This Menu item is implemented to allow users to define and add tracks including their name,
-*  glyph, colour (fore and back ground), size and link. By adding tracks, the user is able to
-*  visually inspect the features of their genomic data. The Glyph library has been hardcoded 
-*  into the software and represents the most used Glyph representations. The "Glyph" option  
-*  determines the shape of each of the displayed genomic features associated with a specific  
-*  GBrowse track. It presents a configurable set of parameters specific to its type allowing 
-*  further control over the display features such as height, color (foreground & backround) etc.
-*
-*
-* @return
-*   An '$form' that is an array of menu items that allows the user to Register a GBrowse instance
-*/
-function tripal_gbrowse_add_tracks_form() {
-
-  
-  //Creating Fieldset for multiple fields in form
-  $form['add_tracks_field_set'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Content-Related Fields'),
-  );
-
-  //Sending query to the database for GBrowse Instances
-  $resource = db_query('SELECT * FROM {tripal_gbrowse_instances}');
-
-  $items = array();
-  
-  while($record = db_fetch_object($resource)){
-      
-    $items[$record->gbrowse_id]= $record->gbrowse_name;
-      
-  }
-
-  //GBrowse Instances
-  $form['add_tracks_field_set']['gbrowse_instances'] = array(
-    '#type' => 'select',
-    '#title' => t('Registered GBrowse Instances'),
-    '#options' => $items,
-    '#description' => t('Selected GBrowse Instances to be Loaded.'),
-    '#required' => TRUE,
-  );
-
-  //Feature Type
-  $sql = 'SELECT name as type, cvterm_id '
-          .'FROM cvterm '
-          .'WHERE cvterm_id IN (SELECT type_id FROM feature)';
-  $previous_db = tripal_db_set_active('chado');
-  $resource = db_query($sql);
-  tripal_db_set_active($previous_db);
-  
-  $items = array();
-  
-  while($record = db_fetch_object($resource)){
-    
-    $items[$record->type] = $record->type;
-  }
-
-  $form['add_tracks_field_set']['type_name'] = array(
-    '#type' => 'select',
-    '#title' => t('Feature Type'),
-    '#options' => $items,
-    '#description' => t('Selected GBrowse Instances to be Loaded.'),
-    '#required' => TRUE,
-  );
-
-  //Populating Select list for  Library    
-  $newArray['none'] = 'None';        //No option for select list
-  $result = tripal_core_chado_select ( 'library', array('library_id','name'), array() );
-  foreach ($result as $value) {
-    $newArray[$value->name]=$value->name;        //options for the select list
-  }
-        
-  //Library
-  $form['add_tracks_field_set']['library_id'] = array(
-    '#type' => 'select',
-    '#title' => t('Library'),
-    '#options' => $newArray,
-    '#description' => t('Selected GBrowse Instances to be Loaded.'),
-  );
-
-  //Creating Fieldset for multiple fields in form
-  $form['track_text'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'Track-Specific Fields'
-  );
-
-  //Specify Track Identifier
-  $form['track_text']['identifier'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Track Identifier'),
-    '#size' => 30,
-    '#maxlength' => 64,
-    '#description' => t('Specify Track Identifier (Must be Unique and Specific)'),
-    '#required' => TRUE,
-  );
-
-  //Specify Track Name
-  $form['track_text']['track_name'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Track Name'),
-    '#size' => 30,
-    '#maxlength' => 64,
-    '#description' => t('Specify Track Name (Must be Unique and Specific)'),
-    '#required' => TRUE,
-  );
-  
-  //Populating Array of Glyph List
-  $item = array();
-  $item[''] = 'Default Glyph';
-  $item['generic'] = 'Generic';
-  $item['allele_tower  '] = 'Allele Tower';
-  $item['anchored_arrow'] = 'Anchored Arrow';
-  $item['arrow'] = 'Arrow';
-  $item['box'] = 'Box';
-  $item['cds'] = 'CDS';
-  $item['crossbox'] = 'Cross Box';
-  $item['diamond'] = 'Diamond';
-  $item['dna'] = 'DNA';
-  $item['dot'] = 'Dot';
-  $item['ellipse'] = 'Ellipse';
-  $item['extending_arrow'] = 'Extending Arrow';
-  $item['generic'] = 'Generic';
-  $item['graded_segments'] = 'Graded Segments';
-  $item['heterogeneous_segments  '] = 'Heterogeneous Segments';
-  $item['image'] = 'Image';
-  $item['line'] = 'Line';
-  $item['primers'] = 'Primers';
-  $item['processed_transcript'] = 'Processed Transcript';
-  $item['rndrect'] = 'Rndrect';
-  $item['ruler_arrow'] = 'Ruler Arrow';
-  $item['segments'] = 'Segments';
-  $item['span'] = 'Span';
-  $item['toomany'] = 'Too Many';
-  $item['transcript'] = 'Transcript';
-  $item['transcript2'] = 'Transcript2';
-  $item['translation'] = 'Translation';
-  $item['triangle'] = 'Triangle';
-  $item['wiggle_densit'] = 'Wiggle Densit';
-  $item['wiggle_xyplot'] = 'Wiggle XYplot';
-  $item['xyplot'] = 'XYplot';
-      
-      
-  //Glyphs
-  $form['track_text']['glyph'] = array(
-    '#type' => 'select',
-    '#title' => t('Glyph'),
-    '#options' => $item,
-    '#description' => t('Shape of Genomic Feature Track '),
-  );
-
-  //Modify The foreground colour of track
-    $form['track_text']['foreground_colour'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Foreground Colour'),
-    '#size' => 30,
-    '#maxlength' => 64,
-    '#description' => t('Enter name/Hex-code for identifying foreground colour of glyph.
-                        List of available colours here:'.l("GBrowse Colour Palette.pdf",
-                        "http://gmod.org/mediawiki/images/a/ae/Gbrowse_Color_Palette.pdf")),
-  );
-
-
-  //Modify The Backround colour of track
-  $form['track_text']['backround_colour'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Background Colour'),
-    '#size' => 30,
-    '#maxlength' => 20,
-    '#description' => t('Enter name/Hex-code for identifying background colour of glyph.
-                        List of available colours here:'.l("GBrowse Colour Palette.pdf",
-                        "http://gmod.org/mediawiki/images/a/ae/Gbrowse_Color_Palette.pdf")),
-  );
-
-
-  //Modify The Height of track
-  $form['track_text']['track_height'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Height'),
-    '#size' => 30,
-    '#maxlength' => 20,
-    '#description' => t('Modify Track Height'),
-  );
-
-  //Specify Link
-  $form['track_text']['link'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Link'),
-    '#size' => 30,
-    '#maxlength' => 64,
-    '#description' => t('Specify to Further details (HTML address)'),
-  );
-
-  //Register job submit button
-  $form['create_instance']['submit'] = array(
-     '#type' => 'submit',
-     '#value' => t('Add Track')
-  );
-  
-  return $form;
-
-}
-
-
-/**
- * Validate User-submitted data for Register GBrowse Instances 
- *
- * This function validates the user input for each form element in the Register GBrowse 
- * instances form that is a text field. Validations checked include:
- *   - database_name: contains only word characters not including punctuation 
- *       or white-space ([A-Z][a-z][0-1]_)
- *
- * @param $form
- *   The form that the user submitted and whose input is being validated
- *
- * @param $form_state
- *   An array containing the state of the form being validated including user-input
- */
-function tripal_gbrowse_add_tracks_form_validate ($form, $form_state) {
-  
-  if (!empty($form_state['values']['foreground_colour'])) {
-    // foreground colour is present and a valid colour
-    if ( !preg_match('/^[\w#]+$/', $form_state['values']['foreground_colour'])) {
-      
-      form_set_error('foreground_colour',
-      'The Foreground Colour should be either the name of a colour listed in the linked to pdf or a valid hex colour');
-    }
-  }
-  
-  if (!empty($form_state['values']['backround_colour'])) {
-    if(!preg_match('/^[\w#]+$/', $form_state['values']['backround_colour'])){
-      form_set_error('backround_colour','The Background Colour should be either the name of a colour listed in the linked to pdf or a valid hex colour');
-    }
-  }
-  
-  if (!empty($form_state['values']['track_height'])){
-    if(!preg_match('/^\d*$/', $form_state['values']['track_height'])){
-      form_set_error('track_height','The Track Height must be a positive integer');
-    }
-  }
-  
-  if(!preg_match('/^\w+$/', $form_state['values']['identifier'])){
-
-    form_set_error('identifier','The Identifier must be composed of the following characters only: [A-Z][a-z][0-9] and _');
-  
-  }
-  
-  if (!empty($form_state['values']['link'])){
-    if(!preg_match('/^http:/', $form_state['values']['link'])){
-      form_set_error('link','The Link must be a conventional web site name, beginging with  http: ');
-    }
-  }
-
-} 
-
-
-/**
-*Add-GBrowse-Tracks Form_Submit
-*
-* @param $form
-*    The form for the information that the user has entered
-*
-* @param $form_state 
-*    This is the state of the form: i.e what button was pressed.The key is 
-*    the name of the fields in database 
-*
-* @return
-*   An '$form' that is an array of menu items that allows the user to Register a GBrowse instance
-*/
-function tripal_gbrowse_add_tracks_form_submit($form, $form_state) {
-
-  
-
-  $string = "\n[".$form_state['values']['identifier']."]\n"
-    ."key = ".$form_state['values']['track_name']."\n";
-    
-  if($form_state['values']['library_id'] == 'none'){    
-    $string .= "feature =  ".$form_state['values']['type_name']."\n";
-  } else {
-    $string .= "feature =  ".$form_state['values']['type_name'].":" .$form_state['values']['library_id']."\n";
-  }
-  
-  if (!empty($form_state['values']['glyph'])) {
-    $string .= "glyph = ".$form_state['values']['glyph']."\n";
-  }
-  
-  if (!empty($form_state['values']['track_height'])) {
-    $string .= "height = ".$form_state['values']['track_height']."\n";
-  }
-  
-  if (!empty($form_state['values']['foreground_colour'])) {
-    $string .= "bgcolor = ".$form_state['values']['foreground_colour']."\n";
-  }
-  
-  if (!empty($form_state['values']['backround_colour'])) {
-    $string .= "fgcolor = ".$form_state['values']['backround_colour']."\n";
-  }
-  
-  if (!empty($form_state['values']['link'])) {
-    $string .= "link = ".$form_state['values']['link']."\n";
-  }
-  
-  $string .= "\n";
-       
-  $record = db_fetch_object(db_query('SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id=%d', $form_state['values']['gbrowse_instances']));
-  
-  $config_file = $record->config_file;
-  
-  $command = "echo '".$string."' >> ".$config_file;
-  
-  exec($command);
-
-}
-
-
-//-----------------------------------------------------------------------------
-//  SECTION: Delete Tracks Form & Form submit
-//-----------------------------------------------------------------------------
-
-
-/**
-*Delete-GBrowse-Tracks
-*    
-*    This Form allows selection for a specific GBrowse Instance to be removed in a multi-submit form outline.
-*    Once the GBrowse instance is selected,the corresponding track list that corresponds to 
-*    the selected GBrowse instance is deleted. This can be done one track at a time. As
-*    there is no limit to the number of tracks that can be added to a particular GBrowse instance and
-*    thus all the tracks that have bee added can be deleted, one track at a time. The track that is to 
-*    be deleted is to be selected from the list. When selected and the delete button is pushed, 
-*    the track that was selected is removed from the 'configuration' file.
-*
-* @param $form_state
-*    The state of the form as it is setting the default value of $form_state is NULL
-*
-* @return
-*   An '$form' that is an array of menu items that allows the user to Register a GBrowse instance
-*/
-function tripal_gbrowse_delete_tracks_form(&$form_state=NULL) {
-
-  //Creating Fieldset for multiple fields in form
-  $form['delete_tracks_field_set'] = array(
-    '#type' => ($form_state['storage']['gbrowse_id']) ? 'hidden' : 'fieldset',
-    '#title' => t('GBrowse Specific Fields'),
-  );
-  
-  //Sending query to the database for GBrowse Instances
-  $resource = db_query('SELECT * FROM {tripal_gbrowse_instances}');
-
-  $items = array();
-  
-  while($record = db_fetch_object($resource)){
-      
-    $items[$record->gbrowse_id]= $record->gbrowse_name;
-    
-  }
-
-  //GBrowse Instance Select List
-  $form['delete_tracks_field_set']['gbrowse_instances'] = array(
-    '#type' => 'select',
-    '#title' => t('Registered GBrowse Instances'),
-    '#options' => $items,
-    '#description' => t('Selected GBrowse Instances to be Loaded.'),
-    '#default_value' => $form_state['values']['gbrowse_instances'],
-  );
-  
-  //Set Instance Submit button
-  $form['delete_tracks_field_set']['submit_instance'] = array(
-    '#type' => 'submit',
-    '#value' => t('Set Instance')
-  );
-
-  //Creating Fieldset for multiple fields in form
-  $form['delete_tracks'] = array(
-    '#type' => ($form_state['storage']['gbrowse_id']) ? 'fieldset' : 'hidden',
-    '#title' => t('Track Specific Fields'),
-  );
-  
-  
-  $gbrowse_id = $form_state['storage']['gbrowse_id'];
-  
-  if ($gbrowse_id){
-  
-    $items = track_name_options($gbrowse_id);
-  
-  }else {
-    
-    $items = array();
-  
-  }
-  
-  //Track Name Select List
-  $form['delete_tracks']['track_line_number'] = array(
-    '#type' => 'select',
-    '#title' => t('Track Name'),
-    '#options' => $items,
-    '#description' => t('Name of Track to Remove '),
-    '#default_value' => $form_state['values']['gbrowse_id'],
-  );
-
-  //Remove Track button
-  $form['delete_tracks']['remove_track'] = array(
-    '#type' => 'submit',
-    '#value' => t('Remove Track')
-  );
-
-  return $form;
-
-}
-
-
-/**
-*Delete-GBrowse-Tracks
-*
-*@param $form
-*    The form that is completed in the above section
-*
-*  @param $form_state
-*    The state of the form, as it is completed by the user and will contain all of the user's
-*    selected infromation that is to be removed from the configuration file.    
-*
-*/
-function tripal_gbrowse_delete_tracks_form_submit($form, &$form_state) {
-
-  $form_state['storage']['gbrowse_id'] = $form_state['values']['gbrowse_instances'];
-  
-  //Checking that the "Remove Track" button was selected      
-  if($form_state['clicked_button']['#value']=='Remove Track'){
-        
-    //selecting GBrowse-ID from the database
-    $resource= db_fetch_object(db_query('SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id=%d', $form_state['storage']['gbrowse_id']));
-    
-    //putting contents of the configuration file into an variable
-    $config_file = (string) $resource->config_file;
-          
-    $read_file_handle = fopen($config_file,'r') or drupal_set_message("WARNING: Can not open file:" .$config_file, 'error');
-
-    $track_number = $form_state['values']['track_line_number'];
-  
-    $line_num = 0;
-  
-    //create temp file 
-    $new_conf_file = '/tmp/temp_config_file.temp';
-          
-    //making '.temp' file in the /tmp directory
-    $command = 'touch /tmp/temp_config_file.temp';
-          
-    exec($command);
-          
-    //Checking that the newly created file is writable    
-    if (is_writable($new_conf_file)) {
-          
-      //opening file for writing to
-      $write_file_handle = fopen($new_conf_file, 'w') or drupal_set_message("WARNING: Can not open file:" .$new_conf_file, 'error');
-          
-     }else{
-           
-       drupal_set_message("WARNING: Attempting to create a temporary file -insufficient permissions: ".$new_conf_file, 'error');                   
-     }    
-
-    while(!feof($read_file_handle)){
-  
-      $file_line = fgets($read_file_handle);
-            
-      $line_num++;
-      
-      if($line_num == $track_number){
-                          
-        $remove_track = TRUE;
-                  
-       }
-       
-       if(preg_match('/^\s*$/',$file_line)){
-                            
-         $remove_track=FALSE;
-                  
-       }
-       
-       if($remove_track==FALSE){
-                  
-         fwrite($write_file_handle, $file_line);              
-                  
-       }
-                                    
-    }
-          
-    $command = 'cp '.$new_conf_file.'  '.$config_file  ; 
-          
-    exec($command);
-          
-    $command = 'rm '.$new_conf_file ;
-          
-    exec($command);
-        
-  }
-      
-}
-
-
-/**
-*  Populate Track-Name List
-*
-* This section  takes a GBrowse ID so the coresponding configuration file can be accessed. Once it has been
-* obtained from the database, by the db_query() command. The configuration file is is searched for lines
-* that start with "[ ]". This corresponds to the framework of the conf file, as the Track Names are
-* enclosed within "[ ]". The file is then scanned from the spots that contain the "[ ]".  
-*
-*
-*  @param gbrowse_id
-*        The Selected GBrowse instance's identification
-*
-* @return
-*    $items() and array with the tracks that are in the selected GBrowse instance.
-*/
-function track_name_options($gbrowse_id) {
-
-  $items = array();
-
-  // Use GBrowse ID to get configuration filename  
-  $record = db_fetch_object(db_query('SELECT * FROM {tripal_gbrowse_instances} WHERE gbrowse_id=%d', $gbrowse_id));
-
-  //putting contents of the configuration file into an variable
-  $config_file = (string) $record->config_file;
-
-  $config_array = array();
-  
-  //command to select the lines that begin with '[' and have characters within the '[ ]'
-  $command = 'grep -n "^\[.*\]" ' .$config_file;
-    
-  //execution of the command
-  exec($command , $config_array);
-  
-  $config_array_size = count($config_array);
-        
-  //while the end-of-file has not been reached
-  for($i = 0 ; $i < $config_array_size; $i++){
-    
-    $file_line = $config_array[$i];      
-          
-        if ($is_track_definition){
-        
-            if(preg_match('/^(\d+):\[(.+)\]$/', $file_line, $matches)){
-  
-              $items[$matches[1]] = $matches[2];
-              
-            }
-        
-    }
-        
-        if(preg_match('/\[TRACK DEFAULTS\]/', $file_line)){
-            
-            $is_track_definition = TRUE;
-        }
-        
-  }
-  
-  return $items;
-}
-
-
-//-----------------------------------------------------------------------------
-//  END OF SOFTWARE
-//-----------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
-

+ 0 - 606
extensions/tripal_gbrowse/tripal_gbrowse.views.inc

@@ -1,606 +0,0 @@
-<?php
-
-
-/**
-* Developed by: Chad N.A Krilow at The University of Saskatchewan
-* Contact:cnk046@mail.usask.ca
-*/
-
-
-/**
- * Implements hook_views_data(): Describe tripal tables & fields to views
- *
- * @return array
- *   A data array which follows the structure outlined in the
- *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by tripal table name. Each table definition 
- *   includes basic details about the table, fields in that table and
- *   relationships between that table and others (joins)
- */ 
-function tripal_gbrowse_views_data() {
-  
-  //array to be filled with views data
-  $data = array();
-
-  // Basic table definition
-  $data['tripal_gbrowse_instances']['table']['group'] = 'Tripal GBrowse';
-  $data['tripal_gbrowse_instances']['table']['base'] = array(
-    'field' => 'gbrowse_id',
-    'title' => 'Tripal GBrowse',
-    'help' => 'A GMOD GBrowse instance registered with Tripal',                                                                                                                                                                          
-  );
-
-  // Join the node table to chado stock
-  $data['node']['table']['join']['tripal_gbrowse_instances'] = array(
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );
-
-  // Field: database_name(varchar 255)
-  $data['tripal_gbrowse_instances']['database_name'] = array(
-    'title' => 'Database Name',
-    'help' => 'The specified name of the Database',
-    '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: database_user(varchar 255)
-  $data['tripal_gbrowse_instances']['database_user'] = array(
-    'title' => 'Database User',
-    'help' => 'The Registered User of the Database',
-    '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: user_password(varchar 255)
-  $data['tripal_gbrowse_instances']['user_password'] = array(
-    'title' => 'User Password',
-    'help' => 'The user password',
-    '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: gbrowse_name(varchar 255)
-  $data['tripal_gbrowse_instances']['gbrowse_name'] = array(
-    'title' => 'GBrowse Instance Name',
-    'help' => 'The Name of the Specified GBrowse Instance',
-    '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: gbrowse_link(varchar 255)
-  $data['tripal_gbrowse_instances']['gbrowse_link'] = array(
-    'title' => 'GBrowse Instance Link',
-    'help' => 'The Link to the GBrowse Instance',
-    '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: config_file(varchar 255)
-  $data['tripal_gbrowse_instances']['config_file'] = array(
-    'title' => 'Configuration File',
-    'help' => 'The Configuration File Associated with the GBrowse Instance',
-    '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;
-  
-}
-
-
-/**
- * Implements hook_views_default_views(): Describe tripal tables & fields to views
- *
- * This function represents the "Default View" that the user will see when on the drupal site.
- *
- */
-function tripal_gbrowse_views_default_views() {
-  
-  $views = array();
-  
-  $view = new view;
-
-  $view->name = 'all_tripal_gbrowse_instances';
-  $view->description = '';
-  $view->tag = '';
-  $view->view_php = '';
-  $view->base_table = 'tripal_gbrowse_instances';
-  $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(
-  'gbrowse_name' => array(
-    'label' => 'Instance Name',
-    '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' => 'gbrowse_name',
-    'table' => 'tripal_gbrowse_instances',
-    'field' => 'gbrowse_name',
-    'relationship' => 'none',
-    'override' => array(
-      'button' => 'Override',
-    ),
-  ),
-  'database_name' => array(
-    'label' => 'Database Name',
-    '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' => 'database_name',
-    'table' => 'tripal_gbrowse_instances',
-    'field' => 'database_name',
-    'relationship' => 'none',
-  ),
-  'gbrowse_link' => array(
-    'label' => 'GBrowse Instance Link',
-    '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' => 'gbrowse_link',
-    'table' => 'tripal_gbrowse_instances',
-    'field' => 'gbrowse_link',
-    'relationship' => 'none',
-  ),
-));
-
-$handler->override_option('filters', array(
-  'database_name' => array(
-    'operator' => '=',
-    'value' => '',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 0,
-      'operator' => 'database_name_op',
-      'identifier' => 'database_name',
-      'label' => 'GBrowse: Database Name',
-      'optional' => 1,
-      'remember' => 0,
-    ),
-    'case' => 1,
-    'id' => 'database_name',
-    'table' => 'tripal_gbrowse_instances',
-    'field' => 'database_name',
-    'relationship' => 'none',
-    'override' => array(
-      'button' => 'Override',
-    ),
-  ),
-  'gbrowse_name' => array(
-    'operator' => '=',
-    'value' => '',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 0,
-      'operator' => 'gbrowse_name_op',
-      'identifier' => 'gbrowse_name',
-      'label' => 'GBrowse: Instance Name',
-      'optional' => 1,
-      'remember' => 0,
-    ),
-    'case' => 1,
-    'id' => 'gbrowse_name',
-    'table' => 'tripal_gbrowse_instances',
-    'field' => 'gbrowse_name',
-    'override' => array(
-      'button' => 'Override',
-    ),
-    'relationship' => 'none',
-  ),
-  'database_user' => array(
-    'operator' => '=',
-    'value' => '',
-    'group' => '0',
-    'exposed' => TRUE,
-    'expose' => array(
-      'use_operator' => 0,
-      'operator' => 'database_user_op',
-      'identifier' => 'database_user',
-      'label' => 'GBrowse: Database User',
-      'optional' => 1,
-      'remember' => 0,
-    ),
-    'case' => 1,
-    'id' => 'database_user',
-    'table' => 'tripal_gbrowse_instances',
-    'field' => 'database_user',
-    'override' => array(
-      'button' => 'Override',
-    ),
-    'relationship' => 'none',
-  ),
-));
-
-  $handler->override_option('access', array(
-    'type' => 'perm',
-    'perm' => 'access tripal_gbrowse content',
-  ));
-
-  $handler->override_option('cache', array(
-    'type' => 'none',
-  ));
-  
-$handler->override_option('empty', 'No GBrowse instances match these criteria.');
-
-$handler->override_option('empty_format', '1');
-
-$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(
-      'gbrowse_name' => 'gbrowse_name',
-      'database_name' => 'database_name',
-      'gbrowse_link' => 'gbrowse_link',
-    ),
-    'info' => array(
-      'gbrowse_name' => array(
-        'sortable' => 1,
-        'separator' => '',
-      ),
-      'database_name' => array(
-        'sortable' => 1,
-        'separator' => '',
-      ),
-      'gbrowse_link' => array(
-        'sortable' => 1,
-        'separator' => '',
-      ),
-    ),
-    'default' => 'gbrowse_name',
-  ));
-
-$handler = $view->new_display('page', 'Page', 'page_1');
-
-  $handler->override_option('fields', array(
-    'title' => array(
-      'label' => 'GBrowse Instance Name',
-      '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,
-			'link_to_node' => 1,
-			'exclude' => 0,
-			'id' => 'title',
-			'table' => 'node',
-			'field' => 'title',
-			'override' => array(
-				'button' => 'Use default',
-			),
-			'relationship' => 'none',
-		),
-		'database_name' => array(
-			'label' => 'Database Name',
-			'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' => 'database_name',
-			'table' => 'tripal_gbrowse_instances',
-			'field' => 'database_name',
-			'relationship' => 'none',
-		),
-		'gbrowse_link' => array(
-			'label' => 'GBrowse Instance Link',
-			'alter' => array(
-				'alter_text' => 0,
-				'text' => '',
-				'make_link' => 1,
-				'path' => '[gbrowse_link]',
-				'link_class' => '',
-				'alt' => '',
-				'prefix' => '',
-				'suffix' => '',
-				'target' => '',
-				'help' => '',
-				'trim' => 0,
-				'max_length' => '',
-				'word_boundary' => 1,
-				'ellipsis' => 1,
-				'html' => 0,
-				'strip_tags' => 0,
-			),
-			'empty' => '',
-			'hide_empty' => 1,
-			'empty_zero' => 0,
-			'exclude' => 0,
-			'id' => 'gbrowse_link',
-			'table' => 'tripal_gbrowse_instances',
-			'field' => 'gbrowse_link',
-			'relationship' => 'none',
-			'override' => array(
-				'button' => 'Use default',
-			),
-		),
-		'changed' => array(
-			'label' => 'Updated date',
-			'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,
-			'date_format' => 'custom',
-			'custom_date_format' => 'D, d M Y ',
-			'exclude' => 0,
-			'id' => 'changed',
-			'table' => 'node',
-			'field' => 'changed',
-			'override' => array(
-				'button' => 'Use default',
-			),
-			'relationship' => 'none',
-		),
-		'created' => array(
-			'label' => 'Post date',
-			'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,
-			'date_format' => 'custom',
-			'custom_date_format' => 'D, d M Y ',
-			'exclude' => 0,
-			'id' => 'created',
-			'table' => 'node',
-			'field' => 'created',
-			'override' => array(
-				'button' => 'Use default',
-			),
-			'relationship' => 'none',
-		),
-		'edit_node' => array(
-			'label' => 'Edit link',
-			'alter' => array(
-				'alter_text' => 0,
-				'text' => '',
-				'make_link' => 1,
-				'path' => '[gbrowse_link]',
-				'link_class' => '',
-				'alt' => '',
-				'prefix' => '',
-				'suffix' => '',
-				'target' => '',
-				'help' => '',
-				'trim' => 0,
-				'max_length' => '',
-				'word_boundary' => 1,
-				'ellipsis' => 1,
-				'html' => 0,
-				'strip_tags' => 0,
-			),
-			'empty' => '',
-			'hide_empty' => 1,
-			'empty_zero' => 0,
-			'text' => '',
-			'exclude' => 0,
-			'id' => 'edit_node',
-			'table' => 'node',
-			'field' => 'edit_node',
-			'override' => array(
-				'button' => 'Use default',
-			),
-			'relationship' => 'none',
-		),
-	));
-	$handler->override_option('path', 'gbrowse_instances');
-	$handler->override_option('menu', array(
-		'type' => 'normal',
-		'title' => 'GBrowse Instances',
-		'description' => '',
-		'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;
-
-}