Browse Source

Renamed _bundle_create_fields and _bundle_create_instances hooks, added new CV's for the EDAM vocab

Stephen Ficklin 8 years ago
parent
commit
4a32c306d8

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

@@ -333,7 +333,7 @@ function tripal_create_bundle($args, &$error = '') {
     // Allow modules to add fields to the new bundle.
     $modules = module_implements('bundle_create_fields');
     foreach ($modules as $module) {
-      $function = $module . '_bundle_create_fields';
+      $function = $module . '_bundle_fields_info';
       $info = $function('TripalEntity', $bundle);
       foreach ($info as $field_name => $details) {
         $field_type = $details['type'];
@@ -359,7 +359,7 @@ function tripal_create_bundle($args, &$error = '') {
     // Allow modules to add instances to the new bundle.
     $modules = module_implements('bundle_create_instances');
     foreach ($modules as $module) {
-      $function = $module . '_bundle_create_instances';
+      $function = $module . '_bundle_instances_info';
       $info = $function('TripalEntity', $bundle);
       foreach ($info as $field_name => $details) {
         // If the field is already attached to this bundle then skip it.
@@ -485,7 +485,7 @@ function tripal_tripal_cron_notification() {
     // Allow modules to add fields to the new bundle.
     $modules = module_implements('bundle_create_fields');
     foreach ($modules as $module) {
-      $function = $module . '_bundle_create_fields';
+      $function = $module . '_bundle_fields_info';
       $info = $function('TripalEntity', $bundle);
       foreach ($info as $field_name => $details) {
 
@@ -510,7 +510,7 @@ function tripal_tripal_cron_notification() {
     // Allow modules to add instances to the new bundle.
     $modules = module_implements('bundle_create_instances');
     foreach ($modules as $module) {
-      $function = $module . '_bundle_create_instances';
+      $function = $module . '_bundle_instances_info';
       $info = $function('TripalEntity', $bundle);
       foreach ($info as $field_name => $details) {
 
@@ -576,7 +576,7 @@ function tripal_refresh_bundle_fields($bundle_name) {
   // Allow modules to add fields to the new bundle.
   $modules = module_implements('bundle_create_fields');
   foreach ($modules as $module) {
-    $function = $module . '_bundle_create_fields';
+    $function = $module . '_bundle_fields_info';
     $info = $function('TripalEntity', $bundle);
     foreach ($info as $field_name => $details) {
       $field_type = $details['type'];
@@ -599,7 +599,7 @@ function tripal_refresh_bundle_fields($bundle_name) {
   // Allow modules to add instances to the new bundle.
   $modules = module_implements('bundle_create_instances');
   foreach ($modules as $module) {
-    $function = $module . '_bundle_create_instances';
+    $function = $module . '_bundle_instances_info';
     $info = $function('TripalEntity', $bundle);
     foreach ($info as $field_name => $details) {
       // If the field is already attached to this bundle then skip it.

+ 2 - 2
tripal/includes/tripal_admin_usage_page.inc

@@ -41,7 +41,7 @@ function tripal_admin_notification_import_field($field_name_note, $bundle_id, $m
   }
 
   if($field_or_instance == 'field'){
-    $function = $module . '_bundle_create_fields';
+    $function = $module . '_bundle_fields_info';
     $info = $function('TripalEntity', $bundle);
     foreach ($info as $field_name => $details) {
       if($details['field_name'] == $field_name_note) {
@@ -57,7 +57,7 @@ function tripal_admin_notification_import_field($field_name_note, $bundle_id, $m
     }
   }
   else if($field_or_instance == 'instance'){
-    $function = $module . '_bundle_create_instances';
+    $function = $module . '_bundle_instances_info';
     $info = $function('TripalEntity', $bundle);
     foreach ($info as $field_name => $details) {
       if($details['field_name'] == $field_name_note) {

+ 15 - 15
tripal_chado/includes/tripal_chado.fields.inc

@@ -1,12 +1,12 @@
 <?php
 
 /**
- * Implements hook_bundle_create_fields().
+ * Implements hook_bundle_fields_info().
  *
  * This is a Tripal defined hook that supports integration with the
  * TripalEntity field.
  */
-function tripal_chado_bundle_create_fields($entity_type, $bundle) {
+function tripal_chado_bundle_fields_info($entity_type, $bundle) {
 
   $chado_bundle = db_select('chado_bundle', 'cb')
     ->fields('cb')
@@ -25,13 +25,13 @@ function tripal_chado_bundle_create_fields($entity_type, $bundle) {
   $info = array();
 
   // Create the fields for each column in the table.
-  tripal_chado_bundle_create_fields_base($info, $details, $entity_type, $bundle);
+  tripal_chado_bundle_fields_info_base($info, $details, $entity_type, $bundle);
 
   // Create custom fields.
-  tripal_chado_bundle_create_fields_custom($info, $details, $entity_type, $bundle);
+  tripal_chado_bundle_fields_info_custom($info, $details, $entity_type, $bundle);
 
   // Create fields for linking tables.
-  tripal_chado_bundle_create_fields_linker($info, $details, $entity_type, $bundle);
+  tripal_chado_bundle_fields_info_linker($info, $details, $entity_type, $bundle);
 
   return $info;
 
@@ -40,7 +40,7 @@ function tripal_chado_bundle_create_fields($entity_type, $bundle) {
  *
  * @param unknown $details
  */
-function tripal_chado_bundle_create_fields_base(&$info, $details, $entity_type, $bundle) {
+function tripal_chado_bundle_fields_info_base(&$info, $details, $entity_type, $bundle) {
 
   $table_name = $details['chado_table'];
   $type_table = $details['chado_type_table'];
@@ -171,7 +171,7 @@ function tripal_chado_bundle_create_fields_base(&$info, $details, $entity_type,
  *
  * @param unknown $details
  */
-function tripal_chado_bundle_create_fields_custom(&$info, $details, $entity_type, $bundle) {
+function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type, $bundle) {
   $table_name = $details['chado_table'];
   $type_table = $details['chado_type_table'];
   $type_field = $details['chado_type_column'];
@@ -357,7 +357,7 @@ function tripal_chado_bundle_create_fields_custom(&$info, $details, $entity_type
  *
  * @param unknown $details
  */
-function tripal_chado_bundle_create_fields_linker(&$info, $details, $entity_type, $bundle) {
+function tripal_chado_bundle_fields_info_linker(&$info, $details, $entity_type, $bundle) {
 
   $table_name = $details['chado_table'];
   $type_table = $details['chado_type_table'];
@@ -586,7 +586,7 @@ function tripal_chado_bundle_create_fields_linker(&$info, $details, $entity_type
  * This is a Tripal defined hook that supports integration with the
  * TripalEntity field.
  */
-function tripal_chado_bundle_create_instances($entity_type, $bundle) {
+function tripal_chado_bundle_instances_info($entity_type, $bundle) {
 
   $chado_bundle = db_select('chado_bundle', 'cb')
     ->fields('cb')
@@ -602,9 +602,9 @@ function tripal_chado_bundle_create_instances($entity_type, $bundle) {
   );
 
   $info = array();
-  tripal_chado_bundle_create_instances_base($info, $entity_type, $bundle, $details);
-  tripal_chado_bundle_create_instances_custom($info, $entity_type, $bundle, $details);
-  tripal_chado_bundle_create_instances_linker($info, $entity_type, $bundle, $details);
+  tripal_chado_bundle_instances_info_base($info, $entity_type, $bundle, $details);
+  tripal_chado_bundle_instances_info_custom($info, $entity_type, $bundle, $details);
+  tripal_chado_bundle_instances_info_linker($info, $entity_type, $bundle, $details);
 
   return $info;
 
@@ -620,7 +620,7 @@ function tripal_chado_bundle_create_instances($entity_type, $bundle) {
  * @param $bundle
  * @param $details
  */
-function tripal_chado_bundle_create_instances_base(&$info, $entity_type, $bundle, $details) {
+function tripal_chado_bundle_instances_info_base(&$info, $entity_type, $bundle, $details) {
   $fields = array();
 
   // Get Chado information
@@ -827,7 +827,7 @@ function tripal_chado_bundle_create_instances_base(&$info, $entity_type, $bundle
  * @param $bundle
  * @param $details
  */
-function tripal_chado_bundle_create_instances_custom(&$info, $entity_type, $bundle, $details) {
+function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle, $details) {
   $table_name = $details['chado_table'];
   $type_table = $details['chado_type_table'];
   $type_field = $details['chado_type_column'];
@@ -1210,7 +1210,7 @@ function tripal_chado_bundle_create_instances_custom(&$info, $entity_type, $bund
  * @param unknown $bundle
  * @param unknown $details
  */
-function tripal_chado_bundle_create_instances_linker(&$info, $entity_type, $bundle, $details) {
+function tripal_chado_bundle_instances_info_linker(&$info, $entity_type, $bundle, $details) {
 
   $table_name = $details['chado_table'];
   $type_table = $details['chado_type_table'];

+ 20 - 3
tripal_chado/includes/tripal_chado.semweb.inc

@@ -219,6 +219,24 @@ function tripal_chado_populate_vocab_EDAM() {
     'url' => 'http://edamontology.org/page',
     'urlprefix' => 'http://edamontology.org/{db}_{accession}',
   ));
+  tripal_insert_db(array(
+    'name' => 'format',
+    'description' => 'A defined way or layout of representing and structuring data in a computer file, blob, string, message, or elsewhere. The main focus in EDAM lies on formats as means of structuring data exchanged between different tools or resources. ',
+    'url' => 'http://edamontology.org/page',
+    'urlprefix' => 'http://edamontology.org/{db}_{accession}',
+  ));
+  tripal_insert_db(array(
+    'name' => 'operation',
+    'description' => 'A function that processes a set of inputs and results in a set of outputs, or associates arguments (inputs) with values (outputs). Special cases are: a) An operation that consumes no input (has no input arguments).',
+    'url' => 'http://edamontology.org/page',
+    'urlprefix' => 'http://edamontology.org/{db}_{accession}',
+  ));
+  tripal_insert_db(array(
+    'name' => 'topic',
+    'description' => 'A category denoting a rather broad domain or field of interest, of study, application, work, data, or technology. Topics have no clearly defined borders between each other.',
+    'url' => 'http://edamontology.org/page',
+    'urlprefix' => 'http://edamontology.org/{db}_{accession}',
+  ));
   tripal_insert_db(array(
     'name' => 'EDAM',
     'description' => 'Bioinformatics operations, data types, formats, identifiers and topics.',
@@ -226,11 +244,10 @@ function tripal_chado_populate_vocab_EDAM() {
     'urlprefix' => 'http://edamontology.org/{db}_{accession}',
   ));
   tripal_insert_cv(
-    'data',
-    'Bioinformatics operations, data types, formats, identifiers and topics.'
+    '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 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, software distributions, and resource registries.'
   );
 
-
   $term = tripal_insert_cvterm(array(
     'id' => 'data:1249',
     'name' => 'Sequence length',

+ 36 - 0
tripal_chado/tripal_chado.install

@@ -755,3 +755,39 @@ function tripal_chado_update_7301() {
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
 }
+
+/**
+ * Corrections to the EDAM database.
+ */
+function tripal_chado_update_7302(){
+  try {
+    // Add the term for the field.
+    tripal_insert_db(array(
+      'name' => 'format',
+      'description' => 'A defined way or layout of representing and structuring data in a computer file, blob, string, message, or elsewhere. The main focus in EDAM lies on formats as means of structuring data exchanged between different tools or resources. ',
+      'url' => 'http://edamontology.org/page',
+      'urlprefix' => 'http://edamontology.org/{db}_{accession}',
+    ));
+    tripal_insert_db(array(
+      'name' => 'operation',
+      'description' => 'A function that processes a set of inputs and results in a set of outputs, or associates arguments (inputs) with values (outputs). Special cases are: a) An operation that consumes no input (has no input arguments).',
+      'url' => 'http://edamontology.org/page',
+      'urlprefix' => 'http://edamontology.org/{db}_{accession}',
+    ));
+    tripal_insert_db(array(
+      'name' => 'topic',
+      'description' => 'A category denoting a rather broad domain or field of interest, of study, application, work, data, or technology. Topics have no clearly defined borders between each other.',
+      'url' => 'http://edamontology.org/page',
+      'urlprefix' => 'http://edamontology.org/{db}_{accession}',
+    ));
+    tripal_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 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, software distributions, and resource registries.'
+    );
+  }
+  catch (\PDOException $e) {
+    $transaction->rollback();
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: '. $error);
+  }
+}