Browse Source

Fix to prepare chado which allows the function to be run outside of a Tripal Job.

Lacey Sanderson 7 years ago
parent
commit
547834a78a
1 changed files with 14 additions and 12 deletions
  1. 14 12
      tripal_chado/includes/setup/tripal_chado.setup.inc

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

@@ -136,13 +136,15 @@ function tripal_chado_load_ontologies() {
 /**
  * Prepares Chado for use by Tripal.
  */
-function tripal_chado_prepare_chado($job) {
+function tripal_chado_prepare_chado($job = NULL) {
 
   // Retrieve the job arguement in order to report progress.
   if (is_int($job)) {
     $job = new TripalJob();
     $job->load($job_id);
   }
+  $report_progress = TRUE;
+  if (!is_object($job)) { $report_progress = FALSE; }
 
   try {
 
@@ -176,19 +178,19 @@ function tripal_chado_prepare_chado($job) {
       tripal_chado_fix_v1_3_custom_tables();
     }
 
-    $job->setProgress(5);
+    if ($report_progress) { $job->setProgress(5); }
 
     // Import commonly used ontologies if needed.
     drush_print("Loading Ontologies...");
     tripal_chado_load_ontologies();
 
-    $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();
 
-    $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
@@ -196,7 +198,7 @@ function tripal_chado_prepare_chado($job) {
     drush_print("Map Chado Controlled vocabularies to Tripal Terms...");
     tripal_chado_map_cvterms();
 
-    $job->setProgress(70);
+    if ($report_progress) { $job->setProgress(70); }
 
     drush_print("Creating common Tripal Content Types...");
 
@@ -217,7 +219,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(74);
+    if ($report_progress) { $job->setProgress(74); }
 
     // Create the 'Analysis' entity type. This uses the local:analysis term.
     $error = '';
@@ -236,7 +238,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(78);
+    if ($report_progress) { $job->setProgress(78); }
 
     // Create the 'Project' entity type. This uses the local:project term.
     $error = '';
@@ -255,7 +257,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(82);
+    if ($report_progress) { $job->setProgress(82); }
 
     // Create the 'Map' entity type. This uses the local:project term.
     $error = '';
@@ -281,7 +283,7 @@ function tripal_chado_prepare_chado($job) {
     );
     $cvterm = tripal_get_cvterm($identifier);
     tripal_chado_add_cvterm_mapping($cvterm->cvterm_id, 'featuremap', NULL);
-    $job->setProgress(86);
+    if ($report_progress) { $job->setProgress(86); }
 
     // Import a publication so we get all of the properties before
     // creating the content type.
@@ -323,7 +325,7 @@ function tripal_chado_prepare_chado($job) {
     );
     $result = chado_select_record('pub_dbxref', array('pub_id'), $values);
     chado_delete_record('pub', array('pub_id' => $result[0]->pub_id));
-    $job->setProgress(90);
+    if ($report_progress) { $job->setProgress(90); }
 
     // Create the 'Gene' entity type.
     $error = '';
@@ -343,7 +345,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(94);
+    if ($report_progress) { $job->setProgress(94); }
 
     // Create the 'mRNA' entity type.
     $error = '';
@@ -363,7 +365,7 @@ function tripal_chado_prepare_chado($job) {
         throw new Exception($error['!message']);
       }
     }
-    $job->setProgress(98);
+    if ($report_progress) { $job->setProgress(98); }
 
     // Add the supported loaders
     variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));