Browse Source

Merge pull request #685 from abretaud/3_fixes

Fix a few warnings
Stephen Ficklin 6 years ago
parent
commit
4b46c43888

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

@@ -3,8 +3,8 @@
 /**
  * @file
  * 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
  * 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.
- * 
- * 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
- * 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
  * @}
  *
@@ -117,15 +117,15 @@ function hook_bundle_delete($bundle) {
  * Implement this hook to define default formats for Tripal Content Types.
  *
  * @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.
  * @param array $available_tokens
  *   An array of available tokens for this particular tripal content type.
  *
  * @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.
- *   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.
  *    - weight: an integer used to determine priority of suggestions.
  *        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 ($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.
     $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.
       'format' => '[organism__genus] [organism__species]',
       // 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.
  *
  * @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.
  *
  * @return
@@ -284,7 +284,7 @@ function tripal_load_term_entity($values) {
  * Retrieves a TripalVocab entity that maches the given arguments.
  *
  * @param $values
- *   An associative array used to match a vocabulary.  
+ *   An associative array used to match a vocabulary.
  *   The valid keys are:
  *      - vocab_id: integer id of the vocabulary.
  *      - vocabulary: string name of vocabulary.
@@ -356,7 +356,7 @@ function tripal_load_bundle_entity($values) {
       return NULL;
     }
     $query->condition('tb.term_id', $term->id);
-    
+
   }
   $bundle = $query->execute()->fetchObject();
 
@@ -375,15 +375,15 @@ function tripal_load_bundle_entity($values) {
  * @param $details
  *   A human-readable sentence or two describing the issue.
  * @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.
  *   If no type is required please pass NULL.
  * @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.
  *   If not type is required please pass NULL.
  * @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.
  *
  * @ingroup tripal_entities_api
@@ -396,7 +396,7 @@ function tripal_add_notification($title, $details, $type, $actions, $submitter_i
       ->fields('tan')
       ->condition('submitter_id', $submitter_id, '=')
       ->execute()->fetchAll();
-  
+
     if (empty($dedup)) {
       $record = new stdClass;
       $record->details = $details;
@@ -439,17 +439,17 @@ function tripal_create_bundle($args, $job = NULL) {
   $accession = $args['accession'];
   $term_name = $args['term_name'];
   $storage_args = $args['storage_args'];
-  
+
   $message_args = [
     'job' => $job,
     'print' => 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. " .
 //     "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);
 
   $transaction = db_transaction();
@@ -463,7 +463,7 @@ function tripal_create_bundle($args, $job = NULL) {
       }
       else {
         $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);
         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);
       return FALSE;
     }
-    
+
     // Set the bundle category
     $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.
     tripal_create_bundle_fields($bundle, $term);
 
     // 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.
     unset($transaction);
 
@@ -577,10 +577,10 @@ function tripal_create_bundle($args, $job = NULL) {
 
   // Set admin access for the new bundle.
   tripal_admin_access($bundle);
-  
+
   // Report that we're done.
   tripal_report_error('tripal_entities', TRIPAL_INFO, "Done.", [], $message_args);
-  
+
   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.
  *
  * @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
   // types they create.
   drupal_alter('bundle_instances_info', $instance_info, $bundle, $term);
-  
+
   // Get the list of existing instances
   $existing_instances = field_info_instances('TripalEntity', $bundle->name);
-  
+
   // Iterate through all of the field instances and create them.
   foreach ($instance_info as $instance_name => $details) {
-    
+
     // Make sure the instance has a term. If not, report it and skip the field.
     if (!array_key_exists('term_vocabulary', $details['settings'])) {
       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.',
         ['!field' => $instance_name], ['drupal_set_message' => TRUE]);
         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.
-    $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']);
     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  ' .
         'field instance cannot be added. Please make sure the term is correct and add it if necessary.',
         ['!term' => $field_term_id,
@@ -799,11 +799,11 @@ function tripal_create_bundle_fields($bundle, $term) {
         ['drupal_set_message' => TRUE]);
       continue;
     }
-    
+
     // Make sure the term is not used for any other existing field instance.
     $skip = FALSE;
     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.
       $existing_term_id = $existing_instance['settings']['term_vocabulary'] . ':' . $existing_instance['settings']['term_accession'];
       $existing_field = field_info_field($existing_name);
@@ -816,7 +816,7 @@ function tripal_create_bundle_fields($bundle, $term) {
           ['drupal_set_message' => TRUE]);
         $skip = TRUE;
       }
-      
+
       // If the instance term is the same as this exsting term but the storage
       // types are different then we have a problem.
       $existing_storage = $existing_field['storage']['type'];
@@ -1022,7 +1022,7 @@ function tripal_set_bundle_variable($variable_name, $bundle_id, $value) {
     }
   }
 
-  // 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.
   $record = array(
     'bundle_id' => $bundle_id,
@@ -1128,7 +1128,7 @@ function tripal_get_default_title_format($bundle) {
   if (!$format) {
     $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.
     foreach($tokens as $token) {
       if ($token['required']) {
@@ -1182,13 +1182,13 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
 
   $instances = field_info_instances('TripalEntity', $bundle->name);
   foreach ($instances as $instance_name => $instance) {
-    
+
     if (!$instance['required'] and $options['required only']) {
       continue;
     }
-    
+
     $use_field = FALSE;
-   
+
     // Iterate through the TripalEntity fields and see if they have
     // sub-elements, if so, add those as tokens too.
     $field_name = $instance['field_name'];
@@ -1198,8 +1198,8 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
         $field_obj = new $field_name($field, $instance);
         $element_info = $field_obj->elementInfo();
         $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) {
           $elements = $element_info[$term_id]['elements'];
           _tripal_get_entity_tokens_for_elements($instance, $field_name, $elements, $tokens, $options);
@@ -1215,7 +1215,7 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
     else {
       $use_field = TRUE;
     }
-    
+
     // If we have no elements to add then just add the field as is.
     if ($use_field) {
       // Build the token from the field information.
@@ -1235,11 +1235,11 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
 
 /**
  * A recursive helper function to get tokens for element sub fields.
- * 
+ *
  * @param $instance
  *   A original field instance object.
  * @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.
  * @param $elements
  *   The array of elements to process.
@@ -1247,21 +1247,21 @@ function tripal_get_entity_tokens($bundle, $options = array()) {
  *   The array of tokens to be added to.
  */
 function _tripal_get_entity_tokens_for_elements($instance, $parent, $elements, &$tokens, $options) {
-  
+
   // Iterate through all of the elements and add tokens for each one.
   foreach ($elements as $child_term_id => $details) {
-    
+
     // We don't need to add the entity element.
     if ($child_term_id == 'entity') {
       continue;
     }
-    
+
     // Skip elements that aren't required.
     $required = array_key_exists('required', $details) ? $details['required'] : FALSE;
     if (!$required and $options['required only']) {
       continue;
     }
-    $token = '[' . $parent . ',' . $child_term_id . ']'; 
+    $token = '[' . $parent . ',' . $child_term_id . ']';
     $label = $child_term_id;
     if (array_key_exists('name', $details)) {
       $label = $details['name'];
@@ -1280,10 +1280,10 @@ function _tripal_get_entity_tokens_for_elements($instance, $parent, $elements, &
       'field_name' => $instance['field_name'],
       'required' => $required
     ];
-    
+
     // Recurse to include sub elements
     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);
     }
   }
@@ -1298,7 +1298,7 @@ function _tripal_get_entity_tokens_for_elements($instance, $parent, $elements, &
  * @param TripalEntity $entity
  *   The entity with field values used to find values of tokens.
  * @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.
  *
  * @return
@@ -1352,20 +1352,20 @@ function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL)
     module_invoke($storage['module'], 'field_storage_load', 'TripalEntity',
         $entities, FIELD_LOAD_CURRENT, $field_ids, array());
   }
-  
+
   // Now that all necessary fields are attached process the tokens.
   foreach($used_tokens as $token) {
     $token = preg_replace('/[\[\]]/', '', $token);
     $elements = explode(',', $token);
     $field_name = array_shift($elements);
     $value = '';
-    
+
     if (property_exists($entity, $field_name)) {
       $value = '';
       // Note: there is a memory leak in field_get_items() so we can't use it
       // here or bulk publishing will slowly erode memory.
       // $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'])) {
         $value = $entity->{$field_name}['und'][0]['value'];
         // If the value is an array it means we have sub elements and we can
@@ -1373,7 +1373,7 @@ function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL)
         if (is_array($value) and count($elements) > 0) {
           $value = _tripal_replace_entity_tokens_for_elements($elements, $value);
         }
-      }    
+      }
     }
     // The TripalBundle__bundle_id is a special token for substituting the
     // bundle id.
@@ -1406,7 +1406,7 @@ function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL)
 
 /**
  * A helper function for tripal_replace_entity_tokens to get token values.
- * 
+ *
  * This helper function is used when the tokens are from subelements.
  * @param $entity
  */
@@ -1595,15 +1595,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
- * in the existing code. 
- * 
+ * in the existing code.
+ *
  * @param $bundle_name
  *   The name of the bundle (e.g. bio_data_xx)
  * @param unknown $values
  *
  * @throws Exception
  *
- * 
+ *
  */
 function tripal_insert_entity($bundle_name, $values){
   global $user;
@@ -1654,12 +1654,12 @@ function tripal_insert_entity($bundle_name, $values){
 }
 
 /**
- * Are we keeping this? 
- * 
+ * Are we keeping this?
+ *
  * @param $bundle_name
  * @param $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
  */
 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.
  *
  * 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
  * but that function cannot handle loops in the ontology graphs and results
  * in stack depth errors in PostgreSQL.
@@ -395,37 +395,37 @@ function chado_clear_cvtermpath($cv_id) {
  * @ingroup tripal_chado_cv_api
  */
 function chado_update_cvtermpath($cv_id, $job = NULL) {
-  
+
   $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";
-  chado_clear_cvtermpath($cv_id);  
+  chado_clear_cvtermpath($cv_id);
   print "Clearing completed.\n";
-  
+
   // The cache is used to limit repetitive queries by storing known data.
   $cache = [
     // Stores all relationships in the cvtermpath table.
     'rels' => [],
     // Stores all nodes that were visited when processing all nodes as roots.
     '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.
     'nodes_processed' => [],
     // For easy lookup stores the is_a relationship.
     'is_a' => NULL,
   ];
-  
+
   // TODO: there's a function to determine the current Chado instance.
   // we should use that.
   $transaction = db_transaction();
-  
+
   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
     // don't have to do repetitive queries to Chado.
     print "Retrieving relationships...\n";
@@ -434,7 +434,7 @@ function chado_update_cvtermpath($cv_id, $job = NULL) {
       FROM {cvterm_relationship} CVTR
         INNER JOIN {cvterm} CVTO on CVTO.cvterm_id = CVTR.object_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
     ";
     $rels = chado_query($sql, [':cv_id' => $cv_id]);
@@ -446,12 +446,12 @@ function chado_update_cvtermpath($cv_id, $job = NULL) {
     if ($job) {
       $job->logMessage('Found !total relationships in this vocabulary.', ['!total' => $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.');
       $job->setProgress(0);
       $job->setInterval(1);
     }
-    
+
     // Next get the tree roots. These are terms that are in relationships as
     // an object but never as a subject.
     $sql = "
@@ -459,44 +459,44 @@ function chado_update_cvtermpath($cv_id, $job = NULL) {
       FROM {cvterm} CVT
         LEFT JOIN {cvterm_relationship} CVTR ON CVT.cvterm_id = CVTR.subject_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
     ";
     $roots = chado_query($sql, [':cvid' => $cv_id]);
-     
+
     // Iterate through the tree roots.
-    print "Processing terms...\n";    
+    print "Processing terms...\n";
     while ($root = $roots->fetchObject()) {
       $root_id =  $root->cvterm_id;
       $root_name = $root->name;
-      
+
       if ($job) {
         $job->logMessage('Processing tree root: ' . $root_name . '...');
       }
-      
+
       // Now start descending through the tree and add the relationships
       // to the cvtermpath table.
       $num_handled = 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);
     }
   }
   catch (Exception $e) {
-    $transaction->rollback();    
+    $transaction->rollback();
     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
  * 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
  * will then recursively treat each child term within the tree as a root in
  * order to find all relationships.
- * 
+ *
  * @param $cv_id
  *   The vocaulary Id
  * @param $root_id
@@ -513,68 +513,74 @@ function chado_update_cvtermpath($cv_id, $job = NULL) {
  * @param $root_depth
  *   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) {
-    
-    
+
+
   // Don't use a node as a root if we've already used it once before.
   if (in_array($root_id, $cache['roots_processed'])) {
     return;
   }
-    
+
   // Mark this node as having been processed as a root node.
   $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) {
-    $is_a = $cache['$is_a'];
+    $is_a = $cache['is_a'];
     $type_id = $is_a->cvterm_id;
     $depth = 1;
     _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.
   $children = $cache['rels'][$root_id];
-  
+
   // If there are no children do nothing.
   if (!$children) {
     return;
   }
-    
+
   // Set the job progress.
   if ($job) {
     $job->setItemsHandled($num_handled);
   }
   $num_handled++;
-  
+
   // 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
   // second time while traversing a single path of the tree then we've hit
   // a loop.
   $path = [];
- 
-  // Process the children of this term.  
+
+  // Process the children of this term.
   $cache['nodes_processed'] = [];
+  $next_depth = 0;
   _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.
   foreach ($children as $child) {
     $child_id = $child[0];
     $child_type_id = $child[1];
     $child_name = $child[2];
 
-    // Process this child as a root. 
+    // Process this child as a root.
     $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);
   }
-}  
+}
 /**
  * Handles a single node in the tree.
- * 
+ *
  * This is a recursive function which calls itself as the tree is descended. It
  * performs a depth-first search of the tree.
- * 
+ *
  * @param $cv_id
  *   The vocaulary Id
  * @param $root_id
@@ -587,65 +593,70 @@ function _chado_update_cvtermpath_root($cv_id, $root_id, $root_name, &$cache,
  * @param $cache
  *   The cache used for lookups.
  * @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) {
-  
+
   $cache['nodes_processed'][$cvterm_id] = TRUE;
-      
+
   // Have we visited this node before while on this path then we won't
   // descend further as this means we've hit a loop.
   if (in_array($cvterm_id, $path)) {
     return;
   }
-  
+
   // Add this term to the path.
   $path[] = $cvterm_id;
   //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.
   $children = $cache['rels'][$cvterm_id];
-  
+
   // If this term does not have children then return.
   if (!$children) {
     return;
   }
-  
+
   // If the term has children then recurse on those.
   $next_depth = $depth + 1;
   foreach ($children as $child) {
     $child_id = $child[0];
     $child_type_id = $child[1];
-         
+
     // Don't descend for children we've already seen.
     if (array_key_exists($child_id, $cache['nodes_processed'])) {
       continue;
     }
-    
+
     _chado_update_cvtermpath_add_relationship($child_type_id, $child_id, $root_id,
       $cv_id, $next_depth);
-    
+
     _chado_update_cvtermpath_process_children($cv_id, $root_id, $child_id, $path, $cache, $next_depth);
   }
 }
 
 /**
  * Inserts values into the cvtermpath table.
- * 
+ *
  * After the entire tree below the current root term is traversed, this
  * function is called and inserts all of the relationships that were found
- * into the cvtermpath table. 
- * 
+ * into the cvtermpath table.
+ *
  * @param $visited
  *   The array contaiing relationships for all visited nodes in the tree. These
  *   elements will become the entries in the cvtermpath table.
  * @param $job
  *   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) {
-  
+
   $cvtermpath = new ChadoRecord('cvtermpath');
   $cvtermpath->setValues([
     '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() {
-  
-  // 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.
   chado_insert_db([
     'name' => 'NCIT',
@@ -84,15 +84,15 @@ function tripal_chado_load_ontologies() {
     '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.'
     );
-  
+
   $term = chado_insert_cvterm([
     'id' => 'NCIT:C25693',
     'name' => 'Subgroup',
     'cv_name' => 'ncit',
     'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
   ]);
-  
-  
+
+
   // Add the rdfs:comment vocabulary.
   chado_insert_db(array(
     'name' => 'rdfs',
@@ -263,7 +263,7 @@ function tripal_chado_prepare_chado($job = NULL) {
     drush_print('Populating materialized view db2cv_mview...');
     $mview_id = chado_get_mview_id('db2cv_mview');
     chado_populate_mview($mview_id);
-    
+
     drush_print("Creating common Tripal Content Types...");
     drush_print("This may take awhile if you are upgrading a site that has lots of data...");
     if ($report_progress) {
@@ -280,16 +280,16 @@ function tripal_chado_prepare_chado($job = NULL) {
 
     // Set a variable to indicate the site is prepared.
     variable_set('tripal_chado_is_prepared', TRUE);
-    
+
     if ($report_progress) {
       $job->setProgress(100);
-    }  
+    }
   }
   catch (Exception $e) {
     $job->logMessage($e);
     throw new Exception($e);
   }
-  
+
   // Clear the Drupal menu cache so that the new content types have "add" links.
   menu_cache_clear_all();
 }
@@ -298,10 +298,10 @@ function tripal_chado_prepare_chado($job = NULL) {
  * Creates the "General" category of content types.
  */
 function tripal_chado_prepare_general_types($job) {
-  
+
   //
   // Create the 'Organism' entity type. This uses the obi:organism term.
-  //  
+  //
   $args = array(
     'vocabulary' => 'OBI',
     'accession' => '0100026',
@@ -311,11 +311,11 @@ function tripal_chado_prepare_general_types($job) {
     ),
     '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.
-  //  
+  //
   $args = array(
     'vocabulary' => 'operation',
     'accession' => '2945',
@@ -325,11 +325,11 @@ function tripal_chado_prepare_general_types($job) {
     ),
     '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.
-  //  
+  //
   $args = array(
     'vocabulary' => 'NCIT',
     'accession' => 'C47885',
@@ -339,12 +339,12 @@ function tripal_chado_prepare_general_types($job) {
     ),
     '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.
-  //  
+  //
   $args = array(
     'vocabulary' => 'SIO',
     'accession' => '001066',
@@ -354,11 +354,11 @@ function tripal_chado_prepare_general_types($job) {
     ),
     '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.
-  //  
+  //
   $args = array(
     'vocabulary' => 'local',
     'accession' => 'contact',
@@ -368,11 +368,11 @@ function tripal_chado_prepare_general_types($job) {
     ),
     'category' => 'General'
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 
   //
   // Create the 'Publication' entity type.
-  //      
+  //
   $args = array(
     'vocabulary' => 'TPUB',
     'accession' => '0000002',
@@ -387,9 +387,9 @@ function tripal_chado_prepare_general_types($job) {
     // Import a publication so we get all of the properties before
     // creating the content type.
     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.
     $values = 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);
     chado_delete_record('pub', array('pub_id' => $result[0]->pub_id));
   }
-  
+
   //
   // Create the 'Protocol' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'sep',
     'accession' => '00101',
@@ -415,7 +415,7 @@ function tripal_chado_prepare_general_types($job) {
     ),
     '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) {
   //
   // Create the 'Gene' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'SO',
     'accession' => '0000704',
@@ -435,11 +435,11 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     'category' => 'Genomic',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   // Create the 'mRNA' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'SO',
     'accession' => '0000234',
@@ -450,11 +450,11 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     'category' => 'Genomic',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   // Create the 'Phylogenetic tree' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'data',
     'accession' => '0872',
@@ -464,9 +464,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     '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']);
   $args = array(
     'vocabulary' => 'data',
@@ -481,9 +481,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     '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(
     'vocabulary' => 'NCIT',
     'accession' => 'C16223',
@@ -494,9 +494,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     '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']);
   $args = array(
     'vocabulary' => 'operation',
@@ -511,9 +511,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     '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']);
   $args = array(
     'vocabulary' => 'operation',
@@ -528,9 +528,9 @@ function tripal_chado_prepare_genomic_types($job) {
     ),
     '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']);
   $args = array(
     'vocabulary' => 'local',
@@ -546,7 +546,7 @@ function tripal_chado_prepare_genomic_types($job) {
     'category' => 'Genomic',
   );
   $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) {
   //
   // Create the 'biological sample' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'sep',
     'accession' => '00195',
@@ -566,11 +566,11 @@ function tripal_chado_prepare_expression_types($job) {
     'Expression',
   );
   $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.
-  //  
+  //
   $args = array(
     'vocabulary' => 'OBI',
     'accession' => '0000070',
@@ -581,11 +581,11 @@ function tripal_chado_prepare_expression_types($job) {
     'Expression',
   );
   $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.
-  //  
+  //
   $args = array(
     'vocabulary' => 'EFO',
     'accession' => '0000269',
@@ -595,19 +595,19 @@ function tripal_chado_prepare_expression_types($job) {
     ),
     'Expression',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 }
 
 /**
  * Creates the "Germplasm/Breeding" category of content types.
  */
 function tripal_chado_prepare_germplasm_types($job) {
-  
+
   //
   // 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.
   $args = array(
     'vocabulary' => 'NCIT',
@@ -619,12 +619,12 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     'category' => 'Germplasm/Breeding',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
   */
-  
+
   //
   // Create the 'Germplasm Accession' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'CO_010',
     'accession' => '0000044',
@@ -635,11 +635,11 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     'category' => 'Germplasm/Breeding',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   // Create the 'Breeding Cross' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'CO_010',
     'accession' => '0000255',
@@ -650,11 +650,11 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     'category' => 'Germplasm/Breeding',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   // Create the 'Germplasm Variety' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'CO_010',
     'accession' => '0000029',
@@ -665,11 +665,11 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     'category' => 'Germplasm/Breeding',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   // Create the 'Germplasm Variety' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'CO_010',
     'accession' => '0000162',
@@ -680,17 +680,17 @@ function tripal_chado_prepare_germplasm_types($job) {
     ),
     'category' => 'Germplasm/Breeding',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
+  _tripal_chado_prepare_create_bundle($args, $job);
 }
 
 /**
  * Creates the "Genetic" category of content types.
  */
 function tripal_chado_prepare_genetic_types($job) {
-  
+
   //
   // Create the 'Genetic Map' entity type.
-  //  
+  //
   $cvterm = tripal_get_cvterm(['id' => 'rdfs:type']);
   $args = array(
     'vocabulary' => 'data',
@@ -705,11 +705,11 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     '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(
     'vocabulary' => 'SO',
     'accession' => '0000771',
@@ -720,11 +720,11 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     'category' => 'Genetic',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   // Create the 'Sequence Variant' entity type.
-  //  
+  //
   $args = array(
     'vocabulary' => 'SO',
     'accession' => '0001060',
@@ -735,8 +735,8 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     'category' => 'Genetic',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
   //
   // Create the 'Genetic Marker' entity type.
   //
@@ -750,9 +750,9 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     'category' => 'Genetic',
   );
-  _tripal_chado_preapre_create_bundle($args, $job);
-  
-  
+  _tripal_chado_prepare_create_bundle($args, $job);
+
+
   //
   // Create the 'Heritable Phenotypic Marker' entity type.
   //
@@ -766,17 +766,17 @@ function tripal_chado_prepare_genetic_types($job) {
     ),
     '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.
  */
-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']]);
   if (!$bundle) {
     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']]);
       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',
     '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.',
   ));
   chado_associate_semweb_term(NULL, 'biomaterial_id', $term);
-  
+
   $term = tripal_insert_cvterm([
     'id' => 'sep:00101',
     'name' => 'protocol',
@@ -370,20 +370,20 @@ function tripal_chado_populate_vocab_SIO() {
     'cv_name' => 'SIO',
     'definition' => 'an email address is an identifier to send mail to particular electronic mailbox.',
   ));
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'SIO:001007',
     'name' => 'assay',
     'cv_name' => 'SIO',
     '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 ' .
       'substance or a cell in an organism or organic sample.',
   ));
   chado_associate_semweb_term(NULL, 'assay_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'SIO:010054',
     'name' => 'cell line',
@@ -391,7 +391,7 @@ function tripal_chado_populate_vocab_SIO() {
     'definition' => 'A cell line is a collection of genetically identifical cells.',
   ));
   chado_associate_semweb_term(NULL, 'cell_line_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'SIO:001066',
     '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.',
   ));
   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}',
   ));
   chado_insert_cv('sequence', 'The sequence ontology.');
-  
+
   $term = chado_get_cvterm(['cv_id' => ['name' => 'sequence'], 'name' => 'sequence_feature']);
   chado_associate_semweb_term(NULL, 'feature_id', $term);
 }
@@ -518,14 +518,14 @@ function tripal_chado_populate_vocab_EDAM() {
   chado_insert_cv(
     'EDAM',
     '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 - ' .
-    '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.'
   );
 
@@ -705,14 +705,14 @@ function tripal_chado_populate_vocab_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.',
   ));
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'operation:0525',
     'name' => 'genome assembly',
     'cv_name' => 'EDAM',
     'definition' => '',
   ));
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'operation:0362',
     'name' => 'Genome annotation ',
@@ -735,7 +735,7 @@ function tripal_chado_populate_vocab_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'
   );
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'EFO:0000548',
     '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.',
   ));
   chado_associate_semweb_term('protocol', 'hardwaredescription', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'EFO:0000269',
     'name' => 'array design',
@@ -751,7 +751,7 @@ function tripal_chado_populate_vocab_EFO() {
     'definition' => 'An instrument design which describes the design of the array.',
   ));
   chado_associate_semweb_term(NULL, 'arraydesign_id', $term);
-   
+
   $term = chado_insert_cvterm(array(
     'id' => 'EFO:0005522',
     'name' => 'substrate type',
@@ -773,7 +773,7 @@ function tripal_chado_populate_vocab_EFO() {
     'definition' => '',
   ));
   chado_associate_semweb_term('arraydesign', 'manufacturer_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'EFO:0000269',
     '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('biomaterial', 'taxon_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'OBI:0000070',
     'name' => 'assay',
     '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.',
-  ));  
+  ));
 }
 
 /**
@@ -1184,7 +1184,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
   ));
   chado_associate_semweb_term(NULL, 'is_current', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'local:is_internal',
     'name' => 'is_internal',
@@ -1192,7 +1192,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
   ));
   chado_associate_semweb_term(NULL, 'is_internal', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'local:miniref',
     'name' => 'Mini-ref',
@@ -1201,7 +1201,7 @@ function tripal_chado_populate_vocab_LOCAL() {
   ));
   chado_associate_semweb_term('pub', 'miniref', $term);
 
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'local:array_batch_identifier',
     'name' => 'Array Batch Identifier',
@@ -1209,7 +1209,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
   ));
   chado_associate_semweb_term('assay', 'arraybatchidentifier', $term);
-  
+
   //-----------------------------
   // Relationship Terms
   //-----------------------------
@@ -1332,7 +1332,7 @@ function tripal_chado_populate_vocab_LOCAL() {
 
   //--------------
   // Project Terms
-  //-------------- 
+  //--------------
   // Insert cvterm 'Project Description' into cvterm table of chado
   // database. This CV term is used to keep track of the project
   // description in the projectprop table.
@@ -1342,7 +1342,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'project_property',
     'db_name' => 'local'
   ));
-  
+
   chado_insert_cvterm(array(
     'name' => 'Project Type',
     'definition'  => 'A type of project',
@@ -1387,7 +1387,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'db_name' => 'local'
   ));
   chado_associate_semweb_term(NULL, 'library_id', $term);
-  
+
   // Insert cvterm 'library_description' into cvterm table of chado
   // database. This CV term is used to keep track of the library
   // description in the libraryprop table.
@@ -1640,7 +1640,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     '(Random House Kernerman Webster\'s College Dictionary, © 2010 K ' .
     'Dictionaries Ltd).',
     'cv_name' => 'local',
-  )); 
+  ));
 
   $term = chado_insert_cvterm(array(
     'id' => 'local:source_data',
@@ -1680,7 +1680,7 @@ function tripal_chado_populate_vocab_LOCAL() {
     'biomaterials via the biomaterialrelationship table.',
     'cv_name' => 'local',
   ));
-  
+
   //
   // Terms for arraydesign table
   //
@@ -1747,8 +1747,8 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
   ));
   chado_associate_semweb_term('arraydesign', 'num_sub_rows', $term);
-  
-  
+
+
   //
   // Terms for Study
   //
@@ -1758,14 +1758,14 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'study_property',
     'db_name' => 'local'
   ));
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'local:Genome Project',
     'name' => 'Genome Project',
     'definition' => 'A project for whole genome analysis that can include assembly and annotation.',
     'cv_name' => 'local',
   ));
-  
+
 }
 /**
  * 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.
  */
 function tripal_chado_populate_vocab_SWO() {
@@ -1852,11 +1852,11 @@ function tripal_chado_populate_vocab_TPUB() {
 
   chado_insert_db(array(
     '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',
     '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
   chado_insert_db(
@@ -1962,7 +1962,7 @@ function tripal_chado_populate_vocab_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.'
   );
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C25164',
     'name' => 'Date',
@@ -1972,7 +1972,7 @@ function tripal_chado_populate_vocab_NCIT() {
   chado_associate_semweb_term('assay', 'assaydate', $term);
   chado_associate_semweb_term('acquisition', 'acquisitiondate', $term);
   chado_associate_semweb_term('quantification', 'quantificationdate', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C48036',
     'name' => 'Operator',
@@ -1980,7 +1980,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A person that operates some apparatus or machine',
   ));
   chado_associate_semweb_term(NULL, 'operator_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C45378',
     '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.',
   ));
   chado_associate_semweb_term('arraydesign', 'platformtype_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C25712',
     'name' => 'Value',
@@ -1996,7 +1996,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A numerical quantity measured or assigned or computed.',
   ));
   chado_associate_semweb_term(NULL, 'value', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C44170',
     '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.',
   ));
   chado_associate_semweb_term(NULL, 'channel_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C48697',
     '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 ]',
   ));
   chado_associate_semweb_term(NULL, 'cv_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C45559',
     'name' => 'Term',
@@ -2020,7 +2020,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A word or expression used for some particular thing. [ NCI ]',
   ));
   chado_associate_semweb_term(NULL, 'cvterm_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C80488',
     'name' => 'Expression',
@@ -2028,7 +2028,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'A combination of symbols that represents a value. [ NCI ]',
   ));
   chado_associate_semweb_term(NULL, 'expression_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C16977',
     '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 ]',
   ));
   chado_associate_semweb_term(NULL, 'phenotype_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C16631',
     '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 ]',
   ));
   chado_associate_semweb_term(NULL, 'genotype_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C25341',
     '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 ]',
   ));
   chado_associate_semweb_term(NULL, 'nd_geolocation_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C802',
     '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 ]',
   ));
   chado_associate_semweb_term(NULL, 'nd_reagent_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C16551',
     'name' => 'Environment',
@@ -2068,7 +2068,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'definition' => 'The totality of surrounding conditions. [ NCI ]',
   ));
   chado_associate_semweb_term(NULL, 'environment_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C42765',
     '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 ]',
   ));
   chado_associate_semweb_term(NULL, 'phylonode_id', $term);
-     
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C15320',
     '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 ]',
   ));
   chado_associate_semweb_term(NULL, 'studydesign_id', $term);
-  
+
   // The Company term is missing for the Tripal Contact ontology, but is
   // 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.
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C54131',
@@ -2095,7 +2095,7 @@ function tripal_chado_populate_vocab_NCIT() {
     'cv_name' => 'ncit',
     'definition' => 'Any formal business entity for profit, which may be a corporation, a partnership, association or individual proprietorship.',
   ));
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C47885',
     '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.',
   ));
   chado_associate_semweb_term(NULL, 'project_id', $term);
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C16223',
     'name' => 'DNA Library',
     'cv_name' => 'ncit',
     'definition' => 'A collection of DNA molecules that have been cloned in vectors.',
   ));
-    
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C85496',
     'name' => 'Trait',
     'cv_name' => 'ncit',
     'definition' => 'Any genetically determined characteristic.',
   ));
-  
+
   $term = chado_insert_cvterm(array(
     'id' => 'NCIT:C25693',
     'name' => 'Subgroup',
     'cv_name' => 'ncit',
     '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);
   }
-  
+
   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(
         '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',
       )
     ),
@@ -1394,11 +1394,11 @@ function tripal_chado_update_7321() {
   try {
     chado_insert_db(array(
       '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',
       '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(
       'name' => 'rdf',
@@ -1439,7 +1439,7 @@ function tripal_chado_update_7322() {
   try {
     chado_insert_db(array(
       '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',
       'urlprefix' => 'cv/lookup/TPUB/{accession}',
     ));
@@ -1578,7 +1578,7 @@ function tripal_chado_update_7328() {
     tripal_chado_add_cv_root_mview_mview();
     $mview_id = chado_get_mview_id($mv_name);
     chado_populate_mview($mview_id);
-  } 
+  }
   catch (\PDOException $e) {
     $error = $e->getMessage();
     throw new DrupalUpdateException('Could not perform update: '. $error);
@@ -1608,7 +1608,7 @@ function tripal_chado_update_7329() {
 function tripal_chado_update_7330() {
   try {
     tripal_insert_variable('bundle_category', 'Bundles can be categorized to allow for grouping');
-    
+
     $bundles = [
       'General' => [
         // Organism
@@ -1624,7 +1624,7 @@ function tripal_chado_update_7330() {
         // Publication
         'TPUB:0000002',
         // Protocol
-        'sep:00101',        
+        'sep:00101',
       ],
       'Genomic' => [
         // Gene
@@ -1642,7 +1642,7 @@ function tripal_chado_update_7330() {
         // Genome Annotation
         'operation:0362',
         // Genome Project
-        'local:Genome Project',                
+        'local:Genome Project',
       ],
       'Genetic' => [
         // Genetic Map
@@ -1654,7 +1654,7 @@ function tripal_chado_update_7330() {
         // Genetic Marker
         'SO:0001645',
         // Heritable Phenotypic Marker
-        'SO:0001500',        
+        'SO:0001500',
       ],
       'Germplasm/Breeding' => [
         // Germplasm Accession
@@ -1664,14 +1664,14 @@ function tripal_chado_update_7330() {
         // Cutlivar
         'CO_010:0000029',
         // Recombinant Inbred Line
-        'CO_010:0000162',        
+        'CO_010:0000162',
       ],
       'Expression' => [
         // Biological Sample
         'sep:00195',
         // Assay
         'OBI:0000070',
-        // Array Design 
+        // Array Design
         'EFO:0000269',
       ]
     ];
@@ -1681,8 +1681,8 @@ function tripal_chado_update_7330() {
         if ($bundle) {
           tripal_set_bundle_variable('bundle_category', $bundle->id, $category);
         }
-      }      
-    }    
+      }
+    }
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();
@@ -1726,15 +1726,15 @@ function tripal_chado_update_7332() {
       '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.'
     );
-    
+
     $term = chado_insert_cvterm([
       'id' => 'NCIT:C25693',
       'name' => 'Subgroup',
       'cv_name' => 'ncit',
       'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
     ]);
-    
-    
+
+
     // Add the rdfs:comment vocabulary.
     chado_insert_db(array(
       'name' => 'rdfs',
@@ -1776,7 +1776,7 @@ function tripal_chado_update_7333() {
  * SQL Fix for the db2cv_mview materialized view.
  */
 function tripal_chado_update_7334() {
-  
+
   try {
     $query = '
        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();
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
-}
+}

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