Browse Source

Added biological sample entity type

Stephen Ficklin 7 years ago
parent
commit
6b78d9da21

+ 57 - 12
tripal_chado/includes/setup/tripal_chado.setup.inc

@@ -144,7 +144,9 @@ function tripal_chado_prepare_chado($job = NULL) {
     $job->load($job);
   }
   $report_progress = TRUE;
-  if (!is_object($job)) { $report_progress = FALSE; }
+  if (!is_object($job)) {
+    $report_progress = FALSE;
+  }
 
   try {
 
@@ -178,19 +180,25 @@ function tripal_chado_prepare_chado($job = NULL) {
       tripal_chado_fix_v1_3_custom_tables();
     }
 
-    if ($report_progress) { $job->setProgress(5); }
+    if ($report_progress) {
+      $job->setProgress(5);
+    }
 
     // Import commonly used ontologies if needed.
     drush_print("Loading Ontologies...");
     tripal_chado_load_ontologies();
 
-    if ($report_progress) { $job->setProgress(50); }
+    if ($report_progress) {
+      $job->setProgress(50);
+    }
 
     // Populate the semantic web associations for Chado tables/fields.
     drush_print("Making semantic connections for Chado tables/fields...");
     tripal_chado_populate_chado_semweb_table();
 
-    if ($report_progress) { $job->setProgress(60); }
+    if ($report_progress) {
+      $job->setProgress(60);
+    }
 
     // Initialize the population of the chado_cvterm_mapping table.  This will
     // map existing data types already in Chado so that when users want to
@@ -198,7 +206,9 @@ function tripal_chado_prepare_chado($job = NULL) {
     drush_print("Map Chado Controlled vocabularies to Tripal Terms...");
     tripal_chado_map_cvterms();
 
-    if ($report_progress) { $job->setProgress(70); }
+    if ($report_progress) {
+      $job->setProgress(70);
+    }
 
     drush_print("Creating common Tripal Content Types...");
 
@@ -219,7 +229,9 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(74); }
+    if ($report_progress) {
+      $job->setProgress(74);
+    }
 
     // Create the 'Analysis' entity type. This uses the local:analysis term.
     $error = '';
@@ -238,7 +250,9 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(78); }
+    if ($report_progress) {
+      $job->setProgress(78);
+    }
 
     // Create the 'Project' entity type. This uses the local:project term.
     $error = '';
@@ -257,7 +271,9 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(82); }
+    if ($report_progress) {
+      $job->setProgress(82);
+    }
 
     // Create the 'Map' entity type. This uses the local:project term.
     $error = '';
@@ -283,7 +299,9 @@ function tripal_chado_prepare_chado($job = NULL) {
     );
     $cvterm = tripal_get_cvterm($identifier);
     tripal_chado_add_cvterm_mapping($cvterm->cvterm_id, 'featuremap', NULL);
-    if ($report_progress) { $job->setProgress(86); }
+    if ($report_progress) {
+      $job->setProgress(86);
+    }
 
     // Import a publication so we get all of the properties before
     // creating the content type.
@@ -325,7 +343,9 @@ function tripal_chado_prepare_chado($job = NULL) {
     );
     $result = chado_select_record('pub_dbxref', array('pub_id'), $values);
     chado_delete_record('pub', array('pub_id' => $result[0]->pub_id));
-    if ($report_progress) { $job->setProgress(90); }
+    if ($report_progress) {
+      $job->setProgress(90);
+    }
 
     // Create the 'Gene' entity type.
     $error = '';
@@ -345,7 +365,9 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(94); }
+    if ($report_progress) {
+      $job->setProgress(94);
+    }
 
     // Create the 'mRNA' entity type.
     $error = '';
@@ -365,7 +387,30 @@ function tripal_chado_prepare_chado($job = NULL) {
         throw new Exception($error['!message']);
       }
     }
-    if ($report_progress) { $job->setProgress(98); }
+    if ($report_progress) {
+      $job->setProgress(98);
+    }
+
+    // Create the 'biological sample' entity type.
+    $error = '';
+    $args = array(
+      'vocabulary' => 'sep',
+      'accession' => '00195',
+      'term_name' => 'biological sample',
+      'storage_args' => array(
+        'data_table' => 'biomaterial',
+      )
+    );
+    $term = tripal_load_term_entity(array('vocabulary' => 'sep', 'accession' => '00195'));
+    $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
+    if (!$term or !$bundle) {
+      if (!tripal_create_bundle($args, $error)) {
+        throw new Exception($error['!message']);
+      }
+    }
+    if ($report_progress) {
+      $job->setProgress(99);
+    }
 
     // Add the supported loaders
     variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));

+ 18 - 0
tripal_chado/includes/tripal_chado.semweb.inc

@@ -237,6 +237,24 @@ function tripal_chado_populate_vocab_SCHEMA() {
   ));
 }
 
+/**
+ * Adds the Sample processing and separation techniques database and terms.
+ */
+function tripal_chado_populate_vocab_SEP() {
+  tripal_insert_db(array(
+    'name' => 'sep',
+    'description' => 'Sample processing and separation techniques.',
+    'url' => 'http://psidev.info/index.php?q=node/312',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
+  ));
+  tripal_insert_cv('sep','A structured controlled vocabulary for the annotation of sample processing and separation techniques in scientific experiments.');
+  $term = tripal_insert_cvterm(array(
+    'id' => 'sep:00195',
+    'name' => 'biological sample',
+    'cv_name' => 'sep',
+    'definition' => 'A biological sample analysed by a particular technology.',
+  ));
+}
 /**
  * Adds the SemanticScience database and terms.
  */

+ 25 - 0
tripal_chado/tripal_chado.install

@@ -1285,4 +1285,29 @@ function tripal_chado_update_7317() {
     $error = $e->getMessage();
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
+}
+
+/**
+ * Adding biological sample term for biomaterial entities.
+ */
+function tripal_chado_update_7318() {
+  try {
+    tripal_insert_db(array(
+      'name' => 'sep',
+      'description' => 'Sample processing and separation techniques.',
+      'url' => 'http://psidev.info/index.php?q=node/312',
+      'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
+    ));
+    tripal_insert_cv('sep','A structured controlled vocabulary for the annotation of sample processing and separation techniques in scientific experiments.');
+    $term = tripal_insert_cvterm(array(
+      'id' => 'sep:00195',
+      'name' => 'biological sample',
+      'cv_name' => 'sep',
+      'definition' => 'A biological sample analysed by a particular technology.',
+    ));
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: '. $error);
+  }
 }