Browse Source

Reorganization of functions into api, includes and theme files to make all modules consistent

spficklin 12 years ago
parent
commit
fb42852fa2
30 changed files with 1363 additions and 1506 deletions
  1. 29 56
      tripal_analysis/api/tripal_analysis.api.inc
  2. 144 127
      tripal_analysis/includes/tripal_analysis.admin.inc
  3. 115 0
      tripal_analysis/theme/tripal_analysis_admin.tpl.php
  4. 15 221
      tripal_analysis/tripal_analysis.module
  5. 9 0
      tripal_core/api/tripal_core.schema_v1.11.api.inc
  6. 0 63
      tripal_db/includes/tripal_db.admin.inc
  7. 47 0
      tripal_db/theme/tripal_db_admin.tpl.php
  8. 19 1
      tripal_db/tripal_db.module
  9. 0 100
      tripal_feature/api/tripal_feature.api.inc
  10. 328 0
      tripal_feature/includes/tripal_feature.admin.inc
  11. 0 325
      tripal_feature/tripal_feature.module
  12. 0 46
      tripal_featuremap/api/tripal_featuremap.api.inc
  13. 4 0
      tripal_featuremap/tripal_featuremap.module
  14. 0 49
      tripal_genetic/api/tripal_genetic.api.inc
  15. 26 0
      tripal_genetic/includes/tripal_genetic.schema.inc
  16. 3 1
      tripal_genetic/tripal_genetic.module
  17. 2 0
      tripal_library/tripal_library.install
  18. 4 4
      tripal_library/tripal_library.module
  19. 6 0
      tripal_natural_diversity/api/tripal_natural_diversity.api.inc
  20. 6 101
      tripal_natural_diversity/includes/tripal_natural_diversity.schema.inc
  21. 2 1
      tripal_natural_diversity/tripal_natural_diversity.module
  22. 0 55
      tripal_organism/api/tripal_organism.api.inc
  23. 351 0
      tripal_project/includes/tripal_project.admin.inc
  24. 93 0
      tripal_project/theme/tripal_project_admin.tpl.php
  25. 0 103
      tripal_project/tripal_project.admin.inc
  26. 34 56
      tripal_project/tripal_project.module
  27. 0 60
      tripal_stock/api/tripal_stock.api.inc
  28. 0 133
      tripal_stock/includes/tripal_stock-administration.inc
  29. 115 0
      tripal_stock/theme/tripal_stock_admin.tpl.php
  30. 11 4
      tripal_stock/tripal_stock.module

+ 29 - 56
tripal_analysis/api/tripal_analysis.api.inc

@@ -8,7 +8,36 @@
  * @ingroup tripal_analysis
  * @ingroup tripal_api
  */
+/**
+ * Register tripal_analysis sub-modules
+ *
+ * @param $modulename
+ *  The name of the module to be registered as a tripal analysis submodule
+ *
+ * @ingroup tripal_analysis
+ */
+function tripal_analysis_register_child($modulename) {
+  $sql = "SELECT * FROM {tripal_analysis} WHERE modulename = '%s'";
+  if(!db_result($sql, $modulename)) {
+    $sql = "INSERT INTO {tripal_analysis} (modulename) VALUES ('%s')";
+    db_query($sql, $modulename);
+  }
+}
 
+/**
+ * Un-register a tripal analysis sub-module
+ *
+ * @param $modulename
+ *  The name of the module to un-register
+ *
+ * @ingroup tripal_analysis
+ */
+function tripal_analysis_unregister_child($modulename) {
+  if (db_table_exists('tripal_analysis')) {
+      $sql = "DELETE FROM {tripal_analysis} WHERE modulename = '%s'";
+      db_query($sql, $modulename);
+  }
+}
 /**
  * Retrieve properties of a given type for a given analysis
  *
@@ -110,59 +139,3 @@ function tripal_analysis_get_node($analysis_id) {
   $node = db_fetch_object(db_query($sql, $analysis_id));
   return $node;
 }
-
-/**
- * @section Chado Table Descriptions
- */
-
-/**
- * Implements hook_chado_schema_v1_11_table()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the analysis table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_analysis_chado_schema_v1_11_analysis() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_schema_v1_11_analysis()
-
-  $referring_tables = array(
-      'analysisfeature',
-      'analysisprop',
-      'phylotree',
-      'quantification'
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-/**
- * Implements hook_chado_schema_v1_2_table()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the analysis table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_analysis_chado_schema_v1_2_analysis() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_schema_v1_2_analysis()
-
-  $referring_tables = array(
-      'analysisfeature',
-      'analysisprop',
-      'phylotree',
-      'quantification'
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}

+ 144 - 127
tripal_analysis/includes/tripal_analysis.admin.inc

@@ -5,133 +5,6 @@
  * Contains functions displaying administrative pages and forms
  */
 
-/**
- * Purpose: Provide Guidance to new Tripal Admin
- *
- * @return
- *   HTML Formatted text
- *
- * @ingroup tripal_analysis
- */
-function tripal_analysis_module_description_page() {
-
-  $text .= '<h3>Tripal Analysis Administrative Tools Quick Links:</h3>';
-  $text .= "<ul>
-             <li><a href=\"" . url("admin/tripal/tripal_analysis/configuration") . "\">Analysis Configuration</a></li>
-           </ul>";
-
-
-  $text .= '<h3>Module Description:</h3>';
-  $text .= '<p>The Tripal Analysis module provides a generic analysis content type that is intended to be
-            used when a more specialized analysis module does not exist.  Because it is generic, it does not
-            provide any visualization or data loading tools for analysis data.  Specialized analysis modules,
-            such as the Tripal Analysis Blast or Tripal Analysis KEGG modules provide loading and custom
-            visualizations for the analysis results.  These modules must be installed separately.
-            </p>';
-
-  $text .= '<h3>Setup Instructions:</h3>';
-  $text .= '<p>After installation of the analysis module or any specialized analysis module.  The following tasks should be performed
-            <ol>
-              <li><p><b>Set Permissions</b>: Each analysis module supports the Drupal user permissions interface for
-               controlling access to the content and functions. These permissions include viewing,
-               creating, editing or administering of
-               analysis content. The default is that only the original site administrator has these
-               permissions.  You can <a href="' . url('admin/user/roles') .  '">add roles</a> for classifying users,
-               <a href="' . url('admin/user/user') . '">assign users to roles</a> and
-               <a href="' . url('admin/user/permissions') . '">assign permissions</a> for the analysis content to
-               those roles.  For a simple setup, allow anonymous users access to view organism content and
-               allow the site administrator all other permissions.</p></li>
-
-
-               <li><p><b>Create Analysis</b>:  An analysis should be <a href="' . url('node/add') . '">created</a> before data is imported into
-               chado.  The generic analysis type should only be used when a more specialized analysis module
-               (e.g. Tripal Analysis Blast module) does not already exists.  All data imported into
-               Chado should be associated with an analysis.
-
-               <li><p><b>Sync Analyses</b>:  If Chado has preloaded analyses then you can sync those.  This process is what
-               creates the pages for viewing an analysis on the site.  Analyses can be synced using the
-               <a href="' . url('admin/tripal/tripal_analysis/configuration') . '">Analysis Configuration page</a>.
-               However, syncing an analyses will always create a generic analysis content type.  If you would like
-               to use a specialized analysis module for visualization of data then do not sync the analysis but recreate it
-               using the appropriate specialized analysis content type.</p></li>
-
-            </ol>
-            </p>';
-
-
-  $text .= '<h3>Features of this Module:</h3>';
-  $text .= '<p>Aside from providing a generic content type the Tripal Analysis module also provides the following functionality
-            <ul>
-
-              <li><p><b>Basic Analysis Lookup View</b>: This module provides a basic <a href="' . url('analyses') . '">analysis search
-              tool</a> for finding or listing analyses in Chado. It does not require indexing for Drupal searching but relies
-              on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed. </p></li>
-
-            </ul>
-            </p>';
-
-  $text .= '<h3>Page Customizations</h3>';
-  $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
-             Below is a description of several methods.  These methods may be used in conjunction with one another to
-             provide fine-grained control.
-             <ul>
-
-             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
-              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.
-              Tripal comes with pre-set layouts for analysis pages.  However,
-              Panels become useful if you prefer a layout that is different from the pre-set layouts.  Chado content
-              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
-              Panel\'s GUI.</p></li>
-
-             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
-             <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
-             to any page without need to edit template files or knowing PHP.  You must first download and install CCK.
-             With CCK, the site administartor can create a new field to appear on the page.  For example, currently,
-             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text
-             field to the analysis pages.  This content is not stored in Chado, but will appear on the analysis page.  A field
-             added by CCK will also appear in the form when editing a analysis to allow users to manually enter the appropriate
-             text.  If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
-             indicate that it is not to be shown (using the CCK interface), then manually add the new content type
-             where desired by editing the templates (as described below).  If using Panels, the CCK field can be added to the
-             location desired using the Panels interface.</p></li>
-
-             <li><p><b>Drupal Node Templates</b>:  The Tripal packages comes with a "theme_tripal" directory that contains the
-             themeing for Chado content.    The analysis module has a template file for analysis "nodes" (Tripal analysis pages).  This file
-             is named "node-chado_analysis.tpl.php", and provides javascript, HTML and PHP code for display of the analysis
-             pages.  Specialized analysis modules will have their own template files as well, such as "node-chado_analysis-blast.tpl.php" for the
-             Tripal Analysis Blast module.  You can edit the template file to control which types of information (or which analysis "blocks") are displayed
-             for analysis. Be sure to
-             copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
-             future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
-             for instructions on how to access variables and other Chado content within the template file.</p></li>
-
-             <li><p><b>Analysis "Block" Templates</b>:  In the "theme_tripal" directory are subdirectories named after each tripal module (e.g. "tripal_feature", "tripal_library", etc.).
-             Inside each directory is a set of templates that control distinct types of information for each content type.  For example,
-             there is a "base" template for displaying of data directly from the Chado feature table, and a "references"
-             template for showing external site references for a feature (data from the feature_dbxref table).
-              These templates are used both by Drupal blocks
-             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
-             provides (also desribed above).  Analyses block templates can exist in any of these directories.  For example, the Tripal Analysis Unigene
-             module uses templates in the tripal_analysis_unigene, tripal_organism, and tripal_feature directories.  Content for a unigene is then
-             cusotmizable within each of these contexts.
-             You can customize block template as you desire.  Be sure to copy the
-             template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
-             future Tripal updates may overwrite your customizations.  See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
-             for instructions on how to access variables and other Chado content within the template files.</p></li>
-             </li>
-
-             <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
-             will see a "Resources" sidebar on each page.  The links that appear on the sidebar are automatically generated
-             using Javascript for all of the analysis "Blocks" that appear on the page. If you want to add additional links
-             (e.g. a dynamic link to GBrowse for the analysis) and you want that link to appear in the
-             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
-             section at the bottom of the template file where the resources section is found.</p></li>
-
-             </ul>
-             </p>';
-
-  return $text;
-}
 
 /**
  * Administration page callbacks for the Tripal Analysis module
@@ -517,3 +390,147 @@ function tripal_analysis_admin_validate($form, &$form_state) {
   }
 }
 
+/**
+ * Synchronize analyses from chado to drupal
+ *
+ * @ingroup tripal_analysis
+ */
+function tripal_analysis_sync_analyses($analysis_id = NULL, $job_id = NULL) {
+  global $user;
+  $page_content = '';
+
+  if (!$analysis_id) {
+    $sql = "SELECT Analysis_id, name, description, program, ".
+        "  programversion, algorithm, sourcename, sourceversion, sourceuri, ".
+          "  timeexecuted ".
+          "FROM {Analysis} ";
+    $results = chado_query($sql);
+  }
+  else {
+    $sql = "SELECT Analysis_id, name, description, program, ".
+         "  programversion, algorithm, sourcename, sourceversion, sourceuri, ".
+          "  timeexecuted ".
+          "FROM {Analysis} ".
+          "WHERE analysis_id = %d";
+    $results = chado_query($sql, $analysis_id);
+  }
+
+
+  // We'll use the following SQL statement for checking if the analysis
+  // already exists as a drupal node.
+  $sql = "SELECT * FROM {chado_analysis} ".
+          "WHERE analysis_id = %d";
+
+  while ($analysis = db_fetch_object($results)) {
+        print "syncing analysis ";
+        print $analysis->name;
+        print ", ";
+        print $analysis->analysis_id;
+        print "\n";
+
+    // check if this analysis already exists in the drupal database. if it
+    // does then skip this analysis and go to the next one.
+    if (!db_fetch_object(db_query($sql, $analysis->analysis_id))) {
+
+      $new_node = new stdClass();
+
+      // try to access analysis type for this analysis
+      $sql = "SELECT * FROM {analysisprop}
+                    WHERE analysis_id = %d
+                    AND type_id =
+                        (SELECT cvterm_id from {cvterm} where name = '%s')
+            ";
+      $analysis_type = db_fetch_object(chado_query($sql, $analysis->analysis_id, "analysis_type"));
+
+      // Get the type of analysis using cvterm_id
+            // Current possibilities: kegg, unigene, interpro, blast
+      if ($analysis_type) {
+
+        // This is a unigene analysis
+        if ($analysis_type->value == 'tripal_analysis_unigene') {
+          $new_node->type = 'chado_analysis_unigene';
+        // This is a blast analysis
+        }
+        elseif ($analysis_type->value == 'tripal_analysis_blast') {
+          $new_node->type = 'chado_analysis_blast';
+         // This is a interpro analysis
+        }
+        elseif ($analysis_type->value == 'tripal_analysis_interpro') {
+          $new_node->type = 'chado_analysis_interpro';
+         // This is a kegg analysis
+        }
+        elseif ($analysis_type->value == 'tripal_analysis_kegg' ) {
+          $new_node->type = 'chado_analysis_kegg';
+        }
+        else {
+          $new_node->type = 'chado_analysis';
+        }
+      // If it doesn't exist, this analysis is generic
+      }
+      else {
+        $new_node->type = 'chado_analysis';
+      }
+
+      print "analysis type is $new_node->type\n";
+
+      $new_node->uid = $user->uid;
+      $new_node->analysis_id = $analysis->analysis_id;
+      $new_node->analysisname = $analysis->name;
+      $new_node->description = $analysis->description;
+      $new_node->program = $analysis->program;
+      $new_node->programversion = $analysis->programversion;
+      $new_node->algorithm = $analysis->algorithm;
+      $new_node->sourcename = $analysis->sourcename;
+      $new_node->sourceversion = $analysis->sourceversion;
+      $new_node->sourceuri = $analysis->sourceuri;
+      $new_node->timeexecuted = $analysis->timeexecuted;
+
+      // If the analysis has a name, use it as the node title. If not,
+      // construct the title using program, programversion, and sourcename
+      if ($new_node->analysisname) {
+        $new_node->title = $new_node->analysisname;
+      }
+      else {
+        //Construct node title as "program (version)"
+        $new_node->title = "$analysis->program ($analysis->programversion)";
+      }
+
+      node_validate($new_node);
+
+            $errors = form_get_errors();
+
+            if ($errors) {
+                print_r($errors);
+            }
+            else{
+      // if(!form_get_errors()){
+        $node = node_submit($new_node);
+        node_save($node);
+
+        if ($node->nid) {
+          $page_content .= "Added $new_node->title<br />";
+        }
+      }
+    }
+    else {
+      $page_content .= "Skipped $new_node->title<br />";
+    }
+  }
+  return $page_content;
+}
+
+/**
+ * Remove orphaned drupal nodes
+ *
+ * @param $dummy
+ *   Not Used -kept for backwards compatibility
+ * @param $job_id
+ *   The id of the tripal job executing this function
+ *
+ * @ingroup tripal_analysis
+ */
+function tripal_analyses_cleanup($dummy = NULL, $job_id = NULL) {
+
+  return tripal_core_clean_orphaned_nodes('analysis', $job_id);
+  
+}

+ 115 - 0
tripal_analysis/theme/tripal_analysis_admin.tpl.php

@@ -0,0 +1,115 @@
+
+  <h3>Tripal Analysis Administrative Tools Quick Links:</h3>
+  <ul>
+             <li><a href="<?php print url("admin/tripal/tripal_analysis/configuration") ?>">Analysis Configuration</a></li>
+           </ul>
+
+
+  <h3>Module Description:</h3>
+  <p>The Tripal Analysis module provides a generic analysis content type that is intended to be
+            used when a more specialized analysis module does not exist.  Because it is generic, it does not
+            provide any visualization or data loading tools for analysis data.  Specialized analysis modules,
+            such as the Tripal Analysis Blast or Tripal Analysis KEGG modules provide loading and custom
+            visualizations for the analysis results.  These modules must be installed separately.
+            </p>
+
+  <h3>Setup Instructions:</h3>
+  <p>After installation of the analysis module or any specialized analysis module.  The following tasks should be performed
+            <ol>
+              <li><p><b>Set Permissions</b>: Each analysis module supports the Drupal user permissions interface for
+               controlling access to the content and functions. These permissions include viewing,
+               creating, editing or administering of
+               analysis content. The default is that only the original site administrator has these
+               permissions.  You can <a href="<?php print url('admin/user/roles') ?>">add roles</a> for classifying users,
+               <a href="<?php print url('admin/user/user') ?>">assign users to roles</a> and
+               <a href="<?php print url('admin/user/permissions') ?>">assign permissions</a> for the analysis content to
+               those roles.  For a simple setup, allow anonymous users access to view organism content and
+               allow the site administrator all other permissions.</p></li>
+
+
+               <li><p><b>Create Analysis</b>:  An analysis should be <a href="<?php print url('node/add') ?>">created</a> before data is imported into
+               chado.  The generic analysis type should only be used when a more specialized analysis module
+               (e.g. Tripal Analysis Blast module) does not already exists.  All data imported into
+               Chado should be associated with an analysis.
+
+               <li><p><b>Sync Analyses</b>:  If Chado has preloaded analyses then you can sync those.  This process is what
+               creates the pages for viewing an analysis on the site.  Analyses can be synced using the
+               <a href="<?php print url('admin/tripal/tripal_analysis/configuration') ?>">Analysis Configuration page</a>.
+               However, syncing an analyses will always create a generic analysis content type.  If you would like
+               to use a specialized analysis module for visualization of data then do not sync the analysis but recreate it
+               using the appropriate specialized analysis content type.</p></li>
+
+            </ol>
+            </p>
+
+
+  <h3>Features of this Module:</h3>
+  <p>Aside from providing a generic content type the Tripal Analysis module also provides the following functionality
+            <ul>
+
+              <li><p><b>Basic Analysis Lookup View</b>: This module provides a basic <a href="<?php print url('analyses') ?>">analysis search
+              tool</a> for finding or listing analyses in Chado. It does not require indexing for Drupal searching but relies
+              on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed. </p></li>
+
+            </ul>
+            </p>
+
+  <h3>Page Customizations</h3>
+  <p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
+             Below is a description of several methods.  These methods may be used in conjunction with one another to
+             provide fine-grained control.
+             <ul>
+
+             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
+              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.
+              Tripal comes with pre-set layouts for analysis pages.  However,
+              Panels become useful if you prefer a layout that is different from the pre-set layouts.  Chado content
+              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
+              Panel\'s GUI.</p></li>
+
+             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
+             <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
+             to any page without need to edit template files or knowing PHP.  You must first download and install CCK.
+             With CCK, the site administartor can create a new field to appear on the page.  For example, currently,
+             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text
+             field to the analysis pages.  This content is not stored in Chado, but will appear on the analysis page.  A field
+             added by CCK will also appear in the form when editing a analysis to allow users to manually enter the appropriate
+             text.  If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
+             indicate that it is not to be shown (using the CCK interface), then manually add the new content type
+             where desired by editing the templates (as described below).  If using Panels, the CCK field can be added to the
+             location desired using the Panels interface.</p></li>
+
+             <li><p><b>Drupal Node Templates</b>:  The Tripal packages comes with a "theme_tripal" directory that contains the
+             themeing for Chado content.    The analysis module has a template file for analysis "nodes" (Tripal analysis pages).  This file
+             is named "node-chado_analysis.tpl.php", and provides javascript, HTML and PHP code for display of the analysis
+             pages.  Specialized analysis modules will have their own template files as well, such as "node-chado_analysis-blast.tpl.php" for the
+             Tripal Analysis Blast module.  You can edit the template file to control which types of information (or which analysis "blocks") are displayed
+             for analysis. Be sure to
+             copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
+             future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
+             for instructions on how to access variables and other Chado content within the template file.</p></li>
+
+             <li><p><b>Analysis "Block" Templates</b>:  In the "theme_tripal" directory are subdirectories named after each tripal module (e.g. "tripal_feature", "tripal_library", etc.).
+             Inside each directory is a set of templates that control distinct types of information for each content type.  For example,
+             there is a "base" template for displaying of data directly from the Chado feature table, and a "references"
+             template for showing external site references for a feature (data from the feature_dbxref table).
+              These templates are used both by Drupal blocks
+             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
+             provides (also desribed above).  Analyses block templates can exist in any of these directories.  For example, the Tripal Analysis Unigene
+             module uses templates in the tripal_analysis_unigene, tripal_organism, and tripal_feature directories.  Content for a unigene is then
+             cusotmizable within each of these contexts.
+             You can customize block template as you desire.  Be sure to copy the
+             template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
+             future Tripal updates may overwrite your customizations.  See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
+             for instructions on how to access variables and other Chado content within the template files.</p></li>
+             </li>
+
+             <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
+             will see a "Resources" sidebar on each page.  The links that appear on the sidebar are automatically generated
+             using Javascript for all of the analysis "Blocks" that appear on the page. If you want to add additional links
+             (e.g. a dynamic link to GBrowse for the analysis) and you want that link to appear in the
+             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
+             section at the bottom of the template file where the resources section is found.</p></li>
+
+             </ul>
+             </p>

+ 15 - 221
tripal_analysis/tripal_analysis.module

@@ -14,36 +14,6 @@
 require('api/tripal_analysis.api.inc');
 require('includes/tripal_analysis_privacy.inc');
 
-/**
- * Register tripal_analysis sub-modules
- *
- * @param $modulename
- *  The name of the module to be registered as a tripal analysis submodule
- *
- * @ingroup tripal_analysis
- */
-function tripal_analysis_register_child($modulename) {
-  $sql = "SELECT * FROM {tripal_analysis} WHERE modulename = '%s'";
-  if(!db_result($sql, $modulename)) {
-    $sql = "INSERT INTO {tripal_analysis} (modulename) VALUES ('%s')";
-    db_query($sql, $modulename);
-  }
-}
-
-/**
- * Un-register a tripal analysis sub-module
- *
- * @param $modulename
- *  The name of the module to un-register
- *
- * @ingroup tripal_analysis
- */
-function tripal_analysis_unregister_child($modulename) {
-  if (db_table_exists('tripal_analysis')) {
-      $sql = "DELETE FROM {tripal_analysis} WHERE modulename = '%s'";
-      db_query($sql, $modulename);
-  }
-}
 
 /**
  * Add tripal javascript to page headers
@@ -65,15 +35,16 @@ function tripal_analysis_menu() {
   $items['chado_sync_analyses'] = array(
      'title' => 'Sync Data',
      'page callback' => 'tripal_analysis_sync_analyses',
-     'access arguments' => array('administer site configuration'),
+     'access arguments' => array('administer tripal analyses'),
      'type' => MENU_CALLBACK
   );
   // Tripal Analysis administrative settings
   $items['admin/tripal/tripal_analysis'] = array(
       'title' => 'Analyses',
       'description' => 'Basic Description of Tripal Analysis Module Functionality.',
-      'page callback' => 'tripal_analysis_module_description_page',
-      'access arguments' => array('administer site configuration'),
+      'page callback' => 'theme',
+      'page arguments' => array('tripal_analysis_admin'),
+      'access arguments' => array('administer tripal analyses'),
       'type' => MENU_NORMAL_ITEM,
       'file' => 'includes/tripal_analysis.admin.inc',
   );
@@ -83,7 +54,7 @@ function tripal_analysis_menu() {
       'description' => 'Settings for the displays of analysis results.',
       'page callback' => 'drupal_get_form',
       'page arguments' => array('tripal_analysis_admin'),
-      'access arguments' => array('administer site configuration'),
+      'access arguments' => array('administer tripal analyses'),
       'type' => MENU_NORMAL_ITEM,
       'file' => 'includes/tripal_analysis.admin.inc',
   );
@@ -483,134 +454,7 @@ function chado_analysis_view($node, $teaser = FALSE, $page = FALSE) {
   return $node;
 }
 
-/**
- * Synchronize analyses from chado to drupal
- *
- * @ingroup tripal_analysis
- */
-function tripal_analysis_sync_analyses($analysis_id = NULL, $job_id = NULL) {
-  global $user;
-  $page_content = '';
-
-  if (!$analysis_id) {
-    $sql = "SELECT Analysis_id, name, description, program, ".
-        "  programversion, algorithm, sourcename, sourceversion, sourceuri, ".
-          "  timeexecuted ".
-          "FROM {Analysis} ";
-    $results = chado_query($sql);
-  }
-  else {
-    $sql = "SELECT Analysis_id, name, description, program, ".
-         "  programversion, algorithm, sourcename, sourceversion, sourceuri, ".
-          "  timeexecuted ".
-          "FROM {Analysis} ".
-          "WHERE analysis_id = %d";
-    $results = chado_query($sql, $analysis_id);
-  }
-
-
-  // We'll use the following SQL statement for checking if the analysis
-  // already exists as a drupal node.
-  $sql = "SELECT * FROM {chado_analysis} ".
-          "WHERE analysis_id = %d";
-
-  while ($analysis = db_fetch_object($results)) {
-        print "syncing analysis ";
-        print $analysis->name;
-        print ", ";
-        print $analysis->analysis_id;
-        print "\n";
-
-    // check if this analysis already exists in the drupal database. if it
-    // does then skip this analysis and go to the next one.
-    if (!db_fetch_object(db_query($sql, $analysis->analysis_id))) {
-
-      $new_node = new stdClass();
-
-      // try to access analysis type for this analysis
-      $sql = "SELECT * FROM {analysisprop}
-                    WHERE analysis_id = %d
-                    AND type_id =
-                        (SELECT cvterm_id from {cvterm} where name = '%s')
-            ";
-      $analysis_type = db_fetch_object(chado_query($sql, $analysis->analysis_id, "analysis_type"));
-
-      // Get the type of analysis using cvterm_id
-            // Current possibilities: kegg, unigene, interpro, blast
-      if ($analysis_type) {
-
-        // This is a unigene analysis
-        if ($analysis_type->value == 'tripal_analysis_unigene') {
-          $new_node->type = 'chado_analysis_unigene';
-        // This is a blast analysis
-        }
-        elseif ($analysis_type->value == 'tripal_analysis_blast') {
-          $new_node->type = 'chado_analysis_blast';
-         // This is a interpro analysis
-        }
-        elseif ($analysis_type->value == 'tripal_analysis_interpro') {
-          $new_node->type = 'chado_analysis_interpro';
-         // This is a kegg analysis
-        }
-        elseif ($analysis_type->value == 'tripal_analysis_kegg' ) {
-          $new_node->type = 'chado_analysis_kegg';
-        }
-        else {
-          $new_node->type = 'chado_analysis';
-        }
-      // If it doesn't exist, this analysis is generic
-      }
-      else {
-        $new_node->type = 'chado_analysis';
-      }
-
-      print "analysis type is $new_node->type\n";
-
-      $new_node->uid = $user->uid;
-      $new_node->analysis_id = $analysis->analysis_id;
-      $new_node->analysisname = $analysis->name;
-      $new_node->description = $analysis->description;
-      $new_node->program = $analysis->program;
-      $new_node->programversion = $analysis->programversion;
-      $new_node->algorithm = $analysis->algorithm;
-      $new_node->sourcename = $analysis->sourcename;
-      $new_node->sourceversion = $analysis->sourceversion;
-      $new_node->sourceuri = $analysis->sourceuri;
-      $new_node->timeexecuted = $analysis->timeexecuted;
-
-      // If the analysis has a name, use it as the node title. If not,
-      // construct the title using program, programversion, and sourcename
-      if ($new_node->analysisname) {
-        $new_node->title = $new_node->analysisname;
-      }
-      else {
-        //Construct node title as "program (version)"
-        $new_node->title = "$analysis->program ($analysis->programversion)";
-      }
 
-      node_validate($new_node);
-
-            $errors = form_get_errors();
-
-            if ($errors) {
-                print_r($errors);
-            }
-            else{
-      // if(!form_get_errors()){
-        $node = node_submit($new_node);
-        node_save($node);
-
-        if ($node->nid) {
-          $page_content .= "Added $new_node->title<br />";
-        }
-      }
-    }
-    else {
-      $page_content .= "Skipped $new_node->title<br />";
-    }
-  }
-  return $page_content;
-}
 
 /**
  * Validates the user input before creating an analysis node
@@ -774,10 +618,11 @@ function chado_analysis_access($op, $node, $account) {
  */
 function tripal_analysis_perm() {
   return array(
-      'access chado_analysis content',
-      'create chado_analysis content',
-      'delete chado_analysis content',
-      'edit chado_analysis content',
+    'access chado_analysis content',
+    'create chado_analysis content',
+    'delete chado_analysis content',
+    'edit chado_analysis content',
+    'administer tripal analyses',
   );
 }
 
@@ -798,6 +643,11 @@ function tripal_analysis_theme() {
       'template' => 'tripal_feature_analyses',  
       'arguments' =>  array('node' => NULL),  
     ),
+    'tripal_analysis_admin' => array(
+      'template' => 'tripal_analysis_admin',  
+      'arguments' =>  array(NULL),  
+      'path' => drupal_get_path('module', 'tripal_analysis') . '/theme', 
+    ),
   );
 }
 /**
@@ -838,62 +688,6 @@ function tripal_analysis_block($op = 'list', $delta = 0, $edit=array()) {
   }
 }
 
-/**
- * This function uses analysis_id's of all drupal analysis nodes as input and
- * pull the analysis information (name, description, program, programversion,
- * algorithm, sourcename, sourceversion, sourceuri, timeexecuted) from
- * chado database. The return type is an object array that stores $analysis
- * objects sorted by program
- *
- * @ingroup tripal_analysis
- */
-function get_chado_analyses() {
-
-  $sql_drupal = "SELECT COUNT (analysis_id) FROM {chado_analysis}";
-  $no_orgs = db_result(db_query($sql_drupal));
-  if ($no_orgs != 0) {
-    $sql = "SELECT analysis_id, CA.nid, type FROM {chado_analysis} CA INNER JOIN node ON CA.nid = node.nid";
-    $result = db_query($sql);
-    $sql = "SELECT Analysis_id, name, description, program,
-                   programversion, algorithm, sourcename, sourceversion,
-                   sourceuri, timeexecuted
-            FROM {Analysis} WHERE analysis_id=%d";
-    $analyses = array();
-    $count = 0;
-    while ($data = db_fetch_object($result)) {
-      $analysis = db_fetch_object(chado_query($sql, $data->analysis_id));
-      $analysis->node_id = $data->nid;
-      $analysis->node_type = $data->type;
-      // Use node_type as the key so we can sort by node type
-      // Since node_type is not unique by itself, we need to add
-      // $count to the key
-      $sortedBy = $analysis->timeexecuted;
-      $analyses ["$sortedBy$count"] = $analysis;
-      $count ++;
-    }
-
-    //Sort analyses by time, descending order
-    krsort($analyses, SORT_STRING);
-
-    return $analyses;
-  }
-}
-
-/**
- * Remove orphaned drupal nodes
- *
- * @param $dummy
- *   Not Used -kept for backwards compatibility
- * @param $job_id
- *   The id of the tripal job executing this function
- *
- * @ingroup tripal_analysis
- */
-function tripal_analyses_cleanup($dummy = NULL, $job_id = NULL) {
-
-  return tripal_core_clean_orphaned_nodes('analysis', $job_id);
-  
-}
 /*******************************************************************************
  * tripal_analysis_nodeapi()
  * HOOK: Implementation of hook_nodeapi()

+ 9 - 0
tripal_core/api/tripal_core.schema_v1.11.api.inc

@@ -9113,6 +9113,15 @@ function tripal_core_chado_schema_v1_11_quantificationprop() {
 function tripal_core_chado_schema_v1_11_stock() {
   $description =  array(
     'table' => 'stock',
+    'referring_tables' => array(
+        1 => 'stock_cvterm',
+        2 => 'stock_dbxref',
+        3 => 'stock_genotype',
+        4 => 'stock_pub',
+        5 => 'stock_relationship',
+        7 => 'stockcollection_stock',
+        8 => 'stockprop',
+     ),
     'fields' => array(
       'stock_id' => array(
         'type' => 'serial',

+ 0 - 63
tripal_db/includes/tripal_db.admin.inc

@@ -1,64 +1,4 @@
 <?php
-/**
- * Purpose: Provide Guidance to new Tripal Admin
- *
- * @return HTML Formatted text
- *
- * @ingroup tripal_db
- */
-function tripal_db_module_description_page() {
-  $text = '';
-
-  $text = '<h3>Tripal External Database Administrative Tools Quick Links</h3>';
-  $text .= '<ul>';
-  $text .= '<li>' . l('Add an external database for cross-refernces.', 'admin/tripal/tripal_db/add_db') . '</li>';
-  $text .= '<li>' . l('Update or delete an external database.', 'admin/tripal/tripal_db/edit_db') . '</li>';
-  $text .= '</ul><br>';
-
-  $text .= '<h3>Module Description:</h3>';
-  $text .= '<p>The Tripal DB Module provides the ability to add database cross reference to the 
-    data in your Tripal Website.  Typically an external database (such as NCBI Genbank, Gene Ontology (GO),
-    stocks database) contains a collection of objects (genomic sequences, vocabulary terms, stocks) that are 
-    uniquely identified using an accession number (or identifier).  Data loaded into Tripal can be a
-    associated with these objects in remote databases, and links can appear on pages allowing site visitors
-    to view the associated objects on the remote database\'s website </p>';
-
-  $text .= '<h3>Setup Instructions:</h3>';
-  $text .= '<ol>';
-  $text .= '<li><b>Set Permissions</b>: This module supports the Drupal user permissions interface for
-               controlling administrative access for creating, editing and deleting database cross-reference resources. 
-               The default is that only the site administrator has these
-               permissions.  Best practice is to create <a href="' . url('admin/user/roles') . '">a new role</a> 
-               for administrative tasks, (such as a webmaster role),
-               and then <a href="' . url('admin/user/user') . '">assign users to the role</a>. Finally,
-               <a href="' . url('admin/user/permissions') . '">assign the permission</a> titled "administer db cross-reference".
-               to the new role.</li>';
-  $text .= '<li><b>Adding or Editing an External Databases</b>. Many resources such as NCBI nr or ExPASy SwissProt (to name a few) 
-            come pre-loaded with Chado.  However, you can add new entries or edit existing entries. Also, when loading 
-            ontologies (controlled vocabularies) using the Tripal CV module new databases are added automaticaly for 
-            each ontology.  To enable linking of accession on a page to the page for that accession on the external
-            database, simply add the URL and the URL prefix when adding or editing a database.</li>';
-  
-  $text .= '<li><b>Associate Data with Accessions</b>.  The Tripal loaders (e.g. GFF, OBO) can associate accessions from
-            remote data to genomic features and controlled vocabularies automatically.  Use the loaders to load genomic
-            features and controlled vocabularies respectively.  Additionally, the bulk loader can be used to create
-            loading templates for associating external database accessions.  
-            </li>';
-  $text .= '</ol>';
-
-
-  $text .= '<br><h3>Features of this Module:</h3>';
-  $text .= '<ul>';
-  $text .= '<li><b>Add an External Databases</b>:';
-  $text .= 'By entering the name and any additional details into the <a href="tripal_db/add_db">add database form</a> you register an external database with your website. This allows you to specify that a sequence feature or other data is also stored in an external database. This is escpecially useful if the external database may contain additional details not stored in yours. If the external database is online you can even provide a URL prefix which will automatically link any data in your website to theirs via a web link.</li>';
-
-  $text .= '<li><b>Update or Delete and External Databases</b>';
-  $text .= 'To edit the details of an external database record or to delete an already existing external database, go to the <a href="tripal_db/edit_db">Update/Delete DBs form</a>. This will allow you to change details or enter new details.</li>';
-
-  $text .= '</ul>';
-
-  return $text;
-}
 /**
  *
  *
@@ -77,9 +17,6 @@ function tripal_db_admin_page() {
  * @ingroup tripal_db
  */
 function tripal_db_select_form() {
-
-
-
   return $form;
 }
 /**

+ 47 - 0
tripal_db/theme/tripal_db_admin.tpl.php

@@ -0,0 +1,47 @@
+<h3>Tripal External Database Administrative Tools Quick Links</h3>
+<ul>
+<li><?php print l('Add an external database for cross-refernces.', 'admin/tripal/tripal_db/add_db') ?></li>
+<li><?php print l('Update or delete an external database.', 'admin/tripal/tripal_db/edit_db') ?></li>
+</ul><br>
+
+<h3>Module Description:</h3>
+<p>The Tripal DB Module provides the ability to add database cross reference to the 
+  data in your Tripal Website.  Typically an external database (such as NCBI Genbank, Gene Ontology (GO),
+  stocks database) contains a collection of objects (genomic sequences, vocabulary terms, stocks) that are 
+  uniquely identified using an accession number (or identifier).  Data loaded into Tripal can be a
+  associated with these objects in remote databases, and links can appear on pages allowing site visitors
+  to view the associated objects on the remote database\'s website </p>
+
+<h3>Setup Instructions:</h3>
+<ol>
+<li><b>Set Permissions</b>: This module supports the Drupal user permissions interface for
+             controlling administrative access for creating, editing and deleting database cross-reference resources. 
+             The default is that only the site administrator has these
+             permissions.  Best practice is to create <a href="<?php print url('admin/user/roles') ?>">a new role</a> 
+             for administrative tasks, (such as a webmaster role),
+             and then <a href="<?php print url('admin/user/user') ?>">assign users to the role</a>. Finally,
+             <a href="<?php print url('admin/user/permissions') ?>">assign the permission</a> titled "administer db cross-reference".
+             to the new role.</li>
+<li><b>Adding or Editing an External Databases</b>. Many resources such as NCBI nr or ExPASy SwissProt (to name a few) 
+          come pre-loaded with Chado.  However, you can add new entries or edit existing entries. Also, when loading 
+          ontologies (controlled vocabularies) using the Tripal CV module new databases are added automaticaly for 
+          each ontology.  To enable linking of accession on a page to the page for that accession on the external
+          database, simply add the URL and the URL prefix when adding or editing a database.</li>
+
+<li><b>Associate Data with Accessions</b>.  The Tripal loaders (e.g. GFF, OBO) can associate accessions from
+          remote data to genomic features and controlled vocabularies automatically.  Use the loaders to load genomic
+          features and controlled vocabularies respectively.  Additionally, the bulk loader can be used to create
+          loading templates for associating external database accessions.  
+          </li>
+</ol>
+
+
+<br><h3>Features of this Module:</h3>
+<ul>
+<li><b>Add an External Databases</b>:
+By entering the name and any additional details into the <a href="tripal_db/add_db">add database form</a> you register an external database with your website. This allows you to specify that a sequence feature or other data is also stored in an external database. This is escpecially useful if the external database may contain additional details not stored in yours. If the external database is online you can even provide a URL prefix which will automatically link any data in your website to theirs via a web link.</li>
+
+<li><b>Update or Delete and External Databases</b>
+To edit the details of an external database record or to delete an already existing external database, go to the <a href="tripal_db/edit_db">Update/Delete DBs form</a>. This will allow you to change details or enter new details.</li>
+
+</ul>

+ 19 - 1
tripal_db/tripal_db.module

@@ -28,7 +28,8 @@ function tripal_db_menu() {
   $items['admin/tripal/tripal_db'] = array(
     'title' => 'Databases',
     'description' => 'Basic Description of Tripal DB Module Functionality',
-    'page callback' => 'tripal_db_module_description_page',
+    'page callback' => 'theme',
+    'page arguments' => array('tripal_db_admin'),
     'access callback' => 'user_access',
     'access arguments' => array('administer db cross-references'),
     'type' => MENU_NORMAL_ITEM,
@@ -99,4 +100,21 @@ function tripal_db_form_alter(&$form, &$form_state, $form_id) {
       $form['#action'] = url("admin/tripal/tripal_db/add_db");
     }
   } 
+}
+
+/**
+ *  We need to let drupal know about our theme functions and their arguments.
+ *  We create theme functions to allow users of the module to customize the
+ *  look and feel of the output generated in this module
+ *
+ * @ingroup tripal_db
+ */
+function tripal_db_theme() {
+  return array(    
+    'tripal_db_admin' => array(
+      'template' => 'tripal_db_admin',  
+      'arguments' =>  array(NULL),  
+      'path' => drupal_get_path('module', 'tripal_db') . '/theme', 
+    ),
+  );
 }

+ 0 - 100
tripal_feature/api/tripal_feature.api.inc

@@ -4,106 +4,6 @@
  * @todo Add file header description
  */
 
-/**
- * Implements hook_chado_feature_schema()
- * Purpose: To add descriptions to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the feature table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_schema_v1_11_feature() {
-  $description = array();
-
-  $referring_tables = array('analysisfeature',
-    'element',
-    'feature_cvterm',
-    'feature_dbxref',
-    'feature_expression',
-    'feature_genotype',
-    'feature_phenotype',
-    'feature_pub',
-    'feature_relationship',
-    'feature_synonym',
-    'featureloc',
-    'featurepos',
-    'featureprop',
-    'featurerange',
-    'library_feature',
-    'phylonode',
-    'wwwuser_feature'
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-/**
- * Implements hook_chado_featureprop_schema()
- * Purpose: To add descriptions to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the featureprop table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_schema_v1_11_featureprop() {
-  $description = array();
-
-  $referring_tables = array('analysisfeature',
-    'featureprop_pub',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-/**
- * Implements hook_chado_schema_v1_11_table()
- * Purpose: To add descriptions to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the featureloc table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_schema_v1_11_featureloc() {
-  $description = array();
-
-  $referring_tables = array('analysisfeature',
-    'featureloc_pub',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-/**
- * Implements hook_chado_schema_v1_2_table()
- * Purpose: To add descriptions and to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the featureloc table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_schema_v1_2_featureloc() {
-  $description = array();
-
-  $referring_tables = array('analysisfeature',
-    'featureloc_pub',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-
-
 
 /**
  * Retrieve properties from the analysisfeatureprop table for a feature.

+ 328 - 0
tripal_feature/includes/tripal_feature.admin.inc

@@ -385,3 +385,331 @@ function get_tripal_feature_admin_form_url_set(&$form) {
   );
 }
 
+/**
+ *
+ *
+ * @ingroup tripal_feature
+ */
+function tripal_features_set_taxonomy($max_sync = 0, $job_id = NULL) {
+
+  // make sure our vocabularies are cleaned and reset before proceeding
+  tripal_feature_del_vocabulary();
+  tripal_feature_set_vocabulary();
+
+  // iterate through all drupal feature nodes and set the taxonomy
+  $results = db_query("SELECT * FROM {chado_feature}");
+  $nsql =  "SELECT * FROM {node} ".
+          "WHERE nid = %d";
+  $i = 0;
+
+  // load into ids array
+  $count = 0;
+  $chado_features = array();
+  while ($chado_feature = db_fetch_object($results)) {
+    $chado_features[$count] = $chado_feature;
+    $count++;
+  }
+
+  // Iterate through features that need to be synced
+  $interval = intval($count * 0.01);
+  foreach ($chado_features as $chado_feature) {
+
+  // update the job status every 1% features
+  if ($job_id and $i % $interval == 0) {
+    tripal_job_set_progress($job_id, intval(($i/$count)*100));
+  }
+  print "$i of $count: ";
+  $node = db_fetch_object(db_query($nsql, $chado_feature->nid));
+  tripal_feature_set_taxonomy($node, $chado_feature->feature_id);
+
+  $i++;
+  }
+}
+
+/**
+ *
+ *
+ * @ingroup tripal_feature
+ */
+function tripal_feature_set_taxonomy($node, $feature_id) {
+
+  // iterate through the taxonomy classes that have been
+  // selected by the admin user and make sure we only set those
+  $tax_classes = variable_get('tax_classes', '');
+  $do_ft = 0;
+  $do_op = 0;
+  $do_lb = 0;
+  $do_an = 0;
+  foreach ($tax_classes as $class) {
+    if (strcmp($class , 'organism')==0) {
+      $do_op = 1;
+    }
+    if (strcmp($class, 'feature_type')==0) {
+      $do_ft = 1;
+    }
+    if (strcmp($class, 'library')==0) {
+      $do_lb = 1;
+    }
+    if (strcmp($class, 'analysis')==0) {
+      $do_an = 1;
+    }
+  }
+
+
+  // get the list of vocabularies and find our two vocabularies of interest
+  $vocabularies = taxonomy_get_vocabularies();
+  $ft_vid = NULL;
+  $op_vid = NULL;
+  $lb_vid = NULL;
+  $an_vid = NULL;
+  foreach ($vocabularies as $vocab) {
+    if ($vocab->name == 'Feature Type') {
+      $ft_vid = $vocab->vid;
+    }
+    if ($vocab->name == 'Organism') {
+      $op_vid = $vocab->vid;
+    }
+    if ($vocab->name == 'Library') {
+      $lb_vid = $vocab->vid;
+    }
+    if ($vocab->name == 'Analysis') {
+      $an_vid = $vocab->vid;
+    }
+  }
+
+  // get the cvterm and the organism for this feature
+  $sql = "SELECT CVT.name AS cvname, O.genus, O.species ".
+        "FROM {CVTerm} CVT ".
+        "  INNER JOIN Feature F on F.type_id = CVT.cvterm_id ".
+        "  INNER JOIN Organism O ON F.organism_id = O.organism_id ".
+        "WHERE F.feature_id = $feature_id";
+  $feature = db_fetch_object(chado_query($sql));
+
+  // Set the feature type for this feature
+  if ($do_ft && $ft_vid) {
+    $tags["$ft_vid"] = "$feature->cvname";
+  }
+  // Set the organism for this feature type
+  if ($do_op && $op_vid) {
+    $tags["$op_vid"] = "$feature->genus $feature->species";
+  }
+
+  // get the library that this feature may belong to and add it as taxonomy
+  if ($do_lb && $lb_vid) {
+    $sql = "SELECT L.name ".
+           "FROM {Library} L ".
+           "  INNER JOIN Library_feature LF ON LF.library_id = L.library_id ".
+           "WHERE LF.feature_id = %d ";
+    $library = db_fetch_object(chado_query($sql, $feature_id));
+    $tags["$lb_vid"] = "$library->name";
+  }
+
+  // now add the taxonomy to the node
+  $terms['tags'] = $tags;
+  taxonomy_node_save($node, $terms);
+  //   print "Setting $node->name: " . implode(", ",$tags) . "\n";
+
+  // get the analysis that this feature may belong to and add it as taxonomy
+  // We'll add each one individually since there may be more than one analysis
+  if ($do_an && $an_vid) {
+    $sql = "SELECT A.name ".
+           "FROM {Analysis} A ".
+           "  INNER JOIN Analysisfeature AF ON AF.analysis_id = A.analysis_id ".
+           "WHERE AF.feature_id = $feature_id ";
+    $results = chado_query($sql);
+    $analysis_terms = array();
+    while ($analysis=db_fetch_object($results)) {
+      $tags2["$an_vid"] = "$analysis->name";
+      $terms['tags'] = $tags2;
+      taxonomy_node_save($node, $terms);
+    }
+  }
+
+}
+
+/**
+ *
+ * Remove orphaned drupal nodes
+ *
+ * @param $dummy
+ *   Not Used -kept for backwards compatibility
+ * @param $job_id
+ *   The id of the tripal job executing this function
+ *
+ * @ingroup tripal_feature
+ */
+function tripal_features_cleanup($dummy = NULL, $job_id = NULL) {
+
+  return tripal_core_clean_orphaned_nodes('feature', $job_id);
+ 
+}
+/**
+ *  This function is an extension of the chado_feature_view by providing
+ *  the markup for the feature object THAT WILL BE INDEXED.
+ *
+ * @ingroup tripal_feature
+ */
+function theme_tripal_feature_search_index($node) {
+  $feature = $node->feature;
+  $content = '';
+
+  // get the accession prefix
+  $aprefix = variable_get('chado_feature_accession_prefix', 'ID');
+
+  $content .= "<h1>$feature->uniquename</h1>. ";
+  $content .= "<strong>$aprefix$feature->feature_id.</strong> ";
+  $content .= "$feature->cvname ";
+  $content .= "$feature->common_name ";
+
+  // add the synonyms of this feature to the text for searching
+  $synonyms = $node->synonyms;
+  if (count($synonyms) > 0) {
+    foreach ($synonyms as $result) {
+      $content .= "$result->name ";
+    }
+  }
+
+  return $content;
+}
+
+/**
+ *  This function is an extension of the chado_feature_view by providing
+ *  the markup for the feature object THAT WILL BE INDEXED.
+ *
+ * @ingroup tripal_feature
+ */
+function theme_tripal_feature_search_results($node) {
+  $feature = $node->feature;
+  $content = '';
+
+  // get the accession prefix
+  $aprefix = variable_get('chado_feature_accession_prefix', 'ID');
+
+  $content .= "Feature Name: <h1>$feature->uniquename</h1>. ";
+  $content .= "<strong>Accession: $aprefix$feature->feature_id.</strong>";
+  $content .= "Type: $feature->cvname. ";
+  $content .= "Organism: $feature->common_name. ";
+
+  // add the synonyms of this feature to the text for searching
+  $synonyms = $node->synonyms;
+  if (count($synonyms) > 0) {
+    $content .= "Synonyms: ";
+    foreach ($synonyms as $result) {
+      $content .= "$result->name, ";
+    }
+  }
+
+  return $content;
+}
+
+
+/**
+ *
+ *
+ * @ingroup tripal_feature
+ */
+function tripal_feature_set_vocabulary() {
+
+  //include the file containing the required functions for adding taxonomy vocabs
+  module_load_include('inc', 'taxonomy', 'taxonomy.admin');
+
+  // get the vocabularies so that we make sure we don't recreate
+  // the vocabs that already exist
+  $vocabularies = taxonomy_get_vocabularies();
+  $ft_vid = NULL;
+  $op_vid = NULL;
+  $lb_vid = NULL;
+  $an_vid = NULL;
+
+  // These taxonomic terms are hard coded because we
+  // konw we have these relationships in the chado tables
+  // through foreign key relationships.  The tripal
+  // modules that correspond to these chado "modules" don't
+  // need to be installed for the taxonomy to work.
+  foreach ($vocabularies as $vocab) {
+    if ($vocab->name == 'Feature Type') {
+      $ft_vid = $vocab->vid;
+    }
+    if ($vocab->name == 'Organism') {
+      $op_vid = $vocab->vid;
+    }
+    if ($vocab->name == 'Library') {
+      $lb_vid = $vocab->vid;
+    }
+    if ($vocab->name == 'Analysis') {
+      $an_vid = $vocab->vid;
+    }
+  }
+
+  if (!$ft_vid) {
+    $form_state = array();
+    $values = array(
+       'name' => t('Feature Type'),
+       'nodes' => array('chado_feature' => 'chado_feature'),
+       'description' => t('The feature type (or SO cvterm for this feature).'),
+       'help' => t('Select the term that matches the feature'),
+       'tags' => 0,
+       'hierarchy' => 1,
+       'relations' => 1,
+       'multiple' => 0,
+       'required' => 0,
+       'weight' => 1,
+    );
+    drupal_execute('taxonomy_form_vocabulary', $form_state, $values);
+    drupal_execute('taxonomy_form_vocabulary', $form_state);
+  }
+
+  if (!$op_vid) {
+    $form_state = array();
+    $values = array(
+       'name' => t('Organism'),
+       'nodes' => array('chado_feature' => 'chado_feature'),
+       'description' => t('The organism to which this feature belongs.'),
+       'help' => t('Select the term that matches the feature'),
+       'tags' => 0,
+       'hierarchy' => 1,
+       'relations' => 1,
+       'multiple' => 0,
+       'required' => 0,
+       'weight' => 2,
+    );
+    drupal_execute('taxonomy_form_vocabulary', $form_state, $values);
+    drupal_execute('taxonomy_form_vocabulary', $form_state);
+  }
+
+  if (!$lb_vid) {
+    $form_state = array();
+    $values = array(
+       'name' => t('Library'),
+       'nodes' => array('chado_feature' => 'chado_feature'),
+       'description' => t('Chado features associated with a library are assigned the term associated with the library'),
+       'help' => t('Select the term that matches the feature'),
+       'tags' => 0,
+       'hierarchy' => 1,
+       'relations' => 1,
+       'multiple' => 0,
+       'required' => 0,
+       'weight' => 3,
+    );
+    drupal_execute('taxonomy_form_vocabulary', $form_state, $values);
+    drupal_execute('taxonomy_form_vocabulary', $form_state);
+  }
+
+  if (!$an_vid) {
+    $form_state = array();
+    $values = array(
+       'name' => t('Analysis'),
+       'nodes' => array('chado_feature' => 'chado_feature'),
+       'description' => t('Any analysis to which this feature belongs.'),
+       'help' => t('Select the term that matches the feature'),
+       'tags' => 0,
+       'hierarchy' => 1,
+       'relations' => 1,
+       'multiple' => 1,
+       'required' => 0,
+       'weight' => 4,
+    );
+    drupal_execute('taxonomy_form_vocabulary', $form_state, $values);
+    drupal_execute('taxonomy_form_vocabulary', $form_state);
+  }
+}

+ 0 - 325
tripal_feature/tripal_feature.module

@@ -2137,175 +2137,7 @@ function tripal_feature_cv_tree($tree_id) {
   return $options;
 }
 
-/**
- *  This function is an extension of the chado_feature_view by providing
- *  the markup for the feature object THAT WILL BE INDEXED.
- *
- * @ingroup tripal_feature
- */
-function theme_tripal_feature_search_index($node) {
-  $feature = $node->feature;
-  $content = '';
-
-  // get the accession prefix
-  $aprefix = variable_get('chado_feature_accession_prefix', 'ID');
-
-  $content .= "<h1>$feature->uniquename</h1>. ";
-  $content .= "<strong>$aprefix$feature->feature_id.</strong> ";
-  $content .= "$feature->cvname ";
-  $content .= "$feature->common_name ";
-
-  // add the synonyms of this feature to the text for searching
-  $synonyms = $node->synonyms;
-  if (count($synonyms) > 0) {
-    foreach ($synonyms as $result) {
-      $content .= "$result->name ";
-    }
-  }
 
-  return $content;
-}
-
-/**
- *  This function is an extension of the chado_feature_view by providing
- *  the markup for the feature object THAT WILL BE INDEXED.
- *
- * @ingroup tripal_feature
- */
-function theme_tripal_feature_search_results($node) {
-  $feature = $node->feature;
-  $content = '';
-
-  // get the accession prefix
-  $aprefix = variable_get('chado_feature_accession_prefix', 'ID');
-
-  $content .= "Feature Name: <h1>$feature->uniquename</h1>. ";
-  $content .= "<strong>Accession: $aprefix$feature->feature_id.</strong>";
-  $content .= "Type: $feature->cvname. ";
-  $content .= "Organism: $feature->common_name. ";
-
-  // add the synonyms of this feature to the text for searching
-  $synonyms = $node->synonyms;
-  if (count($synonyms) > 0) {
-    $content .= "Synonyms: ";
-    foreach ($synonyms as $result) {
-      $content .= "$result->name, ";
-    }
-  }
-
-  return $content;
-}
-
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_set_vocabulary() {
-
-  //include the file containing the required functions for adding taxonomy vocabs
-  module_load_include('inc', 'taxonomy', 'taxonomy.admin');
-
-  // get the vocabularies so that we make sure we don't recreate
-  // the vocabs that already exist
-  $vocabularies = taxonomy_get_vocabularies();
-  $ft_vid = NULL;
-  $op_vid = NULL;
-  $lb_vid = NULL;
-  $an_vid = NULL;
-
-  // These taxonomic terms are hard coded because we
-  // konw we have these relationships in the chado tables
-  // through foreign key relationships.  The tripal
-  // modules that correspond to these chado "modules" don't
-  // need to be installed for the taxonomy to work.
-  foreach ($vocabularies as $vocab) {
-    if ($vocab->name == 'Feature Type') {
-      $ft_vid = $vocab->vid;
-    }
-    if ($vocab->name == 'Organism') {
-      $op_vid = $vocab->vid;
-    }
-    if ($vocab->name == 'Library') {
-      $lb_vid = $vocab->vid;
-    }
-    if ($vocab->name == 'Analysis') {
-      $an_vid = $vocab->vid;
-    }
-  }
-
-  if (!$ft_vid) {
-    $form_state = array();
-    $values = array(
-       'name' => t('Feature Type'),
-       'nodes' => array('chado_feature' => 'chado_feature'),
-       'description' => t('The feature type (or SO cvterm for this feature).'),
-       'help' => t('Select the term that matches the feature'),
-       'tags' => 0,
-       'hierarchy' => 1,
-       'relations' => 1,
-       'multiple' => 0,
-       'required' => 0,
-       'weight' => 1,
-    );
-    drupal_execute('taxonomy_form_vocabulary', $form_state, $values);
-    drupal_execute('taxonomy_form_vocabulary', $form_state);
-  }
-
-  if (!$op_vid) {
-    $form_state = array();
-    $values = array(
-       'name' => t('Organism'),
-       'nodes' => array('chado_feature' => 'chado_feature'),
-       'description' => t('The organism to which this feature belongs.'),
-       'help' => t('Select the term that matches the feature'),
-       'tags' => 0,
-       'hierarchy' => 1,
-       'relations' => 1,
-       'multiple' => 0,
-       'required' => 0,
-       'weight' => 2,
-    );
-    drupal_execute('taxonomy_form_vocabulary', $form_state, $values);
-    drupal_execute('taxonomy_form_vocabulary', $form_state);
-  }
-
-  if (!$lb_vid) {
-    $form_state = array();
-    $values = array(
-       'name' => t('Library'),
-       'nodes' => array('chado_feature' => 'chado_feature'),
-       'description' => t('Chado features associated with a library are assigned the term associated with the library'),
-       'help' => t('Select the term that matches the feature'),
-       'tags' => 0,
-       'hierarchy' => 1,
-       'relations' => 1,
-       'multiple' => 0,
-       'required' => 0,
-       'weight' => 3,
-    );
-    drupal_execute('taxonomy_form_vocabulary', $form_state, $values);
-    drupal_execute('taxonomy_form_vocabulary', $form_state);
-  }
-
-  if (!$an_vid) {
-    $form_state = array();
-    $values = array(
-       'name' => t('Analysis'),
-       'nodes' => array('chado_feature' => 'chado_feature'),
-       'description' => t('Any analysis to which this feature belongs.'),
-       'help' => t('Select the term that matches the feature'),
-       'tags' => 0,
-       'hierarchy' => 1,
-       'relations' => 1,
-       'multiple' => 1,
-       'required' => 0,
-       'weight' => 4,
-    );
-    drupal_execute('taxonomy_form_vocabulary', $form_state, $values);
-    drupal_execute('taxonomy_form_vocabulary', $form_state);
-  }
-}
 
 /**
  *
@@ -2341,164 +2173,7 @@ function tripal_feature_del_vocabulary() {
 
 }
 
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_features_set_taxonomy($max_sync = 0, $job_id = NULL) {
-
-  // make sure our vocabularies are cleaned and reset before proceeding
-  tripal_feature_del_vocabulary();
-  tripal_feature_set_vocabulary();
-
-  // iterate through all drupal feature nodes and set the taxonomy
-  $results = db_query("SELECT * FROM {chado_feature}");
-  $nsql =  "SELECT * FROM {node} ".
-          "WHERE nid = %d";
-  $i = 0;
-
-  // load into ids array
-  $count = 0;
-  $chado_features = array();
-  while ($chado_feature = db_fetch_object($results)) {
-    $chado_features[$count] = $chado_feature;
-    $count++;
-  }
-
-  // Iterate through features that need to be synced
-  $interval = intval($count * 0.01);
-  foreach ($chado_features as $chado_feature) {
-
-  // update the job status every 1% features
-  if ($job_id and $i % $interval == 0) {
-    tripal_job_set_progress($job_id, intval(($i/$count)*100));
-  }
-  print "$i of $count: ";
-  $node = db_fetch_object(db_query($nsql, $chado_feature->nid));
-  tripal_feature_set_taxonomy($node, $chado_feature->feature_id);
-
-  $i++;
-  }
-}
-
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_set_taxonomy($node, $feature_id) {
-
-  // iterate through the taxonomy classes that have been
-  // selected by the admin user and make sure we only set those
-  $tax_classes = variable_get('tax_classes', '');
-  $do_ft = 0;
-  $do_op = 0;
-  $do_lb = 0;
-  $do_an = 0;
-  foreach ($tax_classes as $class) {
-    if (strcmp($class , 'organism')==0) {
-      $do_op = 1;
-    }
-    if (strcmp($class, 'feature_type')==0) {
-      $do_ft = 1;
-    }
-    if (strcmp($class, 'library')==0) {
-      $do_lb = 1;
-    }
-    if (strcmp($class, 'analysis')==0) {
-      $do_an = 1;
-    }
-  }
-
-
-  // get the list of vocabularies and find our two vocabularies of interest
-  $vocabularies = taxonomy_get_vocabularies();
-  $ft_vid = NULL;
-  $op_vid = NULL;
-  $lb_vid = NULL;
-  $an_vid = NULL;
-  foreach ($vocabularies as $vocab) {
-    if ($vocab->name == 'Feature Type') {
-      $ft_vid = $vocab->vid;
-    }
-    if ($vocab->name == 'Organism') {
-      $op_vid = $vocab->vid;
-    }
-    if ($vocab->name == 'Library') {
-      $lb_vid = $vocab->vid;
-    }
-    if ($vocab->name == 'Analysis') {
-      $an_vid = $vocab->vid;
-    }
-  }
-
-  // get the cvterm and the organism for this feature
-  $sql = "SELECT CVT.name AS cvname, O.genus, O.species ".
-        "FROM {CVTerm} CVT ".
-        "  INNER JOIN Feature F on F.type_id = CVT.cvterm_id ".
-        "  INNER JOIN Organism O ON F.organism_id = O.organism_id ".
-        "WHERE F.feature_id = $feature_id";
-  $feature = db_fetch_object(chado_query($sql));
-
-  // Set the feature type for this feature
-  if ($do_ft && $ft_vid) {
-    $tags["$ft_vid"] = "$feature->cvname";
-  }
-  // Set the organism for this feature type
-  if ($do_op && $op_vid) {
-    $tags["$op_vid"] = "$feature->genus $feature->species";
-  }
-
-  // get the library that this feature may belong to and add it as taxonomy
-  if ($do_lb && $lb_vid) {
-    $sql = "SELECT L.name ".
-           "FROM {Library} L ".
-           "  INNER JOIN Library_feature LF ON LF.library_id = L.library_id ".
-           "WHERE LF.feature_id = %d ";
-    $library = db_fetch_object(chado_query($sql, $feature_id));
-    $tags["$lb_vid"] = "$library->name";
-  }
-
-  // now add the taxonomy to the node
-  $terms['tags'] = $tags;
-  taxonomy_node_save($node, $terms);
-  //   print "Setting $node->name: " . implode(", ",$tags) . "\n";
-
-  // get the analysis that this feature may belong to and add it as taxonomy
-  // We'll add each one individually since there may be more than one analysis
-  if ($do_an && $an_vid) {
-    $sql = "SELECT A.name ".
-           "FROM {Analysis} A ".
-           "  INNER JOIN Analysisfeature AF ON AF.analysis_id = A.analysis_id ".
-           "WHERE AF.feature_id = $feature_id ";
-    $results = chado_query($sql);
-    $analysis_terms = array();
-    while ($analysis=db_fetch_object($results)) {
-      $tags2["$an_vid"] = "$analysis->name";
-      $terms['tags'] = $tags2;
-      taxonomy_node_save($node, $terms);
-    }
-  }
-
-}
-
-/**
- *
- * Remove orphaned drupal nodes
- *
- * @param $dummy
- *   Not Used -kept for backwards compatibility
- * @param $job_id
- *   The id of the tripal job executing this function
- *
- * @ingroup tripal_feature
- */
-function tripal_features_cleanup($dummy = NULL, $job_id = NULL) {
 
-  return tripal_core_clean_orphaned_nodes('feature', $job_id);
- 
-}
 
 /**
  *

+ 0 - 46
tripal_featuremap/api/tripal_featuremap.api.inc

@@ -3,49 +3,3 @@
  * @file
  * @todo Add file header description
  */
-
-/**
- * @defgroup tripal_featuremap_api Library Module API
- * @ingroup tripal_api
- * @ingroup tripal_featuremap
- */
-
-/**
- * Implements hook_chado_schema_v1_11_table()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the map table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_featuremap_chado_schema_v1_11_map() {
-  $description = array();
-  $referring_tables = array(
-
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-/**
- * Implements hook_chado_schema_v1_2_table()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the map table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_featuremap_chado_schema_v1_2_map() {
-  $description = array();
-  $referring_tables = array(
-
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}

+ 4 - 0
tripal_featuremap/tripal_featuremap.module

@@ -203,6 +203,10 @@ function tripal_featuremap_theme() {
       'arguments' => array('node' => NULL),
       'template' => 'tripal_featuremap_properties',
     ),
+    'tripal_featuremap_publication' => array(
+      'arguments' => array('node' => NULL),
+      'template' => 'tripal_featuremap_publication',
+    ),
     'tripal_featuremap_admin' => array(
       'template' => 'tripal_featuremap_admin',  
       'arguments' =>  array(NULL),  

+ 0 - 49
tripal_genetic/tripal_genetic.api.inc → tripal_genetic/api/tripal_genetic.api.inc

@@ -42,53 +42,4 @@ function tripal_genetic_get_genotypes_by_feature_id($feature_id) {
 }
 
 
-/**
- * Implements hook_chado_schema_v1_11_table()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the genotype table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_genetic_chado_schema_v1_11_genotype() {
-  $description = array();
 
-  $referring_tables = array('analysisfeature',
-    'feature_genotype',
-    'phendesc',
-    'phenotype_comparison',
-    'phenstatement',
-    'stock_genotype',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-
-}
-/**
- * Implements hook_chado_schema_v1_2_table()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the genotype table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_genetic_chado_schema_v1_2_genotype() {
-  $description = array();
-
-  $referring_tables = array('analysisfeature',
-    'feature_genotype',
-    'phendesc',
-    'phenotype_comparison',
-    'phenstatement',
-    'stock_genotype',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-
-}

+ 26 - 0
tripal_genetic/includes/tripal_genetic.schema.inc

@@ -0,0 +1,26 @@
+<?php
+/**
+ * Implements hook_chado_schema_v1_11_table()
+ * Purpose: To add descriptions and foreign keys to default table description
+ * Note: This array will be merged with the array from all other implementations
+ *
+ * @return
+ *    Array describing the genotype table
+ *
+ * @ingroup tripal_schema_api
+ */
+function tripal_genetic_chado_schema_v1_11_genotype() {
+  $description = array();
+
+  $referring_tables = array('analysisfeature',
+    'feature_genotype',
+    'phendesc',
+    'phenotype_comparison',
+    'phenstatement',
+    'stock_genotype',
+  );
+  $description['referring_tables'] = $referring_tables;
+
+  return $description;
+
+}

+ 3 - 1
tripal_genetic/tripal_genetic.module

@@ -9,7 +9,9 @@
  * @see http://gmod.org/wiki/Chado_General_Module
  */
 
-require('tripal_genetic.api.inc');
+require('api/tripal_genetic.api.inc');
+require('includes/tripal_genetic.api.inc');
+
 
 /*************************************************************************
  * Implements hook_views_api()

+ 2 - 0
tripal_library/tripal_library.install

@@ -161,6 +161,8 @@ function tripal_library_add_cvterms() {
     'tripal_library_types', 0, 1, 'tripal');
   tripal_cv_add_cvterm(array('name' => 'yac_library','def' => 'Yeast Artificial Chromosome (YAC) library'), 
     'tripal_library_types', 0, 1, 'tripal');
+  tripal_cv_add_cvterm(array('name' => 'genomic_library','def' => 'Genomic Library'), 
+    'tripal_library_types', 0, 1, 'tripal');
 }
 
 /**

+ 4 - 4
tripal_library/tripal_library.module

@@ -66,7 +66,7 @@ function tripal_library_perm() {
     'create chado_library content',
     'delete chado_library content',
     'edit chado_library content',
-    'administer tripal library',
+    'administer tripal libraries',
   );
 }
 /**
@@ -112,7 +112,7 @@ function tripal_library_menu() {
     'description' => 'Basic Description of Tripal Library Module Functionality',
     'page callback' => 'theme',
     'page arguments' => array('tripal_library_admin'),
-    'access arguments' => array('administer tripal library'),
+    'access arguments' => array('administer tripal libraries'),
     'type' => MENU_NORMAL_ITEM,
   );
 
@@ -121,7 +121,7 @@ function tripal_library_menu() {
     'description' => 'Manage integration of Chado libraries including associated features.',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_library_admin'),
-    'access arguments' => array('administer tripal library'),
+    'access arguments' => array('administer tripal libraries'),
     'type' => MENU_NORMAL_ITEM,
   );
 
@@ -129,7 +129,7 @@ function tripal_library_menu() {
   $items['chado_sync_libraries'] = array(
     'title' => 'Sync Library Data',
     'page callback' => 'tripal_library_sync_libraries',
-    'access arguments' => array('administer tripal library'),
+    'access arguments' => array('administer tripal libraries'),
     'type' => MENU_CALLBACK
   );
   return $items;

+ 6 - 0
tripal_natural_diversity/api/tripal_natural_diversity.api.inc

@@ -0,0 +1,6 @@
+<?php
+/**
+ * @file
+ * @todo Add file header description
+ */
+

+ 6 - 101
tripal_natural_diversity/tripal_natural_diversity.api.inc → tripal_natural_diversity/includes/tripal_natural_diversity.schema.inc

@@ -1,7 +1,12 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * 
+ * This file contains hooks for specifying the natural diversity tables
+ * when Chado v1.11 is installed.  This is only useful for some specific
+ * sites that required the ND tables before they were released.  These
+ * files should not be needed for most sites as the ND tables are now part
+ * of Chado v1.2. However these hooks remain here for backwards compatibility. 
  */
 
 /**
@@ -66,36 +71,6 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment() {
 
   return $description;
 }
-/**
- * Implements hook_chado_schema_v1_2_table()
- *
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the nd_experiment table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_natural_diversity_chado_schema_v1_2_nd_experiment() {
-  $description = array();
-
-  $description = array(
-    'referring_tables' => array(
-      'nd_experiment_contact',
-      'nd_experiment_dbxref',
-      'nd_experiment_genotype',
-      'nd_experiment_phenotype',
-      'nd_experiment_project',
-      'nd_experiment_protocol',
-      'nd_experiment_pub',
-      'nd_experiment_stock',
-      'nd_experimentprop'
-    ),
-  );
-
-  return $description;
-}
 /**
  * Implements hook_chado_schema_v1_11_table()
  *
@@ -539,29 +514,6 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_experiment_stock() {
 
   return $description;
 }
-/**
- * Implements hook_chado_schema_v1_2_table()
- *
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the nd_experiment_stock table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_natural_diversity_chado_schema_v1_2_nd_experiment_stock() {
-  $description = array();
-
-  $description = array(
-    'referring_tables' => array(
-      'nd_experiment_stock_dbxref',
-      'nd_experiment_stockprop',
-    ),
-  );
-
-  return $description;
-}
 /**
  * Implements hook_chado_schema_v1_11_table()
  *
@@ -786,29 +738,6 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_geolocation() {
 
   return $description;
 }
-/**
- * Implements hook_chado_schema_v1_2_table()
- *
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the nd_geolocation table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_natural_diversity_chado_schema_v1_2_nd_geolocation() {
-  $description = array();
-
-  $description = array(
-    'referring_tables' => array(
-      'nd_experiment',
-      'nd_geolocationprop'
-    ),
-  );
-
-  return $description;
-}
 /**
  * Implements hook_chado_schema_v1_11_table()
  *
@@ -908,30 +837,6 @@ function tripal_natural_diversity_chado_schema_v1_11_nd_protocol() {
 
   return $description;
 }
-/**
- * Implements hook_chado_schema_v1_2_table()
- *
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the nd_protocol table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_natural_diversity_chado_schema_v1_2_nd_protocol() {
-  $description = array();
-
-  $description = array(
-    'referring_tables' => array(
-      'nd_experiment_protocol',
-      'nd_protocol_reagent',
-      'nd_protocolprop'
-    ),
-  );
-
-  return $description;
-}
 /**
  * Implements hook_chado_schema_v1_11_table()
  *

+ 2 - 1
tripal_natural_diversity/tripal_natural_diversity.module

@@ -1,6 +1,7 @@
 <?php
 
-require_once('tripal_natural_diversity.api.inc');
+require_once('api/tripal_natural_diversity.api.inc');
+require_once('includes/tripal_natural_diversity.schema.inc');
 
 /**
  *  @file

+ 0 - 55
tripal_organism/api/tripal_organism.api.inc

@@ -70,63 +70,8 @@ function tripal_organism_get_organism_by_organism_id($organism_id) {
  * in core.
  */
 
-/**
- * Implements hook_chado_schema_v1_11_table()
- *
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the organism table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_organism_chado_schema_v1_11_organism() {
-  $description = array();
-
-  $referring_tables = array(
-    'biomaterial',
-    'feature',
-    'library',
-    'organism_dbxref',
-    'organismprop',
-    'phylonode_organism',
-    'stock',
-    'wwwuser_organism'
-  );
-  $description['referring_tables'] = $referring_tables;
 
-  return $description;
-}
 
-/**
- * Implements hook_chado_schema_v1_2_table()
- *
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the organism table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_organism_chado_schema_v1_2_organism() {
-  $description = array();
-
-  $referring_tables = array(
-    'biomaterial',
-    'feature',
-    'library',
-    'organism_dbxref',
-    'organismprop',
-    'phylonode_organism',
-    'stock',
-    'wwwuser_organism'
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
 
 /**
  *  Returns a list of organisms that are currently synced with Drupal

+ 351 - 0
tripal_project/includes/tripal_project.admin.inc

@@ -0,0 +1,351 @@
+<?php
+/**
+ * @file
+ * @todo Add file header description
+ */
+
+function tripal_project_admin($form_state = NULL) {
+  $form = array();
+
+  // before proceeding check to see if we have any
+  // currently processing jobs. If so, we don't want
+  // to give the opportunity to sync libraries
+  $active_jobs = FALSE;
+  if (tripal_get_module_active_jobs('tripal_project')) {
+    $active_jobs = TRUE;
+  }
+
+  // add the field set for syncing libraries
+  if (!$active_jobs) {
+    get_tripal_project_admin_form_sync_set($form);
+    get_tripal_project_admin_form_cleanup_set($form);
+//    get_tripal_project_admin_form_reindex_set($form);
+
+  }
+  else {
+    $form['notice'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Project Management Temporarily Unavailable')
+    );
+    $form['notice']['message'] = array(
+      '#value' => t('Currently, project management jobs are waiting or are running. . Managemment features have been hidden until these jobs complete.  Please check back later once these jobs have finished.  You can view the status of pending jobs in the Tripal jobs page.'),
+    );
+  }
+
+  return system_settings_form($form);
+}
+/**
+ *
+ *
+ * @ingroup tripal_project
+ */
+function get_tripal_project_admin_form_cleanup_set(&$form) {
+  $form['cleanup'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Clean Up')
+  );
+  $form['cleanup']['description'] = array(
+    '#type' => 'item',
+    '#value' => t("With Drupal and chado residing in different databases ".
+    "it is possible that nodes in Drupal and projects in Chado become ".
+    "\"orphaned\".  This can occur if an project node in Drupal is ".
+    "deleted but the corresponding chado project is not and/or vice ".
+    "versa. Click the button below to resolve these discrepancies."),
+    '#weight' => 1,
+  );
+  $form['cleanup']['button'] = array(
+    '#type' => 'submit',
+    '#value' => t('Clean up orphaned projects'),
+    '#weight' => 2,
+  );
+}
+/**
+ *
+ * @ingroup tripal_project
+ */
+function get_tripal_project_admin_form_sync_set(&$form) {
+  // define the fieldsets
+  $form['sync'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Sync Projects')
+  );
+
+  // before proceeding check to see if we have any
+  // currently processing jobs. If so, we don't want
+  // to give the opportunity to sync libraries
+  $active_jobs = FALSE;
+  if (tripal_get_module_active_jobs('tripal_project')) {
+    $active_jobs = TRUE;
+  }
+
+  if (!$active_jobs) {
+
+    // get the list of projects
+    $sql = "SELECT * FROM {project} ORDER BY name";
+    $org_rset = chado_query($sql);
+
+    // if we've added any projects to the list that can be synced
+    // then we want to build the form components to allow the user
+    // to select one or all of them.  Otherwise, just present
+    // a message stating that all projects are currently synced.
+    $proj_boxes = array();
+    $added = 0;
+    while ($project = db_fetch_object($org_rset)) {
+      // check to see if the project is already present as a node in drupal.
+      // if so, then skip it.
+      $sql = "SELECT * FROM {chado_project} WHERE project_id = %d";
+      if (!db_fetch_object(db_query($sql, $project->project_id))) {
+        $proj_boxes[$project->project_id] = "$project->genus $project->species ($project->common_name)";
+        $added++;
+      }
+    }
+
+    // if we have projects we need to add to the checkbox then
+    // build that form element
+    if ($added > 0) {
+      $proj_boxes['all'] = "All Projects";
+
+      $form['sync']['projects'] = array(
+        '#title'       => t('Available Projects'),
+        '#type'        => t('checkboxes'),
+        '#description' => t("Check the projects you want to sync.  Drupal content will be created for each of the projects listed above.  Select 'All Projects' to sync all of them."),
+        '#required'    => FALSE,
+        '#prefix'      => '<div id="org_boxes">',
+        '#suffix'      => '</div>',
+        '#options'     => $proj_boxes,
+      );
+      $form['sync']['button'] = array(
+        '#type' => 'submit',
+        '#value' => t('Submit Sync Job')
+      );
+    }
+    // we don't have any projects to select from
+    else {
+    $form['sync']['value'] = array(
+        '#value' => t('All projects in Chado are currently synced with Drupal.')
+    );
+    }
+  }
+  // we don't want to present a form since we have an active job running
+  else {
+    $form['sync']['value'] = array(
+        '#value' => t('Currently, jobs exist related to chado projects. Please check back later for projects that can by synced once these jobs have finished.  You can view the status of pending jobs in the Tripal jobs page.')
+    );
+  }
+}
+/**
+ *
+ * @ingroup tripal_project
+ */
+function tripal_project_admin_validate($form, &$form_state) {
+  global $user;  // we need access to the user info
+  $job_args = array();
+
+  if ($form_state['values']['op'] == t('Submit Sync Job')) {
+
+    // check to see if the user wants to sync chado and drupal.  If
+    // so then we need to register a job to do so with tripal
+    $projects = $form_state['values']['projects'];
+    $do_all = FALSE;
+    $to_sync = array();
+
+    foreach ($projects as $project_id) {
+      if (preg_match("/^all$/i" , $project_id)) {
+        $do_all = TRUE;
+      }
+      if ($project_id and preg_match("/^\d+$/i" , $project_id)) {
+        // get the list of projects
+        $sql = "SELECT * FROM {Project} WHERE project_id = %d";
+        $project = db_fetch_object(chado_query($sql, $project_id));
+        $to_sync[$project_id] = "$project->genus $project->species";
+      }
+    }
+
+    // submit the job the tripal job manager
+    if ($do_all) {
+      tripal_add_job('Sync all projects' , 'tripal_project',
+      'tripal_project_sync_projects' , $job_args , $user->uid);
+    }
+    else{
+      foreach ($to_sync as $project_id => $name) {
+        $job_args[0] = $project_id;
+        tripal_add_job("Sync project: $name" , 'tripal_project',
+          'tripal_project_sync_projects' , $job_args , $user->uid);
+      }
+    }
+  }
+
+  // -------------------------------------
+  // Submit the Reindex Job if selected
+  if ($form_state['values']['op'] == t('Reindex Features')) {
+    $projects = $form_state['values']['re-projects'];
+    foreach ($projects as $project_id) {
+      if ($project_id and preg_match("/^\d+$/i" , $project_id)) {
+        // get the project info
+        $sql = "SELECT * FROM {project} WHERE project_id = %d";
+        $project = db_fetch_object(chado_query($sql , $project_id));
+        $job_args[0] = $project_id;
+        tripal_add_job("Reindex features for project: $project->genus ".
+         "$project->species", 'tripal_project' ,
+         'tripal_project_reindex_features', $job_args, $user->uid);
+      }
+    }
+  }
+
+  // -------------------------------------
+  // Submit the taxonomy Job if selected
+  if ($form_state['values']['op'] == t('Set Feature Taxonomy')) {
+    $projects = $form_state['values']['tx-projects'];
+    foreach ($projects as $project_id) {
+      if ($project_id and preg_match("/^\d+$/i", $project_id)) {
+        // get the project info
+        $sql = "SELECT * FROM {project} WHERE project_id = %d";
+        $project = db_fetch_object(chado_query($sql , $project_id));
+        $job_args[0] = $project_id;
+        tripal_add_job("Set taxonomy for features in project: ".
+          "$project->genus $project->species" , 'tripal_project',
+          'tripal_project_taxonify_features', $job_args, $user->uid);
+      }
+    }
+  }
+
+  // -------------------------------------
+  // Submit the Cleanup Job if selected
+  if ($form_state['values']['op'] == t('Clean up orphaned projects')) {
+    tripal_add_job('Cleanup orphaned projects', 'tripal_project',
+      'tripal_project_cleanup', $job_args, $user->uid);
+  }
+}
+/**
+ * Synchronize projects from chado to drupal
+ *
+ * @ingroup tripal_project
+ */
+function tripal_project_sync_projects($project_id = NULL, $job_id = NULL) {
+  global $user;
+  $page_content = '';
+
+  if (!$project_id) {
+    $sql = "SELECT * FROM {project} P";
+    $results = chado_query($sql);
+  }
+  else {
+    $sql = "SELECT * FROM {project} P WHERE project_id = %d";
+    $results = chado_query($sql, $project_id);
+  }
+
+  // We'll use the following SQL statement for checking if the project
+  // already exists as a drupal node.
+  $sql = "SELECT * FROM {chado_project} ".
+         "WHERE project_id = %d";
+
+  while ($project = db_fetch_object($results)) {
+
+    // check if this project already exists in the drupal database. if it
+    // does then skip this project and go to the next one.
+    if (!db_fetch_object(db_query($sql, $project->project_id))) {
+
+      $new_node = new stdClass();
+      $new_node->type = 'chado_project';
+      $new_node->uid = $user->uid;
+      $new_node->title = "$project->name";
+      $new_node->project_id = $project->project_id;
+      $new_node->name = $project->name;
+      $new_node->description = $project->description;
+      node_validate($new_node);
+      if (!form_get_errors()) {
+        $node = node_submit($new_node);
+        node_save($node);
+        if ($node->nid) {
+          print "Added $project->name\n";
+        }
+      }
+      else {
+        print "Failed to insert project $project->name\n";
+      }
+    }
+    else {
+      print "Skipped $project->name\n";
+    }
+  }
+  return $page_content;
+}
+/*
+ * 
+ */
+function tripal_project_sync_projects_form_submit($form, &$form_state) {
+  global $user;
+
+  //sync'ing is done by a tripal_job that is added here
+  $job_id = tripal_add_job('Sync Projects', 'tripal_project',
+  'tripal_project_sync_all_projects', array(), $user->uid);
+
+}
+
+/*
+ * 
+ */
+function tripal_project_sync_all_projects() {
+
+  //retrieve all projects in drupal
+  $resource = db_query('SELECT project_id FROM {chado_project}');
+  $drupal_projects = array();
+  while ($r = db_fetch_object($resource)) {
+    $drupal_projects[$r->project_id] = $r->project_id;
+  }
+
+  // retrieve all projects in chado
+  $chado_projects = array();
+  $resource = chado_query('SELECT project_id FROM {project}');
+  while ($r = db_fetch_object($resource)) {
+    // if not already in drupal add to list to be sync'd
+    if (!isset($drupal_projects[$r->project_id])) {
+      $chado_projects[$r->project_id] = $r->project_id;
+    }
+  }
+
+  print 'Number of Projects to Sync: ' . sizeof($chado_projects) . "\n";
+
+  foreach ($chado_projects as $project_id) {
+    $project = tripal_core_chado_select('project', array('name', 'description'), array('project_id' => $project_id));
+
+    // create node
+    $new_node = new stdClass();
+    $new_node->type = 'chado_project';
+    $new_node->uid = $user->uid;
+    $new_node->title = $project[0]->name;
+    $new_node->project_id = $project_id;
+    $new_node->description = $project[0]->description;
+    node_validate($new_node);
+    $errors = form_get_errors();
+    if (!$errors) {
+      $node = node_submit($new_node);
+      node_save($node);
+      if ($node->nid) {
+        print "Added " . $project[0]->name . " (Node ID:" . $node->nid . ")\n";
+      }
+    }
+    else {
+      print "Failed to insert project: " . $project[0]->name . "\n";
+      print "Errors: " . print_r($errors, TRUE) . "\n";
+    }
+
+  }
+
+
+}
+
+/**
+ * Remove orphaned drupal nodes
+ *
+ * @param $dummy
+ *   Not Used -kept for backwards compatibility
+ * @param $job_id
+ *   The id of the tripal job executing this function
+ *
+ * @ingroup tripal_project
+ */
+function tripal_project_cleanup($dummy = NULL, $job_id = NULL) {
+
+  return tripal_core_clean_orphaned_nodes('project', $job_id);
+}

+ 93 - 0
tripal_project/theme/tripal_project_admin.tpl.php

@@ -0,0 +1,93 @@
+<h3>Tripal Project Administrative Tools Quick Links:</h3>
+<ul>
+ <li><a href="<?php print url("admin/tripal/tripal_project/configuration") ?>">Project Configuration</a></li>
+</ul>
+<h3>Module Description:</h3>
+<p>The Tripal Project module provides support for visualization of "project" pages, editing and updating.</p>
+
+<h3>Setup Instructions:</h3>
+<ol>
+<li><p><b>Set Permissions</b>: The project module supports the Drupal user permissions interface for
+   controlling access to project content and functions. These permissions include viewing,
+   creating, editing or administering of
+   project content. The default is that only the original site administrator has these
+   permissions.  You can <a href="<?php print url('admin/user/roles') ?>">add roles</a> for classifying users,
+   <a href="<?php print url('admin/user/user') ?>">assign users to roles</a> and
+   <a href="<?php print url('admin/user/permissions') ?>">assign permissions</a> for the project content to
+   those roles.  For a simple setup, allow anonymous users access to view organism content and
+   allow the site administrator all other permissions.</p></li>
+<li><p><b>Sync any Existing Projects</b>: Near the top of the ' . l('Project Configuration page', 'admin/tripal/tripal_project/configuration') ?> there is
+  a Sync Projects section which provides list of projects currently in chado which can be sync\'d.
+  Simply select the projects you would like to create Drupal/Tripal pages for and click Sync Projects.</p></li>
+</ol>
+
+
+<h3>Features of this Module:</h3>
+<ul>
+  <li><b>Add/Edit/Delete Projects</b>: Projects with no associated features can be created ' . l('here', 'node/add/chado-project') ?> but it is
+  recommended to create the project using the feature loader. For example, when you load FASTA files using the Tripal loader you are
+  given the option of specifying a project for all created features. Existing Projects (regardless of the method used to create them) can be
+  edited or deleted by clicking the Edit tab at the top of the Project Page.</li>
+  <li><p><b>Integration with Drupal Views</b>: <a href="http://drupal.org/project/views">Drupal Views</a> is
+  a powerful tool that allows the site administrator to create lists or basic searching forms of Chado content.
+  It provides a graphical interface within Drupal to allow the site admin to directly query the Chado database
+  and create custom lists without PHP programming or customization of Tripal source code.  Views can also
+  be created to filter content that has not yet been synced with Druapl in order to protect access to non
+  published data (only works if Chado was installed using Tripal).  You can see a list of available pre-existing
+  Views <a href="<?php print url('admin/build/views/') ?>">here</a>, as well as create your own. </p></li>
+  <li><b>Basic Listing</b>: This module provides a basic <a href="<?php print url('projects') ?>">project display
+  tool</a> for finding or listing projects in Chado. It does not require indexing for Drupal searching but relies
+  on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed.</li>
+</ul>
+
+<h3>Page Customizations</h3>
+<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
+Below is a description of several methods.  These methods may be used in conjunction with one another to
+provide fine-grained control.
+<ul>
+
+<li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
+allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.  Tripal comes with pre-set layouts for project pages.  However,
+Panels become useful if you prefer a layout that is different from the pre-set layouts.  Chado content
+is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
+Panel\'s GUI.</p></li>
+
+<li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
+<a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
+to any page without need to edit template files or knowing PHP.  You must first download and install CCK.
+With CCK, the site administartor can create a new field to appear on the page.  For example, currently,
+the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text
+field to the project pages.  This content is not stored in Chado, but will appear on the project page.  A field
+added by CCK will also appear in the form when editing a project to allow users to manually enter the appropriate
+text.  If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
+indicate that it is not to be shown (using the CCK interface), then manually add the new content type
+where desired by editing the templates (as described below).  If using Panels, the CCK field can be added to the
+location desired using the Panels interface.</p></li>
+
+<li><p><b>Drupal Node Templates</b>:  The Tripal packages comes with a "theme_tripal" directory that contains the
+themeing for Chado content.    The project module has a template file for project "nodes" (Tripal project pages).  This file
+is named "node-chado_project.tpl.php", and provides javascript, HTML and PHP code for display of the project
+pages.  You can edit this file to control which types of information (or which project "blocks") are displayed for projects. Be sure to
+copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
+future Tripal updates may overwrite your customizations. See the <a href="http://tripal.info">Tripal website </a>
+for instructions on how to access variables and other Chado content within the template file.</p></li>
+
+<li><p><b>Project "Block" Templates</b>:  In the "theme_tripal" directory is a subdirectory named "tripal_project".
+Inside this directory is a set of templates that control distinct types of information for projects.  For example,
+there is a "base" template for displaying of data directly from the Chado project table.  These templates are used both by Drupal blocks
+for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
+provides (also desribed above).  You can customize this template as you desire.  Be sure to copy the
+template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
+future Tripal updates may overwrite your customizations.  See the <a href="http://tripal.info">Tripal website </a>
+for instructions on how to access variables and other Chado content within the template files.</p></li>
+</li>
+
+<li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
+will see a "Resources" sidebar on each page.  The links that appear on the sidebar are automatically generated
+using Javascript for all of the project "Blocks" that appear on the page. If you want to add additional links
+(e.g. a link to a views table showing all features of the current project) and you want that link to appear in the
+"Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
+section at the bottom of the template file where the resources section is found.</p></li>
+
+</ul>
+</p>

+ 0 - 103
tripal_project/tripal_project.admin.inc

@@ -1,103 +0,0 @@
-<?php
-/**
- * @file
- * @todo Add file header description
- */
-
-function tripal_project_administration_description_page() {
-  $output = '';
-
-
-  return $output;
-}
-
-function tripal_project_configuration_page() {
-  $output = '';
-
-  $output .= drupal_get_form('tripal_project_sync_projects_form');
-
-  return $output;
-}
-
-function tripal_project_sync_projects_form($form_state = NULL) {
-  $form = array();
-
-  $form['sync'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'Sync Projects'
-  );
-
-  $form['sync']['description'] = array(
-    '#type' => 'item',
-    '#value' => 'Many of the details for projects are stored in chado. Often other tripal '
-      .'modules may create projects as a means of grouping data together. Sync\'ing projects '
-      .'in chado created drupal pages (known as nodes) which display the data to priviledged users.'
-  );
-
-  $form['sync']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => 'Sync All Projects',
-
-  );
-
-  return $form;
-}
-
-function tripal_project_sync_projects_form_submit($form, &$form_state) {
-  global $user;
-
-  //sync'ing is done by a tripal_job that is added here
-  $job_id = tripal_add_job('Sync Projects', 'tripal_project',
-  'tripal_project_sync_all_projects', array(), $user->uid);
-
-}
-
-function tripal_project_sync_all_projects() {
-
-  //retrieve all projects in drupal
-  $resource = db_query('SELECT project_id FROM {chado_project}');
-  $drupal_projects = array();
-  while ($r = db_fetch_object($resource)) {
-    $drupal_projects[$r->project_id] = $r->project_id;
-  }
-
-  // retrieve all projects in chado
-  $chado_projects = array();
-  $resource = chado_query('SELECT project_id FROM {project}');
-  while ($r = db_fetch_object($resource)) {
-    // if not already in drupal add to list to be sync'd
-    if (!isset($drupal_projects[$r->project_id])) {
-      $chado_projects[$r->project_id] = $r->project_id;
-    }
-  }
-
-  print 'Number of Projects to Sync: ' . sizeof($chado_projects) . "\n";
-
-  foreach ($chado_projects as $project_id) {
-    $project = tripal_core_chado_select('project', array('name', 'description'), array('project_id' => $project_id));
-
-    // create node
-    $new_node = new stdClass();
-    $new_node->type = 'chado_project';
-    $new_node->uid = $user->uid;
-    $new_node->title = $project[0]->name;
-    $new_node->project_id = $project_id;
-    $new_node->description = $project[0]->description;
-    node_validate($new_node);
-    $errors = form_get_errors();
-    if (!$errors) {
-      $node = node_submit($new_node);
-      node_save($node);
-      if ($node->nid) {
-        print "Added " . $project[0]->name . " (Node ID:" . $node->nid . ")\n";
-      }
-    }
-    else {
-      print "Failed to insert project: " . $project[0]->name . "\n";
-      print "Errors: " . print_r($errors, TRUE) . "\n";
-    }
-
-  }
-
-
-}

+ 34 - 56
tripal_project/tripal_project.module

@@ -1,6 +1,6 @@
 <?php
 
-require('tripal_project.admin.inc');
+require('includes/tripal_project.admin.inc');
 
 /**
  *  @file
@@ -11,11 +11,6 @@ require('tripal_project.admin.inc');
  * @see http://gmod.org/wiki/Chado_General_Module
  */
 
-//-----------------------------------------------------------------------------
-//  SECTION: Main Outline for Tripal Project Module
-//-----------------------------------------------------------------------------
-
-
 /**
  * Implements hook_views_api()
  *
@@ -36,15 +31,17 @@ function tripal_project_views_api() {
 function tripal_project_menu() {
   $items[ 'admin/tripal/tripal_project' ]= array(
     'title' => 'Projects',
-    'page callback' => 'tripal_project_administration_description_page',
-    'access arguments' => array('administer site configuration'),
+    'page callback' => 'theme',
+    'page arguments' => array('tripal_project_admin'),   
+    'access arguments' => array('adminster tripal projects'),
     'type' => MENU_NORMAL_ITEM
   );
 
   $items[ 'admin/tripal/tripal_project/configuration' ]= array(
     'title' => 'Configuration',
-    'page callback' => 'tripal_project_configuration_page',
-    'access arguments' => array('administer site configuration'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_project_admin'),
+    'access arguments' => array('adminster tripal projects'),
     'type' => MENU_NORMAL_ITEM
   );
 
@@ -59,11 +56,12 @@ function tripal_project_menu() {
  *
  */
 function tripal_project_perm() {
-
   return array(
-    'access chado_projects',
-    'create chado_projects',
-    'edit own chado_projects'
+    'access chado_projects content',
+    'create chado_projects content',
+    'delete chado_projects content',
+    'edit chado_projects content',
+    'adminster tripal projects',
   );
 }
 
@@ -88,7 +86,6 @@ function tripal_project_perm() {
 function chado_project_access($op, $node, $account) {
 
   if ($op == 'create') {
-
     // Only users with permission to do so may create this node type.
     if (!user_access('create chado_projects', $account)) {
       return FALSE;
@@ -115,10 +112,6 @@ function chado_project_access($op, $node, $account) {
   return NULL;
 }
 
-//-----------------------------------------------------------------------------
-//  SECTION: Node Functionality
-//-----------------------------------------------------------------------------
-
 /**
  * Implementation of hook_node_info().
  *
@@ -140,7 +133,26 @@ function tripal_project_node_info() {
     )
   );
 }
-
+/**
+ *  We need to let drupal know about our theme functions and their arguments.
+ *  We create theme functions to allow users of the module to customize the
+ *  look and feel of the output generated in this module
+ *
+ * @ingroup tripal_project
+ */
+function tripal_project_theme() {
+  return array(
+    'tripal_project_base' => array(
+      'arguments' => array('node' => NULL),
+      'template' => 'tripal_project_base',
+    ),  
+    'tripal_project_admin' => array(
+      'template' => 'tripal_project_admin',  
+      'arguments' =>  array(NULL),  
+      'path' => drupal_get_path('module', 'tripal_project') . '/theme' 
+    ),
+  );
+}
 /**
  * Implementation of hook_form().
  *
@@ -173,6 +185,7 @@ function chado_project_form(&$node, $form_state) {
     '#type' => 'textfield',
     '#maxlength' => 255,
     '#title' => 'Short Description',
+    '#description' => t('Please provide a very short description (less than 255 characters) describing this project.'),
     '#default_value' => $node->project->description,
   );
 
@@ -293,39 +306,4 @@ function chado_project_load($node) {
 
   return $node;
 
-}
-
-
-//-----------------------------------------------------------------------------
-//  END OF SOFTWARE
-//-----------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+}

+ 0 - 60
tripal_stock/api/tripal_stock.api.inc

@@ -319,63 +319,3 @@ function tripal_stock_get_stock_by_name_identifier($name, $organism_id) {
   return $stocks;
 }
 
-/**
- * Implements hook_chado_schema_v1_11_table()
- *
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the stock table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_stock_chado_schema_v1_11_stock() {
-  $description = array();
-
-  $description['description'] = 'Any stock can be globally identified by the combination of organism, uniquename and stock type. A stock is the physical entities, either living or preserved, held by collections. Stocks belong to a collection; they have IDs, type, organism, description and may have a genotype.';
-
-  $referring_tables = array(
-    'stock_cvterm',
-    'stock_dbxref',
-    'stock_genotype',
-    'stock_pub',
-    'stock_relationship',
-    'stockcollection_stock',
-    'stockprop'
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-/**
- * Implements hook_chado_schema_v1_2_table()
- *
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the stock table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_stock_chado_schema_v1_2_stock() {
-  $description = array();
-
-  $description['description'] = 'Any stock can be globally identified by the combination of organism, uniquename and stock type. A stock is the physical entities, either living or preserved, held by collections. Stocks belong to a collection; they have IDs, type, organism, description and may have a genotype.';
-
-  $referring_tables = array(
-    'stock_cvterm',
-    'stock_dbxref',
-    'stock_genotype',
-    'stock_pub',
-    'stock_relationship',
-    'stockcollection_stock',
-    'stockprop'
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-

+ 0 - 133
tripal_stock/includes/tripal_stock-administration.inc

@@ -4,139 +4,6 @@
  * @todo Add file header description
  */
 
-/**
- * Purpose: Provide Guidance to new Tripal Admin
- *
- * @return
- *   HTML Formatted text
- *
- * @ingroup tripal_stock
- */
-function tripal_stock_module_description_page() {
-  $text = '';
-
-  $text = '<h3>Tripal Stock Administrative Tools Quick Links</h3>';
-    $text .= '<ul>';
-      $text .= '<li>' . l(t('Configuration'), 'admin/tripal/tripal_stock/configuration') . '</li>';
-      $text .= '<li>' . l(t('Stock Listing'), 'stocks') . '</li>';
-    $text .= '</ul>';
-
-  $text .= '<h3>Module Description:</h3>';
-  //================================================================================
-  $text .= '<p>The Tripal Stock Module provides functionality for adding, editing, deleting and accessing chado stocks. The stock module was designed to store information about stock collections in a laboratory. What is called a stock could also be called a strain or an accession. There is a lot in common between a Drosophila stock and a Saccharomyces strain and an Arabidopsis line. They all come from some taxon, have genotypes, physical locations in the lab, some conceivable relationship with a publication, some conceivable relationship with a sequence feature (such as a transgene), and could be described by some ontology term. For more information about the chado Stock Module <a href="http://gmod.org/wiki/Chado_Stock_Module">see the GMOD Wiki Page</a></p>';
-
-  $text .= '<h3>Setup Instructions:</h3>';
-  //================================================================================
-  $text .= '<ol>';
-  $text .= '<li><b>Set Ontologies</b>: Since at the time of this modules developement there is no accepted ontology for
-            describing stocks, their properties and relationships, this module allows you to select the controlled
-            vocabularies (CVs) in your Chado Database you would like to govern these data. To Set the Controlled Vocabularies for Stocks:
-            First, ensure your Controlled Vocabulary is in Chado. This can be done by either loading an existing Ontology into Chado using
-            the <a href="tripal_cv/ontology_loader">Tripal Ontology Loader</a> OR create your ontology from scratch by first
-            <a href="tripal_cv/add_cv">creating a controlled vocabulary</a> and then <a href="tripal_cv/add_cvterm">adding terms to it</a>.
-            Then go to the <a href="tripal_stock/configuration">Configuration Page for Stocks</a> and, in the "Set Stock Controlled Vocabularies" Fieldset,
-            select the Controlled Vocaulary name for Stock Types, Stock Properties and Stock Relationship Types.</li>';
-      $text .= '<ol type="i">';
-        $text .= '<li>Stock Types: When you are creating stocks, the type of each stock must be indicated. This might include "DNA extraction", "Individual Plant/Animal" or even "Progeny Population".</li>';
-        $text .= '<li>Stock Properties: This module also allows you to assign properties to any stock. Each property has a type and a value where type is required an value is not. Therefore, if you want to say that a stock was grown at 23 degrees Celcius then the Type would be "temperature grown at" and the value would be 23 degrees Celcius. As such the Stock Properties controlled vocabulary might include "temperature grown at", "diet", "extraction date", "stock location", etc.</li>';
-        $text .= '<li>Stock Relationship Types: You can also specify relationships between stocks. For example, a stock of type="DNA extraction" (Stock 1a) is related to the stock of type="Individual Plant/Animal" (Stock 1) that it was extracted from. Thus you might specify the relationship Stock 1 is the source material for Stock 1a where the relationship type is "is the source material for". As such Stock Relationship Types might include "is the source material for", "is maternal parent of", "is individual of population", etc.</li>';
-      $text .= '</ol>';
-
-  $text .= '<li><p><b>Set Permissions</b>: The stock module supports the Drupal user permissions interface for
-               controlling access to stock content and functions. These permissions include viewing,
-               creating, editing or administering of
-               stock content. The default is that only the original site administrator has these
-               permissions.  You can <a href="' . url('admin/user/roles') . '">add roles</a> for classifying users,
-               <a href="' . url('admin/user/user') . '">assign users to roles</a> and
-               <a href="' . url('admin/user/permissions') . '">assign permissions</a> for the stock content to
-               those roles.  For a simple setup, allow anonymous users access to view organism content and
-               allow the site administrator all other permissions.</p></li>';
-
-  $text .= '<li><b>Sync Stocks</b>: if you chado database already contains stocks, they need to be sync\'d with Drupal</b>. This creates Drupal Content including detail pages for each stock (known as nodes in Drupal). To sync\' Chado with Drupal simply go to the <a href="tripal_stock/configuration">Configuration Page for Stocks</a> and in the "Sync Stocks" Fieldset select the Organisms whose associated stocks you would like to sync. If this list doesn\'t contain an organism which you know is in Chado go to the Organism Configuration Page and make sure it is sync\'d with Drupal.</p>';
-  $text .= '</ol>';
-  $text .= '<h3>Features of this Module:</h3>';
-  //================================================================================
-  $text .= '<ul>';
-  $text .= '<li><b><a href="../../node/add/chado_stock">Create a Generic Stock:</a></b>';
-  $text .= '<p>This allows you to create content in your drupal and chado for a stock (only the unique stock identifier is duplicated). A Generic Stock must have a unique name, a type and an organism. In addition, you can optionally supply a more human-readable name, a primary database reference and even a short description. The Create Generic Stock form is a multistep form with the first step creating the Basic stock (stored in the stock table). All the remaining steps are optional and descriptions of each follow:</p>';
-      $text .= '<ol type="i">';
-        $text .= '<li>The Next Step is to Add Properties to the newly created stock. Properties allow you to specify additional details about a given stock. Since the types of properties you can add are goverened by a controlled vocaulary that you can create, you have complete control over what additional properties you want to allow.</li>';
-        $text .= '<li>Then you can Add External Database References. A Database Reference can be thought of as a synonym for the current stock where you want to specify a source for that synonym. The source would then be thought of as the database where a database can either be online and provide automatic linking out to the synonymous record or offline and simply be a text name of the source. To create a database reference with a given source you must first add the database to chado <a href="tripal_db/add_db">here</a>.</li>';
-        $text .= '<li>Finally you can Add Relationships between Stocks. This allows you to specify, for example, the source material of a stock or one of it\'s parents. To create a relationship between your newly added stock and another stock, the other stock must first be created as this one was. Also, since the types of relationships is governed by a controlled vocabulary, just like with properties you have complete control over which relationships you want to allow. Once you click "Finish" you will be re-directed to the Details Page of the new Stock.</li>';
-      $text .= '</ol></li>';
-
-  $text .= '<li><b>Details Page of a Stock:</b>';
-  $text .= '<p>Each stock get\'s it\'s own page on this website. This page is meant to give an overall picture of the stock including listing the basic details, as well as, all properties, database references and relationships. To understand where it is -All page content in Drupal is known as a node and is given a unique identifier or nid. Thus every drupal page has a path of node/<nid>. You can get to the Details page for a given stock from either of the stock listings described below.</p>';
-  $text .= '<p>If you want to customize the look of the stock Details page simply copy the PHP/HTML template node-chado_stock.tpl.php from theme_tripal to the base theme you are currently using. Then edit it as desired. There are plans to integrate this details page with Drupal Panels which will provide a much more user-friendly and no-programming-needed method to customize this page.</p>';
-
-  $text .= '<li><b>Adding/Updating/Deleting Stocks and their Properties, Database References and Relationships:</b>';
-  $text .= '<p>The Stock Details Page also acts as a landing pad for updating/deleting stocks. To <b>update a stock</b>, go to the stocks details page and click on the Edit tab near the top of the page. This tab will only be visable if you have permission to edit chado stock content (See post installation steps above for information on setting user permissions). If you want to <b>delete a stock</b>, click the Edit tab and then near the bottom of the form, click the Delete button. This will delete the entire stock including it\'s properties, database references and any relationships including it.</p>';
-  $text .= '<p>To <b>update/delete a given property of a stock</b>, click the "Edit Properties" Tab near the top of the stock details page. This form provides a listing of all existing properties for the given stock with form elements allowing you to change their value. After editing the properties you wanted to, simply click the "Update Properties" button to update all the properties for that stock. To delete a given property simply click the "Delete" Button beside the property you want to delete. You cannot undo this action! To <b>add a property to the given stock</b> simply fill out the "Add Property" form at the bottom of the "Edit Properties" Tab.</p>';
-  $text .= '<p><b>Adding, updating and deleting Database References and Relationships</b> for a given stock is exactly the same as the method for properties. To edit Database References, click the "Edit DB References" tab and to add/edit/update stock relationships, click the "Edit Relationships" tab.</p></li>';
-
-  $text .= '<li><b><a href="../../stocks">Basic Listing of Stocks:</a></b>';
-  $text .= '<p>This module also provides a basic listing of all stocks currently sync\'d with Drupal. To access this listing, there should be a Stocks Primary Menu item which links you to <a href="../../stocks">this page</a>. This page lists each stock on it\'s own row and provides a link to each stock by clicking on it\'s name. Currently there is no way to easily customize this listing.</p></li>';
-
-  $text .= '<li><b><a href="../build/views/">Flexible Listing of Stocks using Drupal Views:</a></b>';
-  $text .= '<p>In order to access a more flexible listing of stocks you must first install the <a href="http://drupal.org/project/views">Drupal Views2 module</a>. You should then be able to access the default views <a href="../build/views/">here</a>. Essentially, Views is a module which allows you to create custom SQL queries completely through the web interface without knowing SQL. Furthermore, it also does some formatting of the results allowing you to display them as HTML lists, tables or grids. You can also expose filters to the user to let them customize the results they see and even implement various sorting.</p>';
-  $text .= '<p>To use one of the Default Views simply click "Enable" and then "Edit" to change it to show exactly what you want. To view the current listing simply clikc "View Page" at the top of the Edit user interface. There are a number of good tutorials out there for Views2, any of which can be used to help you create your own custom listings of biological content. (Note: there aren\'t any tutorials specifically for tripal content but any tutorial for Views2 will show you how to use the views interface.</p></li>';
-
-  $text .= '<h3>Page Customizations</h3>';
-  $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
-             Below is a description of several methods.  These methods may be used in conjunction with one another to
-             provide fine-grained control.
-             <ul>
-
-             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
-              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.  Tripal comes with pre-set layouts for stock pages.  However,
-              Panels become useful if you prefer a layout that is different from the pre-set layouts.  Chado content
-              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
-              Panel\'s GUI.</p></li>
-
-             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
-             <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
-             to any page without need to edit template files or knowing PHP.  You must first download and install CCK.
-             With CCK, the site administartor can create a new field to appear on the page.  For example, currently,
-             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text
-             field to the stock pages.  This content is not stored in Chado, but will appear on the stock page.  A field
-             added by CCK will also appear in the form when editing a stock to allow users to manually enter the appropriate
-             text.  If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
-             indicate that it is not to be shown (using the CCK interface), then manually add the new content type
-             where desired by editing the templates (as described below).  If using Panels, the CCK field can be added to the
-             location desired using the Panels interface.</p></li>
-
-             <li><p><b>Drupal Node Templates</b>:  The Tripal packages comes with a "theme_tripal" directory that contains the
-             themeing for Chado content.    The stock module has a template file for stock "nodes" (Tripal stock pages).  This file
-             is named "node-chado_stock.tpl.php", and provides javascript, HTML and PHP code for display of the stock
-             pages.  You can edit this file to control which types of information (or which stock "blocks") are displayed for stocks. Be sure to
-             copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
-             future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
-             for instructions on how to access variables and other Chado content within the template file.</p></li>
-
-             <li><p><b>Stock "Block" Templates</b>:  In the "theme_tripal" directory is a subdirectory named "tripal_stock".
-             Inside this directory is a set of templates that control distinct types of information for stocks.  For example,
-             there is a "base" template for displaying of data directly from the Chado stock table, and a "references"
-             template for showing external site references for a stock (data from the stock_dbxref table).  These templates are used both by Drupal blocks
-             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
-             provides (also desribed above).  You can customize this template as you desire.  Be sure to copy the
-             template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
-             future Tripal updates may overwrite your customizations.  See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
-             for instructions on how to access variables and other Chado content within the template files.</p></li>
-             </li>
-
-             <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
-             will see a "Resources" sidebar on each page.  The links that appear on the sidebar are automatically generated
-             using Javascript for all of the stock "Blocks" that appear on the page. If you want to add additional links
-             (e.g. a dynamic link to additional stock content) and you want that link to appear in the
-             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
-             section at the bottom of the template file where the resources section is found.</p></li>
-
-             </ul>
-             </p>';
-
-  return $text;
-}
-
 /**
  * Purpose: Provide administration options for chado_stocks
  *

+ 115 - 0
tripal_stock/theme/tripal_stock_admin.tpl.php

@@ -0,0 +1,115 @@
+  <h3>Tripal Stock Administrative Tools Quick Links</h3>
+    <ul>
+      <li><?php print l(t('Configuration'), 'admin/tripal/tripal_stock/configuration') ?></li>
+      <li><?php print l(t('Stock Listing'), 'stocks') ?></li>
+    </ul>
+
+  <h3>Module Description:</h3>
+  <p>The Tripal Stock Module provides functionality for adding, editing, deleting and accessing chado stocks. The stock module was designed to store information about stock collections in a laboratory. What is called a stock could also be called a strain or an accession. There is a lot in common between a Drosophila stock and a Saccharomyces strain and an Arabidopsis line. They all come from some taxon, have genotypes, physical locations in the lab, some conceivable relationship with a publication, some conceivable relationship with a sequence feature (such as a transgene), and could be described by some ontology term. For more information about the chado Stock Module <a href="http://gmod.org/wiki/Chado_Stock_Module">see the GMOD Wiki Page</a></p>
+
+  <h3>Setup Instructions:</h3>
+  <ol>
+  <li><b>Set Ontologies</b>: Since at the time of this modules developement there is no accepted ontology for
+            describing stocks, their properties and relationships, this module allows you to select the controlled
+            vocabularies (CVs) in your Chado Database you would like to govern these data. To Set the Controlled Vocabularies for Stocks:
+            First, ensure your Controlled Vocabulary is in Chado. This can be done by either loading an existing Ontology into Chado using
+            the <a href="tripal_cv/ontology_loader">Tripal Ontology Loader</a> OR create your ontology from scratch by first
+            <a href="tripal_cv/add_cv">creating a controlled vocabulary</a> and then <a href="tripal_cv/add_cvterm">adding terms to it</a>.
+            Then go to the <a href="tripal_stock/configuration">Configuration Page for Stocks</a> and, in the "Set Stock Controlled Vocabularies" Fieldset,
+            select the Controlled Vocaulary name for Stock Types, Stock Properties and Stock Relationship Types.</li>
+      <ol type="i">
+        <li>Stock Types: When you are creating stocks, the type of each stock must be indicated. This might include "DNA extraction", "Individual Plant/Animal" or even "Progeny Population".</li>
+        <li>Stock Properties: This module also allows you to assign properties to any stock. Each property has a type and a value where type is required an value is not. Therefore, if you want to say that a stock was grown at 23 degrees Celcius then the Type would be "temperature grown at" and the value would be 23 degrees Celcius. As such the Stock Properties controlled vocabulary might include "temperature grown at", "diet", "extraction date", "stock location", etc.</li>
+        <li>Stock Relationship Types: You can also specify relationships between stocks. For example, a stock of type="DNA extraction" (Stock 1a) is related to the stock of type="Individual Plant/Animal" (Stock 1) that it was extracted from. Thus you might specify the relationship Stock 1 is the source material for Stock 1a where the relationship type is "is the source material for". As such Stock Relationship Types might include "is the source material for", "is maternal parent of", "is individual of population", etc.</li>
+      </ol>
+
+  <li><p><b>Set Permissions</b>: The stock module supports the Drupal user permissions interface for
+               controlling access to stock content and functions. These permissions include viewing,
+               creating, editing or administering of
+               stock content. The default is that only the original site administrator has these
+               permissions.  You can <a href="<?php url('admin/user/roles') ?>">add roles</a> for classifying users,
+               <a href="<?php url('admin/user/user') ?>">assign users to roles</a> and
+               <a href="<?php url('admin/user/permissions') ?>">assign permissions</a> for the stock content to
+               those roles.  For a simple setup, allow anonymous users access to view organism content and
+               allow the site administrator all other permissions.</p></li>
+
+  <li><b>Sync Stocks</b>: if you chado database already contains stocks, they need to be sync'd with Drupal</b>. This creates Drupal Content including detail pages for each stock (known as nodes in Drupal). To sync' Chado with Drupal simply go to the <a href="tripal_stock/configuration">Configuration Page for Stocks</a> and in the "Sync Stocks" Fieldset select the Organisms whose associated stocks you would like to sync. If this list doesn't contain an organism which you know is in Chado go to the Organism Configuration Page and make sure it is sync'd with Drupal.</p>
+  </ol>
+  <h3>Features of this Module:</h3>
+  <ul>
+  <li><b><a href="../../node/add/chado_stock">Create a Generic Stock:</a></b>
+  <p>This allows you to create content in your drupal and chado for a stock (only the unique stock identifier is duplicated). A Generic Stock must have a unique name, a type and an organism. In addition, you can optionally supply a more human-readable name, a primary database reference and even a short description. The Create Generic Stock form is a multistep form with the first step creating the Basic stock (stored in the stock table). All the remaining steps are optional and descriptions of each follow:</p>
+      <ol type="i">
+        <li>The Next Step is to Add Properties to the newly created stock. Properties allow you to specify additional details about a given stock. Since the types of properties you can add are goverened by a controlled vocaulary that you can create, you have complete control over what additional properties you want to allow.</li>
+        <li>Then you can Add External Database References. A Database Reference can be thought of as a synonym for the current stock where you want to specify a source for that synonym. The source would then be thought of as the database where a database can either be online and provide automatic linking out to the synonymous record or offline and simply be a text name of the source. To create a database reference with a given source you must first add the database to chado <a href="tripal_db/add_db">here</a>.</li>
+        <li>Finally you can Add Relationships between Stocks. This allows you to specify, for example, the source material of a stock or one of it's parents. To create a relationship between your newly added stock and another stock, the other stock must first be created as this one was. Also, since the types of relationships is governed by a controlled vocabulary, just like with properties you have complete control over which relationships you want to allow. Once you click "Finish" you will be re-directed to the Details Page of the new Stock.</li>
+      </ol></li>
+
+  <li><b>Details Page of a Stock:</b>
+  <p>Each stock get's it's own page on this website. This page is meant to give an overall picture of the stock including listing the basic details, as well as, all properties, database references and relationships. To understand where it is -All page content in Drupal is known as a node and is given a unique identifier or nid. Thus every drupal page has a path of node/<nid>. You can get to the Details page for a given stock from either of the stock listings described below.</p>
+  <p>If you want to customize the look of the stock Details page simply copy the PHP/HTML template node-chado_stock.tpl.php from theme_tripal to the base theme you are currently using. Then edit it as desired. There are plans to integrate this details page with Drupal Panels which will provide a much more user-friendly and no-programming-needed method to customize this page.</p>
+
+  <li><b>Adding/Updating/Deleting Stocks and their Properties, Database References and Relationships:</b>
+  <p>The Stock Details Page also acts as a landing pad for updating/deleting stocks. To <b>update a stock</b>, go to the stocks details page and click on the Edit tab near the top of the page. This tab will only be visable if you have permission to edit chado stock content (See post installation steps above for information on setting user permissions). If you want to <b>delete a stock</b>, click the Edit tab and then near the bottom of the form, click the Delete button. This will delete the entire stock including it's properties, database references and any relationships including it.</p>
+  <p>To <b>update/delete a given property of a stock</b>, click the "Edit Properties" Tab near the top of the stock details page. This form provides a listing of all existing properties for the given stock with form elements allowing you to change their value. After editing the properties you wanted to, simply click the "Update Properties" button to update all the properties for that stock. To delete a given property simply click the "Delete" Button beside the property you want to delete. You cannot undo this action! To <b>add a property to the given stock</b> simply fill out the "Add Property" form at the bottom of the "Edit Properties" Tab.</p>
+  <p><b>Adding, updating and deleting Database References and Relationships</b> for a given stock is exactly the same as the method for properties. To edit Database References, click the "Edit DB References" tab and to add/edit/update stock relationships, click the "Edit Relationships" tab.</p></li>
+
+  <li><b><a href="../../stocks">Basic Listing of Stocks:</a></b>
+  <p>This module also provides a basic listing of all stocks currently sync'd with Drupal. To access this listing, there should be a Stocks Primary Menu item which links you to <a href="../../stocks">this page</a>. This page lists each stock on it's own row and provides a link to each stock by clicking on it's name. Currently there is no way to easily customize this listing.</p></li>
+
+  <li><b><a href="../build/views/">Flexible Listing of Stocks using Drupal Views:</a></b>
+  <p>In order to access a more flexible listing of stocks you must first install the <a href="http://drupal.org/project/views">Drupal Views2 module</a>. You should then be able to access the default views <a href="../build/views/">here</a>. Essentially, Views is a module which allows you to create custom SQL queries completely through the web interface without knowing SQL. Furthermore, it also does some formatting of the results allowing you to display them as HTML lists, tables or grids. You can also expose filters to the user to let them customize the results they see and even implement various sorting.</p>
+  <p>To use one of the Default Views simply click "Enable" and then "Edit" to change it to show exactly what you want. To view the current listing simply clikc "View Page" at the top of the Edit user interface. There are a number of good tutorials out there for Views2, any of which can be used to help you create your own custom listings of biological content. (Note: there aren't any tutorials specifically for tripal content but any tutorial for Views2 will show you how to use the views interface.</p></li>
+
+  <h3>Page Customizations</h3>
+  <p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
+     Below is a description of several methods.  These methods may be used in conjunction with one another to
+     provide fine-grained control.
+     <ul>
+
+     <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
+      allows for customization of a page layout if you don't want to do PHP/Javascript/CSS programming.  Tripal comes with pre-set layouts for stock pages.  However,
+      Panels become useful if you prefer a layout that is different from the pre-set layouts.  Chado content
+      is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
+      Panel's GUI.</p></li>
+
+     <li><p><b>Drupal's Content Construction Kit (CCK)</b>: the
+     <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
+     to any page without need to edit template files or knowing PHP.  You must first download and install CCK.
+     With CCK, the site administartor can create a new field to appear on the page.  For example, currently,
+     the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text
+     field to the stock pages.  This content is not stored in Chado, but will appear on the stock page.  A field
+     added by CCK will also appear in the form when editing a stock to allow users to manually enter the appropriate
+     text.  If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
+     indicate that it is not to be shown (using the CCK interface), then manually add the new content type
+     where desired by editing the templates (as described below).  If using Panels, the CCK field can be added to the
+     location desired using the Panels interface.</p></li>
+
+     <li><p><b>Drupal Node Templates</b>:  The Tripal packages comes with a "theme_tripal" directory that contains the
+     themeing for Chado content.    The stock module has a template file for stock "nodes" (Tripal stock pages).  This file
+     is named "node-chado_stock.tpl.php", and provides javascript, HTML and PHP code for display of the stock
+     pages.  You can edit this file to control which types of information (or which stock "blocks") are displayed for stocks. Be sure to
+     copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
+     future Tripal updates may overwrite your customizations. See the <a href="http://tripal.info/">Tripal website </a>
+     for instructions on how to access variables and other Chado content within the template file.</p></li>
+
+     <li><p><b>Stock "Block" Templates</b>:  In the "theme_tripal" directory is a subdirectory named "tripal_stock".
+     Inside this directory is a set of templates that control distinct types of information for stocks.  For example,
+     there is a "base" template for displaying of data directly from the Chado stock table, and a "references"
+     template for showing external site references for a stock (data from the stock_dbxref table).  These templates are used both by Drupal blocks
+     for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
+     provides (also desribed above).  You can customize this template as you desire.  Be sure to copy the
+     template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
+     future Tripal updates may overwrite your customizations.  See the <a href="http://tripal.info/">Tripal website </a>
+     for instructions on how to access variables and other Chado content within the template files.</p></li>
+     </li>
+
+     <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
+     will see a "Resources" sidebar on each page.  The links that appear on the sidebar are automatically generated
+     using Javascript for all of the stock "Blocks" that appear on the page. If you want to add additional links
+     (e.g. a dynamic link to additional stock content) and you want that link to appear in the
+     "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
+     section at the bottom of the template file where the resources section is found.</p></li>
+
+     </ul>
+   </p>

+ 11 - 4
tripal_stock/tripal_stock.module

@@ -43,8 +43,9 @@ function tripal_stock_menu() {
   $items['admin/tripal/tripal_stock'] = array(
     'title' => 'Stocks',
     'description' => 'Basic Description of Tripal Stock Module Functionality',
-    'page callback' => 'tripal_stock_module_description_page',
-    'access arguments' => array('administer site configuration'),
+    'page callback' => 'theme',
+    'page arguments' => array('tripal_stock_admin'),
+    'access arguments' => array('administer tripal stocks'),
     'type' => MENU_NORMAL_ITEM
   );
 
@@ -53,7 +54,7 @@ function tripal_stock_menu() {
     'description' => 'Settings for Chado Stocks',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_stock_admin'),
-    'access arguments' => array('administer site configuration'),
+    'access arguments' => array('administer tripal stocks'),
     'type' => MENU_NORMAL_ITEM
   );
 
@@ -160,7 +161,8 @@ function tripal_stock_perm() {
     'access chado_stock content',
     'create chado_stock content',
     'edit chado_stock content',
-    'delete chado_stock content'
+    'delete chado_stock content',
+    'administer tripal stocks',
   );
 }
 
@@ -290,6 +292,11 @@ function tripal_stock_theme() {
        'arguments' => array('node' => NULL),
        'template' => 'tripal_organism_stocks',
     ),    
+    'tripal_stock_admin' => array(
+      'template' => 'tripal_stock_admin',  
+      'arguments' =>  array(NULL),  
+      'path' => drupal_get_path('module', 'tripal_stock') . '/theme', 
+    ),
   );
 }