Browse Source

Fixed a few more bugs

Stephen Ficklin 6 years ago
parent
commit
823bdbbd57

+ 2 - 2
tripal_chado/api/ChadoRecord.inc

@@ -323,8 +323,8 @@ class ChadoRecord {
         $this->values[$column] = $value;
       }
       else {
-        $message = t('ChadoRecord::setValues(). The column named, "!column", does not exist in table: "!table".', 
-          ['!column' => $column, '!table' => $this->table_name]);
+        $message = t('ChadoRecord::setValues(). The column named, "!column", does not exist in table: "!table". Values: !values".', 
+          ['!column' => $column, '!table' => $this->table_name, '!values' => print_r($values, TRUE)]);
         throw new Exception($message);
       }
     }

+ 53 - 52
tripal_chado/files/tcontact.obo

@@ -1,150 +1,151 @@
 format-version: 1.2
 default-namespace: tripal_contact
+ontology: tcontact
 
 [Term]
-id: TContact:0000001
+id: TCONTACT:0000001
 name: Contact Type
 
 
 [Term]
-id: TContact:0000002
+id: TCONTACT:0000002
 name: Collective
 def: Used when a contact is a collective of individuals rather than a person.
-is_a: TContact:0000001 ! Contact Type
+is_a: TCONTACT:0000001 ! Contact Type
 
 [Term]
-id: TContact:0000003
+id: TCONTACT:0000003
 name: Person
-is_a: TContact:0000001 ! Contact Type
+is_a: TCONTACT:0000001 ! Contact Type
 
 [Term]
-id: TContact:0000004
+id: TCONTACT:0000004
 name: Organization
-is_a: TContact:0000001 ! Contact Type
+is_a: TCONTACT:0000001 ! Contact Type
 
 [Term]
-id: TContact:0000005
+id: TCONTACT:0000005
 name: University
-is_a: TContact:0000001 ! Contact Type
+is_a: TCONTACT:0000001 ! Contact Type
 
 [Term]
-id: TContact:0000006
+id: TCONTACT:0000006
 name: Lab
-is_a: TContact:0000001 ! Contact Type
+is_a: TCONTACT:0000001 ! Contact Type
 
 [Term]
-id: TContact:0000007
+id: TCONTACT:0000007
 name: Institute
-is_a: TContact:0000001 ! Contact Type
+is_a: TCONTACT:0000001 ! Contact Type
 
 [Term]
-id: TContact:0000008
+id: TCONTACT:0000008
 name: Research Group
-is_a: TContact:0000001 ! Contact Type
+is_a: TCONTACT:0000001 ! Contact Type
 
 [Term]
-id: TContact:0000009
+id: TCONTACT:0000009
 name: Department
-is_a: TContact:0000001 ! Contact Type
+is_a: TCONTACT:0000001 ! Contact Type
 
 [Term]
-id: TContact:0000010
+id: TCONTACT:0000010
 name: First Initials
 def: The first initials for the author including the initial for the first name and any middle names (not the initial for the last name).
-relationship: part_of TContact:0000003 ! Person
+relationship: part_of TCONTACT:0000003 ! Person
 
 [Term]
-id: TContact:0000011
+id: TCONTACT:0000011
 name: Surname
 synonym: "family_name" EXACT []
 synonym: "last_name" EXACT []
-relationship: part_of TContact:0000003 ! Person
+relationship: part_of TCONTACT:0000003 ! Person
 
 [Term]
-id: TContact:0000012
+id: TCONTACT:0000012
 name: Given Name
 synonym: "first_name" EXACT []
-relationship: part_of TContact:0000003 ! Person
+relationship: part_of TCONTACT:0000003 ! Person
 
 [Term]
-id: TContact:0000013
+id: TCONTACT:0000013
 name: Middle Names
 def: One or more middle names for this person.
-relationship: part_of TContact:0000003 ! Person
+relationship: part_of TCONTACT:0000003 ! Person
 
 [Term]
-id: TContact:0000014
+id: TCONTACT:0000014
 name: Middle Initials
 def: The middle initials for this person excluding the initial for the given name and the surname.
-relationship: part_of TContact:0000003 ! Person
+relationship: part_of TCONTACT:0000003 ! Person
 
 [Term]
-id: TContact:0000015
+id: TCONTACT:0000015
 name: Affiliation
 
 [Term]
-id: TContact:0000016
+id: TCONTACT:0000016
 name: Department
 def: The department of an institution or organization.
-relationship: part_of TContact:0000015 ! Affiliation
+relationship: part_of TCONTACT:0000015 ! Affiliation
 
 [Term]
-id: TContact:0000017
+id: TCONTACT:0000017
 name: Institution
-relationship: part_of TContact:0000015 ! Affiliation
+relationship: part_of TCONTACT:0000015 ! Affiliation
 
 [Term]
-id: TContact:0000018
+id: TCONTACT:0000018
 name: Organization
 def: A generic term for any organization.
-relationship: part_of TContact:0000015 ! Affiliation
+relationship: part_of TCONTACT:0000015 ! Affiliation
 
 [Term]
-id: TContact:0000019
+id: TCONTACT:0000019
 name: Address
 
 [Term]
-id: TContact:0000020
+id: TCONTACT:0000020
 name: Address Line 1
-relationship: part_of TContact:0000019 ! Address
+relationship: part_of TCONTACT:0000019 ! Address
 
 [Term]
-id: TContact:0000021
+id: TCONTACT:0000021
 name: Address Line 2
-relationship: part_of TContact:0000019 ! Address
+relationship: part_of TCONTACT:0000019 ! Address
 
 [Term]
-id: TContact:0000022
+id: TCONTACT:0000022
 name: Address Line 3
-relationship: part_of TContact:0000019 ! Address
+relationship: part_of TCONTACT:0000019 ! Address
 
 [Term]
-id: TContact:0000023
+id: TCONTACT:0000023
 name: City
-relationship: part_of TContact:0000019 ! Address
+relationship: part_of TCONTACT:0000019 ! Address
 
 [Term]
-id: TContact:0000024
+id: TCONTACT:0000024
 name: State
-relationship: part_of TContact:0000019 ! Address
+relationship: part_of TCONTACT:0000019 ! Address
 
 [Term]
-id: TContact:0000025
+id: TCONTACT:0000025
 name: Province
-relationship: part_of TContact:0000019 ! Address
+relationship: part_of TCONTACT:0000019 ! Address
 
 [Term]
-id: TContact:0000026
+id: TCONTACT:0000026
 name: Country
-relationship: part_of TContact:0000019 ! Address
+relationship: part_of TCONTACT:0000019 ! Address
 
 [Term]
-id: TContact:0000027
+id: TCONTACT:0000027
 name: Postal Code
-relationship: part_of TContact:0000019 ! Address
+relationship: part_of TCONTACT:0000019 ! Address
 
 [Term]
-id: TContact:0000028
+id: TCONTACT:0000028
 name: contact_description
 def: A description of the contact
 

+ 1 - 2
tripal_chado/files/tpub.obo

@@ -1,6 +1,7 @@
 format-version: 1.2
 default-namespace: tripal_pub
 subsetdef: MeSH_Publication_Type "MeSH Publication Types"
+ontology: tpub
 
 [Term]
 id: TPUB:0000001
@@ -742,8 +743,6 @@ def: Works consisting of or containing a substantial number of blank forms.
 is_a: TPUB:0000015 ! Publication Type
 subset: MeSH_Publication_Type
 
-subset: MeSH_Publication_Type
-
 [Term]
 id: TPUB:0000157
 name: Formularies

+ 20 - 17
tripal_chado/includes/TripalImporter/OBOImporter.inc

@@ -811,9 +811,15 @@ class OBOImporter extends TripalImporter {
     }
     
     // If we have the namespace but not the short name then we have to
-    // do an exhaustive search of EBI to find it.
+    // do an exhaustive search of EBI to find it if we don't alread have it in
+    // chado.
     if ($namespace and !$short_name) {
-      $short_name = $this->findEBIOntologyPrefix($namespace);
+      $sql = "SELECT dbname FROM {db2cv_mview} WHERE cvname = :cvname";
+      $short_name = chado_query($sql, [':cvname' => $namespace])->fetchField();
+      
+      if (!$short_name) {
+       $short_name = $this->findEBIOntologyPrefix($namespace);
+      }
     }
     
     // If we can't find the namespace or the short_name then bust.
@@ -1095,15 +1101,13 @@ class OBOImporter extends TripalImporter {
         // We found the term so do an update and change the dbxref_id.
         if (!$is_borrowed) {
           // This is a borrowed term so just update the dbxref_id.
-          $cvterm->setvalue('dbxref_id', $dbxref->getID());
+          $cvterm->setValue('dbxref_id', $dbxref->getID());
           $cvterm->update();
         }
         else {
-          $cvterm->setValues([
-            $cvterm->setvalue('definition', $definition),
-            $cvterm->setvalue('dbxref_id', $dbxref->getID()),
-            $cvterm->setvalue('is_obsolete', $is_obsolete),
-          ]);
+          $cvterm->setValue('definition', $definition);
+          $cvterm->setValue('dbxref_id', $dbxref->getID());
+          $cvterm->setValue('is_obsolete', $is_obsolete);
           $cvterm->update();
         }
       }
@@ -1601,15 +1605,16 @@ class OBOImporter extends TripalImporter {
     $num_read = 0;
     // The type of term:  Typedef or Term (inside the [] brackets]
     $type = '';
-
+    
     $filesize = filesize($obo_file);
     $this->setTotalItems($filesize);
     $this->setItemsHandled(0);
     $this->setInterval(5);
+    
 
     // iterate through the lines in the OBO file and parse the stanzas
     $fh = fopen($obo_file, 'r');
-    while ($line = fgets($fh)) {
+    while ($line = fgets($fh)) {      
       $line_num++;
       $size = drupal_strlen($line);
       $num_read += $size;
@@ -1635,9 +1640,9 @@ class OBOImporter extends TripalImporter {
       if (preg_match('/^\s*\[/', $line)) {
         
         // After parsing the header we need to get information about this OBO.
-        if ($in_header == TRUE) {
+        if ($in_header == TRUE) {          
           $this->setDefaults($header);
-          $in_header = FALSE;
+          $in_header = FALSE;          
         }
         
         // Store the stanza we just finished reading.
@@ -1884,7 +1889,7 @@ class OBOImporter extends TripalImporter {
       $cv->insert();
     }
     $this->all_cvs[$cvname] = (object) $cv->getValues();
-    $this->obo_namespaces[$namespace] = $cv->getID();
+    $this->obo_namespaces[$cvname] = $cv->getID();
   }
   
   /**
@@ -1955,11 +1960,9 @@ class OBOImporter extends TripalImporter {
       throw new Exception("Cannot add an xref without an accession: '$xref'");
     }
 
-    // If the xref is a database link then use a dbname of 'URL'.
-    // TODO: does this make sense to add a URL database?
+    // If the xref is a database link then skip those for now.
     if (strcmp($dbname, 'http') == 0) {
-      $accession = $xref;
-      $dbname = 'URL';
+      return;
     }
 
     // Add the database if it doesn't exist.

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

@@ -1313,7 +1313,7 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
         break;
       case 'contact':
         $default_vocab = 'tripal_contact';
-        $parent_term = 'TContact:0000001';
+        $parent_term = 'TCONTACT:0000001';
         $description = 'Select the type.';
         break;
       default:

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

@@ -1735,10 +1735,10 @@ function tripal_chado_populate_vocab_SWO() {
  */
 function tripal_chado_populate_vocab_TCONTACT() {
   chado_insert_db(array(
-    'name' => 'TContact',
+    'name' => 'TCONTACT',
     'description' => 'Tripal Contact Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
-    'url' => 'cv/lookup/TContact',
-    'urlprefix' => 'cv/lookup/TContact/{accession}',
+    'url' => 'cv/lookup/TCONTACT',
+    'urlprefix' => 'cv/lookup/TCONTACT/{accession}',
   ));
   chado_insert_cv('tripal_contact', 'Tripal Contact Ontology. A temporary ontology until a more formal appropriate ontology an be identified.');
 }

+ 13 - 0
tripal_chado/tripal_chado.install

@@ -1669,4 +1669,17 @@ function tripal_chado_update_7332() {
     $error = $e->getMessage();
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
+}
+
+/**
+ * Renames the TContact vocabulary database entry to TCONTACT as it should be.
+ */
+function tripal_chado_update_7333() {
+  try {
+    chado_update_record('db', ['name' => 'TContact'], ['name' => 'TCONTACT']);
+  }
+  catch (\PDOException $e) {
+    $error = $e->getMessage();
+    throw new DrupalUpdateException('Could not perform update: '. $error);
+  }
 }