Browse Source

insert cv and db for borrowed terms looked up

bradford.condon 6 years ago
parent
commit
112a371277

+ 10 - 11
tests/tripal_chado/loaders/OBOImporterTest.php

@@ -39,17 +39,16 @@ class OBOImporterTest extends TripalTestCase {
    * @group obo
    */
 
-//   public function testGO_SLIM_load() {
-// //    $this->load_goslim_plant();
-// //
-// //    $exists = db_select('chado.cv', 'c')
-// //      ->fields('c', ['cv_id'])
-// //      ->condition('name', 'core_test_goslim_plant')
-// //      ->execute()
-// //      ->fetchField();
-// //    $this->assertNotFalse($exists);
-// //
-//   }
+   public function testGO_SLIM_load() {
+     $this->load_goslim_plant();
+
+     $exists = db_select('chado.cv', 'c')
+       ->fields('c', ['cv_id'])
+       ->condition('name', 'core_test_goslim_plant')
+       ->execute()
+       ->fetchField();
+     $this->assertNotFalse($exists);
+   }
 
   private function load_pto_mini() {
 

+ 13 - 0
tripal_chado/includes/TripalImporter/OBOImporter.inc

@@ -1173,6 +1173,7 @@ class OBOImporter extends TripalImporter {
         }
       }
       else {
+
         // The term doesnt exist, so let's just do our insert.
         $cvterm->setValues([
           'cv_id' => $cv->cv_id,
@@ -1556,12 +1557,23 @@ class OBOImporter extends TripalImporter {
         // First try to lookup the term and replace the stanza with the updated
         // details. 
         $found = $this->lookupTerm($short_name, $accession);
+
         if ($found) {
           $stanza = $found;
         }
         // If we can't find the term in the database then do an EBI lookup.
         else {          
           $stanza = $this->findEBITerm($id);
+          $db_name = $stanza['db_name'][0];
+          $db = $this->all_dbs[$db_name];
+          if (!$db){
+            $db = $this->addDB($short_name);
+          }
+          $cv_name = $stanza['namespace'][0];
+          $cv = $this->all_cvs[$cv_name];
+          if (!$cv){
+            $cv = $this->addCV($cv_name);
+          }
         }
       }
       // If the term belongs to this OBO then let's set the 'db_name'.
@@ -2009,6 +2021,7 @@ class OBOImporter extends TripalImporter {
     }
     $this->all_cvs[$cvname] = (object) $cv->getValues();
     $this->obo_namespaces[$cvname] = $cv->getID();
+    return $cv->getValues();
   }
   
   /**