Browse Source

Added new files for organization of semantic web support

Stephen Ficklin 8 years ago
parent
commit
ee2027949d

+ 1 - 0
tripal/includes/TripalFieldQuery.inc

@@ -66,6 +66,7 @@ class TripalFieldQuery {
     // Are there any conditions?  If so, then let the field storage
     // systems handle the query. If there are no fields then just pull out
     // the list of entities.
+    dpm($this->conditions);
 
     $entity_ids = array();
     if (count($this->conditions) > 0) {

+ 2 - 36
tripal_chado/api/tripal_chado.api.inc

@@ -107,7 +107,7 @@ function tripal_chado_publish_records($values, $job_id = NULL) {
   $sql = $select . $from . $where;
   $records = chado_query($sql);
   $num_published = 0;
-  //$transaction  = db_transaction();
+  $transaction  = db_transaction();
   try {
     while($record = $records->fetchObject()) {
 
@@ -145,7 +145,7 @@ function tripal_chado_publish_records($values, $job_id = NULL) {
     }
   }
   catch (Exception $e) {
-    //$transaction->rollback();
+    $transaction->rollback();
     $error = $e->getMessage();
     tripal_report_error('tripal_chado', TRIPAL_ERROR, "Could not publish record: @error", array('@error' => $error));
     drupal_set_message('Failed publishing record. See recent logs for more details.', 'error');
@@ -268,38 +268,4 @@ function tripal_replace_chado_tokens($string, $record) {
   return $string;
 }
 
-/**
- *
- */
-function tripal_associate_chado_semweb_term($chado_table, $chado_column, $term) {
-
-  // Check to see if the record has already been added to the chado_semweb table
-  $query = db_select('chado_semweb', 'CS');
-  $query->fields('CS', array('chado_semweb_id'));
-  $query->condition('chado_column', $chado_column);
-  $query->condition('cvterm_id', $term->cvterm_id);
-  if ($chado_table) {
-    $query->condition('chado_table', $chado_table);
-  }
-  $id = $query->execute()->fetchField();
-
-  $values = array(
-    'chado_table' => $chado_table,
-    'chado_column' => $chado_column,
-    'cvterm_id' => $term->cvterm_id,
-  );
-  // If we have an ID then this is an update, otherwise it's an insert.
-  if ($id) {
-    $values['chado_semweb_id'] = $id;
-    $success = drupal_write_record('chado_semweb', $values, 'chado_semweb_id');
-  }
-  else {
-    $success = drupal_write_record('chado_semweb', $values);
-  }
-  if (!$success) {
-    FALSE;
-  }
-
-  return TRUE;
-}
 

+ 7 - 0
tripal_chado/api/tripal_chado.custom_tables.api.inc

@@ -69,6 +69,10 @@ function chado_edit_custom_table($table_id, $table_name, $schema, $skip_if_exist
     // update the custom table record and run the create custom table function
     drupal_write_record('tripal_custom_tables', $record, 'table_id');
     $success = chado_create_custom_table ($table_name, $schema, $skip_if_exists);
+
+    // Re-add the custom table to the semantic web interface to pick up any
+    // changes in fields.
+    tripal_add_chado_semweb_table($table_name);
   }
   catch (Exception $e) {
     $transaction->rollback();
@@ -187,6 +191,9 @@ function chado_create_custom_table($table, $schema, $skip_if_exists = 1, $mview_
         }
       }
     }
+
+    // Add the custom table to the semantic web interface
+    tripal_add_chado_semweb_table($table);
   }
   catch (Exception $e) {
     $transaction->rollback();

+ 6 - 0
tripal_chado/api/tripal_chado.schema.api.inc

@@ -321,6 +321,12 @@ function chado_get_table_names($include_custom = NULL) {
   $v = $GLOBALS["chado_version"];
 
   $tables = array();
+  if ($v == '1.3') {
+    $tables_v1_3 = tripal_chado_chado_get_v1_3_tables();
+    foreach ($tables_v1_3 as $table) {
+      $tables[$table] = $table;
+    }
+  }
   if ($v == '1.2') {
     $tables_v1_2 = tripal_chado_chado_get_v1_2_tables();
     foreach ($tables_v1_2 as $table) {

File diff suppressed because it is too large
+ 112 - 112
tripal_chado/api/tripal_chado.schema_v1.3.api.inc


+ 159 - 0
tripal_chado/api/tripal_chado.semweb.api.inc

@@ -0,0 +1,159 @@
+<?php
+/**
+ * Adds a new Chado table to the semantic web support for Chado.
+ *
+ * Newly added tables (i.e. custom tables) need to be integrated into the
+ * semantic web infrastructure.  After a new table is created and added to
+ * the Chado schema, this function should be called to indicate that the
+ * table should be included in the semantic web. No associations are made for
+ * the columns. The associations should be added using the
+ * tripal_associate_chado_semweb_term() function.
+ *
+ * If the table has already been added previously then this function does
+ * nothing. It will not overwrite existing assocations.
+ *
+ * Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with
+ * '_temp', are not supported.
+ *
+ * @param $chado_table
+ *   The name of the Chado table.
+ */
+function tripal_add_chado_semweb_table($chado_table) {
+
+  // Don't include the tripal temp tables
+  if (preg_match('/tripal_.+_temp/', $chado_table)) {
+    return;
+  }
+
+  // Get the table's schema and add all of it's fields if they aren't
+  // already there.
+  $schema = chado_get_schema($chado_table);
+  foreach ($schema['fields'] as $chado_column => $details) {
+
+    // If the record already exists don't overwrite it
+    $record = db_select('chado_semweb', 'CS')
+      ->fields('CS', array('chado_semweb_id'))
+      ->condition('CS.chado_table', $chado_table)
+      ->condition('CS.chado_column', $chado_column)
+      ->execute()
+      ->fetchField();
+    if (!$record) {
+      $record = array(
+        'chado_table' => $chado_table,
+        'chado_column' => $chado_column,
+      );
+      drupal_write_record('chado_semweb', $record);
+    }
+  }
+}
+/**
+ * Associates a controlled vocabulary term with a field in a Chado table.
+ *
+ * For sharing of data via the semantic web we need to associate a
+ * term from a controlled vocabulary with every column of every table in Chado.
+ *
+ * Temporary tables (e.g. Tripal tables that begin with 'tripal_' and end with
+ * '_temp', are not supported.
+ *
+ * @param $chado_table
+ *   The name of the table in Chado. This argument is optional. If left empty
+ *   or set to NULL then all fields in all Chado tables with that have the
+ *   $column_name will be associated with the provided $term.
+ * @param $chado_column
+ *   The column name in the Chado table to which the term should be associated.
+ * @param $term
+ *   A cvterm object as returned by chado_generate_var().
+ * @param $update
+ *   Set to TRUE if the association should be updated to use the new term
+ *   if a term is already associated with the table and column.  Default is
+ *   FALSE.  If not TRUE and a term is already associated, then no change
+ *   occurs.
+ *
+ * @return boolean
+ *   Returns TRUE if the association was made successfully and FALSE otherwise.
+ */
+function tripal_associate_chado_semweb_term($chado_table, $chado_column, $term,
+    $update = FALSE) {
+
+  // Check for required arguments.
+  if (!$chado_column) {
+    tripal_set_message('Please provide the $chado_column argument.', TRIPAL_ERROR);
+    return FALSE;
+  }
+  if (!$term) {
+    tripal_set_message('Please provide the $term argument.', TRIPAL_ERROR);
+    return FALSE;
+  }
+
+  // Make sure the field is a real field for the table.
+  if ($chado_table) {
+    $schema = chado_get_schema($chado_table);
+    if (!$schema) {
+      tripal_set_message('The $chado_table is not a known table in Chado.', TRIPAL_ERROR);
+      return FALSE;
+    }
+    if (!array_key_exists($chado_column, $schema['fields'])) {
+      tripal_set_message('The $chado_column is not a known column in the $chado_table.', TRIPAL_ERROR);
+      return FALSE;
+    }
+  }
+
+  // First check to see if a valid record exists that matches the table and
+  // column indicated. If it doesn't then insert the record.
+  $query = db_select('chado_semweb', 'CS')
+  ->fields('CS', array('chado_semweb_id'))
+  ->condition('chado_column', $chado_column);
+  if ($chado_table) {
+    $query->condition('chado_table', $chado_table);
+  }
+  $query->range(0,1);
+  $id = $query->execute()->fetchField();
+  if (!$id) {
+
+    // If no $chado_table record is provided then return FALSE as we can't
+    // insert a record without a table.
+    if (!$chado_table) {
+      tripal_set_message('The provided $chado_column has no match for any
+          table currently known. This could be because the table has not yet
+          been added to the semantic web management. Please provide the
+          $chado_table.', TRIPAL_ERROR);
+      return FALSE;
+    }
+
+    // Insert the record.
+    $id = db_insert('chado_semweb')
+    ->fields(array(
+      'chado_table' => $chado_table,
+      'chado_column' => $chado_column,
+      'cvterm_id' => $term->cvterm_id,
+    ));
+    if ($id) {
+      return TRUE;
+    }
+    else {
+      tripal_set_message('Failure associating term.', TRIPAL_ERROR);
+      return FALSE;
+    }
+  }
+
+  // If the $chado_table argument is empty or NULL then the term applies to
+  // all fields of the specified name.
+  $update = db_update('chado_semweb')
+  ->fields(array(
+    'cvterm_id' => $term->cvterm_id
+  ))
+  ->condition('chado_column', $chado_column);
+  if ($chado_table) {
+    $update->condition('chado_table', $chado_table);
+  }
+  if (!$update) {
+    $update->condition('cvterm_id', NULL);
+  }
+  $num_updated = $update->execute();
+  if (!$num_updated) {
+    tripal_set_message('Failure associating term.', TRIPAL_ERROR);
+    return FALSE;
+  }
+
+  return TRUE;
+}

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

@@ -0,0 +1,264 @@
+<?php
+/**
+ * Adds defaults to the chado_semweb table.
+ */
+function tripal_chado_populate_chado_semweb_table() {
+
+  // Add in all tables and fields into the chado_semweb table.
+  $chado_tables = chado_get_table_names(TRUE);
+  foreach ($chado_tables as $chado_table) {
+    tripal_add_chado_semweb_table($chado_table);
+  }
+
+  // Now set defaults!
+
+  //
+  // VOCABUARIES:
+
+  // Add in vocabularies of terms that will be used for the semantic web
+  //
+  tripal_insert_db(array(
+    'name' => 'foaf',
+    'description' => 'Friend of a Friend. A dictionary of people-related terms that can be used in structured data).',
+    'url' => 'http://www.foaf-project.org/',
+    'urlprefix' => 'http://xmlns.com/foaf/spec/#',
+  ));
+  tripal_insert_cv('foaf','Friend of a Friend');
+
+  tripal_insert_db(array(
+    'name' => 'schema',
+    'description' => 'Schema.org. Schema.org is sponsored by Google, Microsoft, Yahoo and Yandex. The vocabularies are developed by an open community process.',
+    'url' => 'https://schema.org/',
+    'urlprefix' => 'https://schema.org/',
+  ));
+  tripal_insert_cv('schema','Schema.org');
+
+  tripal_insert_db(array(
+    'name' => 'TAXRANK',
+    'description' => 'Taxonomic rank vocabulary. A vocabulary of taxonomic ranks (species, family, phylum, etc).',
+    'url' => 'https://github.com/phenoscape/taxrank',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/TAXRANK_',
+  ));
+  tripal_insert_cv('taxrank','Taxonomic rank vocabulary');
+
+  tripal_insert_db(array(
+    'name' => 'NCBITaxon',
+    'description' => 'NCBI organismal classification. An ontology representation of the NCBI organismal taxonomy.',
+    'url' => 'http://www.berkeleybop.org/ontologies/ncbitaxon/',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/ncbitaxon#',
+  ));
+  tripal_insert_cv('ncbitaxon','NCBI organismal classification');
+
+  tripal_insert_db(array(
+    'name' => 'SWO',
+    'description' => 'Software Ontology. An ontology representation of the NCBI organismal taxonomy.',
+    'url' => 'http://theswo.sourceforge.net/',
+    'urlprefix' => '',
+  ));
+  tripal_insert_cv('swo','Software Ontology');
+
+  tripal_insert_db(array(
+    'name' => 'IAO',
+    'description' => 'The Information Artifact Ontology (IAO) is a new ' .
+    'ontology of information entities, originally driven by work by the ' .
+    'OBI digital entity and realizable information entity branch.',
+    'url' => 'https://github.com/information-artifact-ontology/IAO/',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/IAO_',
+  ));
+  tripal_insert_cv('IAO','Information Artifact Ontology');
+
+
+  tripal_insert_db(array(
+    'name' => 'SBO',
+    'description' => 'Systems Biology. Terms commonly used in Systems Biology, and in particular in computational modeling.',
+    'url' => 'http://www.ebi.ac.uk/sbo/main/',
+    'urlprefix' => 'http://purl.obolibrary.org/obo/SBO_',
+  ));
+  tripal_insert_cv('sbo','Systems Biology');
+
+  //
+  // SET TERM DEFAULTS
+  //
+  $name = tripal_insert_cvterm(array(
+    'id' => 'schema:name',
+    'name' => 'name',
+    'cv_name' => 'schema',
+    'definition' => 'The name of the item.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'uniquename', $name);
+  tripal_associate_chado_semweb_term(NULL, 'name', $name);
+
+  $alternate_name = tripal_insert_cvterm(array(
+    'id' => 'schema:alternateName',
+    'name' => 'alternateName',
+    'cv_name' => 'schema',
+    'definition' => 'The name of the item.',
+  ));
+
+  $description = tripal_insert_cvterm(array(
+    'id' => 'schema:description',
+    'name' => 'description',
+    'cv_name' => 'schema',
+    'definition' => 'A description of the item.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'description', $description);
+
+
+  $definition = tripal_insert_cvterm(array(
+    'id' => 'IAO:0000115',
+    'name' => 'definition',
+    'cv_name' => 'iao',
+    'definition' => 'The official OBI definition, explaining the meaning of ' .
+      'a class or property. Shall be Aristotelian, formalized and normalized. ' .
+      'Can be augmented with colloquial definitions.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'definition', $definition);
+
+  $comment = tripal_insert_cvterm(array(
+    'id' => 'schema:comment',
+    'name' => 'comment',
+    'cv_name' => 'schema',
+    'definition' => 'Comments, typically from users.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'comment', $comment);
+
+  $time_last_modified = tripal_insert_cvterm(array(
+    'id' => 'local:timelastmodified',
+    'name' => 'time_last_modified',
+    'cv_name' => 'local',
+    'definition' => 'The time at which a record for an item was first added.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'timelastmodified', $time_last_modified);
+
+
+  $time_accessioned = tripal_insert_cvterm(array(
+    'id' => 'local:timeaccessioned',
+    'name' => 'time_accessioned',
+    'cv_name' => 'local',
+    'definition' => 'The time at which a record for an item was last upated or modified.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'timeaccessioned', $time_accessioned);
+
+  $time_executed = tripal_insert_cvterm(array(
+    'id' => 'local:timeexecuted',
+    'name' => 'time_executed',
+    'cv_name' => 'local',
+    'definition' => 'The time at which a task was executed.',
+  ));
+  tripal_associate_chado_semweb_term(NULL, 'timeaccessioned', $time_executed);
+
+  $dbxref = tripal_insert_cvterm(array(
+    'id' => 'SBO:0000554',
+    'name' => 'database cross reference',
+    'cv_name' => 'sbo',
+    'definition' => 'An annotation which directs one to information contained within a database.',
+  ));
+
+  $relationship = tripal_insert_cvterm(array(
+    'id' => 'SBO:0000374',
+    'name' => 'relationship',
+    'cv_name' => 'sbo',
+    'definition' => 'connectedness between entities and/or interactions representing their relatedness or influence. [ src_code:NR ]',
+  ));
+
+  //
+  // ANALYSIS TABLE
+  //
+  $term = tripal_insert_cvterm(array(
+    'id' => 'SWO:0000001',
+    'name' => 'software',
+    'cv_name' => 'schema',
+    'definition' => 'Computer software, or generally just software, is any ' .
+    'set of machine-readable instructions (most often in the form of a ' .
+    'computer program) that conform to a given syntax (sometimes ' .
+    'referred to as a language) that is interpretable by a given ' .
+    'processor and that directs a computer\'s processor to perform ' .
+    'specific operations.',
+  ));
+  tripal_associate_chado_semweb_term('analysis', 'program', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'IAO:0000129',
+    'name' => 'version number',
+    'cv_name' => 'IAO',
+    'definition' => 'A version number is an ' .
+    'information content entity which is a sequence of characters ' .
+    'borne by part of each of a class of manufactured products or its ' .
+    'packaging and indicates its order within a set of other products ' .
+    'having the same name.',
+  ));
+  tripal_associate_chado_semweb_term('analysis', 'programversion', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'IAO:0000064',
+    'name' => 'algorithm',
+    'cv_name' => 'IAO',
+    'definition' => 'An algorithm is a set of instructions for performing a paticular calculation.',
+  ));
+  tripal_associate_chado_semweb_term('analysis', 'algorithm', $term);
+
+  //
+  // ORGANISM TABLE
+  //
+  $term = tripal_insert_cvterm(array(
+    'id' => 'TAXRANK:0000005',
+    'name' => 'genus',
+    'cv_name' => 'taxrank',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'genus', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'TAXRANK:0000006',
+    'name' => 'species',
+    'cv_name' => 'taxrank',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'species', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'TAXRANK:0000045',
+    'name' => 'infraspecies',
+    'cv_name' => 'taxrank',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'infraspecific_name', $term);
+
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'local:infraspecific_type',
+    'name' => 'infraspecific_type',
+    'definition' => 'The connector type for the infraspecific name',
+    'cv_name' => 'local',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'type_id', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'NCBITaxon:common_name',
+    'name' => 'common name',
+    'cv_name' => 'ncbitaxon',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'common_name', $term);
+
+  $term = tripal_insert_cvterm(array(
+    'id' => 'local:abbreviation',
+    'name' => 'abbreviation',
+    'cv_name' => 'local',
+  ));
+  tripal_associate_chado_semweb_term('organism', 'abbreviation', $term);
+
+  //
+  // FEATURE TABLE
+  //
+  tripal_associate_chado_semweb_term('feature', 'name', $alternate_name);
+
+  //
+  // PUB TABLE
+  //
+  tripal_associate_chado_semweb_term('pub', 'uniquename', $comment);
+
+
+  //
+  // STOCK TABLE
+  //
+  tripal_associate_chado_semweb_term('stock', 'name', $alternate_name);
+
+
+}

+ 4 - 244
tripal_chado/includes/tripal_chado.setup.inc

@@ -433,6 +433,10 @@ function tripal_chado_prepare_chado() {
       throw new Exception($error);
     }
 
+    // Finally deal with the semantic web associations.
+    module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.semweb');
+    tripal_chado_populate_chado_semweb_table();
+
     // Set a variable to indicate the site is prepared.
     variable_set('tripal_chado_is_prepared', TRUE);
   }
@@ -1850,247 +1854,3 @@ function tripal_insert_misc_cvterms() {
   );
 }
 
-/**
- * Adds defaults to the chado_semweb table.
- */
-function tripal_chado_populate_chado_semweb_table() {
-  //
-  // VOCABUARIES:
-  // Add in vocabularies of terms that will be used for the semantic web
-  //
-  tripal_insert_db(array(
-    'name' => 'foaf',
-    'description' => 'Friend of a Friend. A dictionary of people-related terms that can be used in structured data).',
-    'url' => 'http://www.foaf-project.org/',
-    'urlprefix' => 'http://xmlns.com/foaf/spec/#',
-  ));
-  tripal_insert_cv('foaf','Friend of a Friend');
-
-  tripal_insert_db(array(
-    'name' => 'schema',
-    'description' => 'Schema.org. Schema.org is sponsored by Google, Microsoft, Yahoo and Yandex. The vocabularies are developed by an open community process.',
-    'url' => 'https://schema.org/',
-    'urlprefix' => 'https://schema.org/',
-  ));
-  tripal_insert_cv('schema','Schema.org');
-
-  tripal_insert_db(array(
-    'name' => 'TAXRANK',
-    'description' => 'Taxonomic rank vocabulary. A vocabulary of taxonomic ranks (species, family, phylum, etc).',
-    'url' => 'https://github.com/phenoscape/taxrank',
-    'urlprefix' => 'http://purl.obolibrary.org/obo/TAXRANK_',
-  ));
-  tripal_insert_cv('taxrank','Taxonomic rank vocabulary');
-
-  tripal_insert_db(array(
-    'name' => 'NCBITaxon',
-    'description' => 'NCBI organismal classification. An ontology representation of the NCBI organismal taxonomy.',
-    'url' => 'http://www.berkeleybop.org/ontologies/ncbitaxon/',
-    'urlprefix' => 'http://purl.obolibrary.org/obo/ncbitaxon#',
-  ));
-  tripal_insert_cv('ncbitaxon','NCBI organismal classification');
-
-  tripal_insert_db(array(
-    'name' => 'SWO',
-    'description' => 'Software Ontology. An ontology representation of the NCBI organismal taxonomy.',
-    'url' => 'http://theswo.sourceforge.net/',
-    'urlprefix' => '',
-  ));
-  tripal_insert_cv('swo','Software Ontology');
-
-  tripal_insert_db(array(
-    'name' => 'IAO',
-    'description' => 'The Information Artifact Ontology (IAO) is a new ' .
-      'ontology of information entities, originally driven by work by the ' .
-      'OBI digital entity and realizable information entity branch.',
-    'url' => 'https://github.com/information-artifact-ontology/IAO/',
-    'urlprefix' => 'http://purl.obolibrary.org/obo/IAO_',
-  ));
-  tripal_insert_cv('IAO','Information Artifact Ontology');
-
-
-  tripal_insert_db(array(
-    'name' => 'SBO',
-    'description' => 'Systems Biology. Terms commonly used in Systems Biology, and in particular in computational modeling.',
-    'url' => 'http://www.ebi.ac.uk/sbo/main/',
-    'urlprefix' => 'http://purl.obolibrary.org/obo/SBO_',
-  ));
-  tripal_insert_cv('sbo','Systems Biology');
-
-  //
-  // GENERIC TERMS
-  //
-  $name = tripal_insert_cvterm(array(
-    'id' => 'schema:name',
-    'name' => 'name',
-    'cv_name' => 'schema',
-    'definition' => 'The name of the item.',
-  ));
-  tripal_associate_chado_semweb_term(NULL, 'uniquename', $name);
-  tripal_associate_chado_semweb_term(NULL, 'name', $name);
-
-  $alternate_name = tripal_insert_cvterm(array(
-    'id' => 'schema:alternateName',
-    'name' => 'alternateName',
-    'cv_name' => 'schema',
-    'definition' => 'The name of the item.',
-  ));
-
-  $description = tripal_insert_cvterm(array(
-    'id' => 'schema:description',
-    'name' => 'description',
-    'cv_name' => 'schema',
-    'definition' => 'A description of the item.',
-  ));
-  tripal_associate_chado_semweb_term(NULL, 'definition', $description);
-  tripal_associate_chado_semweb_term(NULL, 'description', $description);
-
-  $comment = tripal_insert_cvterm(array(
-    'id' => 'schema:comment',
-    'name' => 'comment',
-    'cv_name' => 'schema',
-    'definition' => 'Comments, typically from users.',
-  ));
-  tripal_associate_chado_semweb_term(NULL, 'comment', $comment);
-
-  $time_last_modified = tripal_insert_cvterm(array(
-    'id' => 'local:timelastmodified',
-    'name' => 'time_last_modified',
-    'cv_name' => 'local',
-    'definition' => 'The time at which a record for an item was first added.',
-  ));
-  tripal_associate_chado_semweb_term(NULL, 'timelastmodified', $time_last_modified);
-
-
-  $time_accessioned = tripal_insert_cvterm(array(
-    'id' => 'local:timeaccessioned',
-    'name' => 'time_accessioned',
-    'cv_name' => 'local',
-    'definition' => 'The time at which a record for an item was last upated or modified.',
-  ));
-  tripal_associate_chado_semweb_term(NULL, 'timeaccessioned', $time_accessioned);
-
-  $time_executed = tripal_insert_cvterm(array(
-    'id' => 'local:timeexecuted',
-    'name' => 'time_executed',
-    'cv_name' => 'local',
-    'definition' => 'The time at which a task was executed.',
-  ));
-  tripal_associate_chado_semweb_term(NULL, 'timeaccessioned', $time_executed);
-
-
-  $dbxref = tripal_insert_cvterm(array(
-    'id' => 'SBO:0000554',
-    'name' => 'database cross reference',
-    'cv_name' => 'sbo',
-    'definition' => 'An annotation which directs one to information contained within a database.',
-  ));
-
-  $relationship = tripal_insert_cvterm(array(
-    'id' => 'SBO:0000374',
-    'name' => 'relationship',
-    'cv_name' => 'sbo',
-    'definition' => 'connectedness between entities and/or interactions representing their relatedness or influence. [ src_code:NR ]',
-  ));
-
-  //
-  // ANALYSIS TABLE
-  //
-  $term = tripal_insert_cvterm(array(
-    'id' => 'SWO:0000001',
-    'name' => 'software',
-    'cv_name' => 'schema',
-    'definition' => 'Computer software, or generally just software, is any ' .
-      'set of machine-readable instructions (most often in the form of a ' .
-      'computer program) that conform to a given syntax (sometimes ' .
-      'referred to as a language) that is interpretable by a given ' .
-      'processor and that directs a computer\'s processor to perform ' .
-      'specific operations.',
-  ));
-  tripal_associate_chado_semweb_term('analysis', 'program', $term);
-
-  $term = tripal_insert_cvterm(array(
-    'id' => 'IAO:0000129',
-    'name' => 'version number',
-    'cv_name' => 'IAO',
-    'definition' => 'A version number is an ' .
-      'information content entity which is a sequence of characters ' .
-      'borne by part of each of a class of manufactured products or its ' .
-      'packaging and indicates its order within a set of other products ' .
-      'having the same name.',
-  ));
-  tripal_associate_chado_semweb_term('analysis', 'programversion', $term);
-
-  $term = tripal_insert_cvterm(array(
-    'id' => 'IAO:0000064',
-    'name' => 'algorithm',
-    'cv_name' => 'IAO',
-    'definition' => 'An algorithm is a set of instructions for performing a paticular calculation.',
-  ));
-  tripal_associate_chado_semweb_term('analysis', 'algorithm', $term);
-
-  //
-  // ORGANISM TABLE
-  //
-  $term = tripal_insert_cvterm(array(
-    'id' => 'TAXRANK:0000005',
-    'name' => 'genus',
-    'cv_name' => 'taxrank',
-  ));
-  tripal_associate_chado_semweb_term('organism', 'genus', $term);
-
-  $term = tripal_insert_cvterm(array(
-    'id' => 'TAXRANK:0000006',
-    'name' => 'species',
-    'cv_name' => 'taxrank',
-  ));
-  tripal_associate_chado_semweb_term('organism', 'species', $term);
-
-  $term = tripal_insert_cvterm(array(
-    'id' => 'TAXRANK:0000045',
-    'name' => 'infraspecies',
-    'cv_name' => 'taxrank',
-  ));
-  tripal_associate_chado_semweb_term('organism', 'infraspecific_name', $term);
-
-
-  $term = tripal_insert_cvterm(array(
-    'id' => 'local:infraspecific_type',
-    'name' => 'infraspecific_type',
-    'definition' => 'The connector type for the infraspecific name',
-    'cv_name' => 'local',
-  ));
-  tripal_associate_chado_semweb_term('organism', 'type_id', $term);
-
-  $term = tripal_insert_cvterm(array(
-    'id' => 'NCBITaxon:common_name',
-    'name' => 'common name',
-    'cv_name' => 'ncbitaxon',
-  ));
-  tripal_associate_chado_semweb_term('organism', 'common_name', $term);
-
-  $term = tripal_insert_cvterm(array(
-    'id' => 'local:abbreviation',
-    'name' => 'abbreviation',
-    'cv_name' => 'local',
-  ));
-  tripal_associate_chado_semweb_term('organism', 'abbreviation', $term);
-
-  //
-  // FEATURE TABLE
-  //
-  tripal_associate_chado_semweb_term('feature', 'name', $alternate_name);
-
-  //
-  // PUB TABLE
-  //
-  tripal_associate_chado_semweb_term('pub', 'uniquename', $comment);
-
-
-  //
-  // STOCK TABLE
-  //
-  tripal_associate_chado_semweb_term('stock', 'name', $alternate_name);
-
-
-}

+ 5 - 2
tripal_chado/tripal_chado.install

@@ -64,6 +64,7 @@ function tripal_chado_chado_semweb_schema(){
       'chado_table' => array(
         'type' => 'varchar',
         'length ' => 128,
+        'not null' => TRUE
       ),
       'chado_column' => array(
         'type' => 'text',
@@ -72,7 +73,6 @@ function tripal_chado_chado_semweb_schema(){
       ),
       'cvterm_id' => array(
         'type' => 'int',
-        'not null' => TRUE
       ),
     ),
     'primary key' => array(
@@ -82,7 +82,10 @@ function tripal_chado_chado_semweb_schema(){
       'chado_semweb_id_idx1' => array('cvterm_id'),
       'chado_semweb_id_idx2' => array('chado_column'),
       'chado_semweb_id_idx3' => array('chado_table', 'chado_table'),
-    )
+    ),
+    'unique keys' => array(
+      'chado_semweb_uq1' => array('chado_table', 'chado_column'),
+    ),
   );
 }
 

+ 1 - 0
tripal_chado/tripal_chado.module

@@ -15,6 +15,7 @@ require_once 'api/tripal_chado.mviews.api.inc';
 require_once 'api/tripal_chado.schema_v1.3.api.inc';
 require_once 'api/tripal_chado.schema_v1.2.api.inc';
 require_once 'api/tripal_chado.schema_v1.11.api.inc';
+require_once 'api/tripal_chado.semweb.api.inc';
 
 // Chado module specific API functions
 require_once 'api/modules/tripal_chado.analysis.api.inc';

Some files were not shown because too many files changed in this diff