Browse Source

Fixed merge conflict

Stephen Ficklin 6 years ago
parent
commit
f4c22eefc7

+ 5 - 4
.github/ISSUE_TEMPLATE/feature_request.md

@@ -12,11 +12,12 @@ INSTRUCTIONS: The following template is meant to structure your feature request.
   if it's decided the feature is not a good fit for Tripal Core.
   if it's decided the feature is not a good fit for Tripal Core.
 --->
 --->
 
 
-<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
+<!--- Go over all the following points, and select the option in the brackets that applies to you. -->
 <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
 <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
-- [ ] does this feature attempt to solve an existing problem with Tripal?
-- [ ] are you open to developing or collaborating on an extension module if this is not a good fit for Tripal Core (no pressure here -just good to know upfront :-) )
-- [ ] do you **Need** this feature ASAP?
+* This feature [does / does not] attempt to solve an existing problem with Tripal
+* I [am/am not] open to developing or collaborating on an extension module if this is not a good fit for Tripal Core
+<!--- (no pressure here -just good to know upfront :-) ) -->
+* This feature is [URGENT/Not Urgent]
 
 
 ### Description
 ### Description
 <!--- A clear and concise description of what you want to happen. -->
 <!--- A clear and concise description of what you want to happen. -->

+ 16 - 19
.github/PULL_REQUEST_TEMPLATE.md

@@ -1,34 +1,31 @@
+<!--- Thank you for contributing! -->
 <!--- Provide a general summary of your changes in the Title above -->
 <!--- Provide a general summary of your changes in the Title above -->
 <!--- See our Contribution Guidelines here:
 <!--- See our Contribution Guidelines here:
           https://github.com/tripal/tripal/blob/7.x-3.x/CONTRIBUTING.md -->
           https://github.com/tripal/tripal/blob/7.x-3.x/CONTRIBUTING.md -->
-          
-<!--- If it fixes an open issue, please add the issue link below. -->
-Issue #
 
 
-## Type(s) of Change(s)
-<!--- What types of changes does your code introduce? 
-         Put an `x` in all the boxes that apply: -->
-- [ ] Bug fix (non-breaking change which fixes an issue)
-- [ ] New feature (non-breaking change which adds functionality)
-- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
-- [ ] API-specific change (fix or addition to an API function)
-- [ ] Updates documentation (inline or markdown files)
+
+<!---  Please set the header below based on the PR type:
+# New Feature
+# Bux Fix
+# Documentation  --->
+
+#
+
+Issue #
 
 
 ## Description
 ## Description
 <!--- Describe your changes in detail -->
 <!--- Describe your changes in detail -->
 <!--- Why is this change required? What problem does it solve? -->
 <!--- Why is this change required? What problem does it solve? -->
 
 
 ## Testing?
 ## Testing?
-<!--- Please describe in detail how you tested your changes. -->
-<!--- Include details of your testing environment, tests ran to see how -->
-<!--- your change affects other areas of the code, etc. -->
+<!--- Please describe in detail how to test these changes. -->
 <!--- Reviewers will use this section to test the submission! -->
 <!--- Reviewers will use this section to test the submission! -->
+<!--- If you've implemented PHPUnit tests, you can describe the test cases here. -->
+<!--- Unit testing guidelines: https://github.com/tripal/tripal/blob/7.x-3.x/tests/README.md -->
 
 
 ## Screenshots (if appropriate):
 ## Screenshots (if appropriate):
 
 
 ## Additional Notes (if any):
 ## Additional Notes (if any):
-<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
-<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
-- [ ] My code follows the code style of this project.
-- [ ] My change requires a change to the documentation.
-- [ ] I have updated the documentation accordingly.
+
+<!--- New features should include in-line code documentation. -->
+<!--- Would a user or developer guide be helpful for this feature? -->

+ 49 - 0
docs/README.md

@@ -0,0 +1,49 @@
+The Tripal documentation is written in [**Restructured Text**](http://docutils.sourceforge.net/rst.html), compiled with [Sphinx](http://www.sphinx-doc.org/en/master/usage/quickstart.html), and built/hosted with [ReadTheDocs](https://readthedocs.org/).  This directory, when compiled, is hosted at https://tripal.readthedocs.io/en/latest/
+
+For minor changes, you can simply [Edit the file using the Github editor](https://help.github.com/articles/editing-files-in-your-repository/), which will allow you to make a Pull Request.  Once approved, your changes will be reflected in the documentation automatically! 
+
+# Guide
+
+### Install Sphinx
+For minor changes, you don't need to build the documentation!  If you want to see how your changes will look on the built site, however, you will need Sphinx installed.
+
+For more information, please see the Sphinx setup guide:
+http://www.sphinx-doc.org/en/master/usage/quickstart.html
+
+
+### Building your changes
+
+For more extensive edits, or when contributing new guides, you should build the documentation locally. From the `docs` root (eg `/var/www/html/sites/all/modules/tripal/docs/`, execute `make html`.  The built site will be in `docs/_build/html/index.html`.
+
+### Tripal conventions
+Please follow these guidelines when updating our docs. Let us know if you have any questions or something isn't clear.
+
+Please place images in the same folder as the guide text file, following the convention [file_name].[n].[optional description].[extension].  For example, `configuring_page_display.3.rearrange.png` or `configuring_page_display.1.png` are both located in `docs/user_guide/` and are part of the `configuring_page_display.rst` guide.
+
+We currently use the following syntax:
+```
+Title of File (using title case)
+=================================
+
+Introduction text.
+
+Section Title
+-------------
+
+We use double backticks to indicate ``inline-code`` including file names, function and method names, paths, etc.
+
+Longer code-blocks should begin with the ``.. code-block:: [type]`` directive and should be indented at least one 
+level. There should also be a blank line before and after it as shown below.
+
+.. code-block:: sql
+  if ($needs_documentation) {
+      use $these_guidelines;
+      $contribute_docs = $appreciated;
+  }
+
+Section 1.1 Title
+^^^^^^^^^^^^^^^^^
+
+The use of appropriate sections makes reading documentation and later specific details easier. Sub sections such 
+as this one will be hidden unless the main section is already selected.
+```

+ 94 - 93
tripal/api/tripal.entities.api.inc

@@ -3,8 +3,8 @@
 /**
 /**
  * @file
  * @file
  * Provides an application programming interface (API) for working with
  * Provides an application programming interface (API) for working with
- * TripalEntity content types (bundles) and their entities. 
- * 
+ * TripalEntity content types (bundles) and their entities.
+ *
  */
  */
 
 
 /**
 /**
@@ -13,32 +13,32 @@
  * @{
  * @{
  * Provides an application programming interface (API) for working with
  * Provides an application programming interface (API) for working with
  * TripalEntity content types (bundles) and their entities.
  * TripalEntity content types (bundles) and their entities.
- * 
- * Bundles (Content Types): Bundles are types of content in a Drupal site.  
- * By default, Drupal provides the Basic Page and Article content types, 
- * and Drupal allows a site developer to create new content types on-the-fly 
- * using the administrative interface--no programming required.  Tripal also 
- * provides several Content Type by default. During installation of Tripal the 
- * Organism, Gene, Project, Analysis and other content types are created 
- * automatically.  The site developer can then create new content types for 
+ *
+ * Bundles (Content Types): Bundles are types of content in a Drupal site.
+ * By default, Drupal provides the Basic Page and Article content types,
+ * and Drupal allows a site developer to create new content types on-the-fly
+ * using the administrative interface--no programming required.  Tripal also
+ * provides several Content Type by default. During installation of Tripal the
+ * Organism, Gene, Project, Analysis and other content types are created
+ * automatically.  The site developer can then create new content types for
  * different biological data--again, without any programming required.
  * different biological data--again, without any programming required.
- * 
- * In order to to assist with data exchange and use of common data formats, 
- * Tripal Bundles are defined using a controlled vocabulary term (cvterm). 
- * For example, a "Gene" Bundle is defined using the Sequence Ontology term for 
- * gene whose term accession is: SO:0000704. This mapping allows Tripal to 
- * compare content across Tripal sites, and expose data to computational tools 
- * that understand these vocabularies. By default, Tripal uses Chado as its 
- * primary data storage back-end.  
- * 
+ *
+ * In order to to assist with data exchange and use of common data formats,
+ * Tripal Bundles are defined using a controlled vocabulary term (cvterm).
+ * For example, a "Gene" Bundle is defined using the Sequence Ontology term for
+ * gene whose term accession is: SO:0000704. This mapping allows Tripal to
+ * compare content across Tripal sites, and expose data to computational tools
+ * that understand these vocabularies. By default, Tripal uses Chado as its
+ * primary data storage back-end.
+ *
  * Entity: An entity is a discrete data record.  Entities are most commonly
  * Entity: An entity is a discrete data record.  Entities are most commonly
- * seen as "pages" on a Drupal web site and are instances of a Bundle 
- * (i.e content type). When data is published on a Tripal site such as 
- * organisms, genes, germplasm, maps, etc., each record is represented by a 
- * single entity with an entity ID as its only attribute. All other 
- * information that the entity provides is made available via Fields.  
- * 
- * For more information please see: 
+ * seen as "pages" on a Drupal web site and are instances of a Bundle
+ * (i.e content type). When data is published on a Tripal site such as
+ * organisms, genes, germplasm, maps, etc., each record is represented by a
+ * single entity with an entity ID as its only attribute. All other
+ * information that the entity provides is made available via Fields.
+ *
+ * For more information please see:
  * http://tripal.info/tutorials/v3.x/developers-handbook/structure
  * http://tripal.info/tutorials/v3.x/developers-handbook/structure
  * @}
  * @}
  *
  *
@@ -117,15 +117,15 @@ function hook_bundle_delete($bundle) {
  * Implement this hook to define default formats for Tripal Content Types.
  * Implement this hook to define default formats for Tripal Content Types.
  *
  *
  * @param TripalBundle $bundle
  * @param TripalBundle $bundle
- *   A tripal content type entity with information to be used for determining 
+ *   A tripal content type entity with information to be used for determining
  *   the default title format.
  *   the default title format.
  * @param array $available_tokens
  * @param array $available_tokens
  *   An array of available tokens for this particular tripal content type.
  *   An array of available tokens for this particular tripal content type.
  *
  *
  * @return array
  * @return array
- *   An array of potential formats. The lightest weighted format suggested by 
+ *   An array of potential formats. The lightest weighted format suggested by
  *   all modules will be chosen.
  *   all modules will be chosen.
- *   Each array item should consist of a 'weight' and 'format'. See the hook 
+ *   Each array item should consist of a 'weight' and 'format'. See the hook
  *   implementation below for examples.
  *   implementation below for examples.
  *    - weight: an integer used to determine priority of suggestions.
  *    - weight: an integer used to determine priority of suggestions.
  *        The smaller/lighter the number the higher the priority.
  *        The smaller/lighter the number the higher the priority.
@@ -148,10 +148,10 @@ function hook_tripal_default_title_format($bundle, $available_tokens) {
 
 
   // If it's the term you are interested in then suggest a format.
   // If it's the term you are interested in then suggest a format.
   if ($term->name == 'organism') {
   if ($term->name == 'organism') {
-    // To suggest a format, add an element to the array with a format & weight 
+    // To suggest a format, add an element to the array with a format & weight
     // key.
     // key.
     $format[] = array(
     $format[] = array(
-      // This is the format/pattern you suggest be used to determine the title 
+      // This is the format/pattern you suggest be used to determine the title
       // of organism pages.
       // of organism pages.
       'format' => '[organism__genus] [organism__species]',
       'format' => '[organism__genus] [organism__species]',
       // The weight/priority of your suggestion.
       // The weight/priority of your suggestion.
@@ -237,12 +237,12 @@ function tripal_load_entity($entity_type, $ids = FALSE, $reset = FALSE,
  * Retrieves a TripalTerm entity that matches the given arguments.
  * Retrieves a TripalTerm entity that matches the given arguments.
  *
  *
  * @param $values
  * @param $values
- *   An associative array used to match a term.  
- *   Valid keys may be: 
- *        - vocabulary: Must always be used with accession to uniquely 
- *                        identify a term.  
- *        - accession: Must always be used with vocabulary to uniquely 
- *                       identify a term. 
+ *   An associative array used to match a term.
+ *   Valid keys may be:
+ *        - vocabulary: Must always be used with accession to uniquely
+ *                        identify a term.
+ *        - accession: Must always be used with vocabulary to uniquely
+ *                       identify a term.
  *        - term_id: Can be used alone to uniquely identify a term.
  *        - term_id: Can be used alone to uniquely identify a term.
  *
  *
  * @return
  * @return
@@ -284,7 +284,7 @@ function tripal_load_term_entity($values) {
  * Retrieves a TripalVocab entity that maches the given arguments.
  * Retrieves a TripalVocab entity that maches the given arguments.
  *
  *
  * @param $values
  * @param $values
- *   An associative array used to match a vocabulary.  
+ *   An associative array used to match a vocabulary.
  *   The valid keys are:
  *   The valid keys are:
  *      - vocab_id: integer id of the vocabulary.
  *      - vocab_id: integer id of the vocabulary.
  *      - vocabulary: string name of vocabulary.
  *      - vocabulary: string name of vocabulary.
@@ -356,7 +356,7 @@ function tripal_load_bundle_entity($values) {
       return NULL;
       return NULL;
     }
     }
     $query->condition('tb.term_id', $term->id);
     $query->condition('tb.term_id', $term->id);
-    
+
   }
   }
   $bundle = $query->execute()->fetchObject();
   $bundle = $query->execute()->fetchObject();
 
 
@@ -375,15 +375,15 @@ function tripal_load_bundle_entity($values) {
  * @param $details
  * @param $details
  *   A human-readable sentence or two describing the issue.
  *   A human-readable sentence or two describing the issue.
  * @param $type
  * @param $type
- *   A one word type indicating the type of notification. Tripal types include: 
+ *   A one word type indicating the type of notification. Tripal types include:
  *   Jobs, Fields.
  *   Jobs, Fields.
  *   If no type is required please pass NULL.
  *   If no type is required please pass NULL.
  * @param $actions
  * @param $actions
- *   A serialized PHP associative array containing the link and URL for each 
+ *   A serialized PHP associative array containing the link and URL for each
  *   action.
  *   action.
  *   If not type is required please pass NULL.
  *   If not type is required please pass NULL.
  * @param $submitter_id
  * @param $submitter_id
- *   A unique ID provided by the submitter for checking to make sure that the 
+ *   A unique ID provided by the submitter for checking to make sure that the
  *   notification is not added more than once.
  *   notification is not added more than once.
  *
  *
  * @ingroup tripal_entities_api
  * @ingroup tripal_entities_api
@@ -396,7 +396,7 @@ function tripal_add_notification($title, $details, $type, $actions, $submitter_i
       ->fields('tan')
       ->fields('tan')
       ->condition('submitter_id', $submitter_id, '=')
       ->condition('submitter_id', $submitter_id, '=')
       ->execute()->fetchAll();
       ->execute()->fetchAll();
-  
+
     if (empty($dedup)) {
     if (empty($dedup)) {
       $record = new stdClass;
       $record = new stdClass;
       $record->details = $details;
       $record->details = $details;
@@ -439,17 +439,17 @@ function tripal_create_bundle($args, $job = NULL) {
   $accession = $args['accession'];
   $accession = $args['accession'];
   $term_name = $args['term_name'];
   $term_name = $args['term_name'];
   $storage_args = $args['storage_args'];
   $storage_args = $args['storage_args'];
-  
+
   $message_args = [
   $message_args = [
     'job' => $job,
     'job' => $job,
     'print' => TRUE,
     'print' => TRUE,
     'watchdog' => TRUE,
     'watchdog' => TRUE,
   ];
   ];
-  
-//   tripal_report_error('tripal_entities', TRIPAL_INFO, 
+
+//   tripal_report_error('tripal_entities', TRIPAL_INFO,
 //    "Creation of a content type is performed using a database transaction. " .
 //    "Creation of a content type is performed using a database transaction. " .
 //     "If it fails or is terminated prematurely then all insertions and " .
 //     "If it fails or is terminated prematurely then all insertions and " .
-//     "updates are rolled back and will not be found in the database", 
+//     "updates are rolled back and will not be found in the database",
 //     [], $message_args);
 //     [], $message_args);
 
 
   $transaction = db_transaction();
   $transaction = db_transaction();
@@ -463,7 +463,7 @@ function tripal_create_bundle($args, $job = NULL) {
       }
       }
       else {
       else {
         $transaction->rollback();
         $transaction->rollback();
-        tripal_report_error('tripal_entities', TRIPAL_ERROR, 
+        tripal_report_error('tripal_entities', TRIPAL_ERROR,
           'Unable to create TripalVocab :vocab', array(':vocab' => $vocabulary), $message_args);
           'Unable to create TripalVocab :vocab', array(':vocab' => $vocabulary), $message_args);
         return FALSE;
         return FALSE;
       }
       }
@@ -540,17 +540,17 @@ function tripal_create_bundle($args, $job = NULL) {
         'Unable to load Tripal Bundle :name after cache clear.', array(':name' => $bundle_name), $message_args);
         'Unable to load Tripal Bundle :name after cache clear.', array(':name' => $bundle_name), $message_args);
       return FALSE;
       return FALSE;
     }
     }
-    
+
     // Set the bundle category
     // Set the bundle category
     $category = array_key_exists('bundle_category', $args) ? $args['bundle_category'] : 'Other';
     $category = array_key_exists('bundle_category', $args) ? $args['bundle_category'] : 'Other';
-    tripal_set_bundle_variable($variable_name, $bundle->id, $category);
+    tripal_set_bundle_variable('bundle_category', $bundle->id, $category);
 
 
     // Attache the bundle fields.
     // Attache the bundle fields.
     tripal_create_bundle_fields($bundle, $term);
     tripal_create_bundle_fields($bundle, $term);
 
 
     // Specifically commiting here since we have a fully featured bundle.
     // Specifically commiting here since we have a fully featured bundle.
-    // Post-create hook implementations assume we have a 
-    // created bundle so we don't want to rollback if a 
+    // Post-create hook implementations assume we have a
+    // created bundle so we don't want to rollback if a
     // custom implementation causes an exception.
     // custom implementation causes an exception.
     unset($transaction);
     unset($transaction);
 
 
@@ -577,10 +577,10 @@ function tripal_create_bundle($args, $job = NULL) {
 
 
   // Set admin access for the new bundle.
   // Set admin access for the new bundle.
   tripal_admin_access($bundle);
   tripal_admin_access($bundle);
-  
+
   // Report that we're done.
   // Report that we're done.
   tripal_report_error('tripal_entities', TRIPAL_INFO, "Done.", [], $message_args);
   tripal_report_error('tripal_entities', TRIPAL_INFO, "Done.", [], $message_args);
-  
+
   return $bundle;
   return $bundle;
 }
 }
 
 
@@ -601,7 +601,7 @@ function tripal_get_content_types() {
 }
 }
 
 
 /**
 /**
- * Refreshes the bundle such that new fields added by modules will be found 
+ * Refreshes the bundle such that new fields added by modules will be found
  * during cron.
  * during cron.
  *
  *
  * @param $bundle_name
  * @param $bundle_name
@@ -766,13 +766,13 @@ function tripal_create_bundle_fields($bundle, $term) {
   // Allow modules to alter which fields should be attached to content
   // Allow modules to alter which fields should be attached to content
   // types they create.
   // types they create.
   drupal_alter('bundle_instances_info', $instance_info, $bundle, $term);
   drupal_alter('bundle_instances_info', $instance_info, $bundle, $term);
-  
+
   // Get the list of existing instances
   // Get the list of existing instances
   $existing_instances = field_info_instances('TripalEntity', $bundle->name);
   $existing_instances = field_info_instances('TripalEntity', $bundle->name);
-  
+
   // Iterate through all of the field instances and create them.
   // Iterate through all of the field instances and create them.
   foreach ($instance_info as $instance_name => $details) {
   foreach ($instance_info as $instance_name => $details) {
-    
+
     // Make sure the instance has a term. If not, report it and skip the field.
     // Make sure the instance has a term. If not, report it and skip the field.
     if (!array_key_exists('term_vocabulary', $details['settings'])) {
     if (!array_key_exists('term_vocabulary', $details['settings'])) {
       tripal_report_error('tripal_fields', TRIPAL_WARNING,
       tripal_report_error('tripal_fields', TRIPAL_WARNING,
@@ -785,13 +785,13 @@ function tripal_create_bundle_fields($bundle, $term) {
         'The field instance, !field, is missing the "term_accession" setting. The field instance cannot be added. Please check the field settings.',
         'The field instance, !field, is missing the "term_accession" setting. The field instance cannot be added. Please check the field settings.',
         ['!field' => $instance_name], ['drupal_set_message' => TRUE]);
         ['!field' => $instance_name], ['drupal_set_message' => TRUE]);
         continue;}
         continue;}
-    
-    // Make sure the term exists. If not, skip the field instance and 
+
+    // Make sure the term exists. If not, skip the field instance and
     // report an error.
     // report an error.
-    $field_term_id = $details['settings']['term_vocabulary'] . ':' . $details['settings']['term_accession'];    
+    $field_term_id = $details['settings']['term_vocabulary'] . ':' . $details['settings']['term_accession'];
     $field_term = tripal_get_term_details($details['settings']['term_vocabulary'], $details['settings']['term_accession']);
     $field_term = tripal_get_term_details($details['settings']['term_vocabulary'], $details['settings']['term_accession']);
     if (!$field_term) {
     if (!$field_term) {
-      tripal_report_error('tripal_fields', TRIPAL_WARNING, 
+      tripal_report_error('tripal_fields', TRIPAL_WARNING,
         'The term, !term, for the field, !field, does not exist in the database. The  ' .
         'The term, !term, for the field, !field, does not exist in the database. The  ' .
         'field instance cannot be added. Please make sure the term is correct and add it if necessary.',
         'field instance cannot be added. Please make sure the term is correct and add it if necessary.',
         ['!term' => $field_term_id,
         ['!term' => $field_term_id,
@@ -799,11 +799,11 @@ function tripal_create_bundle_fields($bundle, $term) {
         ['drupal_set_message' => TRUE]);
         ['drupal_set_message' => TRUE]);
       continue;
       continue;
     }
     }
-    
+
     // Make sure the term is not used for any other existing field instance.
     // Make sure the term is not used for any other existing field instance.
     $skip = FALSE;
     $skip = FALSE;
     foreach ($existing_instances as $existing_name => $existing_instance) {
     foreach ($existing_instances as $existing_name => $existing_instance) {
-      // If this instance term is the same as this exsiting term and the 
+      // If this instance term is the same as this exsiting term and the
       // instance name is not the same then we have a problem.
       // instance name is not the same then we have a problem.
       $existing_term_id = $existing_instance['settings']['term_vocabulary'] . ':' . $existing_instance['settings']['term_accession'];
       $existing_term_id = $existing_instance['settings']['term_vocabulary'] . ':' . $existing_instance['settings']['term_accession'];
       $existing_field = field_info_field($existing_name);
       $existing_field = field_info_field($existing_name);
@@ -816,7 +816,7 @@ function tripal_create_bundle_fields($bundle, $term) {
           ['drupal_set_message' => TRUE]);
           ['drupal_set_message' => TRUE]);
         $skip = TRUE;
         $skip = TRUE;
       }
       }
-      
+
       // If the instance term is the same as this exsting term but the storage
       // If the instance term is the same as this exsting term but the storage
       // types are different then we have a problem.
       // types are different then we have a problem.
       $existing_storage = $existing_field['storage']['type'];
       $existing_storage = $existing_field['storage']['type'];
@@ -967,6 +967,7 @@ function tripal_update_bundle_field($field_name, $field_info, $entity_type_name,
  * @ingroup tripal_entities_api
  * @ingroup tripal_entities_api
  */
  */
 function tripal_get_bundle_variable($variable_name, $bundle_id, $default = FALSE) {
 function tripal_get_bundle_variable($variable_name, $bundle_id, $default = FALSE) {
+
   $variable = tripal_get_variable($variable_name);
   $variable = tripal_get_variable($variable_name);
 
 
   // Warn if we can't find the tripal_variable.
   // Warn if we can't find the tripal_variable.
@@ -1005,7 +1006,7 @@ function tripal_get_bundle_variable($variable_name, $bundle_id, $default = FALSE
 function tripal_set_bundle_variable($variable_name, $bundle_id, $value) {
 function tripal_set_bundle_variable($variable_name, $bundle_id, $value) {
   $variable = tripal_get_variable($variable_name);
   $variable = tripal_get_variable($variable_name);
 
 
-  // And then we need to write the new format to the tripal_bundle_variables 
+  // And then we need to write the new format to the tripal_bundle_variables
   // table.
   // table.
   $record = array(
   $record = array(
     'bundle_id' => $bundle_id,
     'bundle_id' => $bundle_id,
@@ -1111,7 +1112,7 @@ function tripal_get_default_title_format($bundle) {
   if (!$format) {
   if (!$format) {
     $tmp = array();
     $tmp = array();
 
 
-    // Check which tokens are required fields and join them into a default 
+    // Check which tokens are required fields and join them into a default
     // format.
     // format.
     foreach($tokens as $token) {
     foreach($tokens as $token) {
       if ($token['required']) {
       if ($token['required']) {
@@ -1165,13 +1166,13 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
 
 
   $instances = field_info_instances('TripalEntity', $bundle->name);
   $instances = field_info_instances('TripalEntity', $bundle->name);
   foreach ($instances as $instance_name => $instance) {
   foreach ($instances as $instance_name => $instance) {
-    
+
     if (!$instance['required'] and $options['required only']) {
     if (!$instance['required'] and $options['required only']) {
       continue;
       continue;
     }
     }
-    
+
     $use_field = FALSE;
     $use_field = FALSE;
-   
+
     // Iterate through the TripalEntity fields and see if they have
     // Iterate through the TripalEntity fields and see if they have
     // sub-elements, if so, add those as tokens too.
     // sub-elements, if so, add those as tokens too.
     $field_name = $instance['field_name'];
     $field_name = $instance['field_name'];
@@ -1181,8 +1182,8 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
         $field_obj = new $field_name($field, $instance);
         $field_obj = new $field_name($field, $instance);
         $element_info = $field_obj->elementInfo();
         $element_info = $field_obj->elementInfo();
         $term_id = $instance['settings']['term_vocabulary'] . ':' . $instance['settings']['term_accession'];
         $term_id = $instance['settings']['term_vocabulary'] . ':' . $instance['settings']['term_accession'];
-        if ($element_info and 
-            array_key_exists($term_id, $element_info) and 
+        if ($element_info and
+            array_key_exists($term_id, $element_info) and
             array_key_exists('elements', $element_info[$term_id]) and count($element_info[$term_id]['elements']) > 0) {
             array_key_exists('elements', $element_info[$term_id]) and count($element_info[$term_id]['elements']) > 0) {
           $elements = $element_info[$term_id]['elements'];
           $elements = $element_info[$term_id]['elements'];
           _tripal_get_entity_tokens_for_elements($instance, $field_name, $elements, $tokens, $options);
           _tripal_get_entity_tokens_for_elements($instance, $field_name, $elements, $tokens, $options);
@@ -1198,7 +1199,7 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
     else {
     else {
       $use_field = TRUE;
       $use_field = TRUE;
     }
     }
-    
+
     // If we have no elements to add then just add the field as is.
     // If we have no elements to add then just add the field as is.
     if ($use_field) {
     if ($use_field) {
       // Build the token from the field information.
       // Build the token from the field information.
@@ -1218,11 +1219,11 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
 
 
 /**
 /**
  * A recursive helper function to get tokens for element sub fields.
  * A recursive helper function to get tokens for element sub fields.
- * 
+ *
  * @param $instance
  * @param $instance
  *   A original field instance object.
  *   A original field instance object.
  * @param $parent
  * @param $parent
- *   The name of the parent. The first time this is called outside of 
+ *   The name of the parent. The first time this is called outside of
  *   recursion this should be the field name.
  *   recursion this should be the field name.
  * @param $elements
  * @param $elements
  *   The array of elements to process.
  *   The array of elements to process.
@@ -1230,21 +1231,21 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
  *   The array of tokens to be added to.
  *   The array of tokens to be added to.
  */
  */
 function _tripal_get_entity_tokens_for_elements($instance, $parent, $elements, &$tokens, $options) {
 function _tripal_get_entity_tokens_for_elements($instance, $parent, $elements, &$tokens, $options) {
-  
+
   // Iterate through all of the elements and add tokens for each one.
   // Iterate through all of the elements and add tokens for each one.
   foreach ($elements as $child_term_id => $details) {
   foreach ($elements as $child_term_id => $details) {
-    
+
     // We don't need to add the entity element.
     // We don't need to add the entity element.
     if ($child_term_id == 'entity') {
     if ($child_term_id == 'entity') {
       continue;
       continue;
     }
     }
-    
+
     // Skip elements that aren't required.
     // Skip elements that aren't required.
     $required = array_key_exists('required', $details) ? $details['required'] : FALSE;
     $required = array_key_exists('required', $details) ? $details['required'] : FALSE;
     if (!$required and $options['required only']) {
     if (!$required and $options['required only']) {
       continue;
       continue;
     }
     }
-    $token = '[' . $parent . ',' . $child_term_id . ']'; 
+    $token = '[' . $parent . ',' . $child_term_id . ']';
     $label = $child_term_id;
     $label = $child_term_id;
     if (array_key_exists('name', $details)) {
     if (array_key_exists('name', $details)) {
       $label = $details['name'];
       $label = $details['name'];
@@ -1263,10 +1264,10 @@ function _tripal_get_entity_tokens_for_elements($instance, $parent, $elements, &
       'field_name' => $instance['field_name'],
       'field_name' => $instance['field_name'],
       'required' => $required
       'required' => $required
     ];
     ];
-    
+
     // Recurse to include sub elements
     // Recurse to include sub elements
     if (array_key_exists('elements', $details)) {
     if (array_key_exists('elements', $details)) {
-      _tripal_get_entity_tokens_for_elements($instance, $parent . ',' . $child_term_id, 
+      _tripal_get_entity_tokens_for_elements($instance, $parent . ',' . $child_term_id,
         $details['elements'], $tokens, $options);
         $details['elements'], $tokens, $options);
     }
     }
   }
   }
@@ -1281,7 +1282,7 @@ function _tripal_get_entity_tokens_for_elements($instance, $parent, $elements, &
  * @param TripalEntity $entity
  * @param TripalEntity $entity
  *   The entity with field values used to find values of tokens.
  *   The entity with field values used to find values of tokens.
  * @param TripalBundle $bundle_entity
  * @param TripalBundle $bundle_entity
- *   The bundle enitity containing special values sometimes needed for token 
+ *   The bundle enitity containing special values sometimes needed for token
  *   replacement.
  *   replacement.
  *
  *
  * @return
  * @return
@@ -1335,20 +1336,20 @@ function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL)
     module_invoke($storage['module'], 'field_storage_load', 'TripalEntity',
     module_invoke($storage['module'], 'field_storage_load', 'TripalEntity',
         $entities, FIELD_LOAD_CURRENT, $field_ids, array());
         $entities, FIELD_LOAD_CURRENT, $field_ids, array());
   }
   }
-  
+
   // Now that all necessary fields are attached process the tokens.
   // Now that all necessary fields are attached process the tokens.
   foreach($used_tokens as $token) {
   foreach($used_tokens as $token) {
     $token = preg_replace('/[\[\]]/', '', $token);
     $token = preg_replace('/[\[\]]/', '', $token);
     $elements = explode(',', $token);
     $elements = explode(',', $token);
     $field_name = array_shift($elements);
     $field_name = array_shift($elements);
     $value = '';
     $value = '';
-    
+
     if (property_exists($entity, $field_name)) {
     if (property_exists($entity, $field_name)) {
       $value = '';
       $value = '';
       // Note: there is a memory leak in field_get_items() so we can't use it
       // Note: there is a memory leak in field_get_items() so we can't use it
       // here or bulk publishing will slowly erode memory.
       // here or bulk publishing will slowly erode memory.
       // $field_value = field_get_items('TripalEntity', $entity, $field_name);
       // $field_value = field_get_items('TripalEntity', $entity, $field_name);
-      if (array_key_exists('und', $entity->{$field_name}) and 
+      if (array_key_exists('und', $entity->{$field_name}) and
           array_key_exists(0, $entity->{$field_name}['und'])) {
           array_key_exists(0, $entity->{$field_name}['und'])) {
         $value = $entity->{$field_name}['und'][0]['value'];
         $value = $entity->{$field_name}['und'][0]['value'];
         // If the value is an array it means we have sub elements and we can
         // If the value is an array it means we have sub elements and we can
@@ -1356,7 +1357,7 @@ function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL)
         if (is_array($value) and count($elements) > 0) {
         if (is_array($value) and count($elements) > 0) {
           $value = _tripal_replace_entity_tokens_for_elements($elements, $value);
           $value = _tripal_replace_entity_tokens_for_elements($elements, $value);
         }
         }
-      }    
+      }
     }
     }
     // The TripalBundle__bundle_id is a special token for substituting the
     // The TripalBundle__bundle_id is a special token for substituting the
     // bundle id.
     // bundle id.
@@ -1389,7 +1390,7 @@ function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL)
 
 
 /**
 /**
  * A helper function for tripal_replace_entity_tokens to get token values.
  * A helper function for tripal_replace_entity_tokens to get token values.
- * 
+ *
  * This helper function is used when the tokens are from subelements.
  * This helper function is used when the tokens are from subelements.
  * @param $entity
  * @param $entity
  */
  */
@@ -1578,15 +1579,15 @@ function _tripal_get_bundle_field_element_details($elements, &$field_details) {
 
 
 /**
 /**
  * Is this completed? It doesn't look right and I can't find it used anywhere
  * Is this completed? It doesn't look right and I can't find it used anywhere
- * in the existing code. 
- * 
+ * in the existing code.
+ *
  * @param $bundle_name
  * @param $bundle_name
  *   The name of the bundle (e.g. bio_data_xx)
  *   The name of the bundle (e.g. bio_data_xx)
  * @param unknown $values
  * @param unknown $values
  *
  *
  * @throws Exception
  * @throws Exception
  *
  *
- * 
+ *
  */
  */
 function tripal_insert_entity($bundle_name, $values){
 function tripal_insert_entity($bundle_name, $values){
   global $user;
   global $user;
@@ -1637,12 +1638,12 @@ function tripal_insert_entity($bundle_name, $values){
 }
 }
 
 
 /**
 /**
- * Are we keeping this? 
- * 
+ * Are we keeping this?
+ *
  * @param $bundle_name
  * @param $bundle_name
  * @param $values
  * @param $values
  *
  *
- * 
+ *
  */
  */
 function tripal_update_entity($bundle_name, $values) {
 function tripal_update_entity($bundle_name, $values) {
 
 

+ 74 - 63
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -370,7 +370,7 @@ function tripal_update_cvtermpath_old($cv_id, $job_id = NULL) {
 }
 }
 
 
 /**
 /**
- * 
+ *
  * @param unknown $cv_id
  * @param unknown $cv_id
  */
  */
 function chado_clear_cvtermpath($cv_id) {
 function chado_clear_cvtermpath($cv_id) {
@@ -382,7 +382,7 @@ function chado_clear_cvtermpath($cv_id) {
  * Replacement for the fill_cvtermpath() stored procedure in Chado.
  * Replacement for the fill_cvtermpath() stored procedure in Chado.
  *
  *
  * Fills the cvtermpath table of Chado with relationships between every
  * Fills the cvtermpath table of Chado with relationships between every
- * node in the ontology graph and all of it's descendents.  This was 
+ * node in the ontology graph and all of it's descendents.  This was
  * previously performed using the fill_cvtermpath() stored procedure of Chado
  * previously performed using the fill_cvtermpath() stored procedure of Chado
  * but that function cannot handle loops in the ontology graphs and results
  * but that function cannot handle loops in the ontology graphs and results
  * in stack depth errors in PostgreSQL.
  * in stack depth errors in PostgreSQL.
@@ -395,37 +395,37 @@ function chado_clear_cvtermpath($cv_id) {
  * @ingroup tripal_chado_cv_api
  * @ingroup tripal_chado_cv_api
  */
  */
 function chado_update_cvtermpath($cv_id, $job = NULL) {
 function chado_update_cvtermpath($cv_id, $job = NULL) {
-  
+
   $cv = new ChadoRecord('cv', $cv_id);
   $cv = new ChadoRecord('cv', $cv_id);
-  print "Building cvterm paths for vocabulary: " . $cv->getValue('name') ."\n"; 
+  print "Building cvterm paths for vocabulary: " . $cv->getValue('name') ."\n";
   print "Clearing the cvtermpath table for this vocabulary...\n";
   print "Clearing the cvtermpath table for this vocabulary...\n";
-  chado_clear_cvtermpath($cv_id);  
+  chado_clear_cvtermpath($cv_id);
   print "Clearing completed.\n";
   print "Clearing completed.\n";
-  
+
   // The cache is used to limit repetitive queries by storing known data.
   // The cache is used to limit repetitive queries by storing known data.
   $cache = [
   $cache = [
     // Stores all relationships in the cvtermpath table.
     // Stores all relationships in the cvtermpath table.
     'rels' => [],
     'rels' => [],
     // Stores all nodes that were visited when processing all nodes as roots.
     // Stores all nodes that were visited when processing all nodes as roots.
     'roots_processed' => [],
     'roots_processed' => [],
-    // Stores all nodes that were visited when prociessing all children of 
+    // Stores all nodes that were visited when prociessing all children of
     // a single root. It gets emptied at each root.
     // a single root. It gets emptied at each root.
     'nodes_processed' => [],
     'nodes_processed' => [],
     // For easy lookup stores the is_a relationship.
     // For easy lookup stores the is_a relationship.
     'is_a' => NULL,
     'is_a' => NULL,
   ];
   ];
-  
+
   // TODO: there's a function to determine the current Chado instance.
   // TODO: there's a function to determine the current Chado instance.
   // we should use that.
   // we should use that.
   $transaction = db_transaction();
   $transaction = db_transaction();
-  
+
   try {
   try {
-    
-    // Get the is_a term. The OBO importer adds this for evey vocabulary.
-    $sql = "SELECT * FROM {cvterm} WHERE name = :is_a and cv_id = :cv_id";
-    $args = [':is_a' => 'is_a', ':cv_id' => $cv_id];
-    $cache['$is_a'] = chado_query($sql, $args)->fetchObject();
-    
+
+    // Get the is_a term. The OBO importer adds this for every vocabulary.
+    $sql = "SELECT * FROM {cvterm} WHERE (name = :is_a or name = :is_a_alt) and cv_id = :cv_id";
+    $args = [':is_a' => 'is_a', ':is_a_alt' => 'is a', ':cv_id' => $cv_id];
+    $cache['is_a'] = chado_query($sql, $args)->fetchObject();
+
     // First cache all the relationships for this vocaublary so that we
     // First cache all the relationships for this vocaublary so that we
     // don't have to do repetitive queries to Chado.
     // don't have to do repetitive queries to Chado.
     print "Retrieving relationships...\n";
     print "Retrieving relationships...\n";
@@ -434,7 +434,7 @@ function chado_update_cvtermpath($cv_id, $job = NULL) {
       FROM {cvterm_relationship} CVTR
       FROM {cvterm_relationship} CVTR
         INNER JOIN {cvterm} CVTO on CVTO.cvterm_id = CVTR.object_id
         INNER JOIN {cvterm} CVTO on CVTO.cvterm_id = CVTR.object_id
         INNER JOIN {cvterm} CVTS on CVTS.cvterm_id = CVTR.subject_id
         INNER JOIN {cvterm} CVTS on CVTS.cvterm_id = CVTR.subject_id
-      WHERE CVTO.cv_id = :cv_id 
+      WHERE CVTO.cv_id = :cv_id
       ORDER BY CVTO.name, CVTS.name
       ORDER BY CVTO.name, CVTS.name
     ";
     ";
     $rels = chado_query($sql, [':cv_id' => $cv_id]);
     $rels = chado_query($sql, [':cv_id' => $cv_id]);
@@ -446,12 +446,12 @@ function chado_update_cvtermpath($cv_id, $job = NULL) {
     if ($job) {
     if ($job) {
       $job->logMessage('Found !total relationships in this vocabulary.', ['!total' => $total_items]);
       $job->logMessage('Found !total relationships in this vocabulary.', ['!total' => $total_items]);
       $job->setTotalItems($total_items);
       $job->setTotalItems($total_items);
-      $job->logMessage('Note: Progress updates occur as each term is processed and ' . 
+      $job->logMessage('Note: Progress updates occur as each term is processed and ' .
         'some terms take longer than others.');
         'some terms take longer than others.');
       $job->setProgress(0);
       $job->setProgress(0);
       $job->setInterval(1);
       $job->setInterval(1);
     }
     }
-    
+
     // Next get the tree roots. These are terms that are in relationships as
     // Next get the tree roots. These are terms that are in relationships as
     // an object but never as a subject.
     // an object but never as a subject.
     $sql = "
     $sql = "
@@ -459,44 +459,44 @@ function chado_update_cvtermpath($cv_id, $job = NULL) {
       FROM {cvterm} CVT
       FROM {cvterm} CVT
         LEFT JOIN {cvterm_relationship} CVTR ON CVT.cvterm_id = CVTR.subject_id
         LEFT JOIN {cvterm_relationship} CVTR ON CVT.cvterm_id = CVTR.subject_id
         INNER JOIN {cvterm_relationship} CVTR2 ON CVT.cvterm_id = CVTR2.object_id
         INNER JOIN {cvterm_relationship} CVTR2 ON CVT.cvterm_id = CVTR2.object_id
-      WHERE CVT.cv_id = :cvid AND CVTR.subject_id is NULL and 
+      WHERE CVT.cv_id = :cvid AND CVTR.subject_id is NULL and
         CVT.is_relationshiptype = 0 and CVT.is_obsolete = 0
         CVT.is_relationshiptype = 0 and CVT.is_obsolete = 0
     ";
     ";
     $roots = chado_query($sql, [':cvid' => $cv_id]);
     $roots = chado_query($sql, [':cvid' => $cv_id]);
-     
+
     // Iterate through the tree roots.
     // Iterate through the tree roots.
-    print "Processing terms...\n";    
+    print "Processing terms...\n";
     while ($root = $roots->fetchObject()) {
     while ($root = $roots->fetchObject()) {
       $root_id =  $root->cvterm_id;
       $root_id =  $root->cvterm_id;
       $root_name = $root->name;
       $root_name = $root->name;
-      
+
       if ($job) {
       if ($job) {
         $job->logMessage('Processing tree root: ' . $root_name . '...');
         $job->logMessage('Processing tree root: ' . $root_name . '...');
       }
       }
-      
+
       // Now start descending through the tree and add the relationships
       // Now start descending through the tree and add the relationships
       // to the cvtermpath table.
       // to the cvtermpath table.
       $num_handled = 0;
       $num_handled = 0;
       $depth = 0;
       $depth = 0;
-      _chado_update_cvtermpath_root($cv_id, $root_id, $root_name, $cache, $job, 
+      _chado_update_cvtermpath_root($cv_id, $root_id, $root_name, $cache, $job,
         $num_handled, $depth);
         $num_handled, $depth);
     }
     }
   }
   }
   catch (Exception $e) {
   catch (Exception $e) {
-    $transaction->rollback();    
+    $transaction->rollback();
     throw $e;
     throw $e;
   }
   }
 }
 }
 
 
 /**
 /**
- * Treats a term within the ontology as a root. 
- * 
+ * Treats a term within the ontology as a root.
+ *
  * In order to add all relationships between a term and it's descendents each
  * In order to add all relationships between a term and it's descendents each
  * term gets it's turn as a "root".  The first time this function is called
  * term gets it's turn as a "root".  The first time this function is called
  * it should be called with the actual root's of the ontology.  This function
  * it should be called with the actual root's of the ontology.  This function
  * will then recursively treat each child term within the tree as a root in
  * will then recursively treat each child term within the tree as a root in
  * order to find all relationships.
  * order to find all relationships.
- * 
+ *
  * @param $cv_id
  * @param $cv_id
  *   The vocaulary Id
  *   The vocaulary Id
  * @param $root_id
  * @param $root_id
@@ -513,68 +513,74 @@ function chado_update_cvtermpath($cv_id, $job = NULL) {
  * @param $root_depth
  * @param $root_depth
  *   The current depth in the tree of this term.
  *   The current depth in the tree of this term.
  */
  */
-function _chado_update_cvtermpath_root($cv_id, $root_id, $root_name, &$cache, 
+function _chado_update_cvtermpath_root($cv_id, $root_id, $root_name, &$cache,
   $job, &$num_handled, $root_depth = 0) {
   $job, &$num_handled, $root_depth = 0) {
-    
-    
+
+
   // Don't use a node as a root if we've already used it once before.
   // Don't use a node as a root if we've already used it once before.
   if (in_array($root_id, $cache['roots_processed'])) {
   if (in_array($root_id, $cache['roots_processed'])) {
     return;
     return;
   }
   }
-    
+
   // Mark this node as having been processed as a root node.
   // Mark this node as having been processed as a root node.
   $cache['roots_processed'][] = $root_id;
   $cache['roots_processed'][] = $root_id;
-  
-  // For the actual tree roots we need to add a relatioship to themselves.
+
+  // For the actual tree roots we need to add a relationship to themselves.
   if ($root_depth == 0) {
   if ($root_depth == 0) {
-    $is_a = $cache['$is_a'];
+    $is_a = $cache['is_a'];
     $type_id = $is_a->cvterm_id;
     $type_id = $is_a->cvterm_id;
     $depth = 1;
     $depth = 1;
     _chado_update_cvtermpath_add_relationship($type_id, $root_id, $root_id, $cv_id, $depth);
     _chado_update_cvtermpath_add_relationship($type_id, $root_id, $root_id, $cv_id, $depth);
   }
   }
-  
+
+  // If there are no children do nothing.
+  if (!array_key_exists($root_id, $cache['rels'])) {
+    return;
+  }
+
   // Get this term's children and recurse.
   // Get this term's children and recurse.
   $children = $cache['rels'][$root_id];
   $children = $cache['rels'][$root_id];
-  
+
   // If there are no children do nothing.
   // If there are no children do nothing.
   if (!$children) {
   if (!$children) {
     return;
     return;
   }
   }
-    
+
   // Set the job progress.
   // Set the job progress.
   if ($job) {
   if ($job) {
     $job->setItemsHandled($num_handled);
     $job->setItemsHandled($num_handled);
   }
   }
   $num_handled++;
   $num_handled++;
-  
+
   // The $path variable contains only the current path on the descent. This
   // The $path variable contains only the current path on the descent. This
   // is used for detecting loops in the graph. If we encounter a node a
   // is used for detecting loops in the graph. If we encounter a node a
   // second time while traversing a single path of the tree then we've hit
   // second time while traversing a single path of the tree then we've hit
   // a loop.
   // a loop.
   $path = [];
   $path = [];
- 
-  // Process the children of this term.  
+
+  // Process the children of this term.
   $cache['nodes_processed'] = [];
   $cache['nodes_processed'] = [];
+  $next_depth = 0;
   _chado_update_cvtermpath_process_children($cv_id, $root_id, $root_id, $path, $cache, $next_depth);
   _chado_update_cvtermpath_process_children($cv_id, $root_id, $root_id, $path, $cache, $next_depth);
-  
+
   // Next make each child of this node a root and recurse again.
   // Next make each child of this node a root and recurse again.
   foreach ($children as $child) {
   foreach ($children as $child) {
     $child_id = $child[0];
     $child_id = $child[0];
     $child_type_id = $child[1];
     $child_type_id = $child[1];
     $child_name = $child[2];
     $child_name = $child[2];
 
 
-    // Process this child as a root. 
+    // Process this child as a root.
     $next_depth = $root_depth + 1;
     $next_depth = $root_depth + 1;
-    _chado_update_cvtermpath_root($cv_id, $child_id, $child_name, $cache, 
+    _chado_update_cvtermpath_root($cv_id, $child_id, $child_name, $cache,
       $job, $num_handled, $next_depth);
       $job, $num_handled, $next_depth);
   }
   }
-}  
+}
 /**
 /**
  * Handles a single node in the tree.
  * Handles a single node in the tree.
- * 
+ *
  * This is a recursive function which calls itself as the tree is descended. It
  * This is a recursive function which calls itself as the tree is descended. It
  * performs a depth-first search of the tree.
  * performs a depth-first search of the tree.
- * 
+ *
  * @param $cv_id
  * @param $cv_id
  *   The vocaulary Id
  *   The vocaulary Id
  * @param $root_id
  * @param $root_id
@@ -587,65 +593,70 @@ function _chado_update_cvtermpath_root($cv_id, $root_id, $root_name, &$cache,
  * @param $cache
  * @param $cache
  *   The cache used for lookups.
  *   The cache used for lookups.
  * @param $depth
  * @param $depth
- *   The current depth in the tree. 
+ *   The current depth in the tree.
  */
  */
-function _chado_update_cvtermpath_process_children($cv_id, $root_id, $cvterm_id, 
+function _chado_update_cvtermpath_process_children($cv_id, $root_id, $cvterm_id,
   $path, &$cache, $depth = 1) {
   $path, &$cache, $depth = 1) {
-  
+
   $cache['nodes_processed'][$cvterm_id] = TRUE;
   $cache['nodes_processed'][$cvterm_id] = TRUE;
-      
+
   // Have we visited this node before while on this path then we won't
   // Have we visited this node before while on this path then we won't
   // descend further as this means we've hit a loop.
   // descend further as this means we've hit a loop.
   if (in_array($cvterm_id, $path)) {
   if (in_array($cvterm_id, $path)) {
     return;
     return;
   }
   }
-  
+
   // Add this term to the path.
   // Add this term to the path.
   $path[] = $cvterm_id;
   $path[] = $cvterm_id;
   //print implode('-', $path) . "\n";
   //print implode('-', $path) . "\n";
-  
+
+  // If this term does not have children then return.
+  if (!array_key_exists($cvterm_id, $cache['rels'])) {
+    return;
+  }
+
   // Get this term's children and recurse.
   // Get this term's children and recurse.
   $children = $cache['rels'][$cvterm_id];
   $children = $cache['rels'][$cvterm_id];
-  
+
   // If this term does not have children then return.
   // If this term does not have children then return.
   if (!$children) {
   if (!$children) {
     return;
     return;
   }
   }
-  
+
   // If the term has children then recurse on those.
   // If the term has children then recurse on those.
   $next_depth = $depth + 1;
   $next_depth = $depth + 1;
   foreach ($children as $child) {
   foreach ($children as $child) {
     $child_id = $child[0];
     $child_id = $child[0];
     $child_type_id = $child[1];
     $child_type_id = $child[1];
-         
+
     // Don't descend for children we've already seen.
     // Don't descend for children we've already seen.
     if (array_key_exists($child_id, $cache['nodes_processed'])) {
     if (array_key_exists($child_id, $cache['nodes_processed'])) {
       continue;
       continue;
     }
     }
-    
+
     _chado_update_cvtermpath_add_relationship($child_type_id, $child_id, $root_id,
     _chado_update_cvtermpath_add_relationship($child_type_id, $child_id, $root_id,
       $cv_id, $next_depth);
       $cv_id, $next_depth);
-    
+
     _chado_update_cvtermpath_process_children($cv_id, $root_id, $child_id, $path, $cache, $next_depth);
     _chado_update_cvtermpath_process_children($cv_id, $root_id, $child_id, $path, $cache, $next_depth);
   }
   }
 }
 }
 
 
 /**
 /**
  * Inserts values into the cvtermpath table.
  * Inserts values into the cvtermpath table.
- * 
+ *
  * After the entire tree below the current root term is traversed, this
  * After the entire tree below the current root term is traversed, this
  * function is called and inserts all of the relationships that were found
  * function is called and inserts all of the relationships that were found
- * into the cvtermpath table. 
- * 
+ * into the cvtermpath table.
+ *
  * @param $visited
  * @param $visited
  *   The array contaiing relationships for all visited nodes in the tree. These
  *   The array contaiing relationships for all visited nodes in the tree. These
  *   elements will become the entries in the cvtermpath table.
  *   elements will become the entries in the cvtermpath table.
  * @param $job
  * @param $job
  *   The TripalJob instance.
  *   The TripalJob instance.
  */
  */
-function _chado_update_cvtermpath_add_relationship($type_id, $cvterm_id, 
+function _chado_update_cvtermpath_add_relationship($type_id, $cvterm_id,
   $root_id, $cv_id, $depth) {
   $root_id, $cv_id, $depth) {
-  
+
   $cvtermpath = new ChadoRecord('cvtermpath');
   $cvtermpath = new ChadoRecord('cvtermpath');
   $cvtermpath->setValues([
   $cvtermpath->setValues([
     'type_id' =>  $type_id,
     'type_id' =>  $type_id,

File diff suppressed because it is too large
+ 169 - 169
tripal_chado/includes/TripalImporter/OBOImporter.inc


+ 95 - 95
tripal_chado/includes/setup/tripal_chado.setup.inc

@@ -71,8 +71,8 @@ function tripal_chado_prepare_drush_submit() {
  *
  *
  */
  */
 function tripal_chado_load_ontologies() {
 function tripal_chado_load_ontologies() {
-  
-  // Before we can load ontologies we need a few terms that unfortunately 
+
+  // Before we can load ontologies we need a few terms that unfortunately
   // don't get added until later. We'll add them now so the loader works.
   // don't get added until later. We'll add them now so the loader works.
   chado_insert_db([
   chado_insert_db([
     'name' => 'NCIT',
     'name' => 'NCIT',
@@ -84,15 +84,15 @@ function tripal_chado_load_ontologies() {
     'ncit',
     'ncit',
     'The NCIt OBO Edition project aims to increase integration of the NCIt with OBO Library ontologies. NCIt is a reference terminology that includes broad coverage of the cancer domain, including cancer related diseases, findings and abnormalities. NCIt OBO Edition releases should be considered experimental.'
     'The NCIt OBO Edition project aims to increase integration of the NCIt with OBO Library ontologies. NCIt is a reference terminology that includes broad coverage of the cancer domain, including cancer related diseases, findings and abnormalities. NCIt OBO Edition releases should be considered experimental.'
     );
     );
-  
+
   $term = chado_insert_cvterm([
   $term = chado_insert_cvterm([
     'id' => 'NCIT:C25693',
     'id' => 'NCIT:C25693',
     'name' => 'Subgroup',
     'name' => 'Subgroup',
     'cv_name' => 'ncit',
     'cv_name' => 'ncit',
     'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
     'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
   ]);
   ]);
-  
-  
+
+
   // Add the rdfs:comment vocabulary.
   // Add the rdfs:comment vocabulary.
   chado_insert_db(array(
   chado_insert_db(array(
     'name' => 'rdfs',
     'name' => 'rdfs',
@@ -263,7 +263,7 @@ function tripal_chado_prepare_chado($job = NULL) {
     drush_print('Populating materialized view db2cv_mview...');
     drush_print('Populating materialized view db2cv_mview...');
     $mview_id = chado_get_mview_id('db2cv_mview');
     $mview_id = chado_get_mview_id('db2cv_mview');
     chado_populate_mview($mview_id);
     chado_populate_mview($mview_id);
-    
+
     drush_print("Creating common Tripal Content Types...");
     drush_print("Creating common Tripal Content Types...");
     drush_print("This may take awhile if you are upgrading a site that has lots of data...");
     drush_print("This may take awhile if you are upgrading a site that has lots of data...");
     if ($report_progress) {
     if ($report_progress) {
@@ -280,16 +280,16 @@ function tripal_chado_prepare_chado($job = NULL) {
 
 
     // Set a variable to indicate the site is prepared.
     // Set a variable to indicate the site is prepared.
     variable_set('tripal_chado_is_prepared', TRUE);
     variable_set('tripal_chado_is_prepared', TRUE);
-    
+
     if ($report_progress) {
     if ($report_progress) {
       $job->setProgress(100);
       $job->setProgress(100);
-    }  
+    }
   }
   }
   catch (Exception $e) {
   catch (Exception $e) {
     $job->logMessage($e);
     $job->logMessage($e);
     throw new Exception($e);
     throw new Exception($e);
   }
   }
-  
+
   // Clear the Drupal menu cache so that the new content types have "add" links.
   // Clear the Drupal menu cache so that the new content types have "add" links.
   menu_cache_clear_all();
   menu_cache_clear_all();
 }
 }
@@ -298,10 +298,10 @@ function tripal_chado_prepare_chado($job = NULL) {
  * Creates the "General" category of content types.
  * Creates the "General" category of content types.
  */
  */
 function tripal_chado_prepare_general_types($job) {
 function tripal_chado_prepare_general_types($job) {
-  
+
   //
   //
   // Create the 'Organism' entity type. This uses the obi:organism term.
   // Create the 'Organism' entity type. This uses the obi:organism term.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'OBI',
     'vocabulary' => 'OBI',
     'accession' => '0100026',
     'accession' => '0100026',
@@ -311,11 +311,11 @@ function tripal_chado_prepare_general_types($job) {
     ),
     ),
     'category' => 'General'
     'category' => 'General'
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Analysis' entity type. This uses the local:analysis term.
   // Create the 'Analysis' entity type. This uses the local:analysis term.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'operation',
     'vocabulary' => 'operation',
     'accession' => '2945',
     'accession' => '2945',
@@ -325,11 +325,11 @@ function tripal_chado_prepare_general_types($job) {
     ),
     ),
     'category' => 'General'
     'category' => 'General'
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 
 
   //
   //
   // Create the 'Project' entity type. This uses the local:project term.
   // Create the 'Project' entity type. This uses the local:project term.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'NCIT',
     'vocabulary' => 'NCIT',
     'accession' => 'C47885',
     'accession' => 'C47885',
@@ -339,12 +339,12 @@ function tripal_chado_prepare_general_types($job) {
     ),
     ),
     'category' => 'General'
     'category' => 'General'
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
+
 
 
-  
   //
   //
   // Create the 'Study' entity type. This uses the local:project term.
   // Create the 'Study' entity type. This uses the local:project term.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'SIO',
     'vocabulary' => 'SIO',
     'accession' => '001066',
     'accession' => '001066',
@@ -354,11 +354,11 @@ function tripal_chado_prepare_general_types($job) {
     ),
     ),
     'category' => 'General'
     'category' => 'General'
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Contact' entity type. This uses the local:contact term.
   // Create the 'Contact' entity type. This uses the local:contact term.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'local',
     'vocabulary' => 'local',
     'accession' => 'contact',
     'accession' => 'contact',
@@ -368,11 +368,11 @@ function tripal_chado_prepare_general_types($job) {
     ),
     ),
     'category' => 'General'
     'category' => 'General'
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 
 
   //
   //
   // Create the 'Publication' entity type.
   // Create the 'Publication' entity type.
-  //      
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'TPUB',
     'vocabulary' => 'TPUB',
     'accession' => '0000002',
     'accession' => '0000002',
@@ -387,9 +387,9 @@ function tripal_chado_prepare_general_types($job) {
     // Import a publication so we get all of the properties before
     // Import a publication so we get all of the properties before
     // creating the content type.
     // creating the content type.
     chado_import_pub_by_dbxref('PMID:24163125');
     chado_import_pub_by_dbxref('PMID:24163125');
-    
-    _tripal_chado_preapre_create_bundle($args, $job);
-    
+
+    _tripal_chado_prepare_create_bundle($args, $job);
+
     // Now remove the publication that was added above.
     // Now remove the publication that was added above.
     $values = array(
     $values = array(
       'dbxref_id' => array(
       'dbxref_id' => array(
@@ -402,10 +402,10 @@ function tripal_chado_prepare_general_types($job) {
     $result = chado_select_record('pub_dbxref', array('pub_id'), $values);
     $result = chado_select_record('pub_dbxref', array('pub_id'), $values);
     chado_delete_record('pub', array('pub_id' => $result[0]->pub_id));
     chado_delete_record('pub', array('pub_id' => $result[0]->pub_id));
   }
   }
-  
+
   //
   //
   // Create the 'Protocol' entity type.
   // Create the 'Protocol' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'sep',
     'vocabulary' => 'sep',
     'accession' => '00101',
     'accession' => '00101',
@@ -415,7 +415,7 @@ function tripal_chado_prepare_general_types($job) {
     ),
     ),
     'category' => 'General'
     'category' => 'General'
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 }
 }
 
 
 /**
 /**
@@ -424,7 +424,7 @@ function tripal_chado_prepare_general_types($job) {
 function tripal_chado_prepare_genomic_types($job) {
 function tripal_chado_prepare_genomic_types($job) {
   //
   //
   // Create the 'Gene' entity type.
   // Create the 'Gene' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'SO',
     'vocabulary' => 'SO',
     'accession' => '0000704',
     'accession' => '0000704',
@@ -435,11 +435,11 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     ),
     'category' => 'Genomic',
     'category' => 'Genomic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'mRNA' entity type.
   // Create the 'mRNA' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'SO',
     'vocabulary' => 'SO',
     'accession' => '0000234',
     'accession' => '0000234',
@@ -450,11 +450,11 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     ),
     'category' => 'Genomic',
     'category' => 'Genomic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Phylogenetic tree' entity type.
   // Create the 'Phylogenetic tree' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'data',
     'vocabulary' => 'data',
     'accession' => '0872',
     'accession' => '0872',
@@ -464,9 +464,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     ),
     'category' => 'Genomic',
     'category' => 'Genomic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
-  // Create the 'Physical Map' entity type.  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
+  // Create the 'Physical Map' entity type.
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $args = array(
   $args = array(
     'vocabulary' => 'data',
     'vocabulary' => 'data',
@@ -481,9 +481,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     ),
     'category' => 'Genomic',
     'category' => 'Genomic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
-  // Create the 'DNA Library' entity type.  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
+  // Create the 'DNA Library' entity type.
   $args = array(
   $args = array(
     'vocabulary' => 'NCIT',
     'vocabulary' => 'NCIT',
     'accession' => 'C16223',
     'accession' => 'C16223',
@@ -494,9 +494,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     ),
     'category' => 'Genomic',
     'category' => 'Genomic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
-  // Create the 'Genome Assembly' entity type.  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
+  // Create the 'Genome Assembly' entity type.
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $args = array(
   $args = array(
     'vocabulary' => 'operation',
     'vocabulary' => 'operation',
@@ -511,9 +511,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     ),
     'category' => 'Genomic',
     'category' => 'Genomic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
-  // Create the 'Genome Annotation' entity type.  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
+  // Create the 'Genome Annotation' entity type.
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $args = array(
   $args = array(
     'vocabulary' => 'operation',
     'vocabulary' => 'operation',
@@ -528,9 +528,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     ),
     'category' => 'Genomic',
     'category' => 'Genomic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
-  // Create the 'Genome Annotation' entity type.  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
+  // Create the 'Genome Annotation' entity type.
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $args = array(
   $args = array(
     'vocabulary' => 'local',
     'vocabulary' => 'local',
@@ -546,7 +546,7 @@ function tripal_chado_prepare_genomic_types($job) {
     'category' => 'Genomic',
     'category' => 'Genomic',
   );
   );
   $bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
   $bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 }
 }
 
 
 /**
 /**
@@ -555,7 +555,7 @@ function tripal_chado_prepare_genomic_types($job) {
 function tripal_chado_prepare_expression_types($job) {
 function tripal_chado_prepare_expression_types($job) {
   //
   //
   // Create the 'biological sample' entity type.
   // Create the 'biological sample' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'sep',
     'vocabulary' => 'sep',
     'accession' => '00195',
     'accession' => '00195',
@@ -566,11 +566,11 @@ function tripal_chado_prepare_expression_types($job) {
     'Expression',
     'Expression',
   );
   );
   $bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
   $bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Assay' entity type.
   // Create the 'Assay' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'OBI',
     'vocabulary' => 'OBI',
     'accession' => '0000070',
     'accession' => '0000070',
@@ -581,11 +581,11 @@ function tripal_chado_prepare_expression_types($job) {
     'Expression',
     'Expression',
   );
   );
   $bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
   $bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Array Design' entity type.
   // Create the 'Array Design' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'EFO',
     'vocabulary' => 'EFO',
     'accession' => '0000269',
     'accession' => '0000269',
@@ -595,19 +595,19 @@ function tripal_chado_prepare_expression_types($job) {
     ),
     ),
     'Expression',
     'Expression',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 }
 }
 
 
 /**
 /**
  * Creates the "Germplasm/Breeding" category of content types.
  * Creates the "Germplasm/Breeding" category of content types.
  */
  */
 function tripal_chado_prepare_germplasm_types($job) {
 function tripal_chado_prepare_germplasm_types($job) {
-  
+
   //
   //
   // Create the 'Phenotypic Trait' entity type.
   // Create the 'Phenotypic Trait' entity type.
-  // 
+  //
   /**
   /**
-   * SPF:  We need a bit more testing before we add this conteont type as 
+   * SPF:  We need a bit more testing before we add this conteont type as
    * it resolves to the cvterm table. Currently, it can't be created.
    * it resolves to the cvterm table. Currently, it can't be created.
   $args = array(
   $args = array(
     'vocabulary' => 'NCIT',
     'vocabulary' => 'NCIT',
@@ -619,12 +619,12 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     ),
     'category' => 'Germplasm/Breeding',
     'category' => 'Germplasm/Breeding',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
   */
   */
-  
+
   //
   //
   // Create the 'Germplasm Accession' entity type.
   // Create the 'Germplasm Accession' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'CO_010',
     'vocabulary' => 'CO_010',
     'accession' => '0000044',
     'accession' => '0000044',
@@ -635,11 +635,11 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     ),
     'category' => 'Germplasm/Breeding',
     'category' => 'Germplasm/Breeding',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Breeding Cross' entity type.
   // Create the 'Breeding Cross' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'CO_010',
     'vocabulary' => 'CO_010',
     'accession' => '0000255',
     'accession' => '0000255',
@@ -650,11 +650,11 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     ),
     'category' => 'Germplasm/Breeding',
     'category' => 'Germplasm/Breeding',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Germplasm Variety' entity type.
   // Create the 'Germplasm Variety' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'CO_010',
     'vocabulary' => 'CO_010',
     'accession' => '0000029',
     'accession' => '0000029',
@@ -665,11 +665,11 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     ),
     'category' => 'Germplasm/Breeding',
     'category' => 'Germplasm/Breeding',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Germplasm Variety' entity type.
   // Create the 'Germplasm Variety' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'CO_010',
     'vocabulary' => 'CO_010',
     'accession' => '0000162',
     'accession' => '0000162',
@@ -680,17 +680,17 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     ),
     'category' => 'Germplasm/Breeding',
     'category' => 'Germplasm/Breeding',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 }
 }
 
 
 /**
 /**
  * Creates the "Genetic" category of content types.
  * Creates the "Genetic" category of content types.
  */
  */
 function tripal_chado_prepare_genetic_types($job) {
 function tripal_chado_prepare_genetic_types($job) {
-  
+
   //
   //
   // Create the 'Genetic Map' entity type.
   // Create the 'Genetic Map' entity type.
-  //  
+  //
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $args = array(
   $args = array(
     'vocabulary' => 'data',
     'vocabulary' => 'data',
@@ -705,11 +705,11 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     ),
     'category' => 'Genetic',
     'category' => 'Genetic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
+  //
+  // Create the 'QTL' entity type.
   //
   //
-  // Create the 'QTL' entity type. 
-  //  
   $args = array(
   $args = array(
     'vocabulary' => 'SO',
     'vocabulary' => 'SO',
     'accession' => '0000771',
     'accession' => '0000771',
@@ -720,11 +720,11 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     ),
     'category' => 'Genetic',
     'category' => 'Genetic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Sequence Variant' entity type.
   // Create the 'Sequence Variant' entity type.
-  //  
+  //
   $args = array(
   $args = array(
     'vocabulary' => 'SO',
     'vocabulary' => 'SO',
     'accession' => '0001060',
     'accession' => '0001060',
@@ -735,8 +735,8 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     ),
     'category' => 'Genetic',
     'category' => 'Genetic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   //
   // Create the 'Genetic Marker' entity type.
   // Create the 'Genetic Marker' entity type.
   //
   //
@@ -750,9 +750,9 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     ),
     'category' => 'Genetic',
     'category' => 'Genetic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
+
   //
   //
   // Create the 'Heritable Phenotypic Marker' entity type.
   // Create the 'Heritable Phenotypic Marker' entity type.
   //
   //
@@ -766,17 +766,17 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     ),
     'category' => 'Genetic',
     'category' => 'Genetic',
   );
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 }
 }
 /**
 /**
  * A helper function to consolidate the  code used to create a bundle.
  * A helper function to consolidate the  code used to create a bundle.
  */
  */
-function _tripal_chado_preapre_create_bundle($args, $job) {
-  
+function _tripal_chado_prepare_create_bundle($args, $job) {
+
   $bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
   $bundle = tripal_load_bundle_entity(['accession' => $args['vocabulary'] . ':' . $args['accession']]);
   if (!$bundle) {
   if (!$bundle) {
     drush_print("Creating " . $args['term_name'] . "...");
     drush_print("Creating " . $args['term_name'] . "...");
-    if (!tripal_create_bundle($args, $job)) {      
+    if (!tripal_create_bundle($args, $job)) {
       $msg = t('Error encountered creating !type Content Type.', ['!type' => $args['term_name']]);
       $msg = t('Error encountered creating !type Content Type.', ['!type' => $args['term_name']]);
       throw new Exception($msg);
       throw new Exception($msg);
     }
     }

+ 63 - 63
tripal_chado/includes/tripal_chado.semweb.inc

@@ -262,7 +262,7 @@ function tripal_chado_populate_vocab_SCHEMA() {
     'cv_name' => 'schema',
     'cv_name' => 'schema',
     'definition' => 'A page devoted to a single item, such as a particular product or hotel.',
     'definition' => 'A page devoted to a single item, such as a particular product or hotel.',
   ));
   ));
-  
+
 }
 }
 
 
 /**
 /**
@@ -283,7 +283,7 @@ function tripal_chado_populate_vocab_SEP() {
     'definition' => 'A biological sample analysed by a particular technology.',
     'definition' => 'A biological sample analysed by a particular technology.',
   ));
   ));
   chado_associate_semweb_term(NULL, 'biomaterial_id', $term);
   chado_associate_semweb_term(NULL, 'biomaterial_id', $term);
-  
+
   $term = tripal_insert_cvterm([
   $term = tripal_insert_cvterm([
     'id' => 'sep:00101',
     'id' => 'sep:00101',
     'name' => 'protocol',
     'name' => 'protocol',
@@ -370,20 +370,20 @@ function tripal_chado_populate_vocab_SIO() {
     'cv_name' => 'SIO',
     'cv_name' => 'SIO',
     'definition' => 'an email address is an identifier to send mail to particular electronic mailbox.',
     'definition' => 'an email address is an identifier to send mail to particular electronic mailbox.',
   ));
   ));
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'SIO:001007',
     'id' => 'SIO:001007',
     'name' => 'assay',
     'name' => 'assay',
     'cv_name' => 'SIO',
     'cv_name' => 'SIO',
     'definition' => 'An assay is an investigative (analytic) procedure in ' .
     'definition' => 'An assay is an investigative (analytic) procedure in ' .
-      'laboratory medicine, pharmacology, environmental biology, and ' . 
-      'molecular biology for qualitatively assessing or quantitatively ' . 
-      'measuring the presence or amount or the functional activity of a ' . 
+      'laboratory medicine, pharmacology, environmental biology, and ' .
+      'molecular biology for qualitatively assessing or quantitatively ' .
+      'measuring the presence or amount or the functional activity of a ' .
       'target entity (the analyte) which can be a drug or biochemical ' .
       'target entity (the analyte) which can be a drug or biochemical ' .
       'substance or a cell in an organism or organic sample.',
       'substance or a cell in an organism or organic sample.',
   ));
   ));
   chado_associate_semweb_term(NULL, 'assay_id', $term);
   chado_associate_semweb_term(NULL, 'assay_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'SIO:010054',
     'id' => 'SIO:010054',
     'name' => 'cell line',
     'name' => 'cell line',
@@ -391,7 +391,7 @@ function tripal_chado_populate_vocab_SIO() {
     'definition' => 'A cell line is a collection of genetically identifical cells.',
     'definition' => 'A cell line is a collection of genetically identifical cells.',
   ));
   ));
   chado_associate_semweb_term(NULL, 'cell_line_id', $term);
   chado_associate_semweb_term(NULL, 'cell_line_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'SIO:001066',
     'id' => 'SIO:001066',
     'name' => 'study',
     'name' => 'study',
@@ -399,7 +399,7 @@ function tripal_chado_populate_vocab_SIO() {
     'definition' => 'A study is a process that realizes the steps of a study design.',
     'definition' => 'A study is a process that realizes the steps of a study design.',
   ));
   ));
   chado_associate_semweb_term(NULL, 'study_id', $term);
   chado_associate_semweb_term(NULL, 'study_id', $term);
-  
+
 }
 }
 
 
 /**
 /**
@@ -413,7 +413,7 @@ function tripal_chado_populate_vocab_SO() {
     'urlprefix' => 'http://www.sequenceontology.org/browser/current_svn/term/{db}:{accession}',
     'urlprefix' => 'http://www.sequenceontology.org/browser/current_svn/term/{db}:{accession}',
   ));
   ));
   chado_insert_cv('sequence', 'The sequence ontology.');
   chado_insert_cv('sequence', 'The sequence ontology.');
-  
+
   $term = chado_get_cvterm(['cv_id' => ['name' => 'sequence'], 'name' => 'sequence_feature']);
   $term = chado_get_cvterm(['cv_id' => ['name' => 'sequence'], 'name' => 'sequence_feature']);
   chado_associate_semweb_term(NULL, 'feature_id', $term);
   chado_associate_semweb_term(NULL, 'feature_id', $term);
 }
 }
@@ -518,14 +518,14 @@ function tripal_chado_populate_vocab_EDAM() {
   chado_insert_cv(
   chado_insert_cv(
     'EDAM',
     'EDAM',
     'EDAM is an ontology of well established, familiar concepts that are ' .
     'EDAM is an ontology of well established, familiar concepts that are ' .
-    'prevalent within bioinformatics, including types of data and data ' . 
-    'identifiers, data formats, operations and topics. EDAM is a simple ' . 
+    'prevalent within bioinformatics, including types of data and data ' .
+    'identifiers, data formats, operations and topics. EDAM is a simple ' .
     'ontology - essentially a set of terms with synonyms and definitions - ' .
     'ontology - essentially a set of terms with synonyms and definitions - ' .
-    'organised into an intuitive hierarchy for convenient use by curators, ' . 
-    'software developers and end-users. EDAM is suitable for large-scale ' . 
-    'semantic annotations and categorization of diverse bioinformatics ' . 
-    'resources. EDAM is also suitable for diverse application including ' . 
-    'for example within workbenches and workflow-management systems, ' . 
+    'organised into an intuitive hierarchy for convenient use by curators, ' .
+    'software developers and end-users. EDAM is suitable for large-scale ' .
+    'semantic annotations and categorization of diverse bioinformatics ' .
+    'resources. EDAM is also suitable for diverse application including ' .
+    'for example within workbenches and workflow-management systems, ' .
     'software distributions, and resource registries.'
     'software distributions, and resource registries.'
   );
   );
 
 
@@ -705,14 +705,14 @@ function tripal_chado_populate_vocab_EDAM() {
     'cv_name' => 'EDAM',
     'cv_name' => 'EDAM',
     'definition' => 'Visualise, format or render a molecular sequence or sequences such as a sequence alignment, possibly with sequence features or properties shown.',
     'definition' => 'Visualise, format or render a molecular sequence or sequences such as a sequence alignment, possibly with sequence features or properties shown.',
   ));
   ));
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'operation:0525',
     'id' => 'operation:0525',
     'name' => 'genome assembly',
     'name' => 'genome assembly',
     'cv_name' => 'EDAM',
     'cv_name' => 'EDAM',
     'definition' => '',
     'definition' => '',
   ));
   ));
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'operation:0362',
     'id' => 'operation:0362',
     'name' => 'Genome annotation ',
     'name' => 'Genome annotation ',
@@ -735,7 +735,7 @@ function tripal_chado_populate_vocab_EFO() {
     'efo',
     'efo',
     'The Experimental Factor Ontology (EFO) provides a systematic description of many experimental variables available in EBI databases, and for external projects such as the NHGRI GWAS catalogue. It combines parts of several biological ontologies, such as anatomy, disease and chemical compounds. The scope of EFO is to support the annotation, analysis and visualization of data handled by many groups at the EBI and as the core ontology for OpenTargets.org'
     'The Experimental Factor Ontology (EFO) provides a systematic description of many experimental variables available in EBI databases, and for external projects such as the NHGRI GWAS catalogue. It combines parts of several biological ontologies, such as anatomy, disease and chemical compounds. The scope of EFO is to support the annotation, analysis and visualization of data handled by many groups at the EBI and as the core ontology for OpenTargets.org'
   );
   );
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'EFO:0000548',
     'id' => 'EFO:0000548',
     'name' => 'instrument',
     'name' => 'instrument',
@@ -743,7 +743,7 @@ function tripal_chado_populate_vocab_EFO() {
     'definition' => 'An instrument is a device which provides a mechanical or electronic function.',
     'definition' => 'An instrument is a device which provides a mechanical or electronic function.',
   ));
   ));
   chado_associate_semweb_term('protocol', 'hardwaredescription', $term);
   chado_associate_semweb_term('protocol', 'hardwaredescription', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'EFO:0000269',
     'id' => 'EFO:0000269',
     'name' => 'array design',
     'name' => 'array design',
@@ -751,7 +751,7 @@ function tripal_chado_populate_vocab_EFO() {
     'definition' => 'An instrument design which describes the design of the array.',
     'definition' => 'An instrument design which describes the design of the array.',
   ));
   ));
   chado_associate_semweb_term(NULL, 'arraydesign_id', $term);
   chado_associate_semweb_term(NULL, 'arraydesign_id', $term);
-   
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'EFO:0005522',
     'id' => 'EFO:0005522',
     'name' => 'substrate type',
     'name' => 'substrate type',
@@ -773,7 +773,7 @@ function tripal_chado_populate_vocab_EFO() {
     'definition' => '',
     'definition' => '',
   ));
   ));
   chado_associate_semweb_term('arraydesign', 'manufacturer_id', $term);
   chado_associate_semweb_term('arraydesign', 'manufacturer_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'EFO:0000269',
     'id' => 'EFO:0000269',
     'name' => 'assay design',
     'name' => 'assay design',
@@ -858,13 +858,13 @@ function tripal_chado_populate_vocab_OBI() {
   ));
   ));
   chado_associate_semweb_term(NULL, 'organism_id', $term);
   chado_associate_semweb_term(NULL, 'organism_id', $term);
   chado_associate_semweb_term('biomaterial', 'taxon_id', $term);
   chado_associate_semweb_term('biomaterial', 'taxon_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'OBI:0000070',
     'id' => 'OBI:0000070',
     'name' => 'assay',
     'name' => 'assay',
     'cv_name' => 'obi',
     'cv_name' => 'obi',
     'definition' => 'A planned process with the objective to produce information about the material entity that is the evaluant, by physically examining it or its proxies.',
     'definition' => 'A planned process with the objective to produce information about the material entity that is the evaluant, by physically examining it or its proxies.',
-  ));  
+  ));
 }
 }
 
 
 /**
 /**
@@ -1184,7 +1184,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
     'cv_name' => 'local',
   ));
   ));
   chado_associate_semweb_term(NULL, 'is_current', $term);
   chado_associate_semweb_term(NULL, 'is_current', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'local:is_internal',
     'id' => 'local:is_internal',
     'name' => 'is_internal',
     'name' => 'is_internal',
@@ -1192,7 +1192,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
     'cv_name' => 'local',
   ));
   ));
   chado_associate_semweb_term(NULL, 'is_internal', $term);
   chado_associate_semweb_term(NULL, 'is_internal', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'local:miniref',
     'id' => 'local:miniref',
     'name' => 'Mini-ref',
     'name' => 'Mini-ref',
@@ -1201,7 +1201,7 @@ function tripal_chado_populate_vocab_LOCAL() {
   ));
   ));
   chado_associate_semweb_term('pub', 'miniref', $term);
   chado_associate_semweb_term('pub', 'miniref', $term);
 
 
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'local:array_batch_identifier',
     'id' => 'local:array_batch_identifier',
     'name' => 'Array Batch Identifier',
     'name' => 'Array Batch Identifier',
@@ -1209,7 +1209,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
     'cv_name' => 'local',
   ));
   ));
   chado_associate_semweb_term('assay', 'arraybatchidentifier', $term);
   chado_associate_semweb_term('assay', 'arraybatchidentifier', $term);
-  
+
   //-----------------------------
   //-----------------------------
   // Relationship Terms
   // Relationship Terms
   //-----------------------------
   //-----------------------------
@@ -1332,7 +1332,7 @@ function tripal_chado_populate_vocab_LOCAL() {
 
 
   //--------------
   //--------------
   // Project Terms
   // Project Terms
-  //-------------- 
+  //--------------
   // Insert cvterm 'Project Description' into cvterm table of chado
   // Insert cvterm 'Project Description' into cvterm table of chado
   // database. This CV term is used to keep track of the project
   // database. This CV term is used to keep track of the project
   // description in the projectprop table.
   // description in the projectprop table.
@@ -1342,7 +1342,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'project_property',
     'cv_name' => 'project_property',
     'db_name' => 'local'
     'db_name' => 'local'
   ));
   ));
-  
+
   chado_insert_cvterm(array(
   chado_insert_cvterm(array(
     'name' => 'Project Type',
     'name' => 'Project Type',
     'definition'  => 'A type of project',
     'definition'  => 'A type of project',
@@ -1387,7 +1387,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'db_name' => 'local'
     'db_name' => 'local'
   ));
   ));
   chado_associate_semweb_term(NULL, 'library_id', $term);
   chado_associate_semweb_term(NULL, 'library_id', $term);
-  
+
   // Insert cvterm 'library_description' into cvterm table of chado
   // Insert cvterm 'library_description' into cvterm table of chado
   // database. This CV term is used to keep track of the library
   // database. This CV term is used to keep track of the library
   // description in the libraryprop table.
   // description in the libraryprop table.
@@ -1640,7 +1640,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     '(Random House Kernerman Webster\'s College Dictionary, © 2010 K ' .
     '(Random House Kernerman Webster\'s College Dictionary, © 2010 K ' .
     'Dictionaries Ltd).',
     'Dictionaries Ltd).',
     'cv_name' => 'local',
     'cv_name' => 'local',
-  )); 
+  ));
 
 
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'local:source_data',
     'id' => 'local:source_data',
@@ -1680,7 +1680,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'biomaterials via the biomaterialrelationship table.',
     'biomaterials via the biomaterialrelationship table.',
     'cv_name' => 'local',
     'cv_name' => 'local',
   ));
   ));
-  
+
   //
   //
   // Terms for arraydesign table
   // Terms for arraydesign table
   //
   //
@@ -1747,8 +1747,8 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
     'cv_name' => 'local',
   ));
   ));
   chado_associate_semweb_term('arraydesign', 'num_sub_rows', $term);
   chado_associate_semweb_term('arraydesign', 'num_sub_rows', $term);
-  
-  
+
+
   //
   //
   // Terms for Study
   // Terms for Study
   //
   //
@@ -1758,14 +1758,14 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'study_property',
     'cv_name' => 'study_property',
     'db_name' => 'local'
     'db_name' => 'local'
   ));
   ));
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'local:Genome Project',
     'id' => 'local:Genome Project',
     'name' => 'Genome Project',
     'name' => 'Genome Project',
     'definition' => 'A project for whole genome analysis that can include assembly and annotation.',
     'definition' => 'A project for whole genome analysis that can include assembly and annotation.',
     'cv_name' => 'local',
     'cv_name' => 'local',
   ));
   ));
-  
+
 }
 }
 /**
 /**
  * Adds the Systems Biology Ontology database and terms.
  * Adds the Systems Biology Ontology database and terms.
@@ -1805,7 +1805,7 @@ function tripal_chado_populate_vocab_SBO() {
 }
 }
 
 
 /**
 /**
- * Adds the "Bioinformatics operations, data types, formats, identifiers and 
+ * Adds the "Bioinformatics operations, data types, formats, identifiers and
  * topics" database and terms.
  * topics" database and terms.
  */
  */
 function tripal_chado_populate_vocab_SWO() {
 function tripal_chado_populate_vocab_SWO() {
@@ -1852,11 +1852,11 @@ function tripal_chado_populate_vocab_TPUB() {
 
 
   chado_insert_db(array(
   chado_insert_db(array(
     'name' => 'TPUB',
     'name' => 'TPUB',
-    'description' => 'Tripal Publiation Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
+    'description' => 'Tripal Publication Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
     'url' => 'cv/lookup/TPUB',
     'url' => 'cv/lookup/TPUB',
     'urlprefix' => 'cv/lookup/TPUB/{accession}',
     'urlprefix' => 'cv/lookup/TPUB/{accession}',
   ));
   ));
-  chado_insert_cv('tripal_pub', 'Tripal Publiation Ontology. A temporary ontology until a more formal appropriate ontology an be identified.');
+  chado_insert_cv('tripal_pub', 'Tripal Publication Ontology. A temporary ontology until a more formal appropriate ontology an be identified.');
 
 
   // make sure we have our supported databases
   // make sure we have our supported databases
   chado_insert_db(
   chado_insert_db(
@@ -1962,7 +1962,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'ncit',
     'ncit',
     'The NCIt OBO Edition project aims to increase integration of the NCIt with OBO Library ontologies. NCIt is a reference terminology that includes broad coverage of the cancer domain, including cancer related diseases, findings and abnormalities. NCIt OBO Edition releases should be considered experimental.'
     'The NCIt OBO Edition project aims to increase integration of the NCIt with OBO Library ontologies. NCIt is a reference terminology that includes broad coverage of the cancer domain, including cancer related diseases, findings and abnormalities. NCIt OBO Edition releases should be considered experimental.'
   );
   );
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C25164',
     'id' => 'NCIT:C25164',
     'name' => 'Date',
     'name' => 'Date',
@@ -1972,7 +1972,7 @@ function tripal_chado_populate_vocab_NCIT() {
   chado_associate_semweb_term('assay', 'assaydate', $term);
   chado_associate_semweb_term('assay', 'assaydate', $term);
   chado_associate_semweb_term('acquisition', 'acquisitiondate', $term);
   chado_associate_semweb_term('acquisition', 'acquisitiondate', $term);
   chado_associate_semweb_term('quantification', 'quantificationdate', $term);
   chado_associate_semweb_term('quantification', 'quantificationdate', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C48036',
     'id' => 'NCIT:C48036',
     'name' => 'Operator',
     'name' => 'Operator',
@@ -1980,7 +1980,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A person that operates some apparatus or machine',
     'definition' => 'A person that operates some apparatus or machine',
   ));
   ));
   chado_associate_semweb_term(NULL, 'operator_id', $term);
   chado_associate_semweb_term(NULL, 'operator_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C45378',
     'id' => 'NCIT:C45378',
     'name' => 'Technology Platform',
     'name' => 'Technology Platform',
@@ -1988,7 +1988,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'The specific version (manufacturer, model, etc.) of a technology that is used to carry out a laboratory or computational experiment.',
     'definition' => 'The specific version (manufacturer, model, etc.) of a technology that is used to carry out a laboratory or computational experiment.',
   ));
   ));
   chado_associate_semweb_term('arraydesign', 'platformtype_id', $term);
   chado_associate_semweb_term('arraydesign', 'platformtype_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C25712',
     'id' => 'NCIT:C25712',
     'name' => 'Value',
     'name' => 'Value',
@@ -1996,7 +1996,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A numerical quantity measured or assigned or computed.',
     'definition' => 'A numerical quantity measured or assigned or computed.',
   ));
   ));
   chado_associate_semweb_term(NULL, 'value', $term);
   chado_associate_semweb_term(NULL, 'value', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C44170',
     'id' => 'NCIT:C44170',
     'name' => 'Channel',
     'name' => 'Channel',
@@ -2004,7 +2004,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'An independent acquisition scheme, i.e., a route or conduit through which flows data consisting of one particular measurement using one particular parameter.',
     'definition' => 'An independent acquisition scheme, i.e., a route or conduit through which flows data consisting of one particular measurement using one particular parameter.',
   ));
   ));
   chado_associate_semweb_term(NULL, 'channel_id', $term);
   chado_associate_semweb_term(NULL, 'channel_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C48697',
     'id' => 'NCIT:C48697',
     'name' => 'Controlled Vocabulary',
     'name' => 'Controlled Vocabulary',
@@ -2012,7 +2012,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A set of terms that are selected and defined based on the requirements set out by the user group, usually a set of vocabulary is chosen to promote consistency across data collection projects. [ NCI ]',
     'definition' => 'A set of terms that are selected and defined based on the requirements set out by the user group, usually a set of vocabulary is chosen to promote consistency across data collection projects. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'cv_id', $term);
   chado_associate_semweb_term(NULL, 'cv_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C45559',
     'id' => 'NCIT:C45559',
     'name' => 'Term',
     'name' => 'Term',
@@ -2020,7 +2020,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A word or expression used for some particular thing. [ NCI ]',
     'definition' => 'A word or expression used for some particular thing. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'cvterm_id', $term);
   chado_associate_semweb_term(NULL, 'cvterm_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C80488',
     'id' => 'NCIT:C80488',
     'name' => 'Expression',
     'name' => 'Expression',
@@ -2028,7 +2028,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A combination of symbols that represents a value. [ NCI ]',
     'definition' => 'A combination of symbols that represents a value. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'expression_id', $term);
   chado_associate_semweb_term(NULL, 'expression_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C16977',
     'id' => 'NCIT:C16977',
     'name' => 'Phenotype',
     'name' => 'Phenotype',
@@ -2036,7 +2036,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'The assemblage of traits or outward appearance of an individual. It is the product of interactions between genes and between genes and the environment. [ NCI ]',
     'definition' => 'The assemblage of traits or outward appearance of an individual. It is the product of interactions between genes and between genes and the environment. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'phenotype_id', $term);
   chado_associate_semweb_term(NULL, 'phenotype_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C16631',
     'id' => 'NCIT:C16631',
     'name' => 'Genotype',
     'name' => 'Genotype',
@@ -2044,7 +2044,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'The genetic constitution of an organism or cell, as distinct from its expressed features or phenotype. [ NCI ]',
     'definition' => 'The genetic constitution of an organism or cell, as distinct from its expressed features or phenotype. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'genotype_id', $term);
   chado_associate_semweb_term(NULL, 'genotype_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C25341',
     'id' => 'NCIT:C25341',
     'name' => 'Location',
     'name' => 'Location',
@@ -2052,7 +2052,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A position, site, or point in space where something can be found. [ NCI ]',
     'definition' => 'A position, site, or point in space where something can be found. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'nd_geolocation_id', $term);
   chado_associate_semweb_term(NULL, 'nd_geolocation_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C802',
     'id' => 'NCIT:C802',
     'name' => 'Reagent',
     'name' => 'Reagent',
@@ -2060,7 +2060,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'Any natural or synthetic substance used in a chemical or biological reaction in order to produce, identify, or measure another substance. [ NCI ]',
     'definition' => 'Any natural or synthetic substance used in a chemical or biological reaction in order to produce, identify, or measure another substance. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'nd_reagent_id', $term);
   chado_associate_semweb_term(NULL, 'nd_reagent_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C16551',
     'id' => 'NCIT:C16551',
     'name' => 'Environment',
     'name' => 'Environment',
@@ -2068,7 +2068,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'The totality of surrounding conditions. [ NCI ]',
     'definition' => 'The totality of surrounding conditions. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'environment_id', $term);
   chado_associate_semweb_term(NULL, 'environment_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C42765',
     'id' => 'NCIT:C42765',
     'name' => 'Tree Node',
     'name' => 'Tree Node',
@@ -2076,7 +2076,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A term that refers to any individual item or entity in a hierarchy or pedigree. [ NCI ]',
     'definition' => 'A term that refers to any individual item or entity in a hierarchy or pedigree. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'phylonode_id', $term);
   chado_associate_semweb_term(NULL, 'phylonode_id', $term);
-     
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C15320',
     'id' => 'NCIT:C15320',
     'name' => 'Study Design',
     'name' => 'Study Design',
@@ -2084,10 +2084,10 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A plan detailing how a study will be performed in order to represent the phenomenon under examination, to answer the research questions that have been asked, and defining the methods of data analysis. Study design is driven by research hypothesis being posed, study subject/population/sample available, logistics/resources: technology, support, networking, collaborative support, etc. [ NCI ]',
     'definition' => 'A plan detailing how a study will be performed in order to represent the phenomenon under examination, to answer the research questions that have been asked, and defining the methods of data analysis. Study design is driven by research hypothesis being posed, study subject/population/sample available, logistics/resources: technology, support, networking, collaborative support, etc. [ NCI ]',
   ));
   ));
   chado_associate_semweb_term(NULL, 'studydesign_id', $term);
   chado_associate_semweb_term(NULL, 'studydesign_id', $term);
-  
+
   // The Company term is missing for the Tripal Contact ontology, but is
   // The Company term is missing for the Tripal Contact ontology, but is
   // useful for the arraydesign.manufacturer which is an FK to Contact.
   // useful for the arraydesign.manufacturer which is an FK to Contact.
-  // It seems better to use a term from a curated ontology than to add to 
+  // It seems better to use a term from a curated ontology than to add to
   // Tripal Contact.
   // Tripal Contact.
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C54131',
     'id' => 'NCIT:C54131',
@@ -2095,7 +2095,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'cv_name' => 'ncit',
     'cv_name' => 'ncit',
     'definition' => 'Any formal business entity for profit, which may be a corporation, a partnership, association or individual proprietorship.',
     'definition' => 'Any formal business entity for profit, which may be a corporation, a partnership, association or individual proprietorship.',
   ));
   ));
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C47885',
     'id' => 'NCIT:C47885',
     'name' => 'Project',
     'name' => 'Project',
@@ -2103,28 +2103,28 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'Any specifically defined piece of work that is undertaken or attempted to meet a single requirement.',
     'definition' => 'Any specifically defined piece of work that is undertaken or attempted to meet a single requirement.',
   ));
   ));
   chado_associate_semweb_term(NULL, 'project_id', $term);
   chado_associate_semweb_term(NULL, 'project_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C16223',
     'id' => 'NCIT:C16223',
     'name' => 'DNA Library',
     'name' => 'DNA Library',
     'cv_name' => 'ncit',
     'cv_name' => 'ncit',
     'definition' => 'A collection of DNA molecules that have been cloned in vectors.',
     'definition' => 'A collection of DNA molecules that have been cloned in vectors.',
   ));
   ));
-    
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C85496',
     'id' => 'NCIT:C85496',
     'name' => 'Trait',
     'name' => 'Trait',
     'cv_name' => 'ncit',
     'cv_name' => 'ncit',
     'definition' => 'Any genetically determined characteristic.',
     'definition' => 'Any genetically determined characteristic.',
   ));
   ));
-  
+
   $term = chado_insert_cvterm(array(
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C25693',
     'id' => 'NCIT:C25693',
     'name' => 'Subgroup',
     'name' => 'Subgroup',
     'cv_name' => 'ncit',
     'cv_name' => 'ncit',
     'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
     'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
   ));
   ));
-  
+
 }
 }
 
 
 /**
 /**

+ 19 - 19
tripal_chado/tripal_chado.install

@@ -30,7 +30,7 @@ function tripal_chado_install() {
     ";
     ";
     chado_query($sql);
     chado_query($sql);
   }
   }
-  
+
   tripal_insert_variable('bundle_category', 'Bundles can be categorized to allow for grouping');
   tripal_insert_variable('bundle_category', 'Bundles can be categorized to allow for grouping');
 }
 }
 
 
@@ -624,7 +624,7 @@ function tripal_chado_chado_bundle_schema() {
       ),
       ),
       'base_type_id' => array(
       'base_type_id' => array(
         'description' => 'If a property table is used for a linker, and if the base table requires a type_id then this is the type that should be used on insert of new records in the base table.',
         'description' => 'If a property table is used for a linker, and if the base table requires a type_id then this is the type that should be used on insert of new records in the base table.',
-        'size' => 'big',        
+        'size' => 'big',
         'type' => 'int',
         'type' => 'int',
       )
       )
     ),
     ),
@@ -1394,11 +1394,11 @@ function tripal_chado_update_7321() {
   try {
   try {
     chado_insert_db(array(
     chado_insert_db(array(
       'name' => 'TPUB',
       'name' => 'TPUB',
-      'description' => 'Tripal Publiation Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
+      'description' => 'Tripal Publication Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
       'url' => '/cv/lookup/TPUB',
       'url' => '/cv/lookup/TPUB',
       'urlprefix' => '/cv/lookup/TPUB/{accession}',
       'urlprefix' => '/cv/lookup/TPUB/{accession}',
     ));
     ));
-    chado_insert_cv('tripal_pub', 'Tripal Publiation Ontology. A temporary ontology until a more formal appropriate ontology an be identified.');
+    chado_insert_cv('tripal_pub', 'Tripal Publication Ontology. A temporary ontology until a more formal appropriate ontology an be identified.');
 
 
     chado_insert_db(array(
     chado_insert_db(array(
       'name' => 'rdf',
       'name' => 'rdf',
@@ -1439,7 +1439,7 @@ function tripal_chado_update_7322() {
   try {
   try {
     chado_insert_db(array(
     chado_insert_db(array(
       'name' => 'TPUB',
       'name' => 'TPUB',
-      'description' => 'Tripal Publiation Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
+      'description' => 'Tripal Publication Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
       'url' => 'cv/lookup/TPUB',
       'url' => 'cv/lookup/TPUB',
       'urlprefix' => 'cv/lookup/TPUB/{accession}',
       'urlprefix' => 'cv/lookup/TPUB/{accession}',
     ));
     ));
@@ -1578,7 +1578,7 @@ function tripal_chado_update_7328() {
     tripal_chado_add_cv_root_mview_mview();
     tripal_chado_add_cv_root_mview_mview();
     $mview_id = chado_get_mview_id($mv_name);
     $mview_id = chado_get_mview_id($mv_name);
     chado_populate_mview($mview_id);
     chado_populate_mview($mview_id);
-  } 
+  }
   catch (\PDOException $e) {
   catch (\PDOException $e) {
     $error = $e->getMessage();
     $error = $e->getMessage();
     throw new DrupalUpdateException('Could not perform update: '. $error);
     throw new DrupalUpdateException('Could not perform update: '. $error);
@@ -1608,7 +1608,7 @@ function tripal_chado_update_7329() {
 function tripal_chado_update_7330() {
 function tripal_chado_update_7330() {
   try {
   try {
     tripal_insert_variable('bundle_category', 'Bundles can be categorized to allow for grouping');
     tripal_insert_variable('bundle_category', 'Bundles can be categorized to allow for grouping');
-    
+
     $bundles = [
     $bundles = [
       'General' => [
       'General' => [
         // Organism
         // Organism
@@ -1624,7 +1624,7 @@ function tripal_chado_update_7330() {
         // Publication
         // Publication
         'TPUB:0000002',
         'TPUB:0000002',
         // Protocol
         // Protocol
-        'sep:00101',        
+        'sep:00101',
       ],
       ],
       'Genomic' => [
       'Genomic' => [
         // Gene
         // Gene
@@ -1642,7 +1642,7 @@ function tripal_chado_update_7330() {
         // Genome Annotation
         // Genome Annotation
         'operation:0362',
         'operation:0362',
         // Genome Project
         // Genome Project
-        'local:Genome Project',                
+        'local:Genome Project',
       ],
       ],
       'Genetic' => [
       'Genetic' => [
         // Genetic Map
         // Genetic Map
@@ -1654,7 +1654,7 @@ function tripal_chado_update_7330() {
         // Genetic Marker
         // Genetic Marker
         'SO:0001645',
         'SO:0001645',
         // Heritable Phenotypic Marker
         // Heritable Phenotypic Marker
-        'SO:0001500',        
+        'SO:0001500',
       ],
       ],
       'Germplasm/Breeding' => [
       'Germplasm/Breeding' => [
         // Germplasm Accession
         // Germplasm Accession
@@ -1664,14 +1664,14 @@ function tripal_chado_update_7330() {
         // Cutlivar
         // Cutlivar
         'CO_010:0000029',
         'CO_010:0000029',
         // Recombinant Inbred Line
         // Recombinant Inbred Line
-        'CO_010:0000162',        
+        'CO_010:0000162',
       ],
       ],
       'Expression' => [
       'Expression' => [
         // Biological Sample
         // Biological Sample
         'sep:00195',
         'sep:00195',
         // Assay
         // Assay
         'OBI:0000070',
         'OBI:0000070',
-        // Array Design 
+        // Array Design
         'EFO:0000269',
         'EFO:0000269',
       ]
       ]
     ];
     ];
@@ -1681,8 +1681,8 @@ function tripal_chado_update_7330() {
         if ($bundle) {
         if ($bundle) {
           tripal_set_bundle_variable('bundle_category', $bundle->id, $category);
           tripal_set_bundle_variable('bundle_category', $bundle->id, $category);
         }
         }
-      }      
-    }    
+      }
+    }
   }
   }
   catch (\PDOException $e) {
   catch (\PDOException $e) {
     $error = $e->getMessage();
     $error = $e->getMessage();
@@ -1726,15 +1726,15 @@ function tripal_chado_update_7332() {
       'ncit',
       'ncit',
       'The NCIt OBO Edition project aims to increase integration of the NCIt with OBO Library ontologies. NCIt is a reference terminology that includes broad coverage of the cancer domain, including cancer related diseases, findings and abnormalities. NCIt OBO Edition releases should be considered experimental.'
       'The NCIt OBO Edition project aims to increase integration of the NCIt with OBO Library ontologies. NCIt is a reference terminology that includes broad coverage of the cancer domain, including cancer related diseases, findings and abnormalities. NCIt OBO Edition releases should be considered experimental.'
     );
     );
-    
+
     $term = chado_insert_cvterm([
     $term = chado_insert_cvterm([
       'id' => 'NCIT:C25693',
       'id' => 'NCIT:C25693',
       'name' => 'Subgroup',
       'name' => 'Subgroup',
       'cv_name' => 'ncit',
       'cv_name' => 'ncit',
       'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
       'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
     ]);
     ]);
-    
-    
+
+
     // Add the rdfs:comment vocabulary.
     // Add the rdfs:comment vocabulary.
     chado_insert_db(array(
     chado_insert_db(array(
       'name' => 'rdfs',
       'name' => 'rdfs',
@@ -1776,7 +1776,7 @@ function tripal_chado_update_7333() {
  * SQL Fix for the db2cv_mview materialized view.
  * SQL Fix for the db2cv_mview materialized view.
  */
  */
 function tripal_chado_update_7334() {
 function tripal_chado_update_7334() {
-  
+
   try {
   try {
     $query = '
     $query = '
        SELECT DISTINCT CV.cv_id, CV.name as cvname, DB.db_id, DB.name as dbname,
        SELECT DISTINCT CV.cv_id, CV.name as cvname, DB.db_id, DB.name as dbname,
@@ -1824,4 +1824,4 @@ function tripal_chado_update_7335() {
     $error = $e->getMessage();
     $error = $e->getMessage();
     throw new DrupalUpdateException('Could not perform update: '. $error);
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
   }
-}
+}

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