Bläddra i källkod

change osme SO based bundles with the wrong term name, and provide dbupdate for the same

bradfordcondon 5 år sedan
förälder
incheckning
03d983b975

+ 7 - 3
tripal_chado/includes/setup/tripal_chado.setup.inc

@@ -728,7 +728,8 @@ function tripal_chado_prepare_genetic_types($job) {
   $args = [
     'vocabulary' => 'SO',
     'accession' => '0001060',
-    'term_name' => 'Sequence Variant',
+    'label' => "Sequence Variant",
+    'term_name' => 'sequence_variant',
     'storage_args' => [
       'data_table' => 'feature',
       'type_column' => 'type_id',
@@ -743,7 +744,8 @@ function tripal_chado_prepare_genetic_types($job) {
   $args = [
     'vocabulary' => 'SO',
     'accession' => '0001645',
-    'term_name' => 'Genetic Marker',
+    'term_name' => 'genetic_marker',
+    'label' => "Genetic Marker",
     'storage_args' => [
       'data_table' => 'feature',
       'type_column' => 'type_id',
@@ -759,7 +761,9 @@ function tripal_chado_prepare_genetic_types($job) {
   $args = [
     'vocabulary' => 'SO',
     'accession' => '0001500',
-    'term_name' => 'Heritable Phenotypic Marker',
+    'term_name' => 'heritable_phenotypic_marker',
+    'label' => "Heritable Phenotypic Marker",
+
     'storage_args' => [
       'data_table' => 'feature',
       'type_column' => 'type_id',

+ 47 - 0
tripal_chado/tripal_chado.install

@@ -1940,3 +1940,50 @@ function tripal_chado_update_7337(){
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
 }
+
+
+/**
+ * Modify the term name for Sequence Variant, Genetic Marker, and Heritable Phenotypic Marker to match the corresponding SO term.
+ */
+function tripal_chado_update_7338() {
+
+  $terms = [
+    ['label' => 'Sequence Variant', 'term' => 'sequence_variant', 'accession' => '0001060'],
+    ['label' => 'Genetic Marker', 'term' => 'genetic_marker', 'accession' => '0001645'],
+    ['label' => 'Heritable Phenotypic Marker', 'term' => 'heritable_phenotypic_marker', 'accession' => '0001500']
+  ];
+
+  try {
+    foreach ($terms as $term) {
+
+      $label = $term['label'];
+      $termName = $term['term'];
+      $accession = $term['accession'];
+
+      $term = tripal_load_term_entity([
+        'vocabulary' => 'SO',
+        'accession' => $accession
+      ]);
+
+      if (!$term) {
+        continue;
+      }
+      $term->name = $termName;
+      $term->save();
+
+      $bundle = tripal_load_bundle_entity(['term_id' => $term->id]);
+
+      if (!$bundle) {
+        continue;
+      }
+      $bundle->label = $label;
+      $bundle->save();
+
+
+    }
+  } catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: '. $error);
+  }
+
+}